Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge the current vulkan-dev to the master #119

Merged
merged 24 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
731bae1
Add script for SPIR-V compiling
kkristof Nov 6, 2016
a05f278
Store the SPIR-V binaries in auto-generated source files
kkristof Nov 17, 2016
5d20ddf
WIP: Add intel vulkan support
kkristof Jan 13, 2017
39db3ce
Change the default timeout to 32 ms
kkristof Jun 25, 2017
3439dfa
Merge branch 'master' into vulkan-dev
kkristof Jan 18, 2018
3f5511d
Push the X11-xcb dependency to the Vulkan port
kkristof Jan 18, 2018
b6e1a1a
Merge branch 'master' into vulkan-dev
kkristof Jul 1, 2018
e9bd0ce
Add basic image class
kkristof Jul 1, 2018
7db4655
Implement putImage function for the vulkan backend
kkristof Jul 1, 2018
c06b917
Implement getImage function for the vulkan backend
kkristof Jul 8, 2018
018beb8
Add utility functions for the vulkan backend
kkristof Jul 9, 2018
2effe91
Implement drawimage for the vulkan backend
kkristof Jul 15, 2018
957bd74
Add the shaders for the drawimage function
kkristof Sep 7, 2018
36c6eb5
Add some TODO based on the GeCo18
kkristof Sep 26, 2018
46ac6ae
Merge branch 'master' into vulkan-dev
kkristof Sep 26, 2018
d0f22a6
Adapt the image example to the API change
kkristof Sep 26, 2018
661c4c1
Compile the vulkan shaders at build-time
kkristof Sep 29, 2018
c02ba4e
Use hexa output in the generated SPIR-V header
kkristof Sep 29, 2018
420decb
Use image references
kkristof Sep 29, 2018
e324bdc
Merge branch 'master' into vulkan-dev
kkristof Oct 3, 2018
c6a567a
Add glslang to the thirdparties
kkristof Oct 3, 2018
a8e85ca
Rework the SPIR-V handling for the vulkan backend
kkristof Oct 3, 2018
9ff8d42
Review fixes
kkristof Oct 3, 2018
f0f5bf9
Review fixes for the build system
kkristof Oct 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ elseif (BACKEND STREQUAL "VULKAN")

set(VULKAN_INCLUDE_DIR ${PROJECT_BINARY_DIR}/thirdparty/include)
endif()
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders/gepard-vulkan-spirv-binaries.h
${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders/gepard-vulkan-spirv-binaries.inc.h
COMMAND python ${PROJECT_SOURCE_DIR}/tools/build-vulkan-shaders.py
DEPENDS ${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders/*.vert
${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders/*.frag)

add_custom_target(vulkan_shaders
DEPENDS ${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders/gepard-vulkan-spirv-binaries.h
${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders/gepard-vulkan-spirv-binaries.inc.h)

find_program(GLSLANG_VALIDATOR
NAMES glslangValidator
HINTS ${PROJECT_SOURCE_DIR}/thirdparty/bin)

# TODO(kkristof) remove this once XSync has been removed from GepardVulkan::createSwapChain
find_package(X11)
Expand Down
10 changes: 7 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set(COMMON_SOURCES
gepard.cpp
gepard-engine.cpp
gepard-image.cpp
utils/gepard-types.cpp
utils/gepard-bounding-box.cpp
utils/gepard-color.cpp
utils/gepard-defs.cpp
utils/gepard-float-point.cpp
utils/gepard-line-types.cpp
Expand Down Expand Up @@ -44,7 +45,7 @@ set(GLES2_INCLUDE_DIRS

set(VULKAN_INCLUDE_DIRS
engines/vulkan
engines/vulkan/shaders
${PROJECT_BINARY_DIR}/spirv
)

set(SOFTWARE_INCLUDE_DIRS
Expand All @@ -53,6 +54,7 @@ set(SOFTWARE_INCLUDE_DIRS

set(GEPARD_HEADERS
gepard.h
gepard-image.h
)

set(SURFACE_HEADERS
Expand All @@ -71,17 +73,19 @@ if (BACKEND STREQUAL "VULKAN" AND NOT VULKAN_FOUND)
endif()

if (BACKEND STREQUAL "VULKAN")
include(engines/vulkan/shaders/VulkanShaders.cmake)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file should go into the cmake/ directory, with the other cmake modules. Then you can simply use include(VulkanShaders).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

add_dependencies(gepard vulkan_shaders)
endif()

target_compile_definitions(gepard PUBLIC "GD_USE_${BACKEND}")
target_compile_definitions(gepard PRIVATE "GD_USE_${BACKEND}")

target_include_directories(gepard PRIVATE ${COMMON_INCLUDE_DIRS})
target_include_directories(gepard PRIVATE ${${BACKEND}_INCLUDE_DIRS})
target_include_directories(gepard PRIVATE ${GEPARD_DEP_INCLUDES})

# TODO(dbatyai): Add a target to do this instead of doing it at configure time
file(COPY gepard.h DESTINATION ${INCLUDE_OUTPUT_DIR})
file(COPY gepard-image.h DESTINATION ${INCLUDE_OUTPUT_DIR})
file(COPY surfaces DESTINATION ${INCLUDE_OUTPUT_DIR})

set_target_properties(gepard
Expand Down
18 changes: 16 additions & 2 deletions src/engines/vulkan/gepard-vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,25 @@
#include <X11/Xlib-xcb.h>
#endif // VK_USE_PLATFORM_XCB_KHR

#include "gepard-vulkan-spirv-binaries.inc.h"

namespace gepard {
namespace vulkan {

static const uint32_t fillRectVert[] = {
#include "fill-rect.vert.inc"
};

static const uint32_t fillRectFrag[] = {
#include "fill-rect.frag.inc"
};

static const uint32_t imageVert[] = {
#include "image.vert.inc"
};

static const uint32_t imageFrag[] = {
#include "image.frag.inc"
};

static const uint64_t oneMiliSec = 1000000;
static const uint64_t timeout = (uint64_t)32 * oneMiliSec; // 32 ms
#ifdef VK_USE_PLATFORM_XCB_KHR
Expand Down
3 changes: 2 additions & 1 deletion src/engines/vulkan/gepard-vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
#include "gepard-float.h"
#include "gepard-image.h"
#include "gepard-vulkan-interface.h"
#include "gepard-vulkan-spirv-binaries.h"
#include "gepard.h"

#include <vector>

namespace gepard {
Expand Down
35 changes: 35 additions & 0 deletions src/engines/vulkan/shaders/VulkanShaders.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
set(VK_SHADER_DIRECTORY ${PROJECT_SOURCE_DIR}/src/engines/vulkan/shaders)
set(SPIRV_DIRECTORY ${PROJECT_BINARY_DIR}/spirv)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/spirv)

add_custom_target(
vulkan_shaders
DEPENDS ${SPIRV_DIRECTORY}/fill-rect.vert.inc
${SPIRV_DIRECTORY}/fill-rect.frag.inc
${SPIRV_DIRECTORY}/image.vert.inc
${SPIRV_DIRECTORY}/image.frag.inc
)

add_custom_command(
OUTPUT ${SPIRV_DIRECTORY}/fill-rect.vert.inc
COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${SPIRV_DIRECTORY}/fill-rect.vert.inc ${VK_SHADER_DIRECTORY}/fill-rect.vert
DEPENDS ${VK_SHADER_DIRECTORY}/fill-rect.vert ${GLSLANG_VALIDATOR}
)

add_custom_command(
OUTPUT ${SPIRV_DIRECTORY}/fill-rect.frag.inc
COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${SPIRV_DIRECTORY}/fill-rect.frag.inc ${VK_SHADER_DIRECTORY}/fill-rect.frag
DEPENDS ${VK_SHADER_DIRECTORY}/fill-rect.frag ${GLSLANG_VALIDATOR}
)

add_custom_command(
OUTPUT ${SPIRV_DIRECTORY}/image.vert.inc
COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${SPIRV_DIRECTORY}/image.vert.inc ${VK_SHADER_DIRECTORY}/image.vert
DEPENDS ${VK_SHADER_DIRECTORY}/image.vert ${GLSLANG_VALIDATOR}
)

add_custom_command(
OUTPUT ${SPIRV_DIRECTORY}/image.frag.inc
COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${SPIRV_DIRECTORY}/image.frag.inc ${VK_SHADER_DIRECTORY}/image.frag
DEPENDS ${VK_SHADER_DIRECTORY}/image.frag ${GLSLANG_VALIDATOR}
)
3 changes: 1 addition & 2 deletions src/gepard-image.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#ifndef GEPARD_IMAGE_H
#define GEPARD_IMAGE_H

#include "gepard-defs.h"

#include <cstdint>
#include <vector>

namespace gepard {
Expand Down
12 changes: 11 additions & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ set(INCLUDE_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/include)
# - A subdirectory in PROJECT_BINARY_DIR can be used as a build directory.

add_custom_target(common ALL
DEPENDS gtest)
DEPENDS gtest
glslang)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't only the vulkan backend depend on this? Please move this to the vulkan target below this one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I wasn't sure if I first build the gles2 backend then I build the vulkan it would get the glslang and I thought it doesn't have a big toll to build the glslang for every traget. Now I've tried what happend in this case and it works flawless, thanks.


add_custom_target(gles2 ALL
DEPENDS common)
Expand All @@ -44,6 +45,15 @@ ExternalProject_Add(gtest
BUILD_COMMAND make gtest
INSTALL_COMMAND make install > /dev/null)

ExternalProject_Add(glslang
PREFIX ${PROJECT_SOURCE_DIR}/src/glslang
GIT_REPOSITORY https://github.com/KhronosGroup/glslang.git
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR} -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_INCLUDEDIR=include
GIT_TAG master-tot
BINARY_DIR ${PROJECT_BINARY_DIR}/glslang
BUILD_COMMAND make glslangValidator
INSTALL_COMMAND make install > /dev/null)

file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/stamps)
add_custom_command(TARGET gles2
POST_BUILD
Expand Down