Remove glad and replace it with our own GL header
This completely removes the dependency on glad by generating the GL headers from gl.xml directly. This requires adding khrplatform.h so all Khronos dependencies are gathered in third_party/khronos. Also removes a stray CMakeLists.txt that was still hanging out. BUG=dawn:165 Change-Id: Ia64bc51bc8b18c6b48613918e2f309f7405ecb3b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8163 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
abdb566c30
commit
8f4046b0b6
7
BUILD.gn
7
BUILD.gn
|
@ -49,11 +49,12 @@ if (dawn_enable_opengl) {
|
|||
script = "generator/opengl_loader_generator.py"
|
||||
args = [
|
||||
"--gl-xml",
|
||||
rebase_path("third_party/gl.xml", root_build_dir),
|
||||
rebase_path("third_party/khronos/gl.xml", root_build_dir),
|
||||
]
|
||||
outputs = [
|
||||
"dawn_native/opengl/OpenGLFunctionsBase_autogen.cpp",
|
||||
"dawn_native/opengl/OpenGLFunctionsBase_autogen.h",
|
||||
"dawn_native/opengl/opengl_platform_autogen.h",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +278,7 @@ source_set("libdawn_native_sources") {
|
|||
if (dawn_enable_opengl) {
|
||||
deps += [
|
||||
":libdawn_native_opengl_loader_gen",
|
||||
"third_party:glad",
|
||||
"third_party:khronos_platform",
|
||||
]
|
||||
sources += get_target_outputs(":libdawn_native_opengl_loader_gen")
|
||||
sources += [
|
||||
|
@ -316,6 +317,7 @@ source_set("libdawn_native_sources") {
|
|||
"src/dawn_native/opengl/TextureGL.h",
|
||||
"src/dawn_native/opengl/UtilsGL.cpp",
|
||||
"src/dawn_native/opengl/UtilsGL.h",
|
||||
"src/dawn_native/opengl/opengl_platform.h",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -406,7 +408,6 @@ dawn_component("libdawn_native") {
|
|||
}
|
||||
if (dawn_enable_opengl) {
|
||||
sources += [ "src/dawn_native/opengl/OpenGLBackend.cpp" ]
|
||||
deps += [ "third_party:glad" ]
|
||||
}
|
||||
if (dawn_enable_vulkan) {
|
||||
sources += [ "src/dawn_native/vulkan/VulkanBackend.cpp" ]
|
||||
|
|
|
@ -19,7 +19,7 @@ import xml.etree.ElementTree as etree
|
|||
|
||||
from generator_lib import Generator, run_generator, FileRender
|
||||
|
||||
class Proc:
|
||||
class ProcName:
|
||||
def __init__(self, gl_name, proc_name=None):
|
||||
assert(gl_name.startswith('gl'))
|
||||
if proc_name == None:
|
||||
|
@ -40,54 +40,137 @@ class Proc:
|
|||
def __repr__(self):
|
||||
return 'Proc("{}", "{}")'.format(self.gl_name, self.proc_name)
|
||||
|
||||
ProcParam = namedtuple('ProcParam', ['name', 'type'])
|
||||
class Proc:
|
||||
def __init__(self, element):
|
||||
# Type declaration for return values and arguments all have the same
|
||||
# (weird) format.
|
||||
# <element>[A][<ptype>B</ptype>][C]<other stuff.../></element>
|
||||
#
|
||||
# Some examples are:
|
||||
# <proto>void <name>glFinish</name></proto>
|
||||
# <proto><ptype>GLenum</ptype><name>glFenceSync</name></proto>
|
||||
# <proto>const <ptype>GLubyte</ptype> *<name>glGetString</name></proto>
|
||||
#
|
||||
# This handles all the shapes found in gl.xml except for this one that
|
||||
# has an array specifier after </name>:
|
||||
# <param><ptype>GLuint</ptype> <name>baseAndCount</name>[2]</param>
|
||||
def parse_type_declaration(element):
|
||||
result = ''
|
||||
if element.text != None:
|
||||
result += element.text
|
||||
ptype = element.find('ptype')
|
||||
if ptype != None:
|
||||
result += ptype.text
|
||||
if ptype.tail != None:
|
||||
result += ptype.tail
|
||||
return result.strip()
|
||||
|
||||
proto = element.find('proto')
|
||||
|
||||
self.return_type = parse_type_declaration(proto)
|
||||
|
||||
self.params = []
|
||||
for param in element.findall('./param'):
|
||||
self.params.append(ProcParam(param.find('name').text, parse_type_declaration(param)))
|
||||
|
||||
self.gl_name = proto.find('name').text
|
||||
self.alias = None
|
||||
if element.find('alias') != None:
|
||||
self.alias = element.find('alias').attrib['name']
|
||||
|
||||
def glProcName(self):
|
||||
return self.gl_name
|
||||
|
||||
def ProcName(self):
|
||||
assert(self.gl_name.startswith('gl'))
|
||||
return self.gl_name[2:]
|
||||
|
||||
def PFNGLPROCNAME(self):
|
||||
return 'PFN' + self.gl_name.upper() + 'PROC'
|
||||
|
||||
def __repr__(self):
|
||||
return 'Proc("{}")'.format(self.gl_name)
|
||||
|
||||
EnumDefine = namedtuple('EnumDefine', ['name', 'value'])
|
||||
Version = namedtuple('Version', ['major', 'minor'])
|
||||
VersionProcBlock = namedtuple('ProcBlock', ['version', 'procs'])
|
||||
HeaderProcBlock = namedtuple('ProcBlock', ['description', 'procs'])
|
||||
VersionBlock = namedtuple('VersionBlock', ['version', 'procs', 'enums'])
|
||||
HeaderBlock = namedtuple('HeaderBlock', ['description', 'procs', 'enums'])
|
||||
|
||||
def parse_version(version):
|
||||
return Version(*map(int, version.split('.')))
|
||||
|
||||
|
||||
def compute_params(root):
|
||||
# Add proc blocks for OpenGL ES
|
||||
gles_blocks = []
|
||||
for gles_section in root.findall('''feature[@api='gles2']'''):
|
||||
section_procs = []
|
||||
for proc in gles_section.findall('./require/command'):
|
||||
section_procs.append(Proc(proc.attrib['name']))
|
||||
gles_blocks.append(VersionProcBlock(parse_version(gles_section.attrib['number']), section_procs))
|
||||
# Parse all the commands and enums
|
||||
all_procs = {}
|
||||
for command in root.findall('''commands[@namespace='GL']/command'''):
|
||||
proc = Proc(command)
|
||||
assert(proc.gl_name not in all_procs)
|
||||
all_procs[proc.gl_name] = proc
|
||||
|
||||
all_enums = {}
|
||||
for enum in root.findall('''enums[@namespace='GL']/enum'''):
|
||||
enum_name = enum.attrib['name']
|
||||
# Special case an enum we'll never use that has different values in GL and GLES
|
||||
if enum_name == 'GL_ACTIVE_PROGRAM_EXT':
|
||||
continue
|
||||
|
||||
assert(enum_name not in all_enums)
|
||||
all_enums[enum_name] = EnumDefine(enum_name, enum.attrib['value'])
|
||||
|
||||
# Get the list of all Desktop OpenGL function removed by the Core Profile.
|
||||
core_removed_procs = set()
|
||||
for removed_section in root.findall('feature/remove'):
|
||||
assert(removed_section.attrib['profile'] == 'core')
|
||||
for proc in removed_section.findall('./command'):
|
||||
for proc in root.findall('''feature/remove[@profile='core']/command'''):
|
||||
core_removed_procs.add(proc.attrib['name'])
|
||||
|
||||
# Add proc blocks for Desktop GL
|
||||
desktop_gl_blocks = []
|
||||
for gl_section in root.findall('''feature[@api='gl']'''):
|
||||
# Get list of enums and procs per OpenGL ES/Desktop OpenGL version
|
||||
def parse_version_blocks(api, removed_procs = set()):
|
||||
blocks = []
|
||||
for section in root.findall('''feature[@api='{}']'''.format(api)):
|
||||
section_procs = []
|
||||
for proc in gl_section.findall('./require/command'):
|
||||
if proc.attrib['name'] not in core_removed_procs:
|
||||
section_procs.append(Proc(proc.attrib['name']))
|
||||
desktop_gl_blocks.append(VersionProcBlock(parse_version(gl_section.attrib['number']), section_procs))
|
||||
for command in section.findall('./require/command'):
|
||||
proc_name = command.attrib['name']
|
||||
assert(all_procs[proc_name].alias == None)
|
||||
if proc_name not in removed_procs:
|
||||
section_procs.append(all_procs[proc_name])
|
||||
|
||||
section_enums = []
|
||||
for enum in section.findall('./require/enum'):
|
||||
section_enums.append(all_enums[enum.attrib['name']])
|
||||
|
||||
blocks.append(VersionBlock(parse_version(section.attrib['number']), section_procs, section_enums))
|
||||
|
||||
return blocks
|
||||
|
||||
gles_blocks = parse_version_blocks('gles2')
|
||||
desktop_gl_blocks = parse_version_blocks('gl', core_removed_procs)
|
||||
|
||||
# Compute the blocks for headers such that there is no duplicate definition
|
||||
already_added_header_procs = set()
|
||||
already_added_header_enums = set()
|
||||
header_blocks = []
|
||||
def add_header_block(description, procs):
|
||||
def add_header_block(description, block):
|
||||
block_procs = []
|
||||
for proc in procs:
|
||||
for proc in block.procs:
|
||||
if not proc.glProcName() in already_added_header_procs:
|
||||
already_added_header_procs.add(proc.glProcName())
|
||||
block_procs.append(proc)
|
||||
if len(block_procs) > 0:
|
||||
header_blocks.append(HeaderProcBlock(description, block_procs))
|
||||
|
||||
block_enums = []
|
||||
for enum in block.enums:
|
||||
if not enum.name in already_added_header_enums:
|
||||
already_added_header_enums.add(enum.name)
|
||||
block_enums.append(enum)
|
||||
|
||||
if len(block_procs) > 0 or len(block_enums) > 0:
|
||||
header_blocks.append(HeaderBlock(description, block_procs, block_enums))
|
||||
|
||||
for block in gles_blocks:
|
||||
add_header_block('OpenGL ES {}.{}'.format(block.version.major, block.version.minor), block.procs)
|
||||
add_header_block('OpenGL ES {}.{}'.format(block.version.major, block.version.minor), block)
|
||||
|
||||
for block in desktop_gl_blocks:
|
||||
add_header_block('Desktop OpenGL {}.{}'.format(block.version.major, block.version.minor), block.procs)
|
||||
add_header_block('Desktop OpenGL {}.{}'.format(block.version.major, block.version.minor), block)
|
||||
|
||||
return {
|
||||
'gles_blocks': gles_blocks,
|
||||
|
@ -108,6 +191,7 @@ class OpenGLLoaderGenerator(Generator):
|
|||
return [
|
||||
FileRender('opengl/OpenGLFunctionsBase.cpp', 'dawn_native/opengl/OpenGLFunctionsBase_autogen.cpp', [params]),
|
||||
FileRender('opengl/OpenGLFunctionsBase.h', 'dawn_native/opengl/OpenGLFunctionsBase_autogen.h', [params]),
|
||||
FileRender('opengl/opengl_platform.h', 'dawn_native/opengl/opengl_platform_autogen.h', [params]),
|
||||
]
|
||||
|
||||
def get_dependencies(self, args):
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
//* limitations under the License.
|
||||
|
||||
#include "dawn_native/Error.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
using GetProcAddress = void* (*) (const char*);
|
||||
|
@ -24,7 +23,7 @@ namespace dawn_native { namespace opengl {
|
|||
{% for block in header_blocks %}
|
||||
// {{block.description}}
|
||||
{% for proc in block.procs %}
|
||||
{{proc.PFNPROCNAME()}} {{proc.ProcName()}} = nullptr;
|
||||
{{proc.PFNGLPROCNAME()}} {{proc.ProcName()}} = nullptr;
|
||||
{% endfor %}
|
||||
|
||||
{% endfor%}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
//* Copyright 2019 The Dawn Authors
|
||||
//*
|
||||
//* 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.
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
|
||||
using GLvoid = void;
|
||||
using GLchar = char;
|
||||
using GLenum = unsigned int;
|
||||
using GLboolean = unsigned char;
|
||||
using GLbitfield = unsigned int;
|
||||
using GLbyte = khronos_int8_t;
|
||||
using GLshort = short;
|
||||
using GLint = int;
|
||||
using GLsizei = int;
|
||||
using GLubyte = khronos_uint8_t;
|
||||
using GLushort = unsigned short;
|
||||
using GLuint = unsigned int;
|
||||
using GLfloat = khronos_float_t;
|
||||
using GLclampf = khronos_float_t;
|
||||
using GLdouble = double;
|
||||
using GLclampd = double;
|
||||
using GLfixed = khronos_int32_t;
|
||||
using GLintptr = khronos_intptr_t;
|
||||
using GLsizeiptr = khronos_ssize_t;
|
||||
using GLhalf = unsigned short;
|
||||
using GLint64 = khronos_int64_t;
|
||||
using GLuint64 = khronos_uint64_t;
|
||||
using GLsync = struct __GLsync*;
|
||||
using GLDEBUGPROC = void(KHRONOS_APIENTRY*)(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam);
|
||||
using GLDEBUGPROCARB = void(KHRONOS_APIENTRY*)(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam);
|
||||
using GLDEBUGPROCKHR = void(KHRONOS_APIENTRY*)(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam);
|
||||
using GLDEBUGPROCAMD = void(KHRONOS_APIENTRY*)(GLuint id,
|
||||
GLenum category,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
void* userParam);
|
||||
|
||||
{% for block in header_blocks %}
|
||||
// {{block.description}}
|
||||
{% for enum in block.enums %}
|
||||
#define {{enum.name}} {{enum.value}}
|
||||
{% endfor %}
|
||||
|
||||
{% for proc in block.procs %}
|
||||
using {{proc.PFNGLPROCNAME()}} = {{proc.return_type}}(KHRONOS_APIENTRY *)(
|
||||
{%- for param in proc.params -%}
|
||||
{%- if not loop.first %}, {% endif -%}
|
||||
{{param.type}} {{param.name}}
|
||||
{%- endfor -%}
|
||||
);
|
||||
{% endfor %}
|
||||
|
||||
{% endfor%}
|
||||
#undef DAWN_GL_APIENTRY
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/Buffer.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "dawn_native/opengl/PipelineGL.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "dawn_native/OpenGLBackend.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#define DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/Pipeline.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/PipelineLayout.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
#include "dawn_native/RenderPipeline.h"
|
||||
|
||||
#include "dawn_native/opengl/PipelineGL.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/Sampler.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/ShaderModule.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/SwapChain.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "dawn_native/Texture.h"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define DAWNNATIVE_OPENGL_UTILSGL_H_
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
#include "glad/glad.h"
|
||||
#include "dawn_native/opengl/opengl_platform.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2019 The Dawn Authors
|
||||
//
|
||||
// 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.
|
||||
|
||||
#include "dawn_native/opengl/opengl_platform_autogen.h"
|
|
@ -22,21 +22,6 @@ is_msvc = is_win && !is_clang
|
|||
# Third-party dependencies needed by libdawn_native
|
||||
###############################################################################
|
||||
|
||||
# Glad
|
||||
config("glad_public") {
|
||||
include_dirs = [ "glad/include" ]
|
||||
}
|
||||
|
||||
static_library("glad") {
|
||||
sources = [
|
||||
"glad/include/KHR/khrplatform.h",
|
||||
"glad/include/glad/glad.h",
|
||||
"glad/src/glad.c",
|
||||
]
|
||||
|
||||
public_configs = [ ":glad_public" ]
|
||||
}
|
||||
|
||||
# SPIRV-Cross
|
||||
spirv_cross_dir = dawn_spirv_cross_dir
|
||||
|
||||
|
@ -127,19 +112,26 @@ static_library("spirv_cross_full_for_fuzzers") {
|
|||
]
|
||||
}
|
||||
|
||||
# An empty Vulkan target to add the include dirs and list the sources
|
||||
# for the header inclusion check.
|
||||
config("vulkan_headers_public") {
|
||||
include_dirs = [ "." ]
|
||||
# Empty targets to add the include dirs and list the sources of Khronos headers for header inclusion check.
|
||||
config("khronos_headers_public") {
|
||||
include_dirs = [ "khronos" ]
|
||||
}
|
||||
|
||||
source_set("vulkan_headers") {
|
||||
sources = [
|
||||
"vulkan/vk_platform.h",
|
||||
"vulkan/vulkan.h",
|
||||
"khronos/vulkan/vk_platform.h",
|
||||
"khronos/vulkan/vulkan.h",
|
||||
]
|
||||
|
||||
public_configs = [ ":vulkan_headers_public" ]
|
||||
public_configs = [ ":khronos_headers_public" ]
|
||||
}
|
||||
|
||||
source_set("khronos_platform") {
|
||||
sources = [
|
||||
"khronos/KHR/khrplatform.h",
|
||||
]
|
||||
|
||||
public_configs = [ ":khronos_headers_public" ]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
# Copyright 2017 The Dawn Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
# GLFW, only build the library
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(glfw)
|
||||
DawnExternalTarget("third_party" glfw)
|
||||
|
||||
# GoogleTest
|
||||
set(GTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest)
|
||||
set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock)
|
||||
add_library(gtest STATIC ${GTEST_DIR}/src/gtest-all.cc ${GMOCK_DIR}/src/gmock-all.cc)
|
||||
target_include_directories(gtest SYSTEM PUBLIC ${GTEST_DIR}/include ${GMOCK_DIR}/include)
|
||||
target_include_directories(gtest SYSTEM PRIVATE ${GTEST_DIR} ${GMOCK_DIR})
|
||||
find_package(Threads)
|
||||
target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})
|
||||
DawnExternalTarget("third_party" gtest)
|
||||
|
||||
# Glad
|
||||
add_library(glad STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/glad/src/glad.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/glad/include/glad/glad.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/glad/include/KHR/khrplatform.h
|
||||
)
|
||||
set(GLAD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glad/include)
|
||||
set(GLAD_INCLUDE_DIR ${GLAD_INCLUDE_DIR} PARENT_SCOPE)
|
||||
target_include_directories(glad SYSTEM PUBLIC ${GLAD_INCLUDE_DIR})
|
||||
DawnExternalTarget("third_party" glad)
|
||||
|
||||
# SPIRV-Tools
|
||||
set(SPIRV_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools/include PARENT_SCOPE)
|
||||
|
||||
# ShaderC
|
||||
# Prevent SPIRV-Tools from using Werror as it has a warning on MSVC
|
||||
set(SPIRV_WERROR OFF CACHE BOOL "" FORCE)
|
||||
# Don't add unnecessary shaderc targets
|
||||
set(SHADERC_SKIP_TESTS ON)
|
||||
set(SHADERC_SKIP_INSTALL ON)
|
||||
# Remove unused glslang and spirv-tools parts
|
||||
# set(ENABLE_HLSL OFF CACHE BOOL "")
|
||||
set(ENABLE_OPT OFF CACHE BOOL "")
|
||||
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "")
|
||||
set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "")
|
||||
set(SKIP_SPIRV_TOOLS_INSTALL ON CACHE BOOL "")
|
||||
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "")
|
||||
# Help shaderc find the non-standard paths for its dependencies
|
||||
set(SHADERC_GOOGLE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest CACHE STRING "Location of googletest source")
|
||||
set(SHADERC_GLSLANG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/glslang" CACHE STRING "Location of glslang source")
|
||||
set(SHADERC_SPIRV_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools CACHE STRING "Location of spirv-tools source")
|
||||
# Help shaderc find the python executable when run inside VS.
|
||||
find_package(PythonInterp REQUIRED)
|
||||
set(PYTHON_EXE ${PYTHON_EXECUTABLE})
|
||||
# Need to include this for spirv-tools to find it
|
||||
add_subdirectory(spirv-headers)
|
||||
add_subdirectory(shaderc)
|
||||
# Namespace the shaderc targets in a folder to avoid cluttering the
|
||||
# Visual Studio solution explorer
|
||||
set_target_properties(
|
||||
add-copyright
|
||||
build-version
|
||||
check-copyright
|
||||
glslc
|
||||
glslc_exe
|
||||
install-headers
|
||||
shaderc
|
||||
shaderc_shared
|
||||
shaderc_util
|
||||
shaderc_combined_genfile
|
||||
shaderc-online-compile testdata
|
||||
SPIRV-Headers-example
|
||||
SPIRV-Headers-example-1.1
|
||||
PROPERTIES FOLDER "third_party/shaderc"
|
||||
)
|
||||
# Remove a bunch of targets we don't need that are pulled by shaderc and glslang
|
||||
set_target_properties(
|
||||
SPIRV-Headers-example-1.1
|
||||
SPIRV-Headers-example
|
||||
glslc_exe
|
||||
SPIRV-Tools-link
|
||||
SPVRemapper
|
||||
shaderc
|
||||
shaderc-online-compile
|
||||
shaderc_combined_genfile
|
||||
PROPERTIES EXCLUDE_FROM_ALL true
|
||||
)
|
||||
|
||||
# SPIRV-Cross
|
||||
set(SPIRV_CROSS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/GLSL.std.450.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_common.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cfg.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cfg.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cross.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cross.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv.hpp
|
||||
)
|
||||
|
||||
set(NEED_SPIRV_CROSS_GLSL OFF)
|
||||
if (DAWN_ENABLE_D3D12)
|
||||
list(APPEND SPIRV_CROSS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_hlsl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_hlsl.hpp
|
||||
)
|
||||
set(NEED_SPIRV_CROSS_GLSL ON)
|
||||
endif()
|
||||
|
||||
if (DAWN_ENABLE_METAL)
|
||||
list(APPEND SPIRV_CROSS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_msl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_msl.hpp
|
||||
)
|
||||
set(NEED_SPIRV_CROSS_GLSL ON)
|
||||
endif()
|
||||
|
||||
if (DAWN_ENABLE_OPENGL OR NEED_SPIRV_CROSS_GLSL)
|
||||
list(APPEND SPIRV_CROSS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_glsl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_glsl.hpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(spirv_cross STATIC ${SPIRV_CROSS_SOURCES})
|
||||
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
|
||||
set(SPIRV_CROSS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|
||||
DawnExternalTarget("third_party" spirv_cross)
|
||||
|
||||
# STB, used for stb_image
|
||||
set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stb PARENT_SCOPE)
|
||||
|
||||
# glm matrix math library
|
||||
set(GLM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm PARENT_SCOPE)
|
||||
|
||||
# Tiny glTF loader library
|
||||
set(TINYGLTFLOADER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|
||||
|
||||
# Vulkan headers
|
||||
set(VULKAN_HEADERS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue