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") { ...@@ -26,6 +26,8 @@ config("swiftshader_config") {
"/EHs-c-", # Disable C++ exceptions "/EHs-c-", # Disable C++ exceptions
"/nologo", "/nologo",
"/Gd", # Default calling convention "/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) { if (!use_custom_libcxx) {
...@@ -181,10 +183,12 @@ group("swiftshader") { ...@@ -181,10 +183,12 @@ group("swiftshader") {
] ]
} }
group("swiftshader_tests") { if (build_with_chromium) {
testonly = true group("swiftshader_tests") {
testonly = true
data_deps = [ data_deps = [
"tests/GLESUnitTests:swiftshader_unittests", "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") { ...@@ -27,6 +27,11 @@ config("swiftshader_libvulkan_private_config") {
"VK_USE_PLATFORM_FUCHSIA=1", "VK_USE_PLATFORM_FUCHSIA=1",
"VK_EXPORT=__attribute__((visibility(\"default\")))", "VK_EXPORT=__attribute__((visibility(\"default\")))",
] ]
} else if (is_win) {
defines = [
"VK_USE_PLATFORM_WIN32_KHR=1",
"VK_EXPORT=",
]
} else { } else {
defines = [ "VK_EXPORT=" ] defines = [ "VK_EXPORT=" ]
} }
...@@ -134,19 +139,13 @@ swiftshader_shared_library("swiftshader_libvulkan") { ...@@ -134,19 +139,13 @@ swiftshader_shared_library("swiftshader_libvulkan") {
"../System", "../System",
"../WSI", "../WSI",
"../Yarn", "../Yarn",
"$swiftshader_spirv_tools_dir:SPIRV-Tools",
] ]
include_dirs = [ include_dirs = [
"..", "..",
"../../include", "../../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 ...@@ -215,4 +215,4 @@ EXPORTS
vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR
vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR
; VK_KHR_win32_surface ; VK_KHR_win32_surface
vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR
\ No newline at end of file
{ {
"file_format_version": "1.0.0", "file_format_version": "1.0.0",
"ICD": { "ICD": {
"library_path": "..\\..\\bin\\vulkan\\x64\\Debug\\vk_swiftshader.dll", "library_path": "..\\..\\bin\\vulkan\\x64\\Debug\\libvk_swiftshader.dll",
"api_version": "1.0.5" "api_version": "1.0.5"
} }
} }
\ No newline at end of file
...@@ -31,6 +31,13 @@ swiftshader_source_set("WSI") { ...@@ -31,6 +31,13 @@ swiftshader_source_set("WSI") {
] ]
} }
if (is_win) {
sources += [
"Win32SurfaceKHR.cpp",
"Win32SurfaceKHR.hpp",
]
}
include_dirs = [ include_dirs = [
"..", "..",
"../../include", "../../include",
......
...@@ -17,14 +17,11 @@ ...@@ -17,14 +17,11 @@
#include "Vulkan/VkDeviceMemory.hpp" #include "Vulkan/VkDeviceMemory.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <string.h> #include <string.h>
namespace vk { namespace vk {
Win32SurfaceKHR::Win32SurfaceKHR(const VkWin32SurfaceCreateInfoKHR *pCreateInfo, void *mem) : Win32SurfaceKHR::Win32SurfaceKHR(const VkWin32SurfaceCreateInfoKHR *pCreateInfo, void *mem) :
hinstance(pCreateInfo->hinstance),
hwnd(pCreateInfo->hwnd) hwnd(pCreateInfo->hwnd)
{ {
ASSERT(IsWindow(hwnd) == TRUE); ASSERT(IsWindow(hwnd) == TRUE);
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
#include "Vulkan/VkImage.hpp" #include "Vulkan/VkImage.hpp"
#include "VkSurfaceKHR.hpp" #include "VkSurfaceKHR.hpp"
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif // !defined(WIN32_LEAN_AND_MEAN)
#include <Windows.h> #include <Windows.h>
#include "vulkan/vulkan_win32.h" #include "vulkan/vulkan_win32.h"
...@@ -42,7 +44,6 @@ public: ...@@ -42,7 +44,6 @@ public:
void present(PresentImage* image) override; void present(PresentImage* image) override;
private: private:
const HINSTANCE hinstance;
const HWND hwnd; const HWND hwnd;
HDC windowContext = {}; HDC windowContext = {};
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
# SwiftShader libraries # SwiftShader libraries
import("//build_overrides/build.gni") 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") import("//build/config/sanitizers/sanitizers.gni")
} else { } else {
declare_args() { declare_args() {
...@@ -31,7 +33,7 @@ if (is_debug) { ...@@ -31,7 +33,7 @@ if (is_debug) {
configs_to_delete += [ "//build/config/compiler:chromium_code" ] configs_to_delete += [ "//build/config/compiler:chromium_code" ]
configs_to_add += [ configs_to_add += [
"//build/config/compiler:no_chromium_code", "//build/config/compiler:no_chromium_code",
"//third_party/swiftshader:swiftshader_config", "$swiftshader_dir:swiftshader_config",
] ]
template("swiftshader_source_set") { template("swiftshader_source_set") {
......
...@@ -13,48 +13,51 @@ ...@@ -13,48 +13,51 @@
# limitations under the License. # limitations under the License.
import("//testing/test.gni") import("//testing/test.gni")
import("../../src/swiftshader.gni")
test("swiftshader_unittests") { if (build_with_chromium) {
deps = [ test("swiftshader_unittests") {
"//base", deps = [
"//base/test:test_support", "//base",
"//testing/gmock", "//base/test:test_support",
"//testing/gtest", "//testing/gmock",
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL", "//testing/gtest",
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2", "//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
] "//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
sources = [
"//gpu/swiftshader_tests_main.cc",
"unittests.cpp",
]
include_dirs = [ "../../include" ] # Khronos headers sources = [
"//gpu/swiftshader_tests_main.cc",
"unittests.cpp",
]
defines = [ include_dirs = [ "../../include" ] # Khronos headers
"GL_GLEXT_PROTOTYPES",
"GL_APICALL=",
"GLAPI=",
]
# Make sure we're loading SwiftShader's libraries, not ANGLE's or the system defines = [
# provided ones. On Windows an explicit LoadLibrary("swiftshader\lib*.dll") "GL_GLEXT_PROTOTYPES",
# is required before making the first EGL or OpenGL ES call. "GL_APICALL=",
if (is_win) { "GLAPI=",
ldflags = [
"/DELAYLOAD:libEGL.dll",
"/DELAYLOAD:libGLESv2.dll",
] ]
} else if (is_mac) {
ldflags = [ # Make sure we're loading SwiftShader's libraries, not ANGLE's or the system
"-rpath", # provided ones. On Windows an explicit LoadLibrary("swiftshader\lib*.dll")
"@executable_path/", # is required before making the first EGL or OpenGL ES call.
] if (is_win) {
libs = [ ldflags = [
"CoreFoundation.framework", "/DELAYLOAD:libEGL.dll",
"IOSurface.framework", "/DELAYLOAD:libGLESv2.dll",
] ]
} else { } else if (is_mac) {
ldflags = [ "-Wl,-rpath=\$ORIGIN/swiftshader" ] 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