Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
528cfc2d
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
12 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pbrt-v4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
528cfc2d
编写于
10月 09, 2020
作者:
M
Matt Pharr
提交者:
GitHub
10月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #57 from pierremoreau/fix_ptx_generation
Rework the compilation to PTX and embedding
上级
f73d1760
6446512c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
19 deletion
+75
-19
CMakeLists.txt
CMakeLists.txt
+25
-19
cmake/bin2c_wrapper.cmake
cmake/bin2c_wrapper.cmake
+46
-0
src/ext/CMakeLists.txt
src/ext/CMakeLists.txt
+4
-0
未找到文件。
CMakeLists.txt
浏览文件 @
528cfc2d
...
...
@@ -74,8 +74,7 @@ find_package ( Threads )
set_property
(
GLOBAL PROPERTY USE_FOLDERS ON
)
if
(
MSVC
)
add_definitions
(
/D _CRT_SECURE_NO_WARNINGS
)
set
(
PBRT_DEFINITIONS
${
PBRT_DEFINITIONS
}
PBRT_IS_MSVC
)
set
(
PBRT_DEFINITIONS
${
PBRT_DEFINITIONS
}
PBRT_IS_MSVC _CRT_SECURE_NO_WARNINGS
)
endif
()
#######################################
...
...
@@ -189,10 +188,6 @@ if (CMAKE_CUDA_COMPILER)
# optix
# FIXME
include_directories
(
${
PBRT_OPTIX7_PATH
}
/include
)
# FIXME. Sigh. I'm not sure how else to pass this through to cuda_compile_ptx...
include_directories
(
src
)
include_directories
(
${
CMAKE_BINARY_DIR
}
)
include_directories
(
${
NANOVDB_INCLUDE
}
)
# from Ingo's configure_optix.cmake (Apache licensed)
find_program
(
BIN2C bin2c DOC
"Path to the CUDA SDK bin2c executable."
)
...
...
@@ -207,21 +202,32 @@ if (CMAKE_CUDA_COMPILER)
# that PTX string 'embedded' as a global constant.
# 4) assign the name of the intermediary .o file to the cmake variable
# 'output_var', which can then be added to cmake targets.
macro
(
cuda_compile_and_embed output_var cuda_file
)
macro
(
cuda_compile_and_embed output_var cuda_file lib_name
)
add_library
(
"
${
lib_name
}
"
OBJECT
"
${
cuda_file
}
"
)
set_property
(
TARGET
"
${
lib_name
}
"
PROPERTY CUDA_PTX_COMPILATION ON
)
target_compile_options
(
"
${
lib_name
}
"
PRIVATE
# disable "extern declaration... is treated as a static definition" warning
-Xcudafe=--display_error_number -Xcudafe=--diag_suppress=3089
)
target_compile_definitions
(
"
${
lib_name
}
"
PRIVATE
${
PBRT_DEFINITIONS
}
)
target_include_directories
(
"
${
lib_name
}
"
PRIVATE src
${
CMAKE_BINARY_DIR
}
)
target_include_directories
(
"
${
lib_name
}
"
SYSTEM PRIVATE
${
NANOVDB_INCLUDE
}
)
add_dependencies
(
"
${
lib_name
}
"
pbrt_soa_generated
)
set
(
c_var_name
${
output_var
}
)
cuda_compile_ptx
(
ptx_files
${
cuda_file
}
OPTIONS --std=c++17 -O3
${
PBRT_CUDA_DIAG_FLAGS
}
-DNDEBUG --use_fast_math
# disable "extern declaration... is treated as a static definition" warning
-Xcudafe=--display_error_number -Xcudafe=--diag_suppress=3089
--gpu-architecture=
${
ARCH
}
-D PBRT_BUILD_GPU_RENDERER
)
list
(
GET ptx_files 0 ptx_file
)
set
(
embedded_file
${
ptx_file
}
_embedded.c
)
set
(
embedded_file
${
cuda_file
}
.ptx_embedded.c
)
add_custom_command
(
OUTPUT
${
embedded_file
}
COMMAND
${
BIN2C
}
-c --padd 0 --type char --name
${
c_var_name
}
${
ptx_file
}
>
${
embedded_file
}
DEPENDS
${
ptx_file
}
OUTPUT
"
${
embedded_file
}
"
COMMAND
${
CMAKE_COMMAND
}
"-DBIN_TO_C_COMMAND=
${
BIN2C
}
"
"-DOBJECTS=$<TARGET_OBJECTS:
${
lib_name
}
>"
"-DVAR_NAME=
${
c_var_name
}
"
"-DOUTPUT=
${
embedded_file
}
"
-P
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/bin2c_wrapper.cmake
VERBATIM
DEPENDS
"
${
lib_name
}
"
COMMENT
"compiling (and embedding ptx from)
${
cuda_file
}
"
)
)
set
(
${
output_var
}
${
embedded_file
}
)
endmacro
()
endif
()
...
...
@@ -597,7 +603,7 @@ if (PBRT_CUDA_ENABLED)
PROPERTIES LANGUAGE CUDA
)
cuda_compile_and_embed
(
PBRT_EMBEDDED_PTX src/pbrt/gpu/optix.cu
)
cuda_compile_and_embed
(
PBRT_EMBEDDED_PTX src/pbrt/gpu/optix.cu
optix.cu
)
endif
()
source_group
(
"Source Files"
FILES
${
PBRT_SOURCE
}
)
...
...
cmake/bin2c_wrapper.cmake
0 → 100644
浏览文件 @
528cfc2d
# Copyright (c) 1993-2015, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Taken from https://github.com/robertmaynard/code-samples/blob/master/posts/cmake_ptx/bin2c_wrapper.cmake
# Modified to take a custom name instead of using the object name.
set
(
file_contents
)
foreach
(
obj
${
OBJECTS
}
)
get_filename_component
(
obj_ext
${
obj
}
EXT
)
get_filename_component
(
obj_dir
${
obj
}
DIRECTORY
)
if
(
obj_ext MATCHES
".ptx"
)
set
(
args --name
${
VAR_NAME
}
${
obj
}
)
execute_process
(
COMMAND
"
${
BIN_TO_C_COMMAND
}
"
${
args
}
WORKING_DIRECTORY
${
obj_dir
}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error_var
)
set
(
file_contents
"
${
file_contents
}
\n
${
output
}
"
)
endif
()
endforeach
()
file
(
WRITE
"
${
OUTPUT
}
"
"
${
file_contents
}
"
)
src/ext/CMakeLists.txt
浏览文件 @
528cfc2d
cmake_minimum_required
(
VERSION 3.12
)
if
(
MSVC
)
add_definitions
(
/D _CRT_SECURE_NO_WARNINGS
)
endif
()
###########################################################################
# stb
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录