From 1bef6be2ca46a94de785b4ff047842c4058978b0 Mon Sep 17 00:00:00 2001 From: Nikita Gubarkov Date: Mon, 13 Oct 2025 15:33:13 +0200 Subject: [PATCH] JBR-9438 Vulkan: JBR API for accessing configuration info --- .../classes/com/jetbrains/desktop/Vulkan.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/java.desktop/share/classes/com/jetbrains/desktop/Vulkan.java diff --git a/src/java.desktop/share/classes/com/jetbrains/desktop/Vulkan.java b/src/java.desktop/share/classes/com/jetbrains/desktop/Vulkan.java new file mode 100644 index 000000000000..baeb65b56a2b --- /dev/null +++ b/src/java.desktop/share/classes/com/jetbrains/desktop/Vulkan.java @@ -0,0 +1,68 @@ +/* + * Copyright 2025 JetBrains s.r.o. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.jetbrains.desktop; + +import com.jetbrains.exported.JBRApi; +import sun.java2d.vulkan.VKEnv; +import sun.java2d.vulkan.VKGPU; + +@JBRApi.Service +@JBRApi.Provides("Vulkan") +public class Vulkan { + + Vulkan() { + if (!VKEnv.isVulkanEnabled()) throw new JBRApi.ServiceNotAvailableException("Vulkan is not enabled"); + } + + boolean isPresentationEnabled() { + return VKEnv.isPresentationEnabled(); + } + + Device[] getDevices() { + return VKEnv.getDevices().map(Device::new).toArray(Device[]::new); + } + + @JBRApi.Provides("Vulkan.Device") + static class Device { + private final VKGPU device; + + Device(VKGPU device) { + this.device = device; + } + + String getName() { + return device.getName(); + } + + String getTypeString() { + return device.getType().toString(); + } + + int getCapabilities() { + return device.getCaps(); + } + } +}