Commit bbd8c42d by Jamie Madill

Support Windows builds and ANGLE integration.

This CL enables the Windows build integration with ANGLE. Several instances of "build_with_chromium" in the GN are changed to use build_overrides instead. Also in several places in the GN support is added for Windows builds. Also Add guards for WIN32_LEAN_AND_MEAN, and removes an unused variable that shows up when building with GN on Windows configs. Bug: angleproject:3876 Bug: b/140251624 Change-Id: I7a470c7605c2b62420dca44e4797c29983ed7c13 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35631Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 69ffc317
......@@ -26,6 +26,8 @@ config("swiftshader_config") {
"/EHs-c-", # Disable C++ exceptions
"/nologo",
"/Gd", # Default calling convention
# Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
]
if (!use_custom_libcxx) {
......@@ -181,10 +183,12 @@ group("swiftshader") {
]
}
group("swiftshader_tests") {
testonly = true
if (build_with_chromium) {
group("swiftshader_tests") {
testonly = true
data_deps = [
"tests/GLESUnitTests:swiftshader_unittests",
]
}
data_deps = [
"tests/GLESUnitTests:swiftshader_unittests",
]
}
}
\ No newline at end of file
# Copyright 2019 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# We are building inside SwiftShader
spirv_tools_standalone = false
# Paths to SPIRV-Tools dependencies in SwiftShader
spirv_tools_googletest_dir = "//third_party/googletest"
spirv_tools_spirv_headers_dir = "//third_party/SPIRV-Headers"
# Copyright 2019 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# We are building SwiftShader standalone
swiftshader_standalone = true
# Path to SwiftShader
swiftshader_dir = "//"
# Paths to SwiftShader dependencies
swiftshader_spirv_tools_dir = "//third_party/SPIRV-Tools"
......@@ -27,6 +27,11 @@ config("swiftshader_libvulkan_private_config") {
"VK_USE_PLATFORM_FUCHSIA=1",
"VK_EXPORT=__attribute__((visibility(\"default\")))",
]
} else if (is_win) {
defines = [
"VK_USE_PLATFORM_WIN32_KHR=1",
"VK_EXPORT=",
]
} else {
defines = [ "VK_EXPORT=" ]
}
......@@ -134,19 +139,13 @@ swiftshader_shared_library("swiftshader_libvulkan") {
"../System",
"../WSI",
"../Yarn",
"$swiftshader_spirv_tools_dir:SPIRV-Tools",
]
include_dirs = [
"..",
"../../include",
"../../third_party/SPIRV-Headers/include",
"$swiftshader_spirv_tools_dir/include",
"$spirv_tools_spirv_headers_dir/include",
]
if (build_with_chromium) {
deps += [ "//third_party/SPIRV-Tools/src:SPIRV-Tools" ]
include_dirs += [ "//third_party/SPIRV-Tools/src/include" ]
} else {
deps += [ "../../third_party/SPIRV-Tools" ]
include_dirs += [ "../../third_party/SPIRV-Tools/include" ]
}
}
......@@ -215,4 +215,4 @@ EXPORTS
vkGetPhysicalDeviceSurfaceFormatsKHR
vkGetPhysicalDeviceSurfacePresentModesKHR
; VK_KHR_win32_surface
vkCreateWin32SurfaceKHR
\ No newline at end of file
vkCreateWin32SurfaceKHR
{
"file_format_version": "1.0.0",
"ICD": {
"library_path": "..\\..\\bin\\vulkan\\x64\\Debug\\vk_swiftshader.dll",
"library_path": "..\\..\\bin\\vulkan\\x64\\Debug\\libvk_swiftshader.dll",
"api_version": "1.0.5"
}
}
\ No newline at end of file
......@@ -31,6 +31,13 @@ swiftshader_source_set("WSI") {
]
}
if (is_win) {
sources += [
"Win32SurfaceKHR.cpp",
"Win32SurfaceKHR.hpp",
]
}
include_dirs = [
"..",
"../../include",
......
......@@ -17,14 +17,11 @@
#include "Vulkan/VkDeviceMemory.hpp"
#include "Vulkan/VkDebug.hpp"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <string.h>
namespace vk {
Win32SurfaceKHR::Win32SurfaceKHR(const VkWin32SurfaceCreateInfoKHR *pCreateInfo, void *mem) :
hinstance(pCreateInfo->hinstance),
hwnd(pCreateInfo->hwnd)
{
ASSERT(IsWindow(hwnd) == TRUE);
......
......@@ -19,7 +19,9 @@
#include "Vulkan/VkImage.hpp"
#include "VkSurfaceKHR.hpp"
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
#endif // !defined(WIN32_LEAN_AND_MEAN)
#include <Windows.h>
#include "vulkan/vulkan_win32.h"
......@@ -42,7 +44,6 @@ public:
void present(PresentImage* image) override;
private:
const HINSTANCE hinstance;
const HWND hwnd;
HDC windowContext = {};
......
......@@ -6,8 +6,10 @@
# SwiftShader libraries
import("//build_overrides/build.gni")
import("//build_overrides/spirv_tools.gni")
import("//build_overrides/swiftshader.gni")
if (build_with_chromium) {
if (!swiftshader_standalone) {
import("//build/config/sanitizers/sanitizers.gni")
} else {
declare_args() {
......@@ -31,7 +33,7 @@ if (is_debug) {
configs_to_delete += [ "//build/config/compiler:chromium_code" ]
configs_to_add += [
"//build/config/compiler:no_chromium_code",
"//third_party/swiftshader:swiftshader_config",
"$swiftshader_dir:swiftshader_config",
]
template("swiftshader_source_set") {
......
......@@ -13,48 +13,51 @@
# limitations under the License.
import("//testing/test.gni")
import("../../src/swiftshader.gni")
test("swiftshader_unittests") {
deps = [
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
sources = [
"//gpu/swiftshader_tests_main.cc",
"unittests.cpp",
]
if (build_with_chromium) {
test("swiftshader_unittests") {
deps = [
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
include_dirs = [ "../../include" ] # Khronos headers
sources = [
"//gpu/swiftshader_tests_main.cc",
"unittests.cpp",
]
defines = [
"GL_GLEXT_PROTOTYPES",
"GL_APICALL=",
"GLAPI=",
]
include_dirs = [ "../../include" ] # Khronos headers
# Make sure we're loading SwiftShader's libraries, not ANGLE's or the system
# provided ones. On Windows an explicit LoadLibrary("swiftshader\lib*.dll")
# is required before making the first EGL or OpenGL ES call.
if (is_win) {
ldflags = [
"/DELAYLOAD:libEGL.dll",
"/DELAYLOAD:libGLESv2.dll",
defines = [
"GL_GLEXT_PROTOTYPES",
"GL_APICALL=",
"GLAPI=",
]
} else if (is_mac) {
ldflags = [
"-rpath",
"@executable_path/",
]
libs = [
"CoreFoundation.framework",
"IOSurface.framework",
]
} else {
ldflags = [ "-Wl,-rpath=\$ORIGIN/swiftshader" ]
# Make sure we're loading SwiftShader's libraries, not ANGLE's or the system
# provided ones. On Windows an explicit LoadLibrary("swiftshader\lib*.dll")
# is required before making the first EGL or OpenGL ES call.
if (is_win) {
ldflags = [
"/DELAYLOAD:libEGL.dll",
"/DELAYLOAD:libGLESv2.dll",
]
} else if (is_mac) {
ldflags = [
"-rpath",
"@executable_path/",
]
libs = [
"CoreFoundation.framework",
"IOSurface.framework",
]
} else {
ldflags = [ "-Wl,-rpath=\$ORIGIN/swiftshader" ]
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment