Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
Merge branch '0.13-dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
azhirnov committed Jan 24, 2020
2 parents 7251689 + 5233876 commit e751589
Show file tree
Hide file tree
Showing 98 changed files with 7,750 additions and 1,124 deletions.
78 changes: 39 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ language: cpp
matrix:
include:
# Linux GCC x64
- os: linux
name: linux 64
dist: trusty
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- xorg-dev
- g++-8
before_install:
- eval "CC=gcc-8 && CXX=g++-8"
# Download and install cmake
- mkdir $HOME/cmake;
- export PATH="$HOME/cmake/bin:$PATH";
- travis_retry wget -q https://cmake.org/files/v3.15/cmake-3.15.1-Linux-x86_64.sh;
- sh cmake-3.15.1-Linux-x86_64.sh --prefix=$HOME/cmake --exclude-subdir --skip-license;
script:
- mkdir -p build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DFG_CI_BUILD=ON -DFG_EXTERNALS_USE_PREBUILD=OFF ..
- cmake --build . --config Release
- ctest --verbose
#- os: linux
# name: linux 64
# dist: trusty
# compiler: gcc
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - xorg-dev
# - g++-8
# before_install:
# - eval "CC=gcc-8 && CXX=g++-8"
# # Download and install cmake
# - mkdir $HOME/cmake;
# - export PATH="$HOME/cmake/bin:$PATH";
# - travis_retry wget -q https://cmake.org/files/v3.15/cmake-3.15.1-Linux-x86_64.sh;
# - sh cmake-3.15.1-Linux-x86_64.sh --prefix=$HOME/cmake --exclude-subdir --skip-license;
# script:
# - mkdir -p build
# - cd build
# - cmake -DCMAKE_BUILD_TYPE=Release -DFG_CI_BUILD=ON -DFG_EXTERNALS_USE_PREBUILD=OFF ..
# - cmake --build . --config Release
# - ctest --verbose

# Windows MSVC x86
- os: windows
name: win32
before_install:
- choco install python2
- export PATH="/c/Python27:/c/Python27/Scripts:$PATH"
- choco install python3
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
script:
- mkdir -p build
- cd build
Expand All @@ -44,8 +44,8 @@ matrix:
- os: windows
name: win64
before_install:
- choco install python2
- export PATH="/c/Python27:/c/Python27/Scripts:$PATH"
- choco install python3
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
script:
- mkdir -p build
- cd build
Expand All @@ -54,14 +54,14 @@ matrix:
- ctest -C Release --verbose

# Windows MSVC x64 Debug
- os: windows
name: win64 debug
before_install:
- choco install python2
- export PATH="/c/Python27:/c/Python27/Scripts:$PATH"
script:
- mkdir -p build
- cd build
- cmake -G "Visual Studio 15 2017 Win64" -DFG_CI_BUILD=ON -DFG_EXTERNALS_USE_PREBUILD=OFF ..
- travis_wait 40 cmake --build . --config Debug
- ctest -C Debug --verbose
#- os: windows
# name: win64 debug
# before_install:
# - choco install python3
# - export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
# script:
# - mkdir -p build
# - cd build
# - cmake -G "Visual Studio 15 2017 Win64" -DFG_CI_BUILD=ON -DFG_EXTERNALS_USE_PREBUILD=OFF ..
# - travis_wait 40 cmake --build . --config Debug
# - ctest -C Debug --verbose
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ FrameGraph designed for maximum performance but not at the expense of usability.
* glsl debugging.
* supports RTX extensions.
* supports async compute and async transfer queues.
* all render tasks are stateless.

## Samples
[FrameGraph-Samples](https://github.com/azhirnov/FrameGraph-Samples)
Expand All @@ -24,7 +25,7 @@ FrameGraph designed for maximum performance but not at the expense of usability.
* [Porting from OpenGL](docs/Porting-from-OpenGL.md)
* [Porting from Vulkan](docs/Porting-from-Vulkan.md)
* [Extensions overview](extensions/Readme.md)
* [Shader debugging](docs/Shader-debugging.md)
* [Shader debugging and profiling](docs/Shader-debugging.md)
* [Graph visualization](docs/Graph-visualization.md)
* [Roadmap](docs/Roadmap.md)

Expand Down Expand Up @@ -55,10 +56,12 @@ Dependencies:<br/>
[imgui](https://github.com/ocornut/imgui) - (optional) for UI extension.<br/>
[OpenVR](https://github.com/ValveSoftware/openvr) - (optional) for VR support.<br/>
[GLM](https://glm.g-truc.net/0.9.9/index.html) - (optional) for Scene extension.<br/>
[ffmpeg](https://www.ffmpeg.org/) - (optional) for video recording.<br/>


## References
1. [FrameGraph in Frostbite](https://www.gdcvault.com/play/1024612/FrameGraph-Extensible-Rendering-Architecture-in).<br/>
2. [Handles vs pointers](https://floooh.github.io/2018/06/17/handles-vs-pointers.html)<br/>
3. [Porting engine to vulkan](https://gpuopen.com/presentation-porting-engine-to-vulkan-dx12/).<br/>
4. [FrameGraph from Ubisoft](https://developer.download.nvidia.com/assets/gameworks/downloads/regular/GDC17/DX12CaseStudies_GDC2017_FINAL.pdf)
5. [RenderGraph from EA](https://www.khronos.org/assets/uploads/developers/library/2019-reboot-develop-blue/SEED-EA_Rapid-Innovation-Using-Modern-Graphics_Apr19.pdf)
28 changes: 21 additions & 7 deletions cmake/download_ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ if (${FG_EXTERNALS_USE_PREBUILD} AND ${FG_ENABLE_FFMPEG})
add_library( "ffmpeg-lib" INTERFACE )
target_include_directories( "ffmpeg-lib" INTERFACE "${FFMPEG_PATH}/include" )
target_compile_definitions( "ffmpeg-lib" INTERFACE "FG_ENABLE_FFMPEG" )
set_property( TARGET "ffmpeg-lib" PROPERTY INTERFACE_LINK_LIBRARIES

#[[set_property( TARGET "ffmpeg-lib" PROPERTY INTERFACE_LINK_LIBRARIES
"${FFMPEG_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avcodec${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${FFMPEG_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avdevice${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${FFMPEG_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avfilter${CMAKE_STATIC_LIBRARY_SUFFIX}"
Expand All @@ -15,13 +16,14 @@ if (${FG_EXTERNALS_USE_PREBUILD} AND ${FG_ENABLE_FFMPEG})
"${FFMPEG_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}postproc${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${FFMPEG_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}swresample${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${FFMPEG_PATH}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}swscale${CMAKE_STATIC_LIBRARY_SUFFIX}" )

]]

elseif (${FG_ENABLE_FFMPEG})
set( FG_EXTERNAL_FFMPEG_PATH "" CACHE PATH "path to ffmpeg SDK" )
mark_as_advanced( FG_EXTERNAL_FFMPEG_PATH )

if ((NOT WIN32) OR (NOT MSVC))
message( FATAL_ERROR "only win64 and Visual Stuido are supported" )
message( FATAL_ERROR "only Windows 32/64 with Visual Stuido are supported" )
endif ()

# reset to default
Expand All @@ -32,15 +34,27 @@ elseif (${FG_ENABLE_FFMPEG})
message( STATUS "ffmpeg SDK found in \"${FG_EXTERNAL_FFMPEG_PATH}\"" )
endif ()

if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set( FFMPEG_DEV_NAME "ffmpeg-4.2.1-win64-dev.zip" )
set( FFMPEG_DEV_URL "https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.1-win64-dev.zip" )
set( FFMPEG_SHARED_NAME "ffmpeg-4.2.1-win64-shared.zip" )
set( FFMPEG_SHARED_URL "https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.2.1-win64-shared.zip" )
elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set( FFMPEG_DEV_NAME "ffmpeg-4.2.1-win32-dev.zip" )
set( FFMPEG_DEV_URL "https://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-4.2.1-win32-dev.zip" )
set( FFMPEG_SHARED_NAME "ffmpeg-4.2.1-win32-shared.zip" )
set( FFMPEG_SHARED_URL "https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.2.1-win32-shared.zip" )
endif ()

ExternalProject_Add( "External.FFmpeg-dev"
LOG_OUTPUT_ON_FAILURE 1
# download
URL "https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.1-win64-dev.zip"
URL ${FFMPEG_DEV_URL}
DOWNLOAD_DIR "${FG_EXTERNAL_FFMPEG_PATH}/dev-temp"
LOG_DOWNLOAD 1
# configure
SOURCE_DIR "${FG_EXTERNAL_FFMPEG_PATH}/dev"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E tar -xf "${FG_EXTERNAL_FFMPEG_PATH}/dev-temp/ffmpeg-4.2.1-win64-dev.zip"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E tar -xf "${FG_EXTERNAL_FFMPEG_PATH}/dev-temp/${FFMPEG_DEV_NAME}"
LOG_CONFIGURE 1
# build
BUILD_COMMAND ${CMAKE_COMMAND} -E remove_directory "${FG_EXTERNAL_FFMPEG_PATH}/dev-temp"
Expand All @@ -54,12 +68,12 @@ elseif (${FG_ENABLE_FFMPEG})
ExternalProject_Add( "External.FFmpeg-shared"
LOG_OUTPUT_ON_FAILURE 1
# download
URL "https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.2.1-win64-shared.zip"
URL ${FFMPEG_SHARED_URL}
DOWNLOAD_DIR "${FG_EXTERNAL_FFMPEG_PATH}/shared-temp"
LOG_DOWNLOAD 1
# configure
SOURCE_DIR "${FG_EXTERNAL_FFMPEG_PATH}/shared"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E tar -xf "${FG_EXTERNAL_FFMPEG_PATH}/shared-temp/ffmpeg-4.2.1-win64-shared.zip"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E tar -xf "${FG_EXTERNAL_FFMPEG_PATH}/shared-temp/${FFMPEG_SHARED_NAME}"
LOG_CONFIGURE 1
# build
BUILD_COMMAND ${CMAKE_COMMAND} -E remove_directory "${FG_EXTERNAL_FFMPEG_PATH}/shared-temp"
Expand Down
32 changes: 10 additions & 22 deletions cmake/download_glslang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ elseif (${FG_ENABLE_GLSLANG})
set( FG_EXTERNAL_GLSLANG_PATH "" CACHE PATH "path to glslang source" )
mark_as_advanced( FG_EXTERNAL_GLSLANG_PATH )

# SPIRV-Tools require Python 2.7 for building
find_package( PythonInterp 2.7 REQUIRED )
find_package( PythonLibs 2.7 REQUIRED )
# SPIRV-Tools require Python 3.7 for building
find_package( PythonInterp 3.7 REQUIRED )
find_package( PythonLibs 3.7 REQUIRED )

# reset to default
if (NOT EXISTS "${FG_EXTERNAL_GLSLANG_PATH}/CMakeLists.txt")
Expand Down Expand Up @@ -55,20 +55,18 @@ elseif (${FG_ENABLE_GLSLANG})

set( ENABLE_HLSL ON CACHE BOOL "glslang option" )
set( ENABLE_OPT ON CACHE BOOL "glslang option" )
set( ENABLE_AMD_EXTENSIONS ON CACHE BOOL "glslang option" )
set( ENABLE_NV_EXTENSIONS ON CACHE BOOL "glslang option" )
mark_as_advanced( ENABLE_HLSL ENABLE_OPT ENABLE_AMD_EXTENSIONS ENABLE_NV_EXTENSIONS )
mark_as_advanced( ENABLE_HLSL ENABLE_OPT )

if (${FG_EXTERNALS_USE_STABLE_VERSIONS})
#if (${FG_EXTERNALS_USE_STABLE_VERSIONS})
# stable release February 8, 2019
set( GLSLANG_TAG "7.11.3113" )
set( SPIRV_TOOLS_TAG "v2019.1" )
set( SPIRV_HEADERS_TAG "1.3.7" )
else ()
# set( GLSLANG_TAG "7.11.3113" )
# set( SPIRV_TOOLS_TAG "v2019.1" )
# set( SPIRV_HEADERS_TAG "1.3.7" )
#else ()
set( GLSLANG_TAG "master" )
set( SPIRV_TOOLS_TAG "master" )
set( SPIRV_HEADERS_TAG "master" )
endif ()
#endif ()

ExternalProject_Add( "External.glslang"
LOG_OUTPUT_ON_FAILURE 1
Expand Down Expand Up @@ -149,8 +147,6 @@ elseif (${FG_ENABLE_GLSLANG})
CMAKE_ARGS "-DCMAKE_CONFIGURATION_TYPES=${FG_EXTERNAL_CONFIGURATION_TYPES}"
"-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}"
"-DCMAKE_INSTALL_PREFIX=${FG_GLSLANG_INSTALL_DIR}"
"-DENABLE_AMD_EXTENSIONS=${ENABLE_AMD_EXTENSIONS}"
"-DENABLE_NV_EXTENSIONS=${ENABLE_NV_EXTENSIONS}"
"-DENABLE_HLSL=${ENABLE_HLSL}"
"-DENABLE_OPT=${ENABLE_OPT}"
"-DENABLE_SPVREMAPPER=ON"
Expand Down Expand Up @@ -202,14 +198,6 @@ elseif (${FG_ENABLE_GLSLANG})
set( FG_GLSLANG_DEFINITIONS "${FG_GLSLANG_DEFINITIONS}" "ENABLE_HLSL" )
endif ()

if (${ENABLE_AMD_EXTENSIONS})
set( FG_GLSLANG_DEFINITIONS "${FG_GLSLANG_DEFINITIONS}" "AMD_EXTENSIONS" )
endif ()

if (${ENABLE_NV_EXTENSIONS})
set( FG_GLSLANG_DEFINITIONS "${FG_GLSLANG_DEFINITIONS}" "NV_EXTENSIONS" )
endif ()

# glslang libraries
set( FG_GLSLANG_LIBNAMES "SPIRV" "glslang" "OSDependent" "HLSL" )

Expand Down
2 changes: 1 addition & 1 deletion cmake/download_vk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif ()

# select version
if (${FG_EXTERNALS_USE_STABLE_VERSIONS})
set( VULKAN_HEADERS_TAG "v1.1.115" )
set( VULKAN_HEADERS_TAG "v1.2.132" )
else ()
set( VULKAN_HEADERS_TAG "master" )
endif ()
Expand Down
82 changes: 81 additions & 1 deletion docs/Shader-debugging.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Shader debugging supported only for GLSL source. But you can use SPIRV-Cross to convert SPIRV binary into GLSL source.<br/>
Shader debugging and profiling supported only for GLSL source. But you can use SPIRV-Cross to convert SPIRV binary into GLSL source.<br/>

## Shader debugging

For each shader, that you want to debug, add `EnableDebugTrace` flag:
```cpp
desc.AddShader( ... | EShaderLangFormat::EnableDebugTrace, ... );
Expand Down Expand Up @@ -76,3 +79,80 @@ no source
```

The `//>` symbol marks the modified variable or function result.


## Shader profiling

For each shader, that you want to profile, add `EnableProfiling` flag:
```cpp
desc.AddShader( ... | EShaderLangFormat::EnableProfiling, ... );
```
Then setup debug callback:
```cpp
frameGraph.SetShaderDebugCallback( ... );
```
For task that you want to profile add one of this:
```cpp
// record if {thread_x, thread_y, thread_z} == gl_GlobalInvocationID
DispatchCompute().EnableShaderProfiling({ thread_x, thread_y, thread_z });

// record if {pixel_x, pixel_y} == gl_FragCoord.xy
DrawIndexed().EnableFragmentProfiling( pixel_x, pixel_y );

// record if {launch_x, launch_y, launch_z} == gl_LaunchIDNV
TraceRays().EnableShaderProfiling({ launch_x, launch_y, launch_z });
```
Shader profiling will be recorded only for selected thread/pixel/launch.
<br/>
<br/>
Aloso you can enable shader profiling during shader execution:
```cpp
desc.AddShader( ... | EShaderLangFormat::EnableProfiling, "main", R"#(
// empty function will be replaced during shader compilation
void dbg_EnableProfiling (bool b) {}
void main ()
{
bool condition = ...
// if condition is true then profiling will started here
dbg_EnableProfiling( condition );
...
}
)#" );
// supports any shader stage
DrawIndexed().EnableShaderProfiling( EShaderStages::Vertex | EShaderStages::Fragment );
TraceRays().EnableShaderProfiling();
DispatchCompute().EnableShaderProfiling();
```

Example of shader profiling output:
```cpp
//> gl_GlobalInvocationID: uint3 {512, 512, 0}
//> gl_LocalInvocationID: uint3 {0, 0, 0}
//> gl_WorkGroupID: uint3 {64, 64, 0}
no source

// subgroup total: 100.00%, avr: 100.00%, (95108.00)
// device total: 100.00%, avr: 100.00%, (2452.00)
// invocations: 1
106. void main ()

// subgroup total: 89.57%, avr: 89.57%, (85192.00)
// device total: 89.56%, avr: 89.56%, (2196.00)
// invocations: 1
29. float FBM (in float3 coord)

// subgroup total: 84.67%, avr: 12.10%, (11504.57)
// device total: 84.18%, avr: 12.03%, (294.86)
// invocations: 7
56. float GradientNoise (const float3 pos)

// subgroup total: 45.15%, avr: 0.81%, (766.86)
// device total: 44.54%, avr: 0.80%, (19.50)
// invocations: 56
72. float3 DHash33 (const float3 p)
```
3 changes: 3 additions & 0 deletions extensions/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ Can produce debuggable shaders using GLSLTrace library.
## Offline Pipeline Compiler
Compile glsl shader using PipelineCompiler library and serialize it to the C++ code.<br/>
Required for Android because shader compilation is not supported for it.

## Video
Video recorder implementation.
Loading

0 comments on commit e751589

Please sign in to comment.