Compare commits

..

2 Commits

Author SHA1 Message Date
Maxim Kartashev
47797d94b9 Implemented GraphicsEnvironment and Device, HiDPI (scaling) support 2022-12-09 09:04:33 +03:00
Maxim Kartashev
9942659c5e Dialog and window menu support 2022-11-23 13:36:35 +03:00
11 changed files with 6 additions and 569 deletions

View File

@@ -1,6 +1,6 @@
#
# Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2023, JetBrains s.r.o.. All rights reserved.
# Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -42,8 +42,6 @@ AC_DEFUN_ONCE([LIB_SETUP_WAYLAND],
fi
WAYLAND_CFLAGS=
WAYLAND_LIBS=
VULKAN_FLAGS=
VULKAN_ENABLED=false
else
WAYLAND_FOUND=no
@@ -89,74 +87,8 @@ AC_DEFUN_ONCE([LIB_SETUP_WAYLAND],
HELP_MSG_MISSING_DEPENDENCY([wayland])
AC_MSG_ERROR([Could not find wayland! $HELP_MSG ])
fi
# Checking for vulkan sdk
AC_ARG_WITH(vulkan, [AS_HELP_STRING([--with-vulkan],
[specify whether we use vulkan])])
AC_ARG_WITH(vulkan-include, [AS_HELP_STRING([--with-vulkan-include],
[specify directory for the vulkan include files])])
if test "x$SUPPORTS_LIB_VULKAN" = xfalse; then
if (test "x${with_vulkan}" != x && test "x${with_vulkan}" != xno) || \
(test "x${with_vulkan_include}" != x && test "x${with_vulkan_include}" != xno); then
AC_MSG_WARN([[vulkan not used, so --with-vulkan-include is ignored]])
fi
VULKAN_FLAGS=
VULKAN_ENABLED=false
else
# Do not build vulkan rendering pipeline by default
if (test "x${with_vulkan}" = x && test "x${with_vulkan_include}" = x) || \
test "x${with_vulkan}" = xno || test "x${with_vulkan_include}" = xno ; then
VULKAN_FLAGS=
VULKAN_ENABLED=false
else
VULKAN_FOUND=no
if test "x${with_vulkan_include}" != x; then
AC_CHECK_HEADERS([${with_vulkan_include}/include/vulkan/vulkan.h],
[ VULKAN_FOUND=yes
VULKAN_FLAGS="-DVK_USE_PLATFORM_WAYLAND_KHR -I${with_vulkan_include}/include -DVULKAN_ENABLED"
VULKAN_ENABLED=true
],
[ AC_MSG_ERROR([Can't find 'vulkan/vulkan.h' under '${with_vulkan_include}']) ]
)
fi
if test "x$VULKAN_FOUND" = xno; then
# Check vulkan sdk location
AC_CHECK_HEADERS([$VULKAN_SDK/include/vulkan/vulkan.h],
[ VULKAN_FOUND=yes
VULKAN_FLAGS="-DVK_USE_PLATFORM_WAYLAND_KHR -I${VULKAN_SDK}/include -DVULKAN_ENABLED"
VULKAN_ENABLED=true
],
[ VULKAN_FOUND=no; break ]
)
fi
if test "x$VULKAN_FOUND" = xno; then
# Check default /usr/include location
AC_CHECK_HEADERS([vulkan/vulkan.h],
[ VULKAN_FOUND=yes
VULKAN_FLAGS="-DVK_USE_PLATFORM_WAYLAND_KHR -DVULKAN_ENABLED"
VULKAN_ENABLED=true
],
[ VULKAN_FOUND=no; break ]
)
fi
if test "x$VULKAN_FOUND" = xno; then
HELP_MSG_MISSING_DEPENDENCY([vulkan])
AC_MSG_ERROR([Could not find vulkan! $HELP_MSG ])
fi
fi
fi
fi
AC_SUBST(VULKAN_FLAGS)
AC_SUBST(VULKAN_ENABLED)
AC_SUBST(WAYLAND_CFLAGS)
AC_SUBST(WAYLAND_LIBS)
])

View File

@@ -42,23 +42,20 @@ m4_include([lib-tests.m4])
################################################################################
AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
[
# Check if X11, wayland and vulkan is needed
# Check if X11 and wayland is needed
if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then
# No X11 and wayland support on windows or macosx
NEEDS_LIB_X11=false
NEEDS_LIB_WAYLAND=false
SUPPORTS_LIB_VULKAN=false
elif test "x$ENABLE_HEADLESS_ONLY" = xtrue; then
# No X11 support needed when building headless only
NEEDS_LIB_X11=false
NEEDS_LIB_WAYLAND=false
SUPPORTS_LIB_VULKAN=false
else
# All other instances need X11 and wayland, even if building headless only, libawt still
# needs X11 headers.
NEEDS_LIB_X11=true
NEEDS_LIB_WAYLAND=true
SUPPORTS_LIB_VULKAN=true
fi
# Check if fontconfig is needed

View File

@@ -455,8 +455,6 @@ X_CFLAGS:=@X_CFLAGS@
X_LIBS:=@X_LIBS@
WAYLAND_CFLAGS:=@WAYLAND_CFLAGS@
WAYLAND_LIBS:=@WAYLAND_LIBS@
VULKAN_FLAGS:=@VULKAN_FLAGS@
VULKAN_ENABLED:=@VULKAN_ENABLED@
# The lowest required version of macosx
MACOSX_VERSION_MIN=@MACOSX_VERSION_MIN@
# The highest allowed version of macosx

View File

@@ -190,7 +190,7 @@ ifeq ($(call isTargetOs, windows macosx), false)
common/font \
#
LIBAWT_XAWT_EXCLUDES := medialib debug wl vulkan
LIBAWT_XAWT_EXCLUDES := medialib debug wl
LIBAWT_XAWT_EXTRA_HEADER_DIRS := \
$(LIBAWT_DEFAULT_HEADER_DIRS) \
@@ -274,12 +274,6 @@ ifeq ($(call isTargetOs, windows macosx), false)
LIBAWT_WLAWT_EXCLUDES := medialib debug opengl x11
LIBAWT_WLAWT_EXCLUDE_FILES := common/awt/X11Color.c common/awt/awt_Font.c
# Substitute Vulkan with stubs if disabled.
ifeq ($(VULKAN_ENABLED), false)
LIBAWT_WLAWT_EXCLUDES += vulkan
LIBAWT_WLAWT_EXTRA_FILES += $(TOPDIR)/src/$(MODULE)/share/native/common/java2d/vulkan/VKStubs.c
endif
LIBAWT_WLAWT_EXTRA_HEADER_DIRS := \
$(LIBAWT_DEFAULT_HEADER_DIRS) \
libawt_wlawt/awt \
@@ -288,7 +282,6 @@ ifeq ($(call isTargetOs, windows macosx), false)
common/awt/systemscale \
common/font \
common/java2d/wl \
common/java2d/vulkan \
#
# Enable 'wakefield' extension for java.awt.Robot support
@@ -297,11 +290,8 @@ ifeq ($(call isTargetOs, windows macosx), false)
LIBAWT_WLAWT_CFLAGS += -DWLAWT \
$(WAKEFIELD_ROBOT_CFLAGS) \
$(FONTCONFIG_CFLAGS) \
$(VULKAN_FLAGS) \
$(CUPS_CFLAGS)
LIBAWT_WLAWT_CXXFLAGS += $(VULKAN_FLAGS)
LIBAWT_WLAWT_LIBS := $(LIBM) -lawt $(WAYLAND_LIBS) $(LIBDL) -ljava -ljvm -lrt
ifeq ($(call isTargetOs, linux), true)
@@ -320,20 +310,16 @@ ifeq ($(call isTargetOs, windows macosx), false)
$(eval $(call SetupJdkLibrary, BUILD_LIBAWT_WLAWT, \
NAME := awt_wlawt, \
EXCLUDE_FILES := $(LIBAWT_WLAWT_EXCLUDE_FILES), \
EXTRA_FILES := $(LIBAWT_WLAWT_EXTRA_FILES), \
EXTRA_SRC := $(LIBAWT_WLAWT_EXTRA_SRC), \
EXTRA_HEADER_DIRS := $(LIBAWT_WLAWT_EXTRA_HEADER_DIRS), \
EXCLUDES := $(LIBAWT_WLAWT_EXCLUDES), \
OPTIMIZATION := LOW, \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_WLAWT_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBAWT_WLAWT_CXXFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_C_gcc := type-limits pointer-to-int-cast \
DISABLED_WARNINGS_gcc := type-limits pointer-to-int-cast \
unused-result maybe-uninitialized format \
format-security int-to-pointer-cast parentheses \
implicit-fallthrough undef unused-function, \
DISABLED_WARNINGS_CXX_gcc := undef, \
DISABLED_WARNINGS_clang := parentheses format undef \
logical-op-parentheses format-nonliteral int-conversion, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
@@ -451,7 +437,7 @@ ifeq ($(call isTargetOs, windows macosx), false)
$(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
#
LIBAWT_HEADLESS_EXCLUDES := medialib wl vulkan
LIBAWT_HEADLESS_EXCLUDES := medialib
LIBAWT_HEADLESS_EXTRA_HEADER_DIRS := \
$(LIBAWT_DEFAULT_HEADER_DIRS) \

View File

@@ -1,336 +0,0 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* 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.
*/
#include "VKBase.h"
#include <Trace.h>
#include <set>
#define VALIDATION_LAYER_NAME "VK_LAYER_KHRONOS_validation"
static const uint32_t REQUIRED_VULKAN_VERSION = VK_MAKE_API_VERSION(0, 1, 0, 0);
// ========== Vulkan instance ==========
static vk::raii::Context* context = nullptr;
vk::raii::Instance vkInstance = nullptr;
#if defined(DEBUG)
static vk::raii::DebugUtilsMessengerEXT debugMessenger = nullptr;
static VkBool32 debugCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData
) {
auto data = (const vk::DebugUtilsMessengerCallbackDataEXT*) pCallbackData;
if (data == nullptr) return 0;
// Here we can filter messages like this:
// if (std::strcmp(data->pMessageIdName, "UNASSIGNED-BestPractices-DrawState-ClearCmdBeforeDraw") == 0) return 0;
int level = J2D_TRACE_OFF;
if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) level = J2D_TRACE_VERBOSE;
else if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) level = J2D_TRACE_INFO;
else if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) level = J2D_TRACE_WARNING;
else if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) level = J2D_TRACE_ERROR;
J2dRlsTraceLn(level, data->pMessage);
// TODO if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) ABORT?
return 0;
}
#endif
static bool createInstance() {
try {
// Load library.
vk::raii::Context ctx;
uint32_t version = ctx.enumerateInstanceVersion();
J2dRlsTrace3(J2D_TRACE_INFO, "Vulkan: Available (%d.%d.%d)\n",
VK_API_VERSION_MAJOR(version), VK_API_VERSION_MINOR(version), VK_API_VERSION_PATCH(version));
if (version < REQUIRED_VULKAN_VERSION) {
J2dRlsTrace(J2D_TRACE_ERROR, "Vulkan: Unsupported version\n");
return false;
}
// Populate maps and log supported layers & extensions.
std::set<std::string> layers, extensions;
J2dRlsTrace(J2D_TRACE_VERBOSE, " Supported instance layers:\n");
for (auto& l : ctx.enumerateInstanceLayerProperties()) {
J2dRlsTrace1(J2D_TRACE_VERBOSE, " %s\n", (char*) l.layerName);
layers.emplace((char*) l.layerName);
}
J2dRlsTrace(J2D_TRACE_VERBOSE, " Supported instance extensions:\n");
for (auto& e : ctx.enumerateInstanceExtensionProperties(nullptr)) {
J2dRlsTrace1(J2D_TRACE_VERBOSE, " %s\n", (char*) e.extensionName);
extensions.emplace((char*) e.extensionName);
}
std::vector<const char*> enabledLayers, enabledExtensions;
const void* pNext = nullptr;
// Check required layers & extensions.
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
enabledExtensions.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
#endif
enabledExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
bool requiredNotFound = false;
for (auto e : enabledExtensions) {
if (extensions.find(e) == extensions.end()) {
J2dRlsTrace1(J2D_TRACE_ERROR, "Vulkan: Required instance extension not supported: %s\n", (char*) e);
requiredNotFound = true;
}
}
if (requiredNotFound) return false;
// Configure validation
#ifdef DEBUG
std::array<vk::ValidationFeatureEnableEXT, 4> enabledValidationFeatures = {
vk::ValidationFeatureEnableEXT::eGpuAssisted,
vk::ValidationFeatureEnableEXT::eGpuAssistedReserveBindingSlot,
vk::ValidationFeatureEnableEXT::eBestPractices,
vk::ValidationFeatureEnableEXT::eSynchronizationValidation
};
vk::ValidationFeaturesEXT validationFeatures {enabledValidationFeatures};
if (layers.find(VALIDATION_LAYER_NAME) != layers.end() &&
extensions.find(VK_EXT_DEBUG_UTILS_EXTENSION_NAME) != extensions.end()) {
enabledLayers.push_back(VALIDATION_LAYER_NAME);
enabledExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
pNext = &validationFeatures;
} else {
J2dRlsTrace2(J2D_TRACE_WARNING, "Vulkan: %s and %s are not supported\n",
VALIDATION_LAYER_NAME, VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
#endif
vk::ApplicationInfo applicationInfo {
/*pApplicationName*/ "OpenJDK",
/*applicationVersion*/ 0,
/*pEngineName*/ "OpenJDK",
/*engineVersion*/ 0,
/*apiVersion*/ REQUIRED_VULKAN_VERSION
};
vk::InstanceCreateInfo instanceCreateInfo {
/*flags*/ {},
/*pApplicationInfo*/ &applicationInfo,
/*ppEnabledLayerNames*/ enabledLayers,
/*ppEnabledExtensionNames*/ enabledExtensions,
/*pNext*/ pNext
};
// Save context object at persistent address before passing it further.
context = new vk::raii::Context(std::move(ctx));
vkInstance = vk::raii::Instance(*context, instanceCreateInfo);
J2dRlsTrace(J2D_TRACE_INFO, "Vulkan: Instance created\n");
// Create debug messenger
#if defined(DEBUG)
if (pNext) {
debugMessenger = vk::raii::DebugUtilsMessengerEXT(vkInstance, vk::DebugUtilsMessengerCreateInfoEXT {
/*flags*/ {},
/*messageSeverity*/ vk::DebugUtilsMessageSeverityFlagBitsEXT::eError |
vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |
vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo |
vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose,
/*messageType*/ vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral |
vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation |
vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance,
/*pfnUserCallback*/ &debugCallback
});
}
#endif
return true;
} catch (std::exception& e) {
// Usually this means we didn't find the shared library.
J2dRlsTrace1(J2D_TRACE_ERROR, "Vulkan: %s\n", e.what());
return false;
}
}
// ========== Vulkan device ==========
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
extern struct wl_display *wl_display;
#endif
class PhysicalDevice : vk::raii::PhysicalDevice {
friend class Device;
bool supported = false;
int queueFamily = -1;
std::vector<const char*> enabledLayers, enabledExtensions;
public:
PhysicalDevice(vk::raii::PhysicalDevice&& handle) : vk::raii::PhysicalDevice(std::move(handle)) {
const auto& properties = getProperties();
const auto& queueFamilies = getQueueFamilyProperties();
J2dRlsTrace5(J2D_TRACE_INFO, "Vulkan: Found device %s (%d.%d.%d, %s)\n",
(const char*) properties.deviceName,
VK_API_VERSION_MAJOR(properties.apiVersion),
VK_API_VERSION_MINOR(properties.apiVersion),
VK_API_VERSION_PATCH(properties.apiVersion),
vk::to_string(properties.deviceType).c_str());
if (properties.apiVersion < REQUIRED_VULKAN_VERSION) {
J2dRlsTrace(J2D_TRACE_INFO, " Unsupported Vulkan version\n");
return;
}
// Check supported queue families.
for (unsigned int i = 0; i < queueFamilies.size(); i++) {
const auto& family = queueFamilies[i];
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
bool presentationSupported = getWaylandPresentationSupportKHR(i, *wl_display);
#endif
char logFlags[5] {
family.queueFlags & vk::QueueFlagBits::eGraphics ? 'G' : '-',
family.queueFlags & vk::QueueFlagBits::eCompute ? 'C' : '-',
family.queueFlags & vk::QueueFlagBits::eTransfer ? 'T' : '-',
family.queueFlags & vk::QueueFlagBits::eSparseBinding ? 'S' : '-',
presentationSupported ? 'P' : '-'
};
J2dRlsTrace3(J2D_TRACE_INFO, " %d queues in family (%.*s)\n", family.queueCount, 5, logFlags);
// TODO use compute workloads? Separate transfer-only DMA queue?
if (queueFamily == -1 && (family.queueFlags & vk::QueueFlagBits::eGraphics) && presentationSupported) {
queueFamily = i;
}
}
if (queueFamily == -1) {
J2dRlsTrace(J2D_TRACE_INFO, " No suitable queue\n");
return;
}
// Populate maps and log supported layers & extensions.
std::set<std::string> layers, extensions;
J2dRlsTrace(J2D_TRACE_VERBOSE, " Supported device layers:\n");
for (auto& l : enumerateDeviceLayerProperties()) {
J2dRlsTrace1(J2D_TRACE_VERBOSE, " %s\n", (char*) l.layerName);
layers.emplace((char*) l.layerName);
}
J2dRlsTrace(J2D_TRACE_VERBOSE, " Supported device extensions:\n");
for (auto& e : enumerateDeviceExtensionProperties(nullptr)) {
J2dRlsTrace1(J2D_TRACE_VERBOSE, " %s\n", (char*) e.extensionName);
extensions.emplace((char*) e.extensionName);
}
// Check required layers & extensions.
enabledExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
bool requiredNotFound = false;
for (auto e : enabledExtensions) {
if (extensions.find(e) == extensions.end()) {
J2dRlsTrace1(J2D_TRACE_INFO, " Required device extension not supported: %s\n", (char*) e);
requiredNotFound = true;
}
}
if (requiredNotFound) return;
// Validation layer
#ifdef DEBUG
if (layers.find(VALIDATION_LAYER_NAME) != layers.end()) {
enabledLayers.push_back(VALIDATION_LAYER_NAME);
} else {
J2dRlsTrace1(J2D_TRACE_INFO, " %s device layer is not supported\n", VALIDATION_LAYER_NAME);
}
#endif
// This device is supported
supported = true;
}
operator bool() const {
vk::PhysicalDevice handle = **this;
return handle && supported;
}
};
Device::Device(const PhysicalDevice& physicalDevice) : vk::raii::Device(nullptr) {
float queuePriorities[1] {1.0f}; // We only use one queue for now
std::vector<vk::DeviceQueueCreateInfo> queueCreateInfos;
queueCreateInfos.push_back(vk::DeviceQueueCreateInfo {
{}, (uint32_t) physicalDevice.queueFamily, 1, &queuePriorities[0]
});
vk::DeviceCreateInfo deviceCreateInfo {
/*flags*/ {},
/*pQueueCreateInfos*/ queueCreateInfos,
/*ppEnabledLayerNames*/ physicalDevice.enabledLayers,
/*ppEnabledExtensionNames*/ physicalDevice.enabledExtensions,
/*pEnabledFeatures*/ nullptr
};
*((vk::raii::Device*) this) = {physicalDevice, deviceCreateInfo};
J2dRlsTrace(J2D_TRACE_INFO, "Vulkan: Device created\n"); // TODO which one?
}
static std::vector<PhysicalDevice> physicalDevices; // Only supported ones.
static bool initDevices() {
try {
// Find suitable devices.
for (auto& handle : vkInstance.enumeratePhysicalDevices()) {
PhysicalDevice physicalDevice {std::move(handle)};
if (physicalDevice) { // Supported.
physicalDevices.push_back(std::move(physicalDevice));
}
}
if (physicalDevices.empty()) {
J2dRlsTrace(J2D_TRACE_ERROR, "Vulkan: No suitable device found\n");
return false;
}
// Create virtual device for a physical device.
// TODO system property for manual choice of GPU
// TODO integrated/discrete presets
// TODO performance/power saving mode switch on the fly?
Device device {physicalDevices[0]}; // TODO pick first just to check that virtual device creation works
return true;
} catch (std::exception& e) {
J2dRlsTrace1(J2D_TRACE_ERROR, "Vulkan: %s\n", e.what());
return false;
}
}
extern "C" jboolean VK_Init() {
if (createInstance() && initDevices()) {
return true;
}
physicalDevices.clear();
#if defined(DEBUG)
debugMessenger = nullptr;
#endif
vkInstance = nullptr;
delete context;
return false;
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* 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.
*/
#ifndef VKBase_h_Included
#define VKBase_h_Included
#ifdef __cplusplus
#define VK_NO_PROTOTYPES
#define VULKAN_HPP_NO_DEFAULT_DISPATCHER
#include <vulkan/vulkan_raii.hpp>
extern vk::raii::Instance vkInstance;
class PhysicalDevice;
class Device : public vk::raii::Device {
public:
Device(const PhysicalDevice& physicalDevice);
};
extern "C" {
#endif //__cplusplus
typedef unsigned char jboolean;
jboolean VK_Init();
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //VKBase_h_Included

View File

@@ -1,35 +0,0 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* 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.
*/
// These are stubs in case we were built with Vulkan disabled.
#ifndef VULKAN_ENABLED
typedef unsigned char jboolean;
jboolean VK_Init() {
return 0;
}
#endif

View File

@@ -11,23 +11,14 @@ import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.SurfaceManagerFactory;
import sun.java2d.UnixSurfaceManagerFactory;
import sun.util.logging.PlatformLogger;
import sun.util.logging.PlatformLogger.Level;
public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.wl.WLGraphicsEnvironment");
private static boolean vkwlAvailable;
static {
SurfaceManagerFactory.setInstance(new UnixSurfaceManagerFactory());
vkwlAvailable = initVKWL();
if (log.isLoggable(Level.INFO)) {
log.info("Vulkan rendering available: " + (vkwlAvailable?"YES":"NO"));
}
}
private static native boolean initVKWL();
private WLGraphicsEnvironment() {
}
@@ -39,10 +30,6 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
return Holder.INSTANCE;
}
public static boolean isVKWLAvailable() {
return vkwlAvailable;
}
@Override
protected int getNumScreens() {
try {

View File

@@ -1,8 +0,0 @@
#include "VKWLGraphicsConfig.h"
#include <dlfcn.h>
#include <Trace.h>
#include <stdint.h>
#include <jvm_md.h>
#include "jni.h"
// TODO

View File

@@ -1,6 +0,0 @@
#ifndef VKWLGraphicsConfig_h_Included
#define VKWLGraphicsConfig_h_Included
// TODO
#endif /* VKWLGraphicsConfig_h_Included */

View File

@@ -35,8 +35,6 @@
#include "jni_util.h"
#include "awt.h"
#include "WLToolkit.h"
#include "VKBase.h"
#include "VKWLGraphicsConfig.h"
typedef struct WLOutput {
struct WLOutput * next;
@@ -261,26 +259,4 @@ WLOutputByID(uint32_t id)
return NULL;
}
/*
* Class: sun_awt_wl_WLGraphicsEnvironment
* Method: initVKWL
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_wl_WLGraphicsEnvironment_initVKWL(JNIEnv *env, jclass wlge)
{
jboolean vkwlAvailable = JNI_FALSE;
/* TODO: The following sequence lead to uninitialized awt lock
BufferedImage.getGraphics()
BufferedImage.createGraphics()
GraphicsEnvironment.getLocalGraphicsEnvironment()
GraphicsEnvironment$LocalGE.createGE()
PlatformGraphicsInfo.createGE()
WLGraphicsEnvironment.initVKWL()
*/
//AWT_LOCK();
vkwlAvailable = VK_Init();
//AWT_UNLOCK();
return vkwlAvailable;
}
#endif // #ifndef HEADLESS