Skip to content

Commit b2b2f7b

Browse files
committed
<EXPERIMENTAL> Vulkan: decouple from Wayland
1 parent 96da9b1 commit b2b2f7b

File tree

24 files changed

+422
-337
lines changed

24 files changed

+422
-337
lines changed

make/autoconf/lib-vulkan.m4

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#
2+
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2025, JetBrains s.r.o.. All rights reserved.
4+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
#
6+
# This code is free software; you can redistribute it and/or modify it
7+
# under the terms of the GNU General Public License version 2 only, as
8+
# published by the Free Software Foundation. Oracle designates this
9+
# particular file as subject to the "Classpath" exception as provided
10+
# by Oracle in the LICENSE file that accompanied this code.
11+
#
12+
# This code is distributed in the hope that it will be useful, but WITHOUT
13+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
# version 2 for more details (a copy is included in the LICENSE file that
16+
# accompanied this code).
17+
#
18+
# You should have received a copy of the GNU General Public License version
19+
# 2 along with this work; if not, write to the Free Software Foundation,
20+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+
#
22+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+
# or visit www.oracle.com if you need additional information or have any
24+
# questions.
25+
#
26+
27+
################################################################################
28+
# Setup vulkan
29+
################################################################################
30+
AC_DEFUN_ONCE([LIB_SETUP_VULKAN],
31+
[
32+
AC_ARG_WITH(vulkan, [AS_HELP_STRING([--with-vulkan],
33+
[specify whether we use vulkan])])
34+
AC_ARG_WITH(vulkan-include, [AS_HELP_STRING([--with-vulkan-include],
35+
[specify directory for the vulkan include files ({with-vulkan-include}/vulkan/vulkan.h)])])
36+
AC_ARG_WITH(vulkan-shader-compiler, [AS_HELP_STRING([--with-vulkan-shader-compiler],
37+
[specify which shader compiler to use: glslc/glslangValidator])])
38+
39+
VULKAN_ENABLED=false
40+
VULKAN_FLAGS=
41+
42+
# Find Vulkan SDK
43+
if test "x$NEEDS_LIB_VULKAN" = xtrue || test "x${with_vulkan}" = xyes || test "x${with_vulkan_include}" != x ; then
44+
45+
# Check custom directory
46+
if test "x${with_vulkan_include}" != x; then
47+
AC_MSG_CHECKING([for ${with_vulkan_include}/vulkan/vulkan.h])
48+
if test -s "${with_vulkan_include}/vulkan/vulkan.h"; then
49+
VULKAN_ENABLED=true
50+
VULKAN_FLAGS="-I${with_vulkan_include}"
51+
AC_MSG_RESULT([yes])
52+
else
53+
AC_MSG_RESULT([no])
54+
AC_MSG_ERROR([Can't find 'vulkan/vulkan.h' under '${with_vulkan_include}'])
55+
fi
56+
fi
57+
58+
# Check $VULKAN_SDK
59+
if test "x$VULKAN_ENABLED" = xfalse && test "x${VULKAN_SDK}" != x; then
60+
AC_MSG_CHECKING([for ${VULKAN_SDK}/include/vulkan/vulkan.h])
61+
if test -s "${VULKAN_SDK}/include/vulkan/vulkan.h"; then
62+
VULKAN_ENABLED=true
63+
VULKAN_FLAGS="-I${VULKAN_SDK}/include"
64+
AC_MSG_RESULT([yes])
65+
else
66+
AC_MSG_RESULT([no])
67+
fi
68+
fi
69+
70+
# Check default /usr/include location
71+
if test "x$VULKAN_ENABLED" = xfalse; then
72+
AC_CHECK_HEADERS([vulkan/vulkan.h],
73+
[ VULKAN_ENABLED=true ], [ break ]
74+
)
75+
fi
76+
77+
if test "x$VULKAN_ENABLED" = xfalse; then
78+
# Vulkan SDK not found
79+
HELP_MSG_MISSING_DEPENDENCY([vulkan])
80+
AC_MSG_ERROR([Could not find vulkan! $HELP_MSG ])
81+
fi
82+
fi
83+
84+
# Find shader compiler - glslc or glslangValidator
85+
if test "x$VULKAN_ENABLED" = xtrue; then
86+
SHADER_COMPILER=
87+
88+
# Check glslc
89+
if (test "x${with_vulkan_shader_compiler}" = x || test "x${with_vulkan_shader_compiler}" = xglslc); then
90+
UTIL_LOOKUP_PROGS(GLSLC, glslc)
91+
SHADER_COMPILER="$GLSLC"
92+
VULKAN_SHADER_COMPILER="glslc --target-env=vulkan1.2 -mfmt=num -o"
93+
fi
94+
95+
# Check glslangValidator
96+
if (test "x${with_vulkan_shader_compiler}" = x || test "x${with_vulkan_shader_compiler}" = xglslangValidator) && \
97+
test "x$SHADER_COMPILER" = x; then
98+
UTIL_LOOKUP_PROGS(GLSLANG, glslangValidator)
99+
SHADER_COMPILER="$GLSLANG"
100+
VULKAN_SHADER_COMPILER="glslangValidator --target-env vulkan1.2 -x -o"
101+
fi
102+
103+
if test "x$SHADER_COMPILER" = x; then
104+
# Compiler not found
105+
VULKAN_ENABLED=false
106+
VULKAN_FLAGS=
107+
AC_MSG_ERROR([Can't find vulkan shader compiler])
108+
fi
109+
fi
110+
111+
# Add platform-specific flags
112+
if test "x$VULKAN_ENABLED" = xtrue; then
113+
if test "x$NEEDS_LIB_WAYLAND" = xtrue; then
114+
VULKAN_FLAGS="$VULKAN_FLAGS -DVK_USE_PLATFORM_WAYLAND_KHR"
115+
fi
116+
fi
117+
118+
AC_SUBST(VULKAN_ENABLED)
119+
AC_SUBST(VULKAN_FLAGS)
120+
AC_SUBST(VULKAN_SHADER_COMPILER)
121+
])

make/autoconf/lib-wayland.m4

+1-94
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ AC_DEFUN_ONCE([LIB_SETUP_WAYLAND],
4848
fi
4949
WAYLAND_CFLAGS=
5050
WAYLAND_LIBS=
51-
VULKAN_FLAGS=
52-
VULKAN_ENABLED=false
5351
else
5452
WAYLAND_FOUND=no
5553
WAYLAND_INCLUDES=
@@ -106,7 +104,7 @@ AC_DEFUN_ONCE([LIB_SETUP_WAYLAND],
106104
if test "x${with_wayland_lib}" != x; then
107105
WAYLAND_LIBS="-L${with_wayland_lib} -lwayland-client -lwayland-cursor"
108106
fi
109-
107+
110108
if test "x$WAYLAND_FOUND" = xno; then
111109
# Are the wayland headers installed in the default /usr/include location?
112110
AC_CHECK_HEADERS([wayland-client.h wayland-cursor.h],
@@ -124,98 +122,7 @@ AC_DEFUN_ONCE([LIB_SETUP_WAYLAND],
124122
AC_MSG_ERROR([Could not find wayland! $HELP_MSG ])
125123
fi
126124
WAYLAND_CFLAGS="${WAYLAND_INCLUDES} ${WAYLAND_DEFINES}"
127-
128-
# Checking for vulkan sdk
129-
130-
AC_ARG_WITH(vulkan, [AS_HELP_STRING([--with-vulkan],
131-
[specify whether we use vulkan])])
132-
133-
AC_ARG_WITH(vulkan-include, [AS_HELP_STRING([--with-vulkan-include],
134-
[specify directory for the vulkan include files ({with-vulkan-include}/vulkan/vulkan.h)])])
135-
136-
AC_ARG_WITH(vulkan-shader-compiler, [AS_HELP_STRING([--with-vulkan-shader-compiler],
137-
[specify which shader compiler to use: glslc/glslangValidator])])
138-
139-
if test "x$SUPPORTS_LIB_VULKAN" = xfalse; then
140-
141-
if (test "x${with_vulkan}" != x && test "x${with_vulkan}" != xno) || \
142-
(test "x${with_vulkan_include}" != x && test "x${with_vulkan_include}" != xno); then
143-
AC_MSG_WARN([[vulkan not used, so --with-vulkan-include is ignored]])
144-
fi
145-
VULKAN_FLAGS=
146-
VULKAN_ENABLED=false
147-
else
148-
# Do not build vulkan rendering pipeline by default
149-
if (test "x${with_vulkan}" = x && test "x${with_vulkan_include}" = x) || \
150-
test "x${with_vulkan}" = xno || test "x${with_vulkan_include}" = xno ; then
151-
VULKAN_FLAGS=
152-
VULKAN_ENABLED=false
153-
else
154-
VULKAN_FOUND=no
155-
156-
if test "x${with_vulkan_include}" != x; then
157-
AC_MSG_CHECKING([for ${with_vulkan_include}/vulkan/vulkan.h])
158-
if test -s "${with_vulkan_include}/vulkan/vulkan.h"; then
159-
VULKAN_FOUND=yes
160-
VULKAN_FLAGS="-DVK_USE_PLATFORM_WAYLAND_KHR -I${with_vulkan_include} -DVULKAN_ENABLED"
161-
AC_MSG_RESULT([yes])
162-
else
163-
AC_MSG_RESULT([no])
164-
AC_MSG_ERROR([Can't find 'vulkan/vulkan.h' under '${with_vulkan_include}'])
165-
fi
166-
fi
167-
168-
if test "x$VULKAN_FOUND" = xno && test "x${VULKAN_SDK}" != x; then
169-
AC_MSG_CHECKING([for ${VULKAN_SDK}/include/vulkan/vulkan.h])
170-
if test -s "${VULKAN_SDK}/include/vulkan/vulkan.h"; then
171-
VULKAN_FOUND=yes
172-
VULKAN_FLAGS="-DVK_USE_PLATFORM_WAYLAND_KHR -I${VULKAN_SDK}/include -DVULKAN_ENABLED"
173-
AC_MSG_RESULT([yes])
174-
else
175-
AC_MSG_RESULT([no])
176-
fi
177-
fi
178-
179-
if test "x$VULKAN_FOUND" = xno; then
180-
# Check default /usr/include location
181-
AC_CHECK_HEADERS([vulkan/vulkan.h],
182-
[ VULKAN_FOUND=yes
183-
VULKAN_FLAGS="-DVK_USE_PLATFORM_WAYLAND_KHR -DVULKAN_ENABLED"
184-
],
185-
[ VULKAN_FOUND=no; break ]
186-
)
187-
fi
188-
189-
if test "x$VULKAN_FOUND" = xno; then
190-
HELP_MSG_MISSING_DEPENDENCY([vulkan])
191-
AC_MSG_ERROR([Could not find vulkan! $HELP_MSG ])
192-
else
193-
# Find shader compiler - glslc or glslangValidator
194-
if (test "x${with_vulkan_shader_compiler}" = x || test "x${with_vulkan_shader_compiler}" = xglslc); then
195-
UTIL_LOOKUP_PROGS(GLSLC, glslc)
196-
SHADER_COMPILER="$GLSLC"
197-
VULKAN_SHADER_COMPILER="glslc --target-env=vulkan1.2 -mfmt=num -o"
198-
fi
199-
200-
if (test "x${with_vulkan_shader_compiler}" = x || test "x${with_vulkan_shader_compiler}" = xglslangValidator) && \
201-
test "x$SHADER_COMPILER" = x; then
202-
UTIL_LOOKUP_PROGS(GLSLANG, glslangValidator)
203-
SHADER_COMPILER="$GLSLANG"
204-
VULKAN_SHADER_COMPILER="glslangValidator --target-env vulkan1.2 -x -o"
205-
fi
206-
207-
if test "x$SHADER_COMPILER" != x; then
208-
VULKAN_ENABLED=true
209-
else
210-
AC_MSG_ERROR([Can't find shader compiler])
211-
fi
212-
fi
213-
fi
214-
fi
215125
fi
216-
AC_SUBST(VULKAN_FLAGS)
217-
AC_SUBST(VULKAN_SHADER_COMPILER)
218-
AC_SUBST(VULKAN_ENABLED)
219126
AC_SUBST(WAYLAND_CFLAGS)
220127
AC_SUBST(WAYLAND_LIBS)
221128
AC_SUBST(WAYLAND_PROTOCOLS_ROOT)

make/autoconf/libraries.m4

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ m4_include([lib-x11.m4])
3636
m4_include([lib-speechd.m4])
3737
m4_include([lib-nvdacontrollerclient.m4])
3838
m4_include([lib-dbus.m4])
39+
m4_include([lib-vulkan.m4])
3940
m4_include([lib-wayland.m4])
4041
m4_include([lib-tests.m4])
4142

@@ -50,7 +51,6 @@ AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
5051
NEEDS_LIB_X11=false
5152
NEEDS_LIB_SPEECHD=false
5253
NEEDS_LIB_WAYLAND=false
53-
SUPPORTS_LIB_VULKAN=false
5454
else
5555
# All other instances need X11, even if building headless only, libawt still
5656
# needs X11 headers.
@@ -59,14 +59,15 @@ AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
5959
if test "x$ENABLE_HEADLESS_ONLY" = xtrue; then
6060
NEEDS_LIB_SPEECHD=false
6161
NEEDS_LIB_WAYLAND=false
62-
SUPPORTS_LIB_VULKAN=false
6362
else
6463
NEEDS_LIB_SPEECHD=true
6564
NEEDS_LIB_WAYLAND=true
66-
SUPPORTS_LIB_VULKAN=true
6765
fi
6866
fi
6967
68+
# Vulkan is not built by default
69+
NEEDS_LIB_VULKAN=false
70+
7071
# Check if fontconfig is needed
7172
if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
7273
# No fontconfig support on windows or macosx
@@ -148,6 +149,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
148149
LIB_SETUP_SPEECHD
149150
LIB_SETUP_NVDACONTROLLERCLIENT
150151
LIB_SETUP_DBUS
152+
LIB_SETUP_VULKAN
151153
LIB_SETUP_WAYLAND
152154
LIB_TESTS_SETUP_GTEST
153155

make/autoconf/spec.gmk.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ WAYLAND_LIBS:=@WAYLAND_LIBS@
493493
WAYLAND_PROTOCOLS_ROOT:=@WAYLAND_PROTOCOLS_ROOT@
494494
WAYLAND_SCANNER:=@WAYLAND_SCANNER@
495495
GTK_SHELL1_PROTOCOL_PATH:=@GTK_SHELL1_PROTOCOL_PATH@
496+
VULKAN_ENABLED:=@VULKAN_ENABLED@
496497
VULKAN_FLAGS:=@VULKAN_FLAGS@
497498
VULKAN_SHADER_COMPILER:=@VULKAN_SHADER_COMPILER@
498-
VULKAN_ENABLED:=@VULKAN_ENABLED@
499499

500500
# The lowest required version of macosx
501501
MACOSX_VERSION_MIN := @MACOSX_VERSION_MIN@

make/modules/java.desktop/Java.gmk

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ ifeq ($(call isTargetOs, macosx), true)
6363
sun/awt/wl \
6464
sun/java2d/wl \
6565
sun/java2d/x11 \
66-
sun/java2d/vulkan \
6766
sun/java2d/jules \
6867
sun/java2d/xr \
6968
com/sun/java/swing/plaf/gtk \
@@ -129,6 +128,10 @@ ifeq ($(call isTargetOs, windows macosx), false)
129128
EXCLUDE_FILES += sun/awt/AWTCharset.java
130129
endif
131130

131+
ifneq ($(VULKAN_ENABLED), true)
132+
EXCLUDES += sun/java2d/vulkan
133+
endif
134+
132135
# These files do not appear in the build result of the old build. This
133136
# is because they are generated sources, but the AUTO_JAVA_FILES won't
134137
# pick them up since they aren't generated when the source dirs are

make/modules/java.desktop/lib/AwtLibraries.gmk

+13-14
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,20 @@ ifeq ($(call isTargetOs, windows), true)
144144
LIBAWT_CFLAGS += $(A11Y_JAWS_ANNOUNCING_CFLAGS)
145145
endif
146146

147+
# Setup Vulkan
148+
ifeq ($(VULKAN_ENABLED), true)
149+
LIBAWT_EXTRA_SRC += common/font common/java2d/vulkan
150+
LIBAWT_EXTRA_HEADER_DIRS += common/font common/java2d/vulkan common/java2d
151+
LIBAWT_CFLAGS += $(VULKAN_FLAGS)
152+
LIBAWT_EXTRA_FILES += $(TOPDIR)/src/$(MODULE)/share/native/common/java2d/AccelTexturePool.c
153+
endif
154+
147155
# -fgcse-after-reload improves performance of MaskFill in Java2D by 20% for
148156
# some gcc
149157
$(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
150158
NAME := awt, \
151159
EXTRA_SRC := $(LIBAWT_EXTRA_SRC), \
160+
EXTRA_FILES := $(LIBAWT_EXTRA_FILES), \
152161
EXCLUDE_FILES := $(LIBAWT_EXCLUDE_FILES), \
153162
OPTIMIZATION := HIGHEST, \
154163
CFLAGS := $(LIBAWT_CFLAGS) $(X_CFLAGS) $(DBUS_CFLAGS), \
@@ -229,8 +238,8 @@ ifeq ($(VULKAN_ENABLED), true)
229238
$(ECHO) '#include "spirv/$f.h"' >> $(VULKAN_SHADER_LIST) $(NEWLINE) \
230239
$(ECHO) BYTECODE_END >> $(VULKAN_SHADER_LIST) $(NEWLINE) \
231240
$(ECHO) '#endif' >> $(VULKAN_SHADER_LIST) $(NEWLINE) \
232-
)
233-
$(BUILD_LIBAWT): $(VULKAN_SHADER_LIST)
241+
)
242+
$(BUILD_LIBAWT_TARGET_DEPS): $(VULKAN_SHADER_LIST)
234243
endif
235244

236245
TARGETS += $(BUILD_LIBAWT)
@@ -252,7 +261,6 @@ ifeq ($(call isTargetOs, windows macosx), false)
252261
common/awt/debug \
253262
common/font \
254263
common/java2d/opengl \
255-
common/java2d/vulkan \
256264
java.base:libjvm \
257265
#
258266

@@ -417,15 +425,9 @@ ifeq ($(call isTargetOs, windows macosx), false)
417425
$(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/wayland \
418426
#
419427

420-
LIBAWT_WLAWT_EXCLUDES := medialib debug opengl x11
428+
LIBAWT_WLAWT_EXCLUDES := medialib debug opengl vulkan x11
421429
LIBAWT_WLAWT_EXCLUDE_FILES := common/awt/X11Color.c common/awt/awt_Font.c
422430

423-
# Substitute Vulkan with stubs if disabled.
424-
ifeq ($(VULKAN_ENABLED), false)
425-
LIBAWT_WLAWT_EXCLUDES += vulkan
426-
LIBAWT_WLAWT_EXTRA_FILES += $(TOPDIR)/src/$(MODULE)/share/native/common/java2d/vulkan/VKStubs.c
427-
endif
428-
429431
LIBAWT_WLAWT_EXTRA_HEADER_DIRS := \
430432
$(LIBAWT_DEFAULT_HEADER_DIRS) \
431433
libawt_wlawt/awt \
@@ -453,8 +455,6 @@ ifeq ($(call isTargetOs, windows macosx), false)
453455
$(WAYLAND_CFLAGS) \
454456
$(CUPS_CFLAGS)
455457

456-
LIBAWT_WLAWT_CXXFLAGS += $(VULKAN_FLAGS)
457-
458458
ifeq ($(TOOLCHAIN_TYPE), gcc)
459459
# Turn off all warnings for the following files since they contain warnings
460460
# that cannot be turned of individually.
@@ -529,8 +529,7 @@ ifeq ($(call isTargetOs, macosx), true)
529529
#
530530

531531
LIBAWT_LWAWT_EXCLUDE_FILES := fontpath.c awt_Font.c X11Color.c
532-
LIBAWT_LWAWT_EXCLUDES := \
533-
$(TOPDIR)/src/$(MODULE)/share/native/common/java2d/vulkan \
532+
LIBAWT_LWAWT_EXCLUDES := vulkan \
534533
$(TOPDIR)/src/$(MODULE)/unix/native/common/awt/medialib \
535534
#
536535

0 commit comments

Comments
 (0)