|
| 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 | +]) |
0 commit comments