Compare commits
5 Commits
temp-eevee
...
temp-keyma
Author | SHA1 | Date | |
---|---|---|---|
de94b6baf6 | |||
6af169f536 | |||
9eb4a74e9f | |||
15dd7bdf1e | |||
e2edea18c9 |
@@ -1,44 +0,0 @@
|
||||
# C/C++
|
||||
[*.{c,cc,h,hh,inl,glsl}]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# CMake & Text
|
||||
[*.{cmake,txt}]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# Python
|
||||
[*.py]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# Shell
|
||||
[*.sh]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
# reStructuredText
|
||||
[*.rst]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 3
|
||||
max_line_length = 120
|
@@ -227,6 +227,8 @@ option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported
|
||||
mark_as_advanced(WITH_SYSTEM_BULLET)
|
||||
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
|
||||
|
||||
option(WITH_CLAY_ENGINE "Enable Clay engine" ON)
|
||||
|
||||
# Compositor
|
||||
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
|
||||
|
||||
@@ -439,7 +441,7 @@ mark_as_advanced(WITH_MEM_VALGRIND)
|
||||
option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
|
||||
mark_as_advanced(WITH_CXX_GUARDEDALLOC)
|
||||
|
||||
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
|
||||
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
|
||||
mark_as_advanced(WITH_ASSERT_ABORT)
|
||||
|
||||
option(WITH_BOOST "Enable features depending on boost" ON)
|
||||
@@ -458,13 +460,11 @@ endif()
|
||||
|
||||
# OpenGL
|
||||
|
||||
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
|
||||
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
|
||||
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
|
||||
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
|
||||
|
||||
mark_as_advanced(
|
||||
WITH_OPENGL
|
||||
WITH_GLEW_ES
|
||||
WITH_GL_EGL
|
||||
WITH_GL_PROFILE_ES20
|
||||
@@ -545,8 +545,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
find_library(COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
|
||||
else()
|
||||
find_library( COMPILER_ASAN_LIBRARY NAMES clang_rt.asan-x86_64
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/7.0.0/lib/windows
|
||||
PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/7.0.0/lib/windows
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/6.0.0/lib/windows
|
||||
)
|
||||
endif()
|
||||
@@ -806,8 +805,7 @@ set(C_WARNINGS)
|
||||
set(CXX_WARNINGS)
|
||||
|
||||
# for gcc -Wno-blah-blah
|
||||
set(C_REMOVE_STRICT_FLAGS)
|
||||
set(CXX_REMOVE_STRICT_FLAGS)
|
||||
set(CC_REMOVE_STRICT_FLAGS)
|
||||
|
||||
# libraries to link the binary with passed to target_link_libraries()
|
||||
# known as LLIBS to scons
|
||||
@@ -819,8 +817,7 @@ set(PLATFORM_LINKLIBS "")
|
||||
set(PLATFORM_LINKFLAGS "")
|
||||
set(PLATFORM_LINKFLAGS_DEBUG "")
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
if(WITH_COMPILER_ASAN)
|
||||
if(WITH_COMPILER_ASAN)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_ASAN_CFLAGS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CFLAGS}")
|
||||
|
||||
@@ -832,7 +829,6 @@ if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}")
|
||||
set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
|
||||
set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -1006,10 +1002,6 @@ endif()
|
||||
find_package(OpenGL)
|
||||
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
|
||||
|
||||
if(WITH_OPENGL)
|
||||
add_definitions(-DWITH_OPENGL)
|
||||
endif()
|
||||
|
||||
if(WITH_SYSTEM_GLES)
|
||||
find_package_wrapper(OpenGLES)
|
||||
endif()
|
||||
@@ -1416,22 +1408,16 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
endif()
|
||||
|
||||
# flags to undo strict flags
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_TYPE_LIMITS -Wno-type-limits)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_FORMAT -Wno-format)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_SWITCH -Wno-switch)
|
||||
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
|
||||
endif()
|
||||
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
@@ -1460,23 +1446,23 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros)
|
||||
|
||||
# flags to undo strict flags
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
|
||||
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
|
||||
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
|
||||
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
|
||||
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||
|
||||
|
@@ -58,3 +58,4 @@ if(MSVC)
|
||||
DEPENDEES mkdir update patch download configure build install
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@@ -216,3 +216,4 @@ if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe")
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@@ -216,3 +216,4 @@ if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ranlib.exe")
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ranlib.exe"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@@ -37,3 +37,4 @@ endif()
|
||||
if(MSVC)
|
||||
set_target_properties(external_zlib_mingw PROPERTIES FOLDER Mingw)
|
||||
endif()
|
||||
|
||||
|
@@ -79,3 +79,4 @@ macro( select_library_configurations basename )
|
||||
${basename}_LIBRARY_DEBUG
|
||||
)
|
||||
endmacro( select_library_configurations )
|
||||
|
||||
|
@@ -93,3 +93,4 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LLVM DEFAULT_MSG
|
||||
MARK_AS_ADVANCED(
|
||||
LLVM_LIBRARY
|
||||
)
|
||||
|
||||
|
@@ -674,9 +674,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
|
||||
extern_openjpeg
|
||||
ge_videotex
|
||||
bf_dna
|
||||
|
||||
bf_blenfont
|
||||
bf_gpu # duplicate for blenfont
|
||||
bf_blentranslation
|
||||
bf_intern_audaspace
|
||||
audaspace
|
||||
@@ -1056,19 +1054,13 @@ macro(remove_cc_flag
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(add_c_flag
|
||||
macro(add_cc_flag
|
||||
flag)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
endmacro()
|
||||
|
||||
macro(add_cxx_flag
|
||||
flag)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
endmacro()
|
||||
|
||||
macro(remove_strict_flags)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
@@ -1091,8 +1083,7 @@ macro(remove_strict_flags)
|
||||
)
|
||||
|
||||
# negate flags implied by '-Wall'
|
||||
add_c_flag("${C_REMOVE_STRICT_FLAGS}")
|
||||
add_cxx_flag("${CXX_REMOVE_STRICT_FLAGS}")
|
||||
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
@@ -1104,8 +1095,7 @@ macro(remove_strict_flags)
|
||||
)
|
||||
|
||||
# negate flags implied by '-Wall'
|
||||
add_c_flag("${C_REMOVE_STRICT_FLAGS}")
|
||||
add_cxx_flag("${CXX_REMOVE_STRICT_FLAGS}")
|
||||
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
@@ -1135,39 +1125,28 @@ endmacro()
|
||||
# note, we can only append flags on a single file so we need to negate the options.
|
||||
# at the moment we cant shut up ffmpeg deprecations, so use this, but will
|
||||
# probably add more removals here.
|
||||
macro(remove_strict_c_flags_file
|
||||
macro(remove_strict_flags_file
|
||||
filenames)
|
||||
|
||||
foreach(_SOURCE ${ARGV})
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR
|
||||
(CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
||||
set_source_files_properties(${_SOURCE}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${C_REMOVE_STRICT_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# TODO
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_SOURCE)
|
||||
endmacro()
|
||||
|
||||
macro(remove_strict_cxx_flags_file
|
||||
filenames)
|
||||
remove_strict_c_flags_file(${filenames} ${ARHV})
|
||||
foreach(_SOURCE ${ARGV})
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR
|
||||
(CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
set_source_files_properties(${_SOURCE}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${CXX_REMOVE_STRICT_FLAGS}"
|
||||
COMPILE_FLAGS "${CC_REMOVE_STRICT_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# TODO
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
unset(_SOURCE)
|
||||
|
||||
endmacro()
|
||||
|
||||
# External libs may need 'signed char' to be default.
|
||||
|
@@ -2,7 +2,6 @@ if NOT "%verbose%" == "" (
|
||||
echo Detecting msvc 2017
|
||||
)
|
||||
set BUILD_VS_VER=15
|
||||
set BUILD_VS_YEAR=2017
|
||||
set ProgramFilesX86=%ProgramFiles(x86)%
|
||||
if not exist "%ProgramFilesX86%" set ProgramFilesX86=%ProgramFiles%
|
||||
|
||||
|
@@ -3,10 +3,10 @@ if "%GIT%" == "" (
|
||||
goto EOF
|
||||
)
|
||||
cd "%BLENDER_DIR%"
|
||||
for /f "delims=" %%i in ('"%GIT%" rev-parse HEAD') do echo Branch_hash=%%i
|
||||
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Branch_hash=%%i
|
||||
cd "%BLENDER_DIR%/release/datafiles/locale"
|
||||
for /f "delims=" %%i in ('"%GIT%" rev-parse HEAD') do echo Locale_hash=%%i
|
||||
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Locale_hash=%%i
|
||||
cd "%BLENDER_DIR%/release/scripts/addons"
|
||||
for /f "delims=" %%i in ('"%GIT%" rev-parse HEAD') do echo Addons_Hash=%%i
|
||||
for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Addons_Hash=%%i
|
||||
cd "%BLENDER_DIR%"
|
||||
:EOF
|
@@ -76,7 +76,7 @@ class DNACatalogHTML:
|
||||
DNACatalog is a catalog of all information in the DNA1 file-block
|
||||
'''
|
||||
|
||||
def __init__(self, catalog, bpy_module=None):
|
||||
def __init__(self, catalog, bpy_module = None):
|
||||
self.Catalog = catalog
|
||||
self.bpy = bpy_module
|
||||
|
||||
@@ -125,9 +125,9 @@ class DNACatalogHTML:
|
||||
|
||||
# ${endianness}
|
||||
if header.LittleEndianness:
|
||||
endianess = 'Little endianness'
|
||||
endianess= 'Little endianness'
|
||||
else:
|
||||
endianess = 'Big endianness'
|
||||
endianess= 'Big endianness'
|
||||
|
||||
# ${structs_list}
|
||||
log.debug("Creating structs index")
|
||||
@@ -136,7 +136,7 @@ class DNACatalogHTML:
|
||||
structureIndex = 0
|
||||
for structure in self.Catalog.Structs:
|
||||
structs_list += list_item.format(structureIndex, structure.Type.Name)
|
||||
structureIndex += 1
|
||||
structureIndex+=1
|
||||
|
||||
# ${structs_content}
|
||||
log.debug("Creating structs content")
|
||||
@@ -146,12 +146,12 @@ class DNACatalogHTML:
|
||||
structs_content += self.Structure(structure)
|
||||
|
||||
d = dict(
|
||||
version=version,
|
||||
revision=revision,
|
||||
bitness=bitness,
|
||||
endianness=endianess,
|
||||
structs_list=structs_list,
|
||||
structs_content=structs_content
|
||||
version = version,
|
||||
revision = revision,
|
||||
bitness = bitness,
|
||||
endianness = endianess,
|
||||
structs_list = structs_list,
|
||||
structs_content = structs_content
|
||||
)
|
||||
|
||||
dna_html = Template(dna_html_template).substitute(d)
|
||||
@@ -180,9 +180,9 @@ class DNACatalogHTML:
|
||||
<label>(<a href="#top">top</a>)</label><br/>"""
|
||||
|
||||
d = dict(
|
||||
struct_name=structure.Type.Name,
|
||||
fields=self.StructureFields(structure, None, 0),
|
||||
size=str(structure.Type.Size)
|
||||
struct_name = structure.Type.Name,
|
||||
fields = self.StructureFields(structure, None, 0),
|
||||
size = str(structure.Type.Size)
|
||||
)
|
||||
|
||||
struct_table = Template(struct_table_template).substitute(d)
|
||||
@@ -230,12 +230,12 @@ class DNACatalogHTML:
|
||||
size = field.Size(self.Catalog.Header)
|
||||
|
||||
d = dict(
|
||||
reference=reference,
|
||||
struct=struct,
|
||||
type=type,
|
||||
name=name,
|
||||
offset=offset,
|
||||
size=size
|
||||
reference = reference,
|
||||
struct = struct,
|
||||
type = type,
|
||||
name = name,
|
||||
offset = offset,
|
||||
size = size
|
||||
)
|
||||
|
||||
structure_field = Template(structure_field_template).substitute(d)
|
||||
@@ -246,7 +246,7 @@ class DNACatalogHTML:
|
||||
|
||||
return structure_field
|
||||
|
||||
def indent(self, input, dent, startswith=''):
|
||||
def indent(self, input, dent, startswith = ''):
|
||||
output = ''
|
||||
if dent < 0:
|
||||
for line in input.split('\n'):
|
||||
@@ -257,19 +257,19 @@ class DNACatalogHTML:
|
||||
output += line.lstrip() + '\n' # remove indentation completely
|
||||
elif dent > 0:
|
||||
for line in input.split('\n'):
|
||||
output += ' ' * dent + line + '\n'
|
||||
output += ' '* dent + line + '\n'
|
||||
return output
|
||||
|
||||
def format(self, input):
|
||||
diff = {
|
||||
'\n<!DOCTYPE': '<!DOCTYPE',
|
||||
'\n</ul>': '</ul>',
|
||||
'<a name': '\n<a name',
|
||||
'<tr>\n': '<tr>',
|
||||
'<tr>': ' <tr>',
|
||||
'</th>\n': '</th>',
|
||||
'</td>\n': '</td>',
|
||||
'<tbody>\n': '<tbody>'
|
||||
'\n<!DOCTYPE':'<!DOCTYPE',
|
||||
'\n</ul>' :'</ul>',
|
||||
'<a name' :'\n<a name',
|
||||
'<tr>\n' :'<tr>',
|
||||
'<tr>' :' <tr>',
|
||||
'</th>\n' :'</th>',
|
||||
'</td>\n' :'</td>',
|
||||
'<tbody>\n' :'<tbody>'
|
||||
}
|
||||
output = self.indent(input, 0)
|
||||
for key, value in diff.items():
|
||||
@@ -417,7 +417,7 @@ def main():
|
||||
log.info("1: write temp blend file with SDNA info")
|
||||
log.info(" saving to: " + Path_Blend)
|
||||
try:
|
||||
bpy.ops.wm.save_as_mainfile(filepath=Path_Blend, copy=True, compress=False)
|
||||
bpy.ops.wm.save_as_mainfile(filepath = Path_Blend, copy = True, compress = False)
|
||||
except:
|
||||
log.error("Filename {0} does not exist and can't be created... quitting".format(Path_Blend))
|
||||
return
|
||||
|
@@ -34,7 +34,6 @@ log = logging.getLogger("BlendFileReader")
|
||||
# module global routines
|
||||
######################################################
|
||||
|
||||
|
||||
def ReadString(handle, length):
|
||||
'''
|
||||
ReadString reads a String of given length or a zero terminating String
|
||||
@@ -46,7 +45,7 @@ def ReadString(handle, length):
|
||||
# length == 0 means we want a zero terminating string
|
||||
result = ""
|
||||
s = ReadString(handle, 1)
|
||||
while s != "\0":
|
||||
while s!="\0":
|
||||
result += s
|
||||
s = ReadString(handle, 1)
|
||||
return result
|
||||
@@ -95,10 +94,10 @@ def openBlendFile(filename):
|
||||
log.debug("decompressing started")
|
||||
fs = gzip.open(filename, "rb")
|
||||
handle = tempfile.TemporaryFile()
|
||||
data = fs.read(1024 * 1024)
|
||||
data = fs.read(1024*1024)
|
||||
while data:
|
||||
handle.write(data)
|
||||
data = fs.read(1024 * 1024)
|
||||
data = fs.read(1024*1024)
|
||||
log.debug("decompressing finished")
|
||||
fs.close()
|
||||
log.debug("resetting decompressed file")
|
||||
@@ -113,7 +112,7 @@ def Align(handle):
|
||||
offset = handle.tell()
|
||||
trim = offset % 4
|
||||
if trim != 0:
|
||||
handle.seek(4 - trim, os.SEEK_CUR)
|
||||
handle.seek(4-trim, os.SEEK_CUR)
|
||||
|
||||
|
||||
######################################################
|
||||
@@ -267,9 +266,9 @@ class DNACatalog:
|
||||
|
||||
def __init__(self, fileheader, handle):
|
||||
log.debug("building DNA catalog")
|
||||
self.Names = []
|
||||
self.Types = []
|
||||
self.Structs = []
|
||||
self.Names=[]
|
||||
self.Types=[]
|
||||
self.Structs=[]
|
||||
self.Header = fileheader
|
||||
|
||||
SDNA = ReadString(handle, 4)
|
||||
@@ -279,7 +278,7 @@ class DNACatalog:
|
||||
numberOfNames = Read('uint', handle, fileheader)
|
||||
log.debug("building #{0} names".format(numberOfNames))
|
||||
for i in range(numberOfNames):
|
||||
name = ReadString(handle, 0)
|
||||
name = ReadString(handle,0)
|
||||
self.Names.append(DNAName(name))
|
||||
Align(handle)
|
||||
|
||||
@@ -288,7 +287,7 @@ class DNACatalog:
|
||||
numberOfTypes = Read('uint', handle, fileheader)
|
||||
log.debug("building #{0} types".format(numberOfTypes))
|
||||
for i in range(numberOfTypes):
|
||||
type = ReadString(handle, 0)
|
||||
type = ReadString(handle,0)
|
||||
self.Types.append(DNAType(type))
|
||||
Align(handle)
|
||||
|
||||
@@ -333,13 +332,13 @@ class DNAName:
|
||||
if parent is None:
|
||||
result = ""
|
||||
else:
|
||||
result = parent + "."
|
||||
result = parent+"."
|
||||
|
||||
result = result + self.ShortName()
|
||||
return result
|
||||
|
||||
def ShortName(self):
|
||||
result = self.Name
|
||||
result = self.Name;
|
||||
result = result.replace("*", "")
|
||||
result = result.replace("(", "")
|
||||
result = result.replace(")", "")
|
||||
@@ -349,10 +348,10 @@ class DNAName:
|
||||
return result
|
||||
|
||||
def IsPointer(self):
|
||||
return self.Name.find("*") > -1
|
||||
return self.Name.find("*")>-1
|
||||
|
||||
def IsMethodPointer(self):
|
||||
return self.Name.find("(*") > -1
|
||||
return self.Name.find("(*")>-1
|
||||
|
||||
def ArraySize(self):
|
||||
result = 1
|
||||
@@ -361,8 +360,8 @@ class DNAName:
|
||||
|
||||
while Index != -1:
|
||||
Index2 = Temp.find("]")
|
||||
result *= int(Temp[Index + 1:Index2])
|
||||
Temp = Temp[Index2 + 1:]
|
||||
result*=int(Temp[Index+1:Index2])
|
||||
Temp = Temp[Index2+1:]
|
||||
Index = Temp.find("[")
|
||||
|
||||
return result
|
||||
@@ -379,7 +378,7 @@ class DNAType:
|
||||
|
||||
def __init__(self, aName):
|
||||
self.Name = aName
|
||||
self.Structure = None
|
||||
self.Structure=None
|
||||
|
||||
|
||||
class DNAStructure:
|
||||
@@ -393,22 +392,22 @@ class DNAStructure:
|
||||
def __init__(self, aType):
|
||||
self.Type = aType
|
||||
self.Type.Structure = self
|
||||
self.Fields = []
|
||||
self.Fields=[]
|
||||
|
||||
def GetField(self, header, handle, path):
|
||||
splitted = path.partition(".")
|
||||
name = splitted[0]
|
||||
rest = splitted[2]
|
||||
offset = 0
|
||||
offset = 0;
|
||||
for field in self.Fields:
|
||||
if field.Name.ShortName() == name:
|
||||
log.debug("found " + name + "@" + str(offset))
|
||||
log.debug("found "+name+"@"+str(offset))
|
||||
handle.seek(offset, os.SEEK_CUR)
|
||||
return field.DecodeField(header, handle, rest)
|
||||
else:
|
||||
offset += field.Size(header)
|
||||
|
||||
log.debug("error did not find " + path)
|
||||
log.debug("error did not find "+path)
|
||||
return None
|
||||
|
||||
|
||||
@@ -426,21 +425,22 @@ class DNAField:
|
||||
|
||||
def Size(self, header):
|
||||
if self.Name.IsPointer() or self.Name.IsMethodPointer():
|
||||
return header.PointerSize * self.Name.ArraySize()
|
||||
return header.PointerSize*self.Name.ArraySize()
|
||||
else:
|
||||
return self.Type.Size * self.Name.ArraySize()
|
||||
return self.Type.Size*self.Name.ArraySize()
|
||||
|
||||
def DecodeField(self, header, handle, path):
|
||||
if path == "":
|
||||
if self.Name.IsPointer():
|
||||
return Read('pointer', handle, header)
|
||||
if self.Type.Name == "int":
|
||||
if self.Type.Name=="int":
|
||||
return Read('int', handle, header)
|
||||
if self.Type.Name == "short":
|
||||
if self.Type.Name=="short":
|
||||
return Read('short', handle, header)
|
||||
if self.Type.Name == "float":
|
||||
if self.Type.Name=="float":
|
||||
return Read('float', handle, header)
|
||||
if self.Type.Name == "char":
|
||||
if self.Type.Name=="char":
|
||||
return ReadString(handle, self.Name.ArraySize())
|
||||
else:
|
||||
return self.Type.Structure.GetField(header, handle, path)
|
||||
|
||||
|
@@ -42,7 +42,6 @@ def man_format(data):
|
||||
data = data.replace("\t", " ")
|
||||
return data
|
||||
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
import getopt
|
||||
raise getopt.GetoptError("Usage: %s <path-to-blender> <output-filename>" % sys.argv[0])
|
||||
|
@@ -15,7 +15,6 @@ font_info = {
|
||||
"handler": None,
|
||||
}
|
||||
|
||||
|
||||
def init():
|
||||
"""init function - runs once"""
|
||||
import os
|
||||
|
@@ -17,5 +17,4 @@ from bpy.app.handlers import persistent
|
||||
def load_handler(dummy):
|
||||
print("Load Handler:", bpy.data.filepath)
|
||||
|
||||
|
||||
bpy.app.handlers.load_post.append(load_handler)
|
||||
|
@@ -11,5 +11,4 @@ import bpy
|
||||
def my_handler(scene):
|
||||
print("Frame Change", scene.frame_current)
|
||||
|
||||
|
||||
bpy.app.handlers.frame_change_pre.append(my_handler)
|
||||
|
@@ -81,7 +81,6 @@ for msg in translations_tuple:
|
||||
|
||||
# Define remaining addon (operators, UI...) here.
|
||||
|
||||
|
||||
def register():
|
||||
# Usual operator/UI/etc. registration...
|
||||
|
||||
|
@@ -14,7 +14,6 @@ class MaterialSettings(bpy.types.PropertyGroup):
|
||||
my_float = bpy.props.FloatProperty()
|
||||
my_string = bpy.props.StringProperty()
|
||||
|
||||
|
||||
bpy.utils.register_class(MaterialSettings)
|
||||
|
||||
bpy.types.Material.my_settings = \
|
||||
|
@@ -14,7 +14,6 @@ class SceneSettingItem(bpy.types.PropertyGroup):
|
||||
name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
|
||||
value = bpy.props.IntProperty(name="Test Prop", default=22)
|
||||
|
||||
|
||||
bpy.utils.register_class(SceneSettingItem)
|
||||
|
||||
bpy.types.Scene.my_settings = \
|
||||
|
@@ -14,7 +14,6 @@ import bpy
|
||||
def update_func(self, context):
|
||||
print("my test function", self)
|
||||
|
||||
|
||||
bpy.types.Scene.testprop = bpy.props.FloatProperty(update=update_func)
|
||||
|
||||
bpy.context.scene.testprop = 11.0
|
||||
|
@@ -19,7 +19,6 @@ def get_float(self):
|
||||
def set_float(self, value):
|
||||
self["testprop"] = value
|
||||
|
||||
|
||||
bpy.types.Scene.test_float = bpy.props.FloatProperty(get=get_float, set=set_float)
|
||||
|
||||
|
||||
@@ -28,7 +27,6 @@ def get_date(self):
|
||||
import datetime
|
||||
return str(datetime.datetime.now())
|
||||
|
||||
|
||||
bpy.types.Scene.test_date = bpy.props.StringProperty(get=get_date)
|
||||
|
||||
|
||||
@@ -42,7 +40,6 @@ def get_array(self):
|
||||
def set_array(self, values):
|
||||
self["somebool"] = values[0] and values[1]
|
||||
|
||||
|
||||
bpy.types.Scene.test_array = bpy.props.BoolVectorProperty(size=2, get=get_array, set=set_array)
|
||||
|
||||
|
||||
@@ -53,7 +50,7 @@ test_items = [
|
||||
("GREEN", "Green", "", 2),
|
||||
("BLUE", "Blue", "", 3),
|
||||
("YELLOW", "Yellow", "", 4),
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
def get_enum(self):
|
||||
@@ -64,7 +61,6 @@ def get_enum(self):
|
||||
def set_enum(self, value):
|
||||
print("setting value", value)
|
||||
|
||||
|
||||
bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enum, set=set_enum)
|
||||
|
||||
|
||||
|
@@ -9,7 +9,7 @@ bl_info = {
|
||||
"wiki_url": "",
|
||||
"tracker_url": "",
|
||||
"category": "Object",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import bpy
|
||||
|
@@ -14,5 +14,4 @@ import bpy
|
||||
def menu_draw(self, context):
|
||||
self.layout.operator("wm.save_homefile")
|
||||
|
||||
|
||||
bpy.types.INFO_MT_file.append(menu_draw)
|
||||
|
@@ -61,7 +61,7 @@ def panel_func(self, context):
|
||||
classes = (
|
||||
OBJECT_MT_draw_presets,
|
||||
AddPresetObjectDraw,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
|
@@ -60,7 +60,6 @@ def menu_func(self, context):
|
||||
layout.separator()
|
||||
layout.operator(WM_OT_button_context_test.bl_idname)
|
||||
|
||||
|
||||
classes = (
|
||||
WM_OT_button_context_test,
|
||||
WM_MT_button_context,
|
||||
@@ -78,6 +77,5 @@ def unregister():
|
||||
bpy.utils.unregister_class(cls)
|
||||
bpy.types.WM_MT_button_context.remove(menu_func)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
@@ -21,5 +21,4 @@ class CyclesNodeTree(bpy.types.NodeTree):
|
||||
def poll(cls, context):
|
||||
return context.scene.render.engine == 'CYCLES'
|
||||
|
||||
|
||||
bpy.utils.register_class(CyclesNodeTree)
|
||||
|
@@ -42,7 +42,6 @@ class SimpleMouseOperator(bpy.types.Operator):
|
||||
self.y = event.mouse_y
|
||||
return self.execute(context)
|
||||
|
||||
|
||||
bpy.utils.register_class(SimpleMouseOperator)
|
||||
|
||||
# Test call to the newly defined operator.
|
||||
|
@@ -42,7 +42,6 @@ def menu_func(self, context):
|
||||
self.layout.operator_context = 'INVOKE_DEFAULT'
|
||||
self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
|
||||
|
||||
|
||||
# Register and add to the file selector
|
||||
bpy.utils.register_class(ExportSomeData)
|
||||
bpy.types.INFO_MT_file_export.append(menu_func)
|
||||
|
@@ -41,7 +41,6 @@ class CustomDrawOperator(bpy.types.Operator):
|
||||
|
||||
col.prop(self, "my_string")
|
||||
|
||||
|
||||
bpy.utils.register_class(CustomDrawOperator)
|
||||
|
||||
# test call
|
||||
|
@@ -22,7 +22,6 @@ class HelloWorldOperator(bpy.types.Operator):
|
||||
print("Hello World")
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
bpy.utils.register_class(HelloWorldOperator)
|
||||
|
||||
# test call to the newly defined operator
|
||||
|
@@ -31,7 +31,6 @@ class MyPropertyGroup(bpy.types.PropertyGroup):
|
||||
custom_1 = bpy.props.FloatProperty(name="My Float")
|
||||
custom_2 = bpy.props.IntProperty(name="My Int")
|
||||
|
||||
|
||||
bpy.utils.register_class(MyPropertyGroup)
|
||||
|
||||
bpy.types.Object.my_prop_grp = bpy.props.PointerProperty(type=MyPropertyGroup)
|
||||
|
@@ -10,5 +10,4 @@ import bpy
|
||||
def draw(self, context):
|
||||
self.layout.label("Hello World")
|
||||
|
||||
|
||||
bpy.context.window_manager.popup_menu(draw, title="Greeting", icon='INFO')
|
||||
|
@@ -12,7 +12,6 @@ from bpy.props import PointerProperty
|
||||
class MyPropGroup(bpy.types.PropertyGroup):
|
||||
nested = bpy.props.FloatProperty(name="Nested", default=0.0)
|
||||
|
||||
|
||||
# register it so its available for all bones
|
||||
bpy.utils.register_class(MyPropGroup)
|
||||
bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup,
|
||||
|
@@ -73,8 +73,6 @@ def rna_info_BuildRNAInfo_cache():
|
||||
if rna_info_BuildRNAInfo_cache.ret is None:
|
||||
rna_info_BuildRNAInfo_cache.ret = rna_info.BuildRNAInfo()
|
||||
return rna_info_BuildRNAInfo_cache.ret
|
||||
|
||||
|
||||
rna_info_BuildRNAInfo_cache.ret = None
|
||||
# --- end rna_info cache
|
||||
|
||||
@@ -518,8 +516,6 @@ def escape_rst(text):
|
||||
""" Escape plain text which may contain characters used by RST.
|
||||
"""
|
||||
return text.translate(escape_rst.trans)
|
||||
|
||||
|
||||
escape_rst.trans = str.maketrans({
|
||||
"`": "\\`",
|
||||
"|": "\\|",
|
||||
@@ -1022,7 +1018,6 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
||||
|
||||
file.close()
|
||||
|
||||
|
||||
# Changes in Blender will force errors here
|
||||
context_type_map = {
|
||||
"active_base": ("ObjectBase", False),
|
||||
|
@@ -21,7 +21,7 @@
|
||||
# <pep8 compliant>
|
||||
|
||||
bpy_types_Operator_bl_property__doc__ = (
|
||||
"""
|
||||
"""
|
||||
The name of a property to use as this operators primary property.
|
||||
Currently this is only used to select the default property when
|
||||
expanding an operator into a menu.
|
||||
|
@@ -107,16 +107,14 @@ def main():
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
# II) Generate doc source in temp dir.
|
||||
doc_gen_cmd = (
|
||||
args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
|
||||
doc_gen_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
|
||||
"--python", "%s/doc/python_api/sphinx_doc_gen.py" % args.source_dir, "--",
|
||||
"--output", tmp_dir
|
||||
)
|
||||
"--output", tmp_dir)
|
||||
subprocess.run(doc_gen_cmd)
|
||||
|
||||
# III) Get Blender version info.
|
||||
getver_file = os.path.join(tmp_dir, "blendver.txt")
|
||||
getver_script = (
|
||||
getver_script = (""
|
||||
"import sys, bpy\n"
|
||||
"with open(sys.argv[-1], 'w') as f:\n"
|
||||
" is_release = bpy.app.version_cycle in {'rc', 'release'}\n"
|
||||
@@ -126,8 +124,7 @@ def main():
|
||||
" f.write('%d.%d%s\\n' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
|
||||
" if is_release else '%s\\n' % branch)\n"
|
||||
" f.write('%d_%d%s_release' % (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)\n"
|
||||
" if is_release else '%d_%d_%d' % bpy.app.version)\n"
|
||||
)
|
||||
" if is_release else '%d_%d_%d' % bpy.app.version)\n")
|
||||
get_ver_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
|
||||
"--python-expr", getver_script, "--", getver_file)
|
||||
subprocess.run(get_ver_cmd)
|
||||
|
2
extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
vendored
2
extern/audaspace/plugins/ffmpeg/FFMPEG.cpp
vendored
@@ -23,9 +23,7 @@ AUD_NAMESPACE_BEGIN
|
||||
|
||||
FFMPEG::FFMPEG()
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
av_register_all();
|
||||
#endif
|
||||
}
|
||||
|
||||
void FFMPEG::registerPlugin()
|
||||
|
124
extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
vendored
124
extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
vendored
@@ -22,37 +22,37 @@
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include <libavutil/avutil.h>
|
||||
}
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
#define FFMPEG_OLD_CODE
|
||||
#endif
|
||||
|
||||
int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
|
||||
{
|
||||
int buf_size = buffer.getSize();
|
||||
int buf_pos = 0;
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
AVFrame* frame = nullptr;
|
||||
int got_frame;
|
||||
int read_length;
|
||||
uint8_t* orig_data = packet.data;
|
||||
int orig_size = packet.size;
|
||||
|
||||
int buf_size = buffer.getSize();
|
||||
int buf_pos = 0;
|
||||
|
||||
while(packet.size > 0)
|
||||
{
|
||||
got_frame = 0;
|
||||
|
||||
read_length = avcodec_decode_audio4(m_codecCtx, m_frame, &got_frame, &packet);
|
||||
if(!frame)
|
||||
frame = av_frame_alloc();
|
||||
else
|
||||
av_frame_unref(frame);
|
||||
|
||||
read_length = avcodec_decode_audio4(m_codecCtx, frame, &got_frame, &packet);
|
||||
if(read_length < 0)
|
||||
break;
|
||||
|
||||
if(got_frame)
|
||||
{
|
||||
int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 1);
|
||||
int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, frame->nb_samples, m_codecCtx->sample_fmt, 1);
|
||||
|
||||
if(buf_size - buf_pos < data_size)
|
||||
{
|
||||
@@ -62,18 +62,18 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
|
||||
|
||||
if(m_tointerleave)
|
||||
{
|
||||
int single_size = data_size / m_codecCtx->channels / m_frame->nb_samples;
|
||||
int single_size = data_size / m_codecCtx->channels / frame->nb_samples;
|
||||
for(int channel = 0; channel < m_codecCtx->channels; channel++)
|
||||
{
|
||||
for(int i = 0; i < m_frame->nb_samples; i++)
|
||||
for(int i = 0; i < frame->nb_samples; i++)
|
||||
{
|
||||
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
|
||||
m_frame->data[channel] + i * single_size, single_size);
|
||||
frame->data[channel] + i * single_size, single_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, m_frame->data[0], data_size);
|
||||
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, frame->data[0], data_size);
|
||||
|
||||
buf_pos += data_size;
|
||||
}
|
||||
@@ -83,42 +83,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
|
||||
|
||||
packet.data = orig_data;
|
||||
packet.size = orig_size;
|
||||
#else
|
||||
avcodec_send_packet(m_codecCtx, &packet);
|
||||
|
||||
while(true)
|
||||
{
|
||||
auto ret = avcodec_receive_frame(m_codecCtx, m_frame);
|
||||
|
||||
if(ret != 0)
|
||||
break;
|
||||
|
||||
int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 1);
|
||||
|
||||
if(buf_size - buf_pos < data_size)
|
||||
{
|
||||
buffer.resize(buf_size + data_size, true);
|
||||
buf_size += data_size;
|
||||
}
|
||||
|
||||
if(m_tointerleave)
|
||||
{
|
||||
int single_size = data_size / m_codecCtx->channels / m_frame->nb_samples;
|
||||
for(int channel = 0; channel < m_codecCtx->channels; channel++)
|
||||
{
|
||||
for(int i = 0; i < m_frame->nb_samples; i++)
|
||||
{
|
||||
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
|
||||
m_frame->data[channel] + i * single_size, single_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos, m_frame->data[0], data_size);
|
||||
|
||||
buf_pos += data_size;
|
||||
}
|
||||
#endif
|
||||
av_free(frame);
|
||||
|
||||
return buf_pos;
|
||||
}
|
||||
@@ -136,11 +101,7 @@ void FFMPEGReader::init()
|
||||
|
||||
for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++)
|
||||
{
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
#else
|
||||
if((m_formatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
#endif
|
||||
&& (m_stream < 0))
|
||||
{
|
||||
m_stream=i;
|
||||
@@ -151,34 +112,12 @@ void FFMPEGReader::init()
|
||||
if(m_stream == -1)
|
||||
AUD_THROW(FileException, "File couldn't be read, no audio stream found by ffmpeg.");
|
||||
|
||||
// get a decoder and open it
|
||||
#ifndef FFMPEG_OLD_CODE
|
||||
AVCodec* aCodec = avcodec_find_decoder(m_formatCtx->streams[m_stream]->codecpar->codec_id);
|
||||
|
||||
if(!aCodec)
|
||||
AUD_THROW(FileException, "File couldn't be read, no decoder found with ffmpeg.");
|
||||
#endif
|
||||
|
||||
m_frame = av_frame_alloc();
|
||||
|
||||
if(!m_frame)
|
||||
AUD_THROW(FileException, "File couldn't be read, ffmpeg frame couldn't be allocated.");
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
m_codecCtx = m_formatCtx->streams[m_stream]->codec;
|
||||
|
||||
// get a decoder and open it
|
||||
AVCodec* aCodec = avcodec_find_decoder(m_codecCtx->codec_id);
|
||||
#else
|
||||
m_codecCtx = avcodec_alloc_context3(aCodec);
|
||||
#endif
|
||||
|
||||
if(!m_codecCtx)
|
||||
AUD_THROW(FileException, "File couldn't be read, ffmpeg context couldn't be allocated.");
|
||||
|
||||
#ifndef FFMPEG_OLD_CODE
|
||||
if(avcodec_parameters_to_context(m_codecCtx, m_formatCtx->streams[m_stream]->codecpar) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be read, ffmpeg decoder parameters couldn't be copied to decoder context.");
|
||||
#endif
|
||||
if(!aCodec)
|
||||
AUD_THROW(FileException, "File couldn't be read, no decoder found with ffmpeg.");
|
||||
|
||||
if(avcodec_open2(m_codecCtx, aCodec, nullptr) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be read, ffmpeg codec couldn't be opened.");
|
||||
@@ -218,8 +157,6 @@ void FFMPEGReader::init()
|
||||
FFMPEGReader::FFMPEGReader(std::string filename) :
|
||||
m_pkgbuf(),
|
||||
m_formatCtx(nullptr),
|
||||
m_codecCtx(nullptr),
|
||||
m_frame(nullptr),
|
||||
m_aviocontext(nullptr),
|
||||
m_membuf(nullptr)
|
||||
{
|
||||
@@ -240,14 +177,12 @@ FFMPEGReader::FFMPEGReader(std::string filename) :
|
||||
|
||||
FFMPEGReader::FFMPEGReader(std::shared_ptr<Buffer> buffer) :
|
||||
m_pkgbuf(),
|
||||
m_codecCtx(nullptr),
|
||||
m_frame(nullptr),
|
||||
m_membuffer(buffer),
|
||||
m_membufferpos(0)
|
||||
{
|
||||
m_membuf = reinterpret_cast<data_t*>(av_malloc(AV_INPUT_BUFFER_MIN_SIZE + AV_INPUT_BUFFER_PADDING_SIZE));
|
||||
m_membuf = reinterpret_cast<data_t*>(av_malloc(FF_MIN_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE));
|
||||
|
||||
m_aviocontext = avio_alloc_context(m_membuf, AV_INPUT_BUFFER_MIN_SIZE, 0, this, read_packet, nullptr, seek_packet);
|
||||
m_aviocontext = avio_alloc_context(m_membuf, FF_MIN_BUFFER_SIZE, 0, this, read_packet, nullptr, seek_packet);
|
||||
|
||||
if(!m_aviocontext)
|
||||
{
|
||||
@@ -277,14 +212,7 @@ FFMPEGReader::FFMPEGReader(std::shared_ptr<Buffer> buffer) :
|
||||
|
||||
FFMPEGReader::~FFMPEGReader()
|
||||
{
|
||||
if(m_frame)
|
||||
av_frame_free(&m_frame);
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
avcodec_close(m_codecCtx);
|
||||
#else
|
||||
if(m_codecCtx)
|
||||
avcodec_free_context(&m_codecCtx);
|
||||
#endif
|
||||
avformat_close_input(&m_formatCtx);
|
||||
}
|
||||
|
||||
@@ -384,7 +312,7 @@ void FFMPEGReader::seek(int position)
|
||||
}
|
||||
}
|
||||
}
|
||||
av_packet_unref(&packet);
|
||||
av_free_packet(&packet);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -415,7 +343,7 @@ Specs FFMPEGReader::getSpecs() const
|
||||
void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
|
||||
{
|
||||
// read packages and decode them
|
||||
AVPacket packet = {};
|
||||
AVPacket packet;
|
||||
int data_size = 0;
|
||||
int pkgbuf_pos;
|
||||
int left = length;
|
||||
@@ -431,7 +359,7 @@ void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
|
||||
data_size = std::min(pkgbuf_pos, left * sample_size);
|
||||
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
|
||||
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
|
||||
left -= data_size / sample_size;
|
||||
left -= data_size/sample_size;
|
||||
}
|
||||
|
||||
// for each frame read as long as there isn't enough data already
|
||||
@@ -447,9 +375,9 @@ void FFMPEGReader::read(int& length, bool& eos, sample_t* buffer)
|
||||
data_size = std::min(pkgbuf_pos, left * sample_size);
|
||||
m_convert((data_t*) buf, (data_t*) m_pkgbuf.getBuffer(), data_size / AUD_FORMAT_SIZE(m_specs.format));
|
||||
buf += data_size / AUD_FORMAT_SIZE(m_specs.format);
|
||||
left -= data_size / sample_size;
|
||||
left -= data_size/sample_size;
|
||||
}
|
||||
av_packet_unref(&packet);
|
||||
av_free_packet(&packet);
|
||||
}
|
||||
// read more data than necessary?
|
||||
if(pkgbuf_pos > data_size)
|
||||
|
@@ -79,11 +79,6 @@ private:
|
||||
*/
|
||||
AVCodecContext* m_codecCtx;
|
||||
|
||||
/**
|
||||
* The AVFrame structure for using ffmpeg.
|
||||
*/
|
||||
AVFrame* m_frame;
|
||||
|
||||
/**
|
||||
* The AVIOContext to read the data from.
|
||||
*/
|
||||
|
216
extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
vendored
216
extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
vendored
@@ -27,10 +27,6 @@ extern "C" {
|
||||
|
||||
AUD_NAMESPACE_BEGIN
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
#define FFMPEG_OLD_CODE
|
||||
#endif
|
||||
|
||||
void FFMPEGWriter::encode()
|
||||
{
|
||||
sample_t* data = m_input_buffer.getBuffer();
|
||||
@@ -62,106 +58,82 @@ void FFMPEGWriter::encode()
|
||||
if(m_input_size)
|
||||
m_convert(reinterpret_cast<data_t*>(data), reinterpret_cast<data_t*>(data), m_input_samples * m_specs.channels);
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
m_packet->data = nullptr;
|
||||
m_packet->size = 0;
|
||||
AVPacket packet;
|
||||
|
||||
av_init_packet(m_packet);
|
||||
packet.data = nullptr;
|
||||
packet.size = 0;
|
||||
|
||||
av_frame_unref(m_frame);
|
||||
av_init_packet(&packet);
|
||||
|
||||
AVFrame* frame = av_frame_alloc();
|
||||
av_frame_unref(frame);
|
||||
int got_packet;
|
||||
#endif
|
||||
|
||||
m_frame->nb_samples = m_input_samples;
|
||||
m_frame->format = m_codecCtx->sample_fmt;
|
||||
m_frame->channel_layout = m_codecCtx->channel_layout;
|
||||
frame->nb_samples = m_input_samples;
|
||||
frame->format = m_codecCtx->sample_fmt;
|
||||
frame->channel_layout = m_codecCtx->channel_layout;
|
||||
|
||||
if(avcodec_fill_audio_frame(m_frame, m_specs.channels, m_codecCtx->sample_fmt, reinterpret_cast<data_t*>(data), m_input_buffer.getSize(), 0) < 0)
|
||||
if(avcodec_fill_audio_frame(frame, m_specs.channels, m_codecCtx->sample_fmt, reinterpret_cast<data_t*>(data), m_input_buffer.getSize(), 0) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, filling the audio frame failed with ffmpeg.");
|
||||
|
||||
AVRational sample_time = { 1, static_cast<int>(m_specs.rate) };
|
||||
m_frame->pts = av_rescale_q(m_position - m_input_samples, m_codecCtx->time_base, sample_time);
|
||||
frame->pts = av_rescale_q(m_position - m_input_samples, m_codecCtx->time_base, sample_time);
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
if(avcodec_encode_audio2(m_codecCtx, m_packet, m_frame, &got_packet))
|
||||
if(avcodec_encode_audio2(m_codecCtx, &packet, frame, &got_packet))
|
||||
{
|
||||
av_frame_free(&frame);
|
||||
AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
|
||||
}
|
||||
|
||||
if(got_packet)
|
||||
{
|
||||
m_packet->flags |= AV_PKT_FLAG_KEY;
|
||||
m_packet->stream_index = m_stream->index;
|
||||
if(av_write_frame(m_formatCtx, m_packet) < 0)
|
||||
packet.flags |= AV_PKT_FLAG_KEY;
|
||||
packet.stream_index = m_stream->index;
|
||||
if(av_write_frame(m_formatCtx, &packet) < 0)
|
||||
{
|
||||
av_free_packet(m_packet);
|
||||
av_free_packet(&packet);
|
||||
av_frame_free(&frame);
|
||||
AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
|
||||
}
|
||||
av_free_packet(m_packet);
|
||||
av_free_packet(&packet);
|
||||
}
|
||||
#else
|
||||
if(avcodec_send_frame(m_codecCtx, m_frame) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
|
||||
|
||||
while(avcodec_receive_packet(m_codecCtx, m_packet) == 0)
|
||||
{
|
||||
m_packet->stream_index = m_stream->index;
|
||||
|
||||
if(av_write_frame(m_formatCtx, m_packet) < 0)
|
||||
AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
|
||||
}
|
||||
#endif
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
|
||||
void FFMPEGWriter::close()
|
||||
{
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
int got_packet = true;
|
||||
|
||||
while(got_packet)
|
||||
{
|
||||
m_packet->data = nullptr;
|
||||
m_packet->size = 0;
|
||||
AVPacket packet;
|
||||
|
||||
av_init_packet(m_packet);
|
||||
packet.data = nullptr;
|
||||
packet.size = 0;
|
||||
|
||||
if(avcodec_encode_audio2(m_codecCtx, m_packet, nullptr, &got_packet))
|
||||
av_init_packet(&packet);
|
||||
|
||||
if(avcodec_encode_audio2(m_codecCtx, &packet, nullptr, &got_packet))
|
||||
AUD_THROW(FileException, "File end couldn't be written, audio encoding failed with ffmpeg.");
|
||||
|
||||
if(got_packet)
|
||||
{
|
||||
m_packet->flags |= AV_PKT_FLAG_KEY;
|
||||
m_packet->stream_index = m_stream->index;
|
||||
if(av_write_frame(m_formatCtx, m_packet))
|
||||
packet.flags |= AV_PKT_FLAG_KEY;
|
||||
packet.stream_index = m_stream->index;
|
||||
if(av_write_frame(m_formatCtx, &packet))
|
||||
{
|
||||
av_free_packet(m_packet);
|
||||
av_free_packet(&packet);
|
||||
AUD_THROW(FileException, "Final frames couldn't be writen to the file with ffmpeg.");
|
||||
}
|
||||
av_free_packet(m_packet);
|
||||
av_free_packet(&packet);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if(avcodec_send_frame(m_codecCtx, nullptr) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, audio encoding failed with ffmpeg.");
|
||||
|
||||
while(avcodec_receive_packet(m_codecCtx, m_packet) == 0)
|
||||
{
|
||||
m_packet->stream_index = m_stream->index;
|
||||
|
||||
if(av_write_frame(m_formatCtx, m_packet) < 0)
|
||||
AUD_THROW(FileException, "Frame couldn't be writen to the file with ffmpeg.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) :
|
||||
m_position(0),
|
||||
m_specs(specs),
|
||||
m_formatCtx(nullptr),
|
||||
m_codecCtx(nullptr),
|
||||
m_stream(nullptr),
|
||||
m_packet(nullptr),
|
||||
m_frame(nullptr),
|
||||
m_input_samples(0),
|
||||
m_deinterleave(false)
|
||||
{
|
||||
@@ -170,105 +142,75 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
|
||||
if(avformat_alloc_output_context2(&m_formatCtx, nullptr, formats[format], filename.c_str()) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, format couldn't be found with ffmpeg.");
|
||||
|
||||
AVOutputFormat* outputFmt = m_formatCtx->oformat;
|
||||
m_outputFmt = m_formatCtx->oformat;
|
||||
|
||||
if(!outputFmt) {
|
||||
if(!m_outputFmt) {
|
||||
avformat_free_context(m_formatCtx);
|
||||
AUD_THROW(FileException, "File couldn't be written, output format couldn't be found with ffmpeg.");
|
||||
}
|
||||
|
||||
outputFmt->audio_codec = AV_CODEC_ID_NONE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
|
||||
|
||||
switch(codec)
|
||||
{
|
||||
case CODEC_AAC:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_AAC;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_AAC;
|
||||
break;
|
||||
case CODEC_AC3:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_AC3;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_AC3;
|
||||
break;
|
||||
case CODEC_FLAC:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_FLAC;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_FLAC;
|
||||
break;
|
||||
case CODEC_MP2:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_MP2;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_MP2;
|
||||
break;
|
||||
case CODEC_MP3:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_MP3;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_MP3;
|
||||
break;
|
||||
case CODEC_OPUS:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_OPUS;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_OPUS;
|
||||
break;
|
||||
case CODEC_PCM:
|
||||
switch(specs.format)
|
||||
{
|
||||
case FORMAT_U8:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
|
||||
break;
|
||||
case FORMAT_S16:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
|
||||
break;
|
||||
case FORMAT_S24:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
|
||||
break;
|
||||
case FORMAT_S32:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
|
||||
break;
|
||||
case FORMAT_FLOAT32:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
|
||||
break;
|
||||
case FORMAT_FLOAT64:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
|
||||
break;
|
||||
default:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_NONE;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CODEC_VORBIS:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
|
||||
break;
|
||||
default:
|
||||
outputFmt->audio_codec = AV_CODEC_ID_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t channel_layout = 0;
|
||||
|
||||
switch(m_specs.channels)
|
||||
{
|
||||
case CHANNELS_MONO:
|
||||
channel_layout = AV_CH_LAYOUT_MONO;
|
||||
break;
|
||||
case CHANNELS_STEREO:
|
||||
channel_layout = AV_CH_LAYOUT_STEREO;
|
||||
break;
|
||||
case CHANNELS_STEREO_LFE:
|
||||
channel_layout = AV_CH_LAYOUT_2POINT1;
|
||||
break;
|
||||
case CHANNELS_SURROUND4:
|
||||
channel_layout = AV_CH_LAYOUT_QUAD;
|
||||
break;
|
||||
case CHANNELS_SURROUND5:
|
||||
channel_layout = AV_CH_LAYOUT_5POINT0_BACK;
|
||||
break;
|
||||
case CHANNELS_SURROUND51:
|
||||
channel_layout = AV_CH_LAYOUT_5POINT1_BACK;
|
||||
break;
|
||||
case CHANNELS_SURROUND61:
|
||||
channel_layout = AV_CH_LAYOUT_6POINT1_BACK;
|
||||
break;
|
||||
case CHANNELS_SURROUND71:
|
||||
channel_layout = AV_CH_LAYOUT_7POINT1;
|
||||
m_outputFmt->audio_codec = AV_CODEC_ID_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(outputFmt->audio_codec == AV_CODEC_ID_NONE)
|
||||
if(m_outputFmt->audio_codec == AV_CODEC_ID_NONE)
|
||||
AUD_THROW(FileException, "File couldn't be written, audio codec not found with ffmpeg.");
|
||||
|
||||
AVCodec* codec = avcodec_find_encoder(outputFmt->audio_codec);
|
||||
AVCodec* codec = avcodec_find_encoder(m_outputFmt->audio_codec);
|
||||
if(!codec)
|
||||
AUD_THROW(FileException, "File couldn't be written, audio encoder couldn't be found with ffmpeg.");
|
||||
|
||||
@@ -278,14 +220,7 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
|
||||
|
||||
m_stream->id = m_formatCtx->nb_streams - 1;
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
m_codecCtx = m_stream->codec;
|
||||
#else
|
||||
m_codecCtx = avcodec_alloc_context3(codec);
|
||||
#endif
|
||||
|
||||
if(!m_codecCtx)
|
||||
AUD_THROW(FileException, "File couldn't be written, context creation failed with ffmpeg.");
|
||||
|
||||
switch(m_specs.format)
|
||||
{
|
||||
@@ -312,7 +247,7 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
|
||||
}
|
||||
|
||||
if(m_formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
m_codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
m_codecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
bool format_supported = false;
|
||||
|
||||
@@ -393,13 +328,9 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
|
||||
|
||||
m_specs.rate = m_codecCtx->sample_rate;
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
m_codecCtx->codec_id = outputFmt->audio_codec;
|
||||
#endif
|
||||
|
||||
m_codecCtx->codec_id = m_outputFmt->audio_codec;
|
||||
m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
m_codecCtx->bit_rate = bitrate;
|
||||
m_codecCtx->channel_layout = channel_layout;
|
||||
m_codecCtx->channels = m_specs.channels;
|
||||
m_stream->time_base.num = m_codecCtx->time_base.num = 1;
|
||||
m_stream->time_base.den = m_codecCtx->time_base.den = m_codecCtx->sample_rate;
|
||||
@@ -407,11 +338,6 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
|
||||
if(avcodec_open2(m_codecCtx, codec, nullptr) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, encoder couldn't be opened with ffmpeg.");
|
||||
|
||||
#ifndef FFMPEG_OLD_CODE
|
||||
if(avcodec_parameters_from_context(m_stream->codecpar, m_codecCtx) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, codec parameters couldn't be copied to the context.");
|
||||
#endif
|
||||
|
||||
int samplesize = std::max(int(AUD_SAMPLE_SIZE(m_specs)), AUD_DEVICE_SAMPLE_SIZE(m_specs));
|
||||
|
||||
if((m_input_size = m_codecCtx->frame_size))
|
||||
@@ -420,26 +346,13 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
|
||||
if(avio_open(&m_formatCtx->pb, filename.c_str(), AVIO_FLAG_WRITE))
|
||||
AUD_THROW(FileException, "File couldn't be written, file opening failed with ffmpeg.");
|
||||
|
||||
if(avformat_write_header(m_formatCtx, nullptr) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, writing the header failed.");
|
||||
avformat_write_header(m_formatCtx, nullptr);
|
||||
}
|
||||
catch(Exception&)
|
||||
{
|
||||
#ifndef FFMPEG_OLD_CODE
|
||||
if(m_codecCtx)
|
||||
avcodec_free_context(&m_codecCtx);
|
||||
#endif
|
||||
avformat_free_context(m_formatCtx);
|
||||
throw;
|
||||
}
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
m_packet = new AVPacket({});
|
||||
#else
|
||||
m_packet = av_packet_alloc();
|
||||
#endif
|
||||
|
||||
m_frame = av_frame_alloc();
|
||||
}
|
||||
|
||||
FFMPEGWriter::~FFMPEGWriter()
|
||||
@@ -452,26 +365,9 @@ FFMPEGWriter::~FFMPEGWriter()
|
||||
|
||||
av_write_trailer(m_formatCtx);
|
||||
|
||||
if(m_frame)
|
||||
av_frame_free(&m_frame);
|
||||
|
||||
if(m_packet)
|
||||
{
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
delete m_packet;
|
||||
#else
|
||||
av_packet_free(&m_packet);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FFMPEG_OLD_CODE
|
||||
avcodec_close(m_codecCtx);
|
||||
#else
|
||||
if(m_codecCtx)
|
||||
avcodec_free_context(&m_codecCtx);
|
||||
#endif
|
||||
|
||||
avio_closep(&m_formatCtx->pb);
|
||||
avio_close(m_formatCtx->pb);
|
||||
avformat_free_context(m_formatCtx);
|
||||
}
|
||||
|
||||
|
15
extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
vendored
15
extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h
vendored
@@ -65,21 +65,16 @@ private:
|
||||
*/
|
||||
AVCodecContext* m_codecCtx;
|
||||
|
||||
/**
|
||||
* The AVOutputFormat structure for using ffmpeg.
|
||||
*/
|
||||
AVOutputFormat* m_outputFmt;
|
||||
|
||||
/**
|
||||
* The AVStream structure for using ffmpeg.
|
||||
*/
|
||||
AVStream* m_stream;
|
||||
|
||||
/**
|
||||
* The AVPacket structure for using ffmpeg.
|
||||
*/
|
||||
AVPacket* m_packet;
|
||||
|
||||
/**
|
||||
* The AVFrame structure for using ffmpeg.
|
||||
*/
|
||||
AVFrame* m_frame;
|
||||
|
||||
/**
|
||||
* The input buffer for the format converted data before encoding.
|
||||
*/
|
||||
|
1
extern/rangetree/CMakeLists.txt
vendored
1
extern/rangetree/CMakeLists.txt
vendored
@@ -28,3 +28,4 @@ set(SRC
|
||||
)
|
||||
|
||||
blender_add_lib(extern_rangetree "${SRC}" "${INC}" "")
|
||||
|
||||
|
8
extern/xdnd/xdnd.c
vendored
8
extern/xdnd/xdnd.c
vendored
@@ -121,10 +121,10 @@ char *xdnd_debug_milliseconds (void)
|
||||
#define dnd_debug3(a,b,c) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c)
|
||||
#define dnd_debug4(a,b,c,d) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c, d)
|
||||
#else
|
||||
#define dnd_debug1(a) do {} while (0)
|
||||
#define dnd_debug2(a,b) do {} while (0)
|
||||
#define dnd_debug3(a,b,c) do {} while (0)
|
||||
#define dnd_debug4(a,b,c,d) do {} while (0)
|
||||
#define dnd_debug1(a)
|
||||
#define dnd_debug2(a,b)
|
||||
#define dnd_debug3(a,b,c)
|
||||
#define dnd_debug4(a,b,c,d)
|
||||
#endif
|
||||
|
||||
#define dnd_warning(a) fprintf (stderr, a)
|
||||
|
@@ -326,14 +326,6 @@ if(WITH_CYCLES_NETWORK)
|
||||
add_definitions(-DWITH_NETWORK)
|
||||
endif()
|
||||
|
||||
if(WITH_OPENCOLORIO)
|
||||
add_definitions(-DWITH_OCIO)
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${OPENCOLORIO_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES_STANDALONE OR WITH_CYCLES_NETWORK OR WITH_CYCLES_CUBIN_COMPILER)
|
||||
add_subdirectory(app)
|
||||
endif()
|
||||
@@ -355,3 +347,4 @@ endif()
|
||||
if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
|
||||
delayed_do_install(${CMAKE_BINARY_DIR}/bin)
|
||||
endif()
|
||||
|
||||
|
@@ -80,10 +80,6 @@ macro(cycles_target_link_libraries target)
|
||||
if(WITH_CYCLES_OPENSUBDIV)
|
||||
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
|
||||
endif()
|
||||
if(WITH_OPENCOLORIO)
|
||||
link_directories(${OPENCOLORIO_LIBPATH})
|
||||
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${target}
|
||||
${OPENIMAGEIO_LIBRARIES}
|
||||
|
@@ -112,3 +112,4 @@ int main(int argc, const char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -524,3 +524,4 @@ int main(int argc, const char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -697,3 +697,4 @@ void xml_read_file(Scene *scene, const char *filepath)
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -147,3 +147,5 @@ def unregister():
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
|
||||
|
@@ -63,3 +63,4 @@ endif()
|
||||
add_dependencies(bf_intern_cycles bf_rna)
|
||||
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${ADDON_FILES}" ${CYCLES_INSTALL_PATH})
|
||||
|
||||
|
@@ -128,12 +128,6 @@ enum_volume_interpolation = (
|
||||
('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower")
|
||||
)
|
||||
|
||||
enum_world_mis = (
|
||||
('NONE', "None", "Don't sample the background, faster but might cause noise for non-solid backgrounds"),
|
||||
('AUTOMATIC', "Auto", "Automatically try to determine the best setting"),
|
||||
('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise")
|
||||
)
|
||||
|
||||
enum_device_type = (
|
||||
('CPU', "CPU", "CPU", 0),
|
||||
('CUDA', "CUDA", "CUDA", 1),
|
||||
@@ -887,17 +881,17 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
|
||||
del bpy.types.Material.cycles
|
||||
|
||||
|
||||
class CyclesLightSettings(bpy.types.PropertyGroup):
|
||||
class CyclesLampSettings(bpy.types.PropertyGroup):
|
||||
@classmethod
|
||||
def register(cls):
|
||||
bpy.types.Light.cycles = PointerProperty(
|
||||
name="Cycles Light Settings",
|
||||
description="Cycles light settings",
|
||||
bpy.types.Lamp.cycles = PointerProperty(
|
||||
name="Cycles Lamp Settings",
|
||||
description="Cycles lamp settings",
|
||||
type=cls,
|
||||
)
|
||||
cls.cast_shadow = BoolProperty(
|
||||
name="Cast Shadow",
|
||||
description="Light casts shadows",
|
||||
description="Lamp casts shadows",
|
||||
default=True,
|
||||
)
|
||||
cls.samples = IntProperty(
|
||||
@@ -914,20 +908,20 @@ class CyclesLightSettings(bpy.types.PropertyGroup):
|
||||
)
|
||||
cls.use_multiple_importance_sampling = BoolProperty(
|
||||
name="Multiple Importance Sample",
|
||||
description="Use multiple importance sampling for the light, "
|
||||
"reduces noise for area lights and sharp glossy materials",
|
||||
description="Use multiple importance sampling for the lamp, "
|
||||
"reduces noise for area lamps and sharp glossy materials",
|
||||
default=True,
|
||||
)
|
||||
cls.is_portal = BoolProperty(
|
||||
name="Is Portal",
|
||||
description="Use this area light to guide sampling of the background, "
|
||||
"note that this will make the light invisible",
|
||||
description="Use this area lamp to guide sampling of the background, "
|
||||
"note that this will make the lamp invisible",
|
||||
default=False,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.Light.cycles
|
||||
del bpy.types.Lamp.cycles
|
||||
|
||||
|
||||
class CyclesWorldSettings(bpy.types.PropertyGroup):
|
||||
@@ -938,15 +932,15 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
|
||||
description="Cycles world settings",
|
||||
type=cls,
|
||||
)
|
||||
cls.sampling_method = EnumProperty(
|
||||
name="Sampling method",
|
||||
description="How to sample the background light",
|
||||
items=enum_world_mis,
|
||||
default='AUTOMATIC',
|
||||
cls.sample_as_light = BoolProperty(
|
||||
name="Multiple Importance Sample",
|
||||
description="Use multiple importance sampling for the environment, "
|
||||
"enabling for non-solid colors is recommended",
|
||||
default=True,
|
||||
)
|
||||
cls.sample_map_resolution = IntProperty(
|
||||
name="Map Resolution",
|
||||
description="Importance map size is resolution x resolution/2; "
|
||||
description="Importance map size is resolution x resolution; "
|
||||
"higher values potentially produce less noise, at the cost of memory and speed",
|
||||
min=4, max=8192,
|
||||
default=1024,
|
||||
@@ -1460,7 +1454,7 @@ def register():
|
||||
bpy.utils.register_class(CyclesRenderSettings)
|
||||
bpy.utils.register_class(CyclesCameraSettings)
|
||||
bpy.utils.register_class(CyclesMaterialSettings)
|
||||
bpy.utils.register_class(CyclesLightSettings)
|
||||
bpy.utils.register_class(CyclesLampSettings)
|
||||
bpy.utils.register_class(CyclesWorldSettings)
|
||||
bpy.utils.register_class(CyclesVisibilitySettings)
|
||||
bpy.utils.register_class(CyclesMeshSettings)
|
||||
@@ -1475,7 +1469,7 @@ def unregister():
|
||||
bpy.utils.unregister_class(CyclesRenderSettings)
|
||||
bpy.utils.unregister_class(CyclesCameraSettings)
|
||||
bpy.utils.unregister_class(CyclesMaterialSettings)
|
||||
bpy.utils.unregister_class(CyclesLightSettings)
|
||||
bpy.utils.unregister_class(CyclesLampSettings)
|
||||
bpy.utils.unregister_class(CyclesWorldSettings)
|
||||
bpy.utils.unregister_class(CyclesMeshSettings)
|
||||
bpy.utils.unregister_class(CyclesObjectSettings)
|
||||
|
@@ -17,8 +17,7 @@
|
||||
# <pep8 compliant>
|
||||
|
||||
import bpy
|
||||
from bpy_extras.node_utils import find_node_input
|
||||
from bl_operators.presets import PresetMenu
|
||||
from bpy_extras.node_utils import find_node_input, find_output_node
|
||||
|
||||
from bpy.types import (
|
||||
Panel,
|
||||
@@ -27,20 +26,20 @@ from bpy.types import (
|
||||
)
|
||||
|
||||
|
||||
class CYCLES_MT_sampling_presets(PresetMenu):
|
||||
class CYCLES_MT_sampling_presets(Menu):
|
||||
bl_label = "Sampling Presets"
|
||||
preset_subdir = "cycles/sampling"
|
||||
preset_operator = "script.execute_preset"
|
||||
preset_add_operator = "render.cycles_sampling_preset_add"
|
||||
COMPAT_ENGINES = {'CYCLES'}
|
||||
draw = Menu.draw_preset
|
||||
|
||||
|
||||
class CYCLES_MT_integrator_presets(PresetMenu):
|
||||
class CYCLES_MT_integrator_presets(Menu):
|
||||
bl_label = "Integrator Presets"
|
||||
preset_subdir = "cycles/integrator"
|
||||
preset_operator = "script.execute_preset"
|
||||
preset_add_operator = "render.cycles_integrator_preset_add"
|
||||
COMPAT_ENGINES = {'CYCLES'}
|
||||
draw = Menu.draw_preset
|
||||
|
||||
|
||||
class CyclesButtonsPanel:
|
||||
@@ -145,9 +144,6 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Sampling"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw_header_preset(self, context):
|
||||
CYCLES_MT_sampling_presets.draw_panel_header(self.layout)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = False
|
||||
@@ -155,6 +151,11 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
|
||||
scene = context.scene
|
||||
cscene = scene.cycles
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.menu("CYCLES_MT_sampling_presets", text=bpy.types.CYCLES_MT_sampling_presets.bl_label)
|
||||
row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMIN")
|
||||
row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMOUT").remove_active = True
|
||||
|
||||
layout.use_property_split = True
|
||||
|
||||
layout.prop(cscene, "progressive")
|
||||
@@ -193,7 +194,7 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(cscene, "seed")
|
||||
row.prop(cscene, "use_animated_seed", text="", icon='TIME')
|
||||
row.prop(cscene, "use_animated_seed", text="", icon="TIME")
|
||||
|
||||
layout.prop(cscene, "sampling_pattern", text="Pattern")
|
||||
|
||||
@@ -314,11 +315,17 @@ class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Light Paths"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw_header_preset(self, context):
|
||||
CYCLES_MT_integrator_presets.draw_panel_header(self.layout)
|
||||
|
||||
def draw(self, context):
|
||||
pass
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
scene = context.scene
|
||||
cscene = scene.cycles
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
|
||||
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
|
||||
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
|
||||
|
||||
|
||||
class CYCLES_RENDER_PT_light_paths_max_bounces(CyclesButtonsPanel, Panel):
|
||||
@@ -820,7 +827,6 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
cam = context.camera
|
||||
ccam = cam.cycles
|
||||
@@ -829,62 +835,16 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop(cam, "dof_object", text="Focus Object")
|
||||
col.label("Focus:")
|
||||
col.prop(cam, "dof_object", text="")
|
||||
|
||||
sub = col.row()
|
||||
sub.active = cam.dof_object is None
|
||||
sub.prop(cam, "dof_distance", text="Distance")
|
||||
|
||||
|
||||
class CYCLES_CAMERA_PT_dof_aperture(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Aperture"
|
||||
bl_parent_id = "CYCLES_CAMERA_PT_dof"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.camera and CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
cam = context.camera
|
||||
ccam = cam.cycles
|
||||
dof_options = cam.gpu_dof
|
||||
|
||||
col = flow.column()
|
||||
col.prop(ccam, "aperture_type")
|
||||
if ccam.aperture_type == 'RADIUS':
|
||||
col.prop(ccam, "aperture_size", text="Size")
|
||||
elif ccam.aperture_type == 'FSTOP':
|
||||
col.prop(ccam, "aperture_fstop", text="Number")
|
||||
col.separator()
|
||||
|
||||
col = flow.column()
|
||||
col.prop(ccam, "aperture_blades", text="Blades")
|
||||
col.prop(ccam, "aperture_rotation", text="Rotation")
|
||||
col.prop(ccam, "aperture_ratio", text="Ratio")
|
||||
|
||||
|
||||
class CYCLES_CAMERA_PT_dof_viewport(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Viewport"
|
||||
bl_parent_id = "CYCLES_CAMERA_PT_dof"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.camera and CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
cam = context.camera
|
||||
dof_options = cam.gpu_dof
|
||||
|
||||
hq_support = dof_options.is_hq_supported
|
||||
sub = flow.column(align=True)
|
||||
sub = col.column(align=True)
|
||||
sub.label("Viewport:")
|
||||
subhq = sub.column()
|
||||
subhq.active = hq_support
|
||||
subhq.prop(dof_options, "use_high_quality")
|
||||
@@ -892,6 +852,21 @@ class CYCLES_CAMERA_PT_dof_viewport(CyclesButtonsPanel, Panel):
|
||||
if dof_options.use_high_quality and hq_support:
|
||||
sub.prop(dof_options, "blades")
|
||||
|
||||
col = split.column()
|
||||
|
||||
col.label("Aperture:")
|
||||
sub = col.column(align=True)
|
||||
sub.prop(ccam, "aperture_type", text="")
|
||||
if ccam.aperture_type == 'RADIUS':
|
||||
sub.prop(ccam, "aperture_size", text="Size")
|
||||
elif ccam.aperture_type == 'FSTOP':
|
||||
sub.prop(ccam, "aperture_fstop", text="Number")
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.prop(ccam, "aperture_blades", text="Blades")
|
||||
sub.prop(ccam, "aperture_rotation", text="Rotation")
|
||||
sub.prop(ccam, "aperture_ratio", text="Ratio")
|
||||
|
||||
|
||||
class CYCLES_PT_context_material(CyclesButtonsPanel, Panel):
|
||||
bl_label = ""
|
||||
@@ -1008,7 +983,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
|
||||
def poll(cls, context):
|
||||
ob = context.object
|
||||
return (CyclesButtonsPanel.poll(context) and
|
||||
ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT'}) or
|
||||
ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'}) or
|
||||
(ob.dupli_type == 'COLLECTION' and ob.dupli_group)))
|
||||
|
||||
def draw(self, context):
|
||||
@@ -1029,7 +1004,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
|
||||
flow.prop(visibility, "transmission")
|
||||
flow.prop(visibility, "scatter")
|
||||
|
||||
if ob.type != 'LIGHT':
|
||||
if ob.type != 'LAMP':
|
||||
flow.prop(visibility, "shadow")
|
||||
|
||||
row = layout.row()
|
||||
@@ -1049,7 +1024,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
|
||||
|
||||
|
||||
class CYCLES_OT_use_shading_nodes(Operator):
|
||||
"""Enable nodes on a material, world or light"""
|
||||
"""Enable nodes on a material, world or lamp"""
|
||||
bl_idname = "cycles.use_shading_nodes"
|
||||
bl_label = "Use Nodes"
|
||||
|
||||
@@ -1063,20 +1038,20 @@ class CYCLES_OT_use_shading_nodes(Operator):
|
||||
context.material.use_nodes = True
|
||||
elif context.world:
|
||||
context.world.use_nodes = True
|
||||
elif context.light:
|
||||
context.light.use_nodes = True
|
||||
elif context.lamp:
|
||||
context.lamp.use_nodes = True
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
def panel_node_draw(layout, id_data, output_type, input_name):
|
||||
def panel_node_draw(layout, id_data, output_types, input_name):
|
||||
if not id_data.use_nodes:
|
||||
layout.operator("cycles.use_shading_nodes", icon='NODETREE')
|
||||
return False
|
||||
|
||||
ntree = id_data.node_tree
|
||||
|
||||
node = ntree.get_output_node('CYCLES')
|
||||
node = find_output_node(ntree, output_types)
|
||||
if node:
|
||||
input = find_node_input(node, input_name)
|
||||
if input:
|
||||
@@ -1089,7 +1064,7 @@ def panel_node_draw(layout, id_data, output_type, input_name):
|
||||
return True
|
||||
|
||||
|
||||
class CYCLES_LIGHT_PT_preview(CyclesButtonsPanel, Panel):
|
||||
class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Preview"
|
||||
bl_context = "data"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
@@ -1097,107 +1072,113 @@ class CYCLES_LIGHT_PT_preview(CyclesButtonsPanel, Panel):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (
|
||||
context.light and
|
||||
context.lamp and
|
||||
not (
|
||||
context.light.type == 'AREA' and
|
||||
context.light.cycles.is_portal
|
||||
context.lamp.type == 'AREA' and
|
||||
context.lamp.cycles.is_portal
|
||||
) and
|
||||
CyclesButtonsPanel.poll(context)
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
self.layout.template_preview(context.light)
|
||||
self.layout.template_preview(context.lamp)
|
||||
|
||||
|
||||
class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Light"
|
||||
class CYCLES_LAMP_PT_lamp(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Lamp"
|
||||
bl_context = "data"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.light and CyclesButtonsPanel.poll(context)
|
||||
return context.lamp and CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
light = context.light
|
||||
clamp = light.cycles
|
||||
lamp = context.lamp
|
||||
clamp = lamp.cycles
|
||||
# cscene = context.scene.cycles
|
||||
|
||||
layout.prop(light, "type", expand=True)
|
||||
layout.prop(lamp, "type", expand=True)
|
||||
|
||||
layout.use_property_split = True
|
||||
split = layout.split()
|
||||
col = split.column(align=True)
|
||||
|
||||
col = layout.column()
|
||||
|
||||
if light.type in {'POINT', 'SUN', 'SPOT'}:
|
||||
col.prop(light, "shadow_soft_size", text="Size")
|
||||
elif light.type == 'AREA':
|
||||
col.prop(light, "shape", text="Shape")
|
||||
if lamp.type in {'POINT', 'SUN', 'SPOT'}:
|
||||
col.prop(lamp, "shadow_soft_size", text="Size")
|
||||
elif lamp.type == 'AREA':
|
||||
col.prop(lamp, "shape", text="")
|
||||
sub = col.column(align=True)
|
||||
|
||||
if light.shape in {'SQUARE', 'DISK'}:
|
||||
sub.prop(light, "size")
|
||||
elif light.shape in {'RECTANGLE', 'ELLIPSE'}:
|
||||
sub.prop(light, "size", text="Size X")
|
||||
sub.prop(light, "size_y", text="Y")
|
||||
if lamp.shape in {'SQUARE', 'DISK'}:
|
||||
sub.prop(lamp, "size")
|
||||
elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
|
||||
sub.prop(lamp, "size", text="Size X")
|
||||
sub.prop(lamp, "size_y", text="Size Y")
|
||||
|
||||
if not (light.type == 'AREA' and clamp.is_portal):
|
||||
sub = col.column()
|
||||
if not (lamp.type == 'AREA' and clamp.is_portal):
|
||||
sub = col.column(align=True)
|
||||
if use_branched_path(context):
|
||||
subsub = sub.row(align=True)
|
||||
subsub.active = use_sample_all_lights(context)
|
||||
subsub.prop(clamp, "samples")
|
||||
sub.prop(clamp, "max_bounces")
|
||||
|
||||
col = split.column()
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.active = not (light.type == 'AREA' and clamp.is_portal)
|
||||
sub.active = not (lamp.type == 'AREA' and clamp.is_portal)
|
||||
sub.prop(clamp, "cast_shadow")
|
||||
sub.prop(clamp, "use_multiple_importance_sampling", text="Multiple Importance")
|
||||
|
||||
if light.type == 'AREA':
|
||||
if lamp.type == 'AREA':
|
||||
col.prop(clamp, "is_portal", text="Portal")
|
||||
|
||||
if light.type == 'HEMI':
|
||||
layout.label(text="Not supported, interpreted as sun light")
|
||||
if lamp.type == 'HEMI':
|
||||
layout.label(text="Not supported, interpreted as sun lamp")
|
||||
|
||||
|
||||
class CYCLES_LIGHT_PT_nodes(CyclesButtonsPanel, Panel):
|
||||
class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Nodes"
|
||||
bl_context = "data"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.light and not (context.light.type == 'AREA' and
|
||||
context.light.cycles.is_portal) and \
|
||||
return context.lamp and not (context.lamp.type == 'AREA' and
|
||||
context.lamp.cycles.is_portal) and \
|
||||
CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
light = context.light
|
||||
if not panel_node_draw(layout, light, 'OUTPUT_LIGHT', 'Surface'):
|
||||
layout.prop(light, "color")
|
||||
lamp = context.lamp
|
||||
if not panel_node_draw(layout, lamp, ('OUTPUT_LAMP',), 'Surface'):
|
||||
layout.prop(lamp, "color")
|
||||
|
||||
|
||||
class CYCLES_LIGHT_PT_spot(CyclesButtonsPanel, Panel):
|
||||
class CYCLES_LAMP_PT_spot(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Spot Shape"
|
||||
bl_context = "data"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
light = context.light
|
||||
return (light and light.type == 'SPOT') and CyclesButtonsPanel.poll(context)
|
||||
lamp = context.lamp
|
||||
return (lamp and lamp.type == 'SPOT') and CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
light = context.light
|
||||
layout.use_property_split = True
|
||||
|
||||
col = layout.column()
|
||||
col.prop(light, "spot_size", text="Size")
|
||||
col.prop(light, "spot_blend", text="Blend", slider=True)
|
||||
col.prop(light, "show_cone")
|
||||
lamp = context.lamp
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
sub = col.column()
|
||||
sub.prop(lamp, "spot_size", text="Size")
|
||||
sub.prop(lamp, "spot_blend", text="Blend", slider=True)
|
||||
|
||||
col = split.column()
|
||||
col.prop(lamp, "show_cone")
|
||||
|
||||
|
||||
class CYCLES_WORLD_PT_preview(CyclesButtonsPanel, Panel):
|
||||
@@ -1226,7 +1207,7 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel):
|
||||
|
||||
world = context.world
|
||||
|
||||
if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
|
||||
if not panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Surface'):
|
||||
layout.prop(world, "horizon_color", text="Color")
|
||||
|
||||
|
||||
@@ -1244,7 +1225,7 @@ class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel):
|
||||
layout = self.layout
|
||||
|
||||
world = context.world
|
||||
panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
|
||||
panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Volume')
|
||||
|
||||
|
||||
class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
|
||||
@@ -1361,13 +1342,11 @@ class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
|
||||
cworld = world.cycles
|
||||
|
||||
col = layout.column()
|
||||
col.prop(cworld, "sampling_method", text="Sampling")
|
||||
col.prop(cworld, "sample_as_light", text="Multiple Importance")
|
||||
|
||||
sub = col.column()
|
||||
sub.active = cworld.sampling_method != 'NONE'
|
||||
subsub = sub.row(align=True)
|
||||
subsub.active = cworld.sampling_method == 'MANUAL'
|
||||
subsub.prop(cworld, "sample_map_resolution")
|
||||
sub.active = cworld.sample_as_light
|
||||
sub.prop(cworld, "sample_map_resolution")
|
||||
if use_branched_path(context):
|
||||
subsub = sub.column(align=True)
|
||||
subsub.active = use_sample_all_lights(context)
|
||||
@@ -1425,7 +1404,7 @@ class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, Panel):
|
||||
layout = self.layout
|
||||
|
||||
mat = context.material
|
||||
if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
|
||||
if not panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Surface'):
|
||||
layout.prop(mat, "diffuse_color")
|
||||
|
||||
|
||||
@@ -1445,7 +1424,7 @@ class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, Panel):
|
||||
mat = context.material
|
||||
# cmat = mat.cycles
|
||||
|
||||
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
|
||||
panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Volume')
|
||||
|
||||
|
||||
class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel):
|
||||
@@ -1461,7 +1440,7 @@ class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel):
|
||||
layout = self.layout
|
||||
|
||||
mat = context.material
|
||||
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
|
||||
panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Displacement')
|
||||
|
||||
|
||||
class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
|
||||
@@ -1539,7 +1518,6 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
layout.use_property_decorate = False # No animation.
|
||||
|
||||
scene = context.scene
|
||||
cscene = scene.cycles
|
||||
@@ -1568,7 +1546,7 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
|
||||
if cscene.bake_type == 'NORMAL':
|
||||
col.prop(cbk, "normal_space", text="Space")
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub = col.row(align=True)
|
||||
sub.prop(cbk, "normal_r", text="Swizzle R")
|
||||
sub.prop(cbk, "normal_g", text="G")
|
||||
sub.prop(cbk, "normal_b", text="B")
|
||||
@@ -1590,7 +1568,6 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
|
||||
|
||||
elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
|
||||
row = col.row(align=True)
|
||||
row.use_property_split = False
|
||||
row.prop(cbk, "use_pass_direct", toggle=True)
|
||||
row.prop(cbk, "use_pass_indirect", toggle=True)
|
||||
row.prop(cbk, "use_pass_color", toggle=True)
|
||||
@@ -1609,12 +1586,10 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
|
||||
sub.prop(cbk, "use_cage", text="Cage")
|
||||
if cbk.use_cage:
|
||||
sub.prop(cbk, "cage_extrusion", text="Extrusion")
|
||||
sub.prop_search(cbk, "cage_object", scene, "objects", text="Cage Object")
|
||||
sub.prop_search(cbk, "cage_object", scene, "objects", text="")
|
||||
else:
|
||||
sub.prop(cbk, "cage_extrusion", text="Ray Distance")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type
|
||||
|
||||
|
||||
@@ -1781,7 +1756,7 @@ def draw_pause(self, context):
|
||||
|
||||
if view.shading.type == 'RENDERED':
|
||||
cscene = scene.cycles
|
||||
layout.prop(cscene, "preview_pause", icon='PAUSE', text="")
|
||||
layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
|
||||
|
||||
|
||||
def get_panels():
|
||||
@@ -1789,7 +1764,7 @@ def get_panels():
|
||||
'DATA_PT_area',
|
||||
'DATA_PT_camera_dof',
|
||||
'DATA_PT_falloff_curve',
|
||||
'DATA_PT_light',
|
||||
'DATA_PT_lamp',
|
||||
'DATA_PT_preview',
|
||||
'DATA_PT_spot',
|
||||
'MATERIAL_PT_context_material',
|
||||
@@ -1837,16 +1812,14 @@ classes = (
|
||||
CYCLES_RENDER_PT_denoising,
|
||||
CYCLES_PT_post_processing,
|
||||
CYCLES_CAMERA_PT_dof,
|
||||
CYCLES_CAMERA_PT_dof_aperture,
|
||||
CYCLES_CAMERA_PT_dof_viewport,
|
||||
CYCLES_PT_context_material,
|
||||
CYCLES_OBJECT_PT_motion_blur,
|
||||
CYCLES_OBJECT_PT_cycles_settings,
|
||||
CYCLES_OT_use_shading_nodes,
|
||||
CYCLES_LIGHT_PT_preview,
|
||||
CYCLES_LIGHT_PT_light,
|
||||
CYCLES_LIGHT_PT_nodes,
|
||||
CYCLES_LIGHT_PT_spot,
|
||||
CYCLES_LAMP_PT_preview,
|
||||
CYCLES_LAMP_PT_lamp,
|
||||
CYCLES_LAMP_PT_nodes,
|
||||
CYCLES_LAMP_PT_spot,
|
||||
CYCLES_WORLD_PT_preview,
|
||||
CYCLES_WORLD_PT_surface,
|
||||
CYCLES_WORLD_PT_volume,
|
||||
|
@@ -22,6 +22,45 @@ import math
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
|
||||
def check_is_new_shading_ntree(node_tree):
|
||||
for node in node_tree.nodes:
|
||||
# If material has any node with ONLY new shading system
|
||||
# compatibility then it's considered a Cycles material
|
||||
# and versioning code would need to perform on it.
|
||||
#
|
||||
# We can not check for whether NEW_SHADING in compatibility
|
||||
# because some nodes could have compatibility with both old
|
||||
# and new shading system and they can't be used for any
|
||||
# decision here.
|
||||
if node.shading_compatibility == {'NEW_SHADING'}:
|
||||
return True
|
||||
|
||||
# If node is only compatible with old shading system
|
||||
# then material can not be Cycles material and we
|
||||
# can stopiterating nodes now.
|
||||
if node.shading_compatibility == {'OLD_SHADING'}:
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
def check_is_new_shading_material(material):
|
||||
if not material.node_tree:
|
||||
return False
|
||||
return check_is_new_shading_ntree(material.node_tree)
|
||||
|
||||
|
||||
def check_is_new_shading_world(world):
|
||||
if not world.node_tree:
|
||||
return False
|
||||
return check_is_new_shading_ntree(world.node_tree)
|
||||
|
||||
|
||||
def check_is_new_shading_lamp(lamp):
|
||||
if not lamp.node_tree:
|
||||
return False
|
||||
return check_is_new_shading_ntree(lamp.node_tree)
|
||||
|
||||
|
||||
def foreach_notree_node(nodetree, callback, traversed):
|
||||
if nodetree in traversed:
|
||||
return
|
||||
@@ -35,18 +74,18 @@ def foreach_notree_node(nodetree, callback, traversed):
|
||||
def foreach_cycles_node(callback):
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if material.node_tree:
|
||||
if check_is_new_shading_material(material):
|
||||
foreach_notree_node(material.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
for world in bpy.data.worlds:
|
||||
if world.node_tree:
|
||||
if check_is_new_shading_world(world):
|
||||
foreach_notree_node(world.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
for light in bpy.data.lights:
|
||||
if light.node_tree:
|
||||
foreach_notree_node(light.node_tree,
|
||||
for lamp in bpy.data.lamps:
|
||||
if check_is_new_shading_world(lamp):
|
||||
foreach_notree_node(lamp.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
|
||||
@@ -89,7 +128,7 @@ def displacement_node_insert(material, nodetree, traversed):
|
||||
def displacement_nodes_insert():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if material.node_tree:
|
||||
if check_is_new_shading_material(material):
|
||||
displacement_node_insert(material, material.node_tree, traversed)
|
||||
|
||||
def displacement_principled_nodes(node):
|
||||
@@ -147,7 +186,7 @@ def square_roughness_node_insert(material, nodetree, traversed):
|
||||
def square_roughness_nodes_insert():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if material.node_tree:
|
||||
if check_is_new_shading_material(material):
|
||||
square_roughness_node_insert(material, material.node_tree, traversed)
|
||||
|
||||
|
||||
@@ -232,40 +271,6 @@ def custom_bake_remap(scene):
|
||||
scene.render.bake.use_pass_indirect = False
|
||||
|
||||
|
||||
def ambient_occlusion_node_relink(material, nodetree, traversed):
|
||||
if nodetree in traversed:
|
||||
return
|
||||
traversed.add(nodetree)
|
||||
|
||||
for node in nodetree.nodes:
|
||||
if node.bl_idname == 'ShaderNodeAmbientOcclusion':
|
||||
node.samples = 1
|
||||
node.only_local = False
|
||||
node.inputs['Distance'].default_value = 0.0
|
||||
elif node.bl_idname == 'ShaderNodeGroup':
|
||||
ambient_occlusion_node_relink(material, node.node_tree, traversed)
|
||||
|
||||
# Gather links to replace
|
||||
ao_links = []
|
||||
for link in nodetree.links:
|
||||
if link.from_node.bl_idname == 'ShaderNodeAmbientOcclusion':
|
||||
ao_links.append(link)
|
||||
|
||||
# Replace links
|
||||
for link in ao_links:
|
||||
from_node = link.from_node
|
||||
to_socket = link.to_socket
|
||||
|
||||
nodetree.links.remove(link)
|
||||
nodetree.links.new(from_node.outputs['Color'], to_socket)
|
||||
|
||||
def ambient_occlusion_nodes_relink():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if material.node_tree:
|
||||
ambient_occlusion_node_relink(material, material.node_tree, traversed)
|
||||
|
||||
|
||||
@persistent
|
||||
def do_versions(self):
|
||||
if bpy.context.user_preferences.version <= (2, 78, 1):
|
||||
@@ -354,12 +359,12 @@ def do_versions(self):
|
||||
if not cscene.is_property_set("tile_order"):
|
||||
cscene.tile_order = 'CENTER'
|
||||
|
||||
for light in bpy.data.lights:
|
||||
clight = light.cycles
|
||||
for lamp in bpy.data.lamps:
|
||||
clamp = lamp.cycles
|
||||
|
||||
# MIS
|
||||
if not clight.is_property_set("use_multiple_importance_sampling"):
|
||||
clight.use_multiple_importance_sampling = False
|
||||
if not clamp.is_property_set("use_multiple_importance_sampling"):
|
||||
clamp.use_multiple_importance_sampling = False
|
||||
|
||||
for mat in bpy.data.materials:
|
||||
cmat = mat.cycles
|
||||
@@ -372,6 +377,10 @@ def do_versions(self):
|
||||
for world in bpy.data.worlds:
|
||||
cworld = world.cycles
|
||||
|
||||
# World MIS
|
||||
if not cworld.is_property_set("sample_as_light"):
|
||||
cworld.sample_as_light = False
|
||||
|
||||
# World MIS Samples
|
||||
if not cworld.is_property_set("samples"):
|
||||
cworld.samples = 4
|
||||
@@ -435,16 +444,3 @@ def do_versions(self):
|
||||
part.tip_radius = cpart.get("tip_width", 0.0)
|
||||
part.radius_scale = cpart.get("radius_scale", 0.01)
|
||||
part.use_close_tip = cpart.get("use_closetip", True)
|
||||
|
||||
if bpy.data.version <= (2, 79, 4) or \
|
||||
(bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 18)):
|
||||
for world in bpy.data.worlds:
|
||||
cworld = world.cycles
|
||||
# World MIS
|
||||
if not cworld.is_property_set("sampling_method"):
|
||||
if cworld.get("sample_as_light", True):
|
||||
cworld.sampling_method = 'MANUAL'
|
||||
else:
|
||||
cworld.sampling_method = 'NONE'
|
||||
|
||||
ambient_occlusion_nodes_relink()
|
||||
|
@@ -90,7 +90,7 @@ struct BlenderCamera {
|
||||
static void blender_camera_init(BlenderCamera *bcam,
|
||||
BL::RenderSettings& b_render)
|
||||
{
|
||||
memset((void *)bcam, 0, sizeof(BlenderCamera));
|
||||
memset(bcam, 0, sizeof(BlenderCamera));
|
||||
|
||||
bcam->type = CAMERA_PERSPECTIVE;
|
||||
bcam->zoom = 1.0f;
|
||||
@@ -232,7 +232,7 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
||||
bcam->motion_steps = object_motion_steps(b_ob, b_ob);
|
||||
}
|
||||
else {
|
||||
/* from light not implemented yet */
|
||||
/* from lamp not implemented yet */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +457,6 @@ static void blender_camera_sync(Camera *cam,
|
||||
cam->matrix = blender_camera_matrix(bcam->matrix,
|
||||
bcam->type,
|
||||
bcam->panorama_type);
|
||||
cam->motion.clear();
|
||||
cam->motion.resize(bcam->motion_steps, cam->matrix);
|
||||
cam->use_perspective_motion = false;
|
||||
cam->shuttertime = bcam->shuttertime;
|
||||
@@ -895,3 +894,4 @@ BufferParams BlenderSync::get_buffer_params(BL::RenderSettings& b_render,
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -770,18 +770,17 @@ static void ExportCurveTriangleVcol(ParticleCurveData *CData,
|
||||
|
||||
for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
|
||||
for(int section = 0; section < resol; section++) {
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_linear_v3(CData->curve_vcol[curve]));
|
||||
cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
|
||||
vertexindex++;
|
||||
}
|
||||
}
|
||||
@@ -994,10 +993,9 @@ void BlenderSync::sync_curves(Mesh *mesh,
|
||||
if(fdata) {
|
||||
size_t i = 0;
|
||||
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++)
|
||||
if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f))
|
||||
fdata[i++] = color_srgb_to_linear_v3(CData.curve_vcol[curve]);
|
||||
fdata[i++] = color_srgb_to_scene_linear_v3(CData.curve_vcol[curve]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -401,8 +401,7 @@ static void attr_create_vertex_color(Scene *scene,
|
||||
int n = p->loop_total();
|
||||
for(int i = 0; i < n; i++) {
|
||||
float3 color = get_float3(l->data[p->loop_start() + i].color());
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
*(cdata++) = color_float_to_byte(color_srgb_to_linear_v3(color));
|
||||
*(cdata++) = color_float_to_byte(color_srgb_to_scene_linear_v3(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,13 +424,12 @@ static void attr_create_vertex_color(Scene *scene,
|
||||
int tri_a[3], tri_b[3];
|
||||
face_split_tri_indices(face_flags[i], tri_a, tri_b);
|
||||
|
||||
/* Encode vertex color using the sRGB curve. */
|
||||
uchar4 colors[4];
|
||||
colors[0] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color1())));
|
||||
colors[1] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color2())));
|
||||
colors[2] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color3())));
|
||||
colors[0] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color1())));
|
||||
colors[1] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color2())));
|
||||
colors[2] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color3())));
|
||||
if(nverts[i] == 4) {
|
||||
colors[3] = color_float_to_byte(color_srgb_to_linear_v3(get_float3(c->color4())));
|
||||
colors[3] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color4())));
|
||||
}
|
||||
|
||||
cdata[0] = colors[tri_a[0]];
|
||||
|
@@ -89,7 +89,7 @@ bool BlenderSync::object_is_light(BL::Object& b_ob)
|
||||
{
|
||||
BL::ID b_ob_data = b_ob.data();
|
||||
|
||||
return (b_ob_data && b_ob_data.is_a(&RNA_Light));
|
||||
return (b_ob_data && b_ob_data.is_a(&RNA_Lamp));
|
||||
}
|
||||
|
||||
static uint object_ray_visibility(BL::Object& b_ob)
|
||||
@@ -127,56 +127,56 @@ void BlenderSync::sync_light(BL::Object& b_parent,
|
||||
return;
|
||||
}
|
||||
|
||||
BL::Light b_light(b_ob.data());
|
||||
BL::Lamp b_lamp(b_ob.data());
|
||||
|
||||
/* type */
|
||||
switch(b_light.type()) {
|
||||
case BL::Light::type_POINT: {
|
||||
BL::PointLight b_point_light(b_light);
|
||||
light->size = b_point_light.shadow_soft_size();
|
||||
switch(b_lamp.type()) {
|
||||
case BL::Lamp::type_POINT: {
|
||||
BL::PointLamp b_point_lamp(b_lamp);
|
||||
light->size = b_point_lamp.shadow_soft_size();
|
||||
light->type = LIGHT_POINT;
|
||||
break;
|
||||
}
|
||||
case BL::Light::type_SPOT: {
|
||||
BL::SpotLight b_spot_light(b_light);
|
||||
light->size = b_spot_light.shadow_soft_size();
|
||||
case BL::Lamp::type_SPOT: {
|
||||
BL::SpotLamp b_spot_lamp(b_lamp);
|
||||
light->size = b_spot_lamp.shadow_soft_size();
|
||||
light->type = LIGHT_SPOT;
|
||||
light->spot_angle = b_spot_light.spot_size();
|
||||
light->spot_smooth = b_spot_light.spot_blend();
|
||||
light->spot_angle = b_spot_lamp.spot_size();
|
||||
light->spot_smooth = b_spot_lamp.spot_blend();
|
||||
break;
|
||||
}
|
||||
case BL::Light::type_HEMI: {
|
||||
case BL::Lamp::type_HEMI: {
|
||||
light->type = LIGHT_DISTANT;
|
||||
light->size = 0.0f;
|
||||
break;
|
||||
}
|
||||
case BL::Light::type_SUN: {
|
||||
BL::SunLight b_sun_light(b_light);
|
||||
light->size = b_sun_light.shadow_soft_size();
|
||||
case BL::Lamp::type_SUN: {
|
||||
BL::SunLamp b_sun_lamp(b_lamp);
|
||||
light->size = b_sun_lamp.shadow_soft_size();
|
||||
light->type = LIGHT_DISTANT;
|
||||
break;
|
||||
}
|
||||
case BL::Light::type_AREA: {
|
||||
BL::AreaLight b_area_light(b_light);
|
||||
case BL::Lamp::type_AREA: {
|
||||
BL::AreaLamp b_area_lamp(b_lamp);
|
||||
light->size = 1.0f;
|
||||
light->axisu = transform_get_column(&tfm, 0);
|
||||
light->axisv = transform_get_column(&tfm, 1);
|
||||
light->sizeu = b_area_light.size();
|
||||
switch(b_area_light.shape()) {
|
||||
case BL::AreaLight::shape_SQUARE:
|
||||
light->sizeu = b_area_lamp.size();
|
||||
switch(b_area_lamp.shape()) {
|
||||
case BL::AreaLamp::shape_SQUARE:
|
||||
light->sizev = light->sizeu;
|
||||
light->round = false;
|
||||
break;
|
||||
case BL::AreaLight::shape_RECTANGLE:
|
||||
light->sizev = b_area_light.size_y();
|
||||
case BL::AreaLamp::shape_RECTANGLE:
|
||||
light->sizev = b_area_lamp.size_y();
|
||||
light->round = false;
|
||||
break;
|
||||
case BL::AreaLight::shape_DISK:
|
||||
case BL::AreaLamp::shape_DISK:
|
||||
light->sizev = light->sizeu;
|
||||
light->round = true;
|
||||
break;
|
||||
case BL::AreaLight::shape_ELLIPSE:
|
||||
light->sizev = b_area_light.size_y();
|
||||
case BL::AreaLamp::shape_ELLIPSE:
|
||||
light->sizev = b_area_lamp.size_y();
|
||||
light->round = true;
|
||||
break;
|
||||
}
|
||||
@@ -192,22 +192,22 @@ void BlenderSync::sync_light(BL::Object& b_parent,
|
||||
|
||||
/* shader */
|
||||
vector<Shader*> used_shaders;
|
||||
find_shader(b_light, used_shaders, scene->default_light);
|
||||
find_shader(b_lamp, used_shaders, scene->default_light);
|
||||
light->shader = used_shaders[0];
|
||||
|
||||
/* shadow */
|
||||
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
||||
PointerRNA clight = RNA_pointer_get(&b_light.ptr, "cycles");
|
||||
light->cast_shadow = get_boolean(clight, "cast_shadow");
|
||||
light->use_mis = get_boolean(clight, "use_multiple_importance_sampling");
|
||||
PointerRNA clamp = RNA_pointer_get(&b_lamp.ptr, "cycles");
|
||||
light->cast_shadow = get_boolean(clamp, "cast_shadow");
|
||||
light->use_mis = get_boolean(clamp, "use_multiple_importance_sampling");
|
||||
|
||||
int samples = get_int(clight, "samples");
|
||||
int samples = get_int(clamp, "samples");
|
||||
if(get_boolean(cscene, "use_square_samples"))
|
||||
light->samples = samples * samples;
|
||||
else
|
||||
light->samples = samples;
|
||||
|
||||
light->max_bounces = get_int(clight, "max_bounces");
|
||||
light->max_bounces = get_int(clamp, "max_bounces");
|
||||
|
||||
if(b_ob != b_ob_instance) {
|
||||
light->random_id = random_id;
|
||||
@@ -217,7 +217,7 @@ void BlenderSync::sync_light(BL::Object& b_parent,
|
||||
}
|
||||
|
||||
if(light->type == LIGHT_AREA)
|
||||
light->is_portal = get_boolean(clight, "is_portal");
|
||||
light->is_portal = get_boolean(clamp, "is_portal");
|
||||
else
|
||||
light->is_portal = false;
|
||||
|
||||
@@ -242,15 +242,7 @@ void BlenderSync::sync_background_light(bool use_portal)
|
||||
if(b_world) {
|
||||
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
||||
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
|
||||
|
||||
enum SamplingMethod {
|
||||
SAMPLING_NONE = 0,
|
||||
SAMPLING_AUTOMATIC,
|
||||
SAMPLING_MANUAL,
|
||||
SAMPLING_NUM
|
||||
};
|
||||
int sampling_method = get_enum(cworld, "sampling_method", SAMPLING_NUM, SAMPLING_AUTOMATIC);
|
||||
bool sample_as_light = (sampling_method != SAMPLING_NONE);
|
||||
bool sample_as_light = get_boolean(cworld, "sample_as_light");
|
||||
|
||||
if(sample_as_light || use_portal) {
|
||||
/* test if we need to sync */
|
||||
@@ -262,12 +254,7 @@ void BlenderSync::sync_background_light(bool use_portal)
|
||||
b_world.ptr.data != world_map)
|
||||
{
|
||||
light->type = LIGHT_BACKGROUND;
|
||||
if(sampling_method == SAMPLING_MANUAL) {
|
||||
light->map_resolution = get_int(cworld, "sample_map_resolution");
|
||||
}
|
||||
else {
|
||||
light->map_resolution = 0;
|
||||
}
|
||||
light->shader = scene->default_background;
|
||||
light->use_mis = sample_as_light;
|
||||
light->max_bounces = get_int(cworld, "max_bounces");
|
||||
@@ -315,7 +302,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
|
||||
|
||||
/* light is handled separately */
|
||||
if(object_is_light(b_ob)) {
|
||||
/* don't use lights for excluded layers used as mask layer */
|
||||
/* don't use lamps for excluded layers used as mask layer */
|
||||
if(!motion && !((layer_flag & view_layer.holdout_layer) &&
|
||||
(layer_flag & view_layer.exclude_layer)))
|
||||
{
|
||||
@@ -448,7 +435,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
|
||||
mesh->motion_steps = motion_steps;
|
||||
}
|
||||
|
||||
object->motion.clear();
|
||||
object->motion.resize(motion_steps, transform_empty());
|
||||
|
||||
if(motion_steps) {
|
||||
@@ -592,6 +578,9 @@ void BlenderSync::sync_objects(BL::Depsgraph& b_depsgraph, float motion_time)
|
||||
{
|
||||
BL::DepsgraphObjectInstance b_instance = *b_instance_iter;
|
||||
BL::Object b_ob = b_instance.object();
|
||||
if(!b_ob.is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
progress.set_sync_status("Synchronizing object", b_ob.name());
|
||||
|
||||
@@ -729,3 +718,4 @@ void BlenderSync::sync_motion(BL::RenderSettings& b_render,
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -146,3 +146,4 @@ bool BlenderObjectCulling::test_distance(Scene *scene, float3 bb[8])
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -54,7 +54,6 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
||||
BL::BlendData& b_data,
|
||||
bool preview_osl)
|
||||
: session(NULL),
|
||||
sync(NULL),
|
||||
b_engine(b_engine),
|
||||
b_userpref(b_userpref),
|
||||
b_data(b_data),
|
||||
@@ -82,7 +81,6 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
|
||||
BL::RegionView3D& b_rv3d,
|
||||
int width, int height)
|
||||
: session(NULL),
|
||||
sync(NULL),
|
||||
b_engine(b_engine),
|
||||
b_userpref(b_userpref),
|
||||
b_data(b_data),
|
||||
@@ -211,8 +209,11 @@ void BlenderSession::reset_session(BL::BlendData& b_data, BL::Depsgraph& b_depsg
|
||||
/* if scene or session parameters changed, it's easier to simply re-create
|
||||
* them rather than trying to distinguish which settings need to be updated
|
||||
*/
|
||||
free_session();
|
||||
|
||||
delete session;
|
||||
|
||||
create_session();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -453,7 +454,6 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
|
||||
b_camera_override,
|
||||
width, height,
|
||||
&python_thread_state);
|
||||
builtin_images_load();
|
||||
|
||||
/* Make sure all views have different noise patterns. - hardcoded value just to make it random */
|
||||
if(view_index != 0) {
|
||||
@@ -614,7 +614,6 @@ void BlenderSession::bake(BL::Depsgraph& b_depsgraph_,
|
||||
b_camera_override,
|
||||
width, height,
|
||||
&python_thread_state);
|
||||
builtin_images_load();
|
||||
}
|
||||
|
||||
BakeData *bake_data = NULL;
|
||||
@@ -804,8 +803,6 @@ void BlenderSession::synchronize(BL::Depsgraph& b_depsgraph_)
|
||||
else
|
||||
sync->sync_camera(b_render, b_camera_override, width, height, "");
|
||||
|
||||
builtin_images_load();
|
||||
|
||||
/* unlock */
|
||||
session->scene->mutex.unlock();
|
||||
|
||||
@@ -1330,16 +1327,6 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
void BlenderSession::builtin_images_load()
|
||||
{
|
||||
/* Force builtin images to be loaded along with Blender data sync. This
|
||||
* is needed because we may be reading from depsgraph evaluated data which
|
||||
* can be freed by Blender before Cycles reads it. */
|
||||
ImageManager *manager = session->scene->image_manager;
|
||||
Device *device = session->device;
|
||||
manager->device_load_builtin(device, session->scene, session->progress);
|
||||
}
|
||||
|
||||
void BlenderSession::update_resumable_tile_manager(int num_samples)
|
||||
{
|
||||
const int num_resumable_chunks = BlenderSession::num_resumable_chunks,
|
||||
|
@@ -166,7 +166,6 @@ protected:
|
||||
float *pixels,
|
||||
const size_t pixels_size,
|
||||
const bool free_cache);
|
||||
void builtin_images_load();
|
||||
|
||||
/* Update tile manager to reflect resumable render settings. */
|
||||
void update_resumable_tile_manager(int num_samples);
|
||||
|
@@ -551,12 +551,7 @@ static ShaderNode *add_node(Scene *scene,
|
||||
node = new EmissionNode();
|
||||
}
|
||||
else if(b_node.is_a(&RNA_ShaderNodeAmbientOcclusion)) {
|
||||
BL::ShaderNodeAmbientOcclusion b_ao_node(b_node);
|
||||
AmbientOcclusionNode *ao = new AmbientOcclusionNode();
|
||||
ao->samples = b_ao_node.samples();
|
||||
ao->inside = b_ao_node.inside();
|
||||
ao->only_local = b_ao_node.only_local();
|
||||
node = ao;
|
||||
node = new AmbientOcclusionNode();
|
||||
}
|
||||
else if(b_node.is_a(&RNA_ShaderNodeVolumeScatter)) {
|
||||
node = new ScatterVolumeNode();
|
||||
@@ -867,11 +862,9 @@ static ShaderNode *add_node(Scene *scene,
|
||||
point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
|
||||
point_density->interpolation = get_image_interpolation(b_point_density_node);
|
||||
point_density->builtin_data = b_point_density_node.ptr.data;
|
||||
point_density->image_manager = scene->image_manager;
|
||||
|
||||
/* TODO(sergey): Use more proper update flag. */
|
||||
if(true) {
|
||||
point_density->add_image();
|
||||
b_point_density_node.cache_point_density(b_depsgraph);
|
||||
scene->image_manager->tag_reload_image(
|
||||
point_density->filename.string(),
|
||||
@@ -1001,6 +994,31 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node,
|
||||
return node->output(name.c_str());
|
||||
}
|
||||
|
||||
static BL::ShaderNode find_output_node(BL::ShaderNodeTree& b_ntree)
|
||||
{
|
||||
BL::ShaderNodeTree::nodes_iterator b_node;
|
||||
BL::ShaderNode output_node(PointerRNA_NULL);
|
||||
|
||||
for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
|
||||
BL::ShaderNodeOutputMaterial b_output_node(*b_node);
|
||||
|
||||
if (b_output_node.is_a(&RNA_ShaderNodeOutputMaterial) ||
|
||||
b_output_node.is_a(&RNA_ShaderNodeOutputWorld) ||
|
||||
b_output_node.is_a(&RNA_ShaderNodeOutputLamp)) {
|
||||
/* regular Cycles output node */
|
||||
if(b_output_node.is_active_output()) {
|
||||
output_node = b_output_node;
|
||||
break;
|
||||
}
|
||||
else if(!output_node.ptr.data) {
|
||||
output_node = b_output_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output_node;
|
||||
}
|
||||
|
||||
static void add_nodes(Scene *scene,
|
||||
BL::RenderEngine& b_engine,
|
||||
BL::BlendData& b_data,
|
||||
@@ -1020,7 +1038,7 @@ static void add_nodes(Scene *scene,
|
||||
BL::Node::outputs_iterator b_output;
|
||||
|
||||
/* find the node to use for output if there are multiple */
|
||||
BL::ShaderNode output_node = b_ntree.get_output_node(BL::ShaderNodeOutputMaterial::target_CYCLES);
|
||||
BL::ShaderNode output_node = find_output_node(b_ntree);
|
||||
|
||||
/* add nodes */
|
||||
for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
|
||||
@@ -1393,45 +1411,45 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all)
|
||||
background->tag_update(scene);
|
||||
}
|
||||
|
||||
/* Sync Lights */
|
||||
/* Sync Lamps */
|
||||
|
||||
void BlenderSync::sync_lights(BL::Depsgraph& b_depsgraph, bool update_all)
|
||||
void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all)
|
||||
{
|
||||
shader_map.set_default(scene->default_light);
|
||||
|
||||
BL::Depsgraph::ids_iterator b_id;
|
||||
for(b_depsgraph.ids.begin(b_id); b_id != b_depsgraph.ids.end(); ++b_id) {
|
||||
if (!b_id->is_a(&RNA_Light)) {
|
||||
if (!b_id->is_a(&RNA_Lamp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BL::Light b_light(*b_id);
|
||||
BL::Lamp b_lamp(*b_id);
|
||||
Shader *shader;
|
||||
|
||||
/* test if we need to sync */
|
||||
if(shader_map.sync(&shader, b_light) || update_all) {
|
||||
if(shader_map.sync(&shader, b_lamp) || update_all) {
|
||||
ShaderGraph *graph = new ShaderGraph();
|
||||
|
||||
/* create nodes */
|
||||
if(b_light.use_nodes() && b_light.node_tree()) {
|
||||
shader->name = b_light.name().c_str();
|
||||
if(b_lamp.use_nodes() && b_lamp.node_tree()) {
|
||||
shader->name = b_lamp.name().c_str();
|
||||
|
||||
BL::ShaderNodeTree b_ntree(b_light.node_tree());
|
||||
BL::ShaderNodeTree b_ntree(b_lamp.node_tree());
|
||||
|
||||
add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree);
|
||||
}
|
||||
else {
|
||||
float strength = 1.0f;
|
||||
|
||||
if(b_light.type() == BL::Light::type_POINT ||
|
||||
b_light.type() == BL::Light::type_SPOT ||
|
||||
b_light.type() == BL::Light::type_AREA)
|
||||
if(b_lamp.type() == BL::Lamp::type_POINT ||
|
||||
b_lamp.type() == BL::Lamp::type_SPOT ||
|
||||
b_lamp.type() == BL::Lamp::type_AREA)
|
||||
{
|
||||
strength = 100.0f;
|
||||
}
|
||||
|
||||
EmissionNode *emission = new EmissionNode();
|
||||
emission->color = get_float3(b_light.color());
|
||||
emission->color = get_float3(b_lamp.color());
|
||||
emission->strength = strength;
|
||||
graph->add(emission);
|
||||
|
||||
@@ -1459,7 +1477,7 @@ void BlenderSync::sync_shaders(BL::Depsgraph& b_depsgraph)
|
||||
shader_map.pre_sync();
|
||||
|
||||
sync_world(b_depsgraph, auto_refresh_update);
|
||||
sync_lights(b_depsgraph, auto_refresh_update);
|
||||
sync_lamps(b_depsgraph, auto_refresh_update);
|
||||
sync_materials(b_depsgraph, auto_refresh_update);
|
||||
|
||||
/* false = don't delete unused shaders, not supported */
|
||||
@@ -1467,3 +1485,4 @@ void BlenderSync::sync_shaders(BL::Depsgraph& b_depsgraph)
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -113,17 +113,17 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph)
|
||||
BL::Material b_mat(b_id);
|
||||
shader_map.set_recalc(b_mat);
|
||||
}
|
||||
/* Light */
|
||||
else if (b_id.is_a(&RNA_Light)) {
|
||||
BL::Light b_light(b_id);
|
||||
shader_map.set_recalc(b_light);
|
||||
/* Lamp */
|
||||
else if (b_id.is_a(&RNA_Lamp)) {
|
||||
BL::Lamp b_lamp(b_id);
|
||||
shader_map.set_recalc(b_lamp);
|
||||
}
|
||||
/* Object */
|
||||
else if (b_id.is_a(&RNA_Object)) {
|
||||
BL::Object b_ob(b_id);
|
||||
const bool updated_geometry = !b_update->is_dirty_geometry();
|
||||
const bool updated_geometry = b_update->updated_geometry();
|
||||
|
||||
if (!b_update->is_dirty_transform()) {
|
||||
if (b_update->updated_transform()) {
|
||||
object_map.set_recalc(b_ob);
|
||||
light_map.set_recalc(b_ob);
|
||||
}
|
||||
@@ -833,3 +833,4 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -100,7 +100,7 @@ public:
|
||||
|
||||
private:
|
||||
/* sync */
|
||||
void sync_lights(BL::Depsgraph& b_depsgraph, bool update_all);
|
||||
void sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all);
|
||||
void sync_materials(BL::Depsgraph& b_depsgraph, bool update_all);
|
||||
void sync_objects(BL::Depsgraph& b_depsgraph, float motion_time = 0.0f);
|
||||
void sync_motion(BL::RenderSettings& b_render,
|
||||
@@ -218,3 +218,4 @@ private:
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __BLENDER_SYNC_H__ */
|
||||
|
||||
|
@@ -251,7 +251,7 @@ static inline Transform get_transform(const BL::Array<float, 16>& array)
|
||||
|
||||
/* We assume both types to be just 16 floats, and transpose because blender
|
||||
* use column major matrix order while we use row major. */
|
||||
memcpy((void *)&projection, &array, sizeof(float)*16);
|
||||
memcpy(&projection, &array, sizeof(float)*16);
|
||||
projection = projection_transpose(projection);
|
||||
|
||||
/* Drop last row, matrix is assumed to be affine transform. */
|
||||
@@ -293,7 +293,7 @@ static inline int4 get_int4(const BL::Array<int, 4>& array)
|
||||
return make_int4(array[0], array[1], array[2], array[3]);
|
||||
}
|
||||
|
||||
static inline uint get_layer(const BL::Array<bool, 20>& array)
|
||||
static inline uint get_layer(const BL::Array<int, 20>& array)
|
||||
{
|
||||
uint layer = 0;
|
||||
|
||||
@@ -304,8 +304,8 @@ static inline uint get_layer(const BL::Array<bool, 20>& array)
|
||||
return layer;
|
||||
}
|
||||
|
||||
static inline uint get_layer(const BL::Array<bool, 20>& array,
|
||||
const BL::Array<bool, 8>& local_array,
|
||||
static inline uint get_layer(const BL::Array<int, 20>& array,
|
||||
const BL::Array<int, 8>& local_array,
|
||||
bool is_light = false,
|
||||
uint view_layers = (1 << 20) - 1)
|
||||
{
|
||||
|
@@ -251,3 +251,4 @@ void BVHObjectBinning::split(BVHReference* prims,
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -224,3 +224,4 @@ void LeafNode::print(int depth) const
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -182,10 +182,7 @@ public:
|
||||
|
||||
BVHReference& operator=(const BVHReference &arg) {
|
||||
if(&arg != this) {
|
||||
/* TODO(sergey): Check if it is still faster to memcpy() with
|
||||
* modern compilers.
|
||||
*/
|
||||
memcpy((void *)this, &arg, sizeof(BVHReference));
|
||||
memcpy(this, &arg, sizeof(BVHReference));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@@ -201,3 +201,4 @@ void bvh_reference_sort(int start,
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -97,12 +97,6 @@ if(CYCLES_STANDALONE_REPOSITORY)
|
||||
find_package(LLVM REQUIRED)
|
||||
endif()
|
||||
|
||||
####
|
||||
# OpenColorIO
|
||||
if(WITH_OPENCOLORIO)
|
||||
find_package(OpenColorIO REQUIRED)
|
||||
endif()
|
||||
|
||||
####
|
||||
# Boost
|
||||
set(__boost_packages filesystem regex system thread date_time)
|
||||
|
@@ -376,3 +376,4 @@ private:
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __DEVICE_H__ */
|
||||
|
||||
|
@@ -179,8 +179,8 @@ public:
|
||||
KernelFunctions<void(*)(KernelGlobals *, uchar4 *, float *, float, int, int, int, int)> convert_to_byte_kernel;
|
||||
KernelFunctions<void(*)(KernelGlobals *, uint4 *, float4 *, int, int, int, int, int)> shader_kernel;
|
||||
|
||||
KernelFunctions<void(*)(int, TileInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel;
|
||||
KernelFunctions<void(*)(int, TileInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel;
|
||||
KernelFunctions<void(*)(int, TilesInfo*, int, int, float*, float*, float*, float*, float*, int*, int, int)> filter_divide_shadow_kernel;
|
||||
KernelFunctions<void(*)(int, TilesInfo*, int, int, int, int, float*, float*, int*, int, int)> filter_get_feature_kernel;
|
||||
KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_detect_outliers_kernel;
|
||||
KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int)> filter_combine_halves_kernel;
|
||||
|
||||
@@ -459,6 +459,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool denoising_set_tiles(device_ptr *buffers, DenoisingTask *task)
|
||||
{
|
||||
TilesInfo *tiles = (TilesInfo*) task->tiles_mem.host_pointer;
|
||||
for(int i = 0; i < 9; i++) {
|
||||
tiles->buffers[i] = buffers[i];
|
||||
}
|
||||
|
||||
task->tiles_mem.copy_to_device();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool denoising_non_local_means(device_ptr image_ptr, device_ptr guide_ptr, device_ptr variance_ptr, device_ptr out_ptr,
|
||||
DenoisingTask *task)
|
||||
{
|
||||
@@ -614,7 +626,7 @@ public:
|
||||
for(int y = task->rect.y; y < task->rect.w; y++) {
|
||||
for(int x = task->rect.x; x < task->rect.z; x++) {
|
||||
filter_divide_shadow_kernel()(task->render_buffer.samples,
|
||||
task->tile_info,
|
||||
task->tiles,
|
||||
x, y,
|
||||
(float*) a_ptr,
|
||||
(float*) b_ptr,
|
||||
@@ -623,7 +635,7 @@ public:
|
||||
(float*) buffer_variance_ptr,
|
||||
&task->rect.x,
|
||||
task->render_buffer.pass_stride,
|
||||
task->render_buffer.offset);
|
||||
task->render_buffer.denoising_data_offset);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -638,7 +650,7 @@ public:
|
||||
for(int y = task->rect.y; y < task->rect.w; y++) {
|
||||
for(int x = task->rect.x; x < task->rect.z; x++) {
|
||||
filter_get_feature_kernel()(task->render_buffer.samples,
|
||||
task->tile_info,
|
||||
task->tiles,
|
||||
mean_offset,
|
||||
variance_offset,
|
||||
x, y,
|
||||
@@ -646,7 +658,7 @@ public:
|
||||
(float*) variance_ptr,
|
||||
&task->rect.x,
|
||||
task->render_buffer.pass_stride,
|
||||
task->render_buffer.offset);
|
||||
task->render_buffer.denoising_data_offset);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -699,7 +711,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void denoise(DenoisingTask& denoising, RenderTile &tile)
|
||||
void denoise(DeviceTask &task, DenoisingTask& denoising, RenderTile &tile)
|
||||
{
|
||||
tile.sample = tile.start_sample + tile.num_samples;
|
||||
|
||||
@@ -710,11 +722,23 @@ public:
|
||||
denoising.functions.combine_halves = function_bind(&CPUDevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising);
|
||||
denoising.functions.get_feature = function_bind(&CPUDevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising);
|
||||
denoising.functions.detect_outliers = function_bind(&CPUDevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising);
|
||||
denoising.functions.set_tiles = function_bind(&CPUDevice::denoising_set_tiles, this, _1, &denoising);
|
||||
|
||||
denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h);
|
||||
denoising.render_buffer.samples = tile.sample;
|
||||
|
||||
denoising.run_denoising(&tile);
|
||||
RenderTile rtiles[9];
|
||||
rtiles[4] = tile;
|
||||
task.map_neighbor_tiles(rtiles, this);
|
||||
denoising.tiles_from_rendertiles(rtiles);
|
||||
|
||||
denoising.init_from_devicetask(task);
|
||||
|
||||
denoising.run_denoising();
|
||||
|
||||
task.unmap_neighbor_tiles(rtiles, this);
|
||||
|
||||
task.update_progress(&tile, tile.w*tile.h);
|
||||
}
|
||||
|
||||
void thread_render(DeviceTask& task)
|
||||
@@ -742,7 +766,7 @@ public:
|
||||
}
|
||||
|
||||
RenderTile tile;
|
||||
DenoisingTask denoising(this, task);
|
||||
DenoisingTask denoising(this);
|
||||
|
||||
while(task.acquire_tile(this, tile)) {
|
||||
if(tile.task == RenderTile::PATH_TRACE) {
|
||||
@@ -755,9 +779,7 @@ public:
|
||||
}
|
||||
}
|
||||
else if(tile.task == RenderTile::DENOISE) {
|
||||
denoise(denoising, tile);
|
||||
|
||||
task.update_progress(&tile, tile.w*tile.h);
|
||||
denoise(task, denoising, tile);
|
||||
}
|
||||
|
||||
task.release_tile(tile);
|
||||
|
@@ -385,7 +385,7 @@ public:
|
||||
VLOG(1) << "Found nvcc " << nvcc
|
||||
<< ", CUDA version " << cuda_version
|
||||
<< ".";
|
||||
const int major = cuda_version / 10, minor = cuda_version % 10;
|
||||
const int major = cuda_version / 10, minor = cuda_version & 10;
|
||||
if(cuda_version == 0) {
|
||||
cuda_error_message("CUDA nvcc compiler version could not be parsed.");
|
||||
return false;
|
||||
@@ -1072,7 +1072,6 @@ public:
|
||||
CUarray_format_enum format;
|
||||
switch(mem.data_type) {
|
||||
case TYPE_UCHAR: format = CU_AD_FORMAT_UNSIGNED_INT8; break;
|
||||
case TYPE_UINT16: format = CU_AD_FORMAT_UNSIGNED_INT16; break;
|
||||
case TYPE_UINT: format = CU_AD_FORMAT_UNSIGNED_INT32; break;
|
||||
case TYPE_INT: format = CU_AD_FORMAT_SIGNED_INT32; break;
|
||||
case TYPE_FLOAT: format = CU_AD_FORMAT_FLOAT; break;
|
||||
@@ -1252,6 +1251,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool denoising_set_tiles(device_ptr *buffers, DenoisingTask *task)
|
||||
{
|
||||
TilesInfo *tiles = (TilesInfo*) task->tiles_mem.host_pointer;
|
||||
for(int i = 0; i < 9; i++) {
|
||||
tiles->buffers[i] = buffers[i];
|
||||
}
|
||||
|
||||
task->tiles_mem.copy_to_device();
|
||||
|
||||
return !have_error();
|
||||
}
|
||||
|
||||
#define CUDA_GET_BLOCKSIZE(func, w, h) \
|
||||
int threads_per_block; \
|
||||
cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, func)); \
|
||||
@@ -1523,7 +1534,7 @@ public:
|
||||
task->rect.w-task->rect.y);
|
||||
|
||||
void *args[] = {&task->render_buffer.samples,
|
||||
&task->tile_info_mem.device_pointer,
|
||||
&task->tiles_mem.device_pointer,
|
||||
&a_ptr,
|
||||
&b_ptr,
|
||||
&sample_variance_ptr,
|
||||
@@ -1531,7 +1542,7 @@ public:
|
||||
&buffer_variance_ptr,
|
||||
&task->rect,
|
||||
&task->render_buffer.pass_stride,
|
||||
&task->render_buffer.offset};
|
||||
&task->render_buffer.denoising_data_offset};
|
||||
CUDA_LAUNCH_KERNEL(cuFilterDivideShadow, args);
|
||||
cuda_assert(cuCtxSynchronize());
|
||||
|
||||
@@ -1557,14 +1568,14 @@ public:
|
||||
task->rect.w-task->rect.y);
|
||||
|
||||
void *args[] = {&task->render_buffer.samples,
|
||||
&task->tile_info_mem.device_pointer,
|
||||
&task->tiles_mem.device_pointer,
|
||||
&mean_offset,
|
||||
&variance_offset,
|
||||
&mean_ptr,
|
||||
&variance_ptr,
|
||||
&task->rect,
|
||||
&task->render_buffer.pass_stride,
|
||||
&task->render_buffer.offset};
|
||||
&task->render_buffer.denoising_data_offset};
|
||||
CUDA_LAUNCH_KERNEL(cuFilterGetFeature, args);
|
||||
cuda_assert(cuCtxSynchronize());
|
||||
|
||||
@@ -1602,7 +1613,7 @@ public:
|
||||
return !have_error();
|
||||
}
|
||||
|
||||
void denoise(RenderTile &rtile, DenoisingTask& denoising)
|
||||
void denoise(RenderTile &rtile, DenoisingTask& denoising, const DeviceTask &task)
|
||||
{
|
||||
denoising.functions.construct_transform = function_bind(&CUDADevice::denoising_construct_transform, this, &denoising);
|
||||
denoising.functions.reconstruct = function_bind(&CUDADevice::denoising_reconstruct, this, _1, _2, _3, &denoising);
|
||||
@@ -1611,11 +1622,21 @@ public:
|
||||
denoising.functions.combine_halves = function_bind(&CUDADevice::denoising_combine_halves, this, _1, _2, _3, _4, _5, _6, &denoising);
|
||||
denoising.functions.get_feature = function_bind(&CUDADevice::denoising_get_feature, this, _1, _2, _3, _4, &denoising);
|
||||
denoising.functions.detect_outliers = function_bind(&CUDADevice::denoising_detect_outliers, this, _1, _2, _3, _4, &denoising);
|
||||
denoising.functions.set_tiles = function_bind(&CUDADevice::denoising_set_tiles, this, _1, &denoising);
|
||||
|
||||
denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h);
|
||||
denoising.render_buffer.samples = rtile.sample;
|
||||
|
||||
denoising.run_denoising(&rtile);
|
||||
RenderTile rtiles[9];
|
||||
rtiles[4] = rtile;
|
||||
task.map_neighbor_tiles(rtiles, this);
|
||||
denoising.tiles_from_rendertiles(rtiles);
|
||||
|
||||
denoising.init_from_devicetask(task);
|
||||
|
||||
denoising.run_denoising();
|
||||
|
||||
task.unmap_neighbor_tiles(rtiles, this);
|
||||
}
|
||||
|
||||
void path_trace(DeviceTask& task, RenderTile& rtile, device_vector<WorkTile>& work_tiles)
|
||||
@@ -2071,7 +2092,7 @@ public:
|
||||
|
||||
/* keep rendering tiles until done */
|
||||
RenderTile tile;
|
||||
DenoisingTask denoising(this, *task);
|
||||
DenoisingTask denoising(this);
|
||||
|
||||
while(task->acquire_tile(this, tile)) {
|
||||
if(tile.task == RenderTile::PATH_TRACE) {
|
||||
@@ -2086,7 +2107,7 @@ public:
|
||||
else if(tile.task == RenderTile::DENOISE) {
|
||||
tile.sample = tile.start_sample + tile.num_samples;
|
||||
|
||||
denoise(tile, denoising);
|
||||
denoise(tile, denoising, *task);
|
||||
|
||||
task->update_progress(&tile, tile.w*tile.h);
|
||||
}
|
||||
@@ -2404,7 +2425,7 @@ bool device_cuda_init(void)
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
VLOG(1) << "Neither precompiled kernels nor CUDA compiler was found,"
|
||||
VLOG(1) << "Neither precompiled kernels nor CUDA compiler wad found,"
|
||||
<< " unable to use CUDA";
|
||||
}
|
||||
#endif
|
||||
|
@@ -20,29 +20,12 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
DenoisingTask::DenoisingTask(Device *device, const DeviceTask &task)
|
||||
: tile_info_mem(device, "denoising tile info mem", MEM_READ_WRITE),
|
||||
DenoisingTask::DenoisingTask(Device *device)
|
||||
: tiles_mem(device, "denoising tiles_mem", MEM_READ_WRITE),
|
||||
storage(device),
|
||||
buffer(device),
|
||||
device(device)
|
||||
{
|
||||
radius = task.denoising_radius;
|
||||
nlm_k_2 = powf(2.0f, lerp(-5.0f, 3.0f, task.denoising_strength));
|
||||
if(task.denoising_relative_pca) {
|
||||
pca_threshold = -powf(10.0f, lerp(-8.0f, 0.0f, task.denoising_feature_strength));
|
||||
}
|
||||
else {
|
||||
pca_threshold = powf(10.0f, lerp(-5.0f, 3.0f, task.denoising_feature_strength));
|
||||
}
|
||||
|
||||
render_buffer.pass_stride = task.pass_stride;
|
||||
render_buffer.offset = task.pass_denoising_data;
|
||||
|
||||
target_buffer.pass_stride = task.pass_stride;
|
||||
target_buffer.denoising_clean_offset = task.pass_denoising_clean;
|
||||
|
||||
functions.map_neighbor_tiles = function_bind(task.map_neighbor_tiles, _1, device);
|
||||
functions.unmap_neighbor_tiles = function_bind(task.unmap_neighbor_tiles, _1, device);
|
||||
}
|
||||
|
||||
DenoisingTask::~DenoisingTask()
|
||||
@@ -55,56 +38,70 @@ DenoisingTask::~DenoisingTask()
|
||||
storage.temporary_2.free();
|
||||
storage.temporary_color.free();
|
||||
buffer.mem.free();
|
||||
tile_info_mem.free();
|
||||
tiles_mem.free();
|
||||
}
|
||||
|
||||
void DenoisingTask::set_render_buffer(RenderTile *rtiles)
|
||||
void DenoisingTask::init_from_devicetask(const DeviceTask &task)
|
||||
{
|
||||
tile_info = (TileInfo*) tile_info_mem.alloc(sizeof(TileInfo)/sizeof(int));
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
tile_info->offsets[i] = rtiles[i].offset;
|
||||
tile_info->strides[i] = rtiles[i].stride;
|
||||
tile_info->buffers[i] = rtiles[i].buffer;
|
||||
radius = task.denoising_radius;
|
||||
nlm_k_2 = powf(2.0f, lerp(-5.0f, 3.0f, task.denoising_strength));
|
||||
if(task.denoising_relative_pca) {
|
||||
pca_threshold = -powf(10.0f, lerp(-8.0f, 0.0f, task.denoising_feature_strength));
|
||||
}
|
||||
else {
|
||||
pca_threshold = powf(10.0f, lerp(-5.0f, 3.0f, task.denoising_feature_strength));
|
||||
}
|
||||
tile_info->x[0] = rtiles[3].x;
|
||||
tile_info->x[1] = rtiles[4].x;
|
||||
tile_info->x[2] = rtiles[5].x;
|
||||
tile_info->x[3] = rtiles[5].x + rtiles[5].w;
|
||||
tile_info->y[0] = rtiles[1].y;
|
||||
tile_info->y[1] = rtiles[4].y;
|
||||
tile_info->y[2] = rtiles[7].y;
|
||||
tile_info->y[3] = rtiles[7].y + rtiles[7].h;
|
||||
|
||||
target_buffer.offset = rtiles[9].offset;
|
||||
target_buffer.stride = rtiles[9].stride;
|
||||
target_buffer.ptr = rtiles[9].buffer;
|
||||
render_buffer.pass_stride = task.pass_stride;
|
||||
render_buffer.denoising_data_offset = task.pass_denoising_data;
|
||||
render_buffer.denoising_clean_offset = task.pass_denoising_clean;
|
||||
|
||||
tile_info_mem.copy_to_device();
|
||||
}
|
||||
|
||||
void DenoisingTask::setup_denoising_buffer()
|
||||
{
|
||||
/* Expand filter_area by radius pixels and clamp the result to the extent of the neighboring tiles */
|
||||
rect = rect_from_shape(filter_area.x, filter_area.y, filter_area.z, filter_area.w);
|
||||
rect = rect_expand(rect, radius);
|
||||
rect = rect_clip(rect, make_int4(tile_info->x[0], tile_info->y[0], tile_info->x[3], tile_info->y[3]));
|
||||
rect = rect_clip(rect, make_int4(tiles->x[0], tiles->y[0], tiles->x[3], tiles->y[3]));
|
||||
}
|
||||
|
||||
void DenoisingTask::tiles_from_rendertiles(RenderTile *rtiles)
|
||||
{
|
||||
tiles = (TilesInfo*) tiles_mem.alloc(sizeof(TilesInfo)/sizeof(int));
|
||||
|
||||
device_ptr buffers[9];
|
||||
for(int i = 0; i < 9; i++) {
|
||||
buffers[i] = rtiles[i].buffer;
|
||||
tiles->offsets[i] = rtiles[i].offset;
|
||||
tiles->strides[i] = rtiles[i].stride;
|
||||
}
|
||||
tiles->x[0] = rtiles[3].x;
|
||||
tiles->x[1] = rtiles[4].x;
|
||||
tiles->x[2] = rtiles[5].x;
|
||||
tiles->x[3] = rtiles[5].x + rtiles[5].w;
|
||||
tiles->y[0] = rtiles[1].y;
|
||||
tiles->y[1] = rtiles[4].y;
|
||||
tiles->y[2] = rtiles[7].y;
|
||||
tiles->y[3] = rtiles[7].y + rtiles[7].h;
|
||||
|
||||
render_buffer.offset = rtiles[4].offset;
|
||||
render_buffer.stride = rtiles[4].stride;
|
||||
render_buffer.ptr = rtiles[4].buffer;
|
||||
|
||||
functions.set_tiles(buffers);
|
||||
}
|
||||
|
||||
bool DenoisingTask::run_denoising()
|
||||
{
|
||||
/* Allocate denoising buffer. */
|
||||
buffer.passes = 14;
|
||||
buffer.width = rect.z - rect.x;
|
||||
buffer.stride = align_up(buffer.width, 4);
|
||||
buffer.h = rect.w - rect.y;
|
||||
int alignment_floats = divide_up(device->mem_sub_ptr_alignment(), sizeof(float));
|
||||
buffer.pass_stride = align_up(buffer.stride * buffer.h, alignment_floats);
|
||||
/* Pad the total size by four floats since the SIMD kernels might go a bit over the end. */
|
||||
int mem_size = align_up(buffer.pass_stride * buffer.passes + 4, alignment_floats);
|
||||
buffer.mem.alloc_to_device(mem_size, false);
|
||||
}
|
||||
buffer.pass_stride = align_up(buffer.stride * buffer.h, divide_up(device->mem_sub_ptr_alignment(), sizeof(float)));
|
||||
buffer.mem.alloc_to_device(buffer.pass_stride * buffer.passes, false);
|
||||
|
||||
void DenoisingTask::prefilter_shadowing()
|
||||
{
|
||||
device_ptr null_ptr = (device_ptr) 0;
|
||||
|
||||
/* Prefilter shadow feature. */
|
||||
{
|
||||
device_sub_ptr unfiltered_a (buffer.mem, 0, buffer.pass_stride);
|
||||
device_sub_ptr unfiltered_b (buffer.mem, 1*buffer.pass_stride, buffer.pass_stride);
|
||||
device_sub_ptr sample_var (buffer.mem, 2*buffer.pass_stride, buffer.pass_stride);
|
||||
@@ -148,10 +145,10 @@ void DenoisingTask::prefilter_shadowing()
|
||||
/* Combine the two double-filtered halves to a final shadow feature. */
|
||||
device_sub_ptr shadow_pass(buffer.mem, 4*buffer.pass_stride, buffer.pass_stride);
|
||||
functions.combine_halves(final_a, final_b, *shadow_pass, null_ptr, 0, rect);
|
||||
}
|
||||
}
|
||||
|
||||
void DenoisingTask::prefilter_features()
|
||||
{
|
||||
/* Prefilter general features. */
|
||||
{
|
||||
device_sub_ptr unfiltered (buffer.mem, 8*buffer.pass_stride, buffer.pass_stride);
|
||||
device_sub_ptr variance (buffer.mem, 9*buffer.pass_stride, buffer.pass_stride);
|
||||
device_sub_ptr nlm_temporary_1(buffer.mem, 10*buffer.pass_stride, buffer.pass_stride);
|
||||
@@ -173,10 +170,10 @@ void DenoisingTask::prefilter_features()
|
||||
nlm_state.set_parameters(2, 2, 1.0f, 0.25f);
|
||||
functions.non_local_means(*unfiltered, *unfiltered, *variance, *feature_pass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DenoisingTask::prefilter_color()
|
||||
{
|
||||
/* Copy color passes. */
|
||||
{
|
||||
int mean_from[] = {20, 21, 22};
|
||||
int variance_from[] = {23, 24, 25};
|
||||
int mean_to[] = { 8, 9, 10};
|
||||
@@ -184,13 +181,6 @@ void DenoisingTask::prefilter_color()
|
||||
int num_color_passes = 3;
|
||||
|
||||
storage.temporary_color.alloc_to_device(3*buffer.pass_stride, false);
|
||||
device_sub_ptr nlm_temporary_1(storage.temporary_color, 0*buffer.pass_stride, buffer.pass_stride);
|
||||
device_sub_ptr nlm_temporary_2(storage.temporary_color, 1*buffer.pass_stride, buffer.pass_stride);
|
||||
device_sub_ptr nlm_temporary_3(storage.temporary_color, 2*buffer.pass_stride, buffer.pass_stride);
|
||||
|
||||
nlm_state.temporary_1_ptr = *nlm_temporary_1;
|
||||
nlm_state.temporary_2_ptr = *nlm_temporary_2;
|
||||
nlm_state.temporary_3_ptr = *nlm_temporary_3;
|
||||
|
||||
for(int pass = 0; pass < num_color_passes; pass++) {
|
||||
device_sub_ptr color_pass(storage.temporary_color, pass*buffer.pass_stride, buffer.pass_stride);
|
||||
@@ -198,27 +188,20 @@ void DenoisingTask::prefilter_color()
|
||||
functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass);
|
||||
}
|
||||
|
||||
{
|
||||
device_sub_ptr depth_pass (buffer.mem, 0, buffer.pass_stride);
|
||||
device_sub_ptr color_var_pass(buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride);
|
||||
device_sub_ptr output_pass (buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride);
|
||||
functions.detect_outliers(storage.temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass);
|
||||
}
|
||||
}
|
||||
|
||||
storage.temporary_color.free();
|
||||
}
|
||||
|
||||
void DenoisingTask::construct_transform()
|
||||
{
|
||||
storage.w = filter_area.z;
|
||||
storage.h = filter_area.w;
|
||||
|
||||
storage.transform.alloc_to_device(storage.w*storage.h*TRANSFORM_SIZE, false);
|
||||
storage.rank.alloc_to_device(storage.w*storage.h, false);
|
||||
|
||||
functions.construct_transform();
|
||||
}
|
||||
|
||||
void DenoisingTask::reconstruct()
|
||||
{
|
||||
|
||||
device_only_memory<float> temporary_1(device, "Denoising NLM temporary 1");
|
||||
device_only_memory<float> temporary_2(device, "Denoising NLM temporary 2");
|
||||
@@ -231,36 +214,21 @@ void DenoisingTask::reconstruct()
|
||||
storage.XtWY.alloc_to_device(storage.w*storage.h*XTWY_SIZE, false);
|
||||
|
||||
reconstruction_state.filter_window = rect_from_shape(filter_area.x-rect.x, filter_area.y-rect.y, storage.w, storage.h);
|
||||
int tile_coordinate_offset = filter_area.y*target_buffer.stride + filter_area.x;
|
||||
reconstruction_state.buffer_params = make_int4(target_buffer.offset + tile_coordinate_offset,
|
||||
target_buffer.stride,
|
||||
target_buffer.pass_stride,
|
||||
target_buffer.denoising_clean_offset);
|
||||
int tile_coordinate_offset = filter_area.y*render_buffer.stride + filter_area.x;
|
||||
reconstruction_state.buffer_params = make_int4(render_buffer.offset + tile_coordinate_offset,
|
||||
render_buffer.stride,
|
||||
render_buffer.pass_stride,
|
||||
render_buffer.denoising_clean_offset);
|
||||
reconstruction_state.source_w = rect.z-rect.x;
|
||||
reconstruction_state.source_h = rect.w-rect.y;
|
||||
|
||||
{
|
||||
device_sub_ptr color_ptr (buffer.mem, 8*buffer.pass_stride, 3*buffer.pass_stride);
|
||||
device_sub_ptr color_var_ptr(buffer.mem, 11*buffer.pass_stride, 3*buffer.pass_stride);
|
||||
functions.reconstruct(*color_ptr, *color_var_ptr, target_buffer.ptr);
|
||||
}
|
||||
functions.reconstruct(*color_ptr, *color_var_ptr, render_buffer.ptr);
|
||||
}
|
||||
|
||||
void DenoisingTask::run_denoising(RenderTile *tile)
|
||||
{
|
||||
RenderTile rtiles[10];
|
||||
rtiles[4] = *tile;
|
||||
functions.map_neighbor_tiles(rtiles);
|
||||
set_render_buffer(rtiles);
|
||||
|
||||
setup_denoising_buffer();
|
||||
|
||||
prefilter_shadowing();
|
||||
prefilter_features();
|
||||
prefilter_color();
|
||||
|
||||
construct_transform();
|
||||
reconstruct();
|
||||
|
||||
functions.unmap_neighbor_tiles(rtiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
@@ -32,24 +32,20 @@ public:
|
||||
float nlm_k_2;
|
||||
float pca_threshold;
|
||||
|
||||
/* Parameters of the RenderBuffers. */
|
||||
/* Pointer and parameters of the RenderBuffers. */
|
||||
struct RenderBuffers {
|
||||
int offset;
|
||||
int denoising_data_offset;
|
||||
int denoising_clean_offset;
|
||||
int pass_stride;
|
||||
int offset;
|
||||
int stride;
|
||||
device_ptr ptr;
|
||||
int samples;
|
||||
} render_buffer;
|
||||
|
||||
/* Pointer and parameters of the target buffer. */
|
||||
struct TargetBuffer {
|
||||
int offset;
|
||||
int stride;
|
||||
int pass_stride;
|
||||
int denoising_clean_offset;
|
||||
device_ptr ptr;
|
||||
} target_buffer;
|
||||
|
||||
TileInfo *tile_info;
|
||||
device_vector<int> tile_info_mem;
|
||||
TilesInfo *tiles;
|
||||
device_vector<int> tiles_mem;
|
||||
void tiles_from_rendertiles(RenderTile *rtiles);
|
||||
|
||||
int4 rect;
|
||||
int4 filter_area;
|
||||
@@ -89,8 +85,7 @@ public:
|
||||
device_ptr depth_ptr,
|
||||
device_ptr output_ptr
|
||||
)> detect_outliers;
|
||||
function<void(RenderTile *rtiles)> map_neighbor_tiles;
|
||||
function<void(RenderTile *rtiles)> unmap_neighbor_tiles;
|
||||
function<bool(device_ptr*)> set_tiles;
|
||||
} functions;
|
||||
|
||||
/* Stores state of the current Reconstruction operation,
|
||||
@@ -143,10 +138,12 @@ public:
|
||||
{}
|
||||
} storage;
|
||||
|
||||
DenoisingTask(Device *device, const DeviceTask &task);
|
||||
DenoisingTask(Device *device);
|
||||
~DenoisingTask();
|
||||
|
||||
void run_denoising(RenderTile *tile);
|
||||
void init_from_devicetask(const DeviceTask &task);
|
||||
|
||||
bool run_denoising();
|
||||
|
||||
struct DenoiseBuffers {
|
||||
int pass_stride;
|
||||
@@ -163,14 +160,6 @@ public:
|
||||
|
||||
protected:
|
||||
Device *device;
|
||||
|
||||
void set_render_buffer(RenderTile *rtiles);
|
||||
void setup_denoising_buffer();
|
||||
void prefilter_shadowing();
|
||||
void prefilter_features();
|
||||
void prefilter_color();
|
||||
void construct_transform();
|
||||
void reconstruct();
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
@@ -41,3 +41,4 @@ string device_cuda_capabilities(void);
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __DEVICE_INTERN_H__ */
|
||||
|
||||
|
@@ -104,26 +104,6 @@ void device_memory::device_zero()
|
||||
}
|
||||
}
|
||||
|
||||
void device_memory::swap_device(Device *new_device,
|
||||
size_t new_device_size,
|
||||
device_ptr new_device_ptr)
|
||||
{
|
||||
original_device = device;
|
||||
original_device_size = device_size;
|
||||
original_device_ptr = device_pointer;
|
||||
|
||||
device = new_device;
|
||||
device_size = new_device_size;
|
||||
device_pointer = new_device_ptr;
|
||||
}
|
||||
|
||||
void device_memory::restore_device()
|
||||
{
|
||||
device = original_device;
|
||||
device_size = original_device_size;
|
||||
device_pointer = original_device_ptr;
|
||||
}
|
||||
|
||||
/* Device Sub Ptr */
|
||||
|
||||
device_sub_ptr::device_sub_ptr(device_memory& mem, int offset, int size)
|
||||
@@ -138,3 +118,4 @@ device_sub_ptr::~device_sub_ptr()
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -43,7 +43,6 @@ enum MemoryType {
|
||||
enum DataType {
|
||||
TYPE_UNKNOWN,
|
||||
TYPE_UCHAR,
|
||||
TYPE_UINT16,
|
||||
TYPE_UINT,
|
||||
TYPE_INT,
|
||||
TYPE_FLOAT,
|
||||
@@ -58,7 +57,6 @@ static inline size_t datatype_size(DataType datatype)
|
||||
case TYPE_UCHAR: return sizeof(uchar);
|
||||
case TYPE_FLOAT: return sizeof(float);
|
||||
case TYPE_UINT: return sizeof(uint);
|
||||
case TYPE_UINT16: return sizeof(uint16_t);
|
||||
case TYPE_INT: return sizeof(int);
|
||||
case TYPE_HALF: return sizeof(half);
|
||||
case TYPE_UINT64: return sizeof(uint64_t);
|
||||
@@ -158,16 +156,6 @@ template<> struct device_type_traits<half> {
|
||||
static const int num_elements = 1;
|
||||
};
|
||||
|
||||
template<> struct device_type_traits<ushort4> {
|
||||
static const DataType data_type = TYPE_UINT16;
|
||||
static const int num_elements = 4;
|
||||
};
|
||||
|
||||
template<> struct device_type_traits<uint16_t> {
|
||||
static const DataType data_type = TYPE_UINT16;
|
||||
static const int num_elements = 1;
|
||||
};
|
||||
|
||||
template<> struct device_type_traits<half4> {
|
||||
static const DataType data_type = TYPE_HALF;
|
||||
static const int num_elements = 4;
|
||||
@@ -212,9 +200,6 @@ public:
|
||||
|
||||
virtual ~device_memory();
|
||||
|
||||
void swap_device(Device *new_device, size_t new_device_size, device_ptr new_device_ptr);
|
||||
void restore_device();
|
||||
|
||||
protected:
|
||||
friend class CUDADevice;
|
||||
|
||||
@@ -237,10 +222,6 @@ protected:
|
||||
void device_copy_to();
|
||||
void device_copy_from(int y, int w, int h, int elem);
|
||||
void device_zero();
|
||||
|
||||
device_ptr original_device_ptr;
|
||||
size_t original_device_size;
|
||||
Device *original_device;
|
||||
};
|
||||
|
||||
/* Device Only Memory
|
||||
@@ -497,3 +478,4 @@ protected:
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __DEVICE_MEMORY_H__ */
|
||||
|
||||
|
@@ -285,27 +285,26 @@ public:
|
||||
mem.copy_from_device(0, mem.data_size, 1);
|
||||
}
|
||||
|
||||
mem.swap_device(sub_device, 0, 0);
|
||||
Device *original_device = mem.device;
|
||||
device_ptr original_ptr = mem.device_pointer;
|
||||
size_t original_size = mem.device_size;
|
||||
|
||||
mem.device = sub_device;
|
||||
mem.device_pointer = 0;
|
||||
mem.device_size = 0;
|
||||
|
||||
mem.copy_to_device();
|
||||
tiles[i].buffer = mem.device_pointer;
|
||||
tiles[i].device_size = mem.device_size;
|
||||
|
||||
mem.restore_device();
|
||||
mem.device = original_device;
|
||||
mem.device_pointer = original_ptr;
|
||||
mem.device_size = original_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unmap_neighbor_tiles(Device * sub_device, RenderTile * tiles)
|
||||
{
|
||||
/* Copy denoised result back to the host. */
|
||||
device_vector<float> &mem = tiles[9].buffers->buffer;
|
||||
mem.swap_device(sub_device, tiles[9].device_size, tiles[9].buffer);
|
||||
mem.copy_from_device(0, mem.data_size, 1);
|
||||
mem.restore_device();
|
||||
/* Copy denoised result to the original device. */
|
||||
mem.copy_to_device();
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
if(!tiles[i].buffers) {
|
||||
continue;
|
||||
@@ -313,9 +312,28 @@ public:
|
||||
|
||||
device_vector<float> &mem = tiles[i].buffers->buffer;
|
||||
if(mem.device != sub_device) {
|
||||
mem.swap_device(sub_device, tiles[i].device_size, tiles[i].buffer);
|
||||
Device *original_device = mem.device;
|
||||
device_ptr original_ptr = mem.device_pointer;
|
||||
size_t original_size = mem.device_size;
|
||||
|
||||
mem.device = sub_device;
|
||||
mem.device_pointer = tiles[i].buffer;
|
||||
|
||||
/* Copy denoised tile to the host. */
|
||||
if(i == 4) {
|
||||
mem.copy_from_device(0, mem.data_size, 1);
|
||||
}
|
||||
|
||||
sub_device->mem_free(mem);
|
||||
mem.restore_device();
|
||||
|
||||
mem.device = original_device;
|
||||
mem.device_pointer = original_ptr;
|
||||
mem.device_size = original_size;
|
||||
|
||||
/* Copy denoised tile to the original device. */
|
||||
if(i == 4) {
|
||||
mem.copy_to_device();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -379,3 +397,4 @@ Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -797,3 +797,5 @@ void Device::server_run()
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -489,3 +489,4 @@ CCL_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
#endif /* __DEVICE_NETWORK_H__ */
|
||||
|
||||
|
@@ -137,10 +137,6 @@ void device_opencl_info(vector<DeviceInfo>& devices)
|
||||
info.has_volume_decoupled = false;
|
||||
info.bvh_layout_mask = BVH_LAYOUT_BVH2;
|
||||
info.id = id;
|
||||
|
||||
/* Check OpenCL extensions */
|
||||
info.has_half_images = platform_device.device_extensions.find("cl_khr_fp16") != string::npos;
|
||||
|
||||
devices.push_back(info);
|
||||
num_devices++;
|
||||
}
|
||||
|
@@ -322,3 +322,5 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
||||
|
@@ -131,3 +131,6 @@ public:
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __DEVICE_SPLIT_KERNEL_H__ */
|
||||
|
||||
|
||||
|
||||
|
@@ -126,3 +126,4 @@ void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples)
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -86,3 +86,4 @@ protected:
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __DEVICE_TASK_H__ */
|
||||
|
||||
|
@@ -254,3 +254,4 @@ void MemoryManager::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg)
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* WITH_OPENCL */
|
||||
|
||||
|
@@ -104,3 +104,4 @@ public:
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
@@ -59,22 +59,19 @@ struct OpenCLPlatformDevice {
|
||||
cl_device_id device_id,
|
||||
cl_device_type device_type,
|
||||
const string& device_name,
|
||||
const string& hardware_id,
|
||||
const string& device_extensions)
|
||||
const string& hardware_id)
|
||||
: platform_id(platform_id),
|
||||
platform_name(platform_name),
|
||||
device_id(device_id),
|
||||
device_type(device_type),
|
||||
device_name(device_name),
|
||||
hardware_id(hardware_id),
|
||||
device_extensions(device_extensions) {}
|
||||
hardware_id(hardware_id) {}
|
||||
cl_platform_id platform_id;
|
||||
string platform_name;
|
||||
cl_device_id device_id;
|
||||
cl_device_type device_type;
|
||||
string device_name;
|
||||
string hardware_id;
|
||||
string device_extensions;
|
||||
};
|
||||
|
||||
/* Contains all static OpenCL helper functions. */
|
||||
@@ -133,12 +130,6 @@ public:
|
||||
|
||||
static string get_device_name(cl_device_id device_id);
|
||||
|
||||
static bool get_device_extensions(cl_device_id device_id,
|
||||
string *device_extensions,
|
||||
cl_int* error = NULL);
|
||||
|
||||
static string get_device_extensions(cl_device_id device_id);
|
||||
|
||||
static bool get_device_type(cl_device_id device_id,
|
||||
cl_device_type *device_type,
|
||||
cl_int* error = NULL);
|
||||
@@ -371,7 +362,7 @@ public:
|
||||
void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half);
|
||||
void shader(DeviceTask& task);
|
||||
|
||||
void denoise(RenderTile& tile, DenoisingTask& denoising);
|
||||
void denoise(RenderTile& tile, DenoisingTask& denoising, const DeviceTask& task);
|
||||
|
||||
class OpenCLDeviceTask : public DeviceTask {
|
||||
public:
|
||||
@@ -445,6 +436,8 @@ protected:
|
||||
device_ptr depth_ptr,
|
||||
device_ptr output_ptr,
|
||||
DenoisingTask *task);
|
||||
bool denoising_set_tiles(device_ptr *buffers,
|
||||
DenoisingTask *task);
|
||||
|
||||
device_ptr mem_alloc_sub_ptr(device_memory& mem, int offset, int size);
|
||||
void mem_free_sub_ptr(device_ptr ptr);
|
||||
|
@@ -246,6 +246,7 @@ bool OpenCLDeviceBase::load_kernels(const DeviceRequestedFeatures& requested_fea
|
||||
denoising_program.add_kernel(ustring("filter_nlm_normalize"));
|
||||
denoising_program.add_kernel(ustring("filter_nlm_construct_gramian"));
|
||||
denoising_program.add_kernel(ustring("filter_finalize"));
|
||||
denoising_program.add_kernel(ustring("filter_set_tiles"));
|
||||
|
||||
vector<OpenCLProgram*> programs;
|
||||
programs.push_back(&base_program);
|
||||
@@ -976,20 +977,13 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr,
|
||||
cl_mem sv_variance_mem = CL_MEM_PTR(sv_variance_ptr);
|
||||
cl_mem buffer_variance_mem = CL_MEM_PTR(buffer_variance_ptr);
|
||||
|
||||
cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer);
|
||||
cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer);
|
||||
|
||||
cl_kernel ckFilterDivideShadow = denoising_program(ustring("filter_divide_shadow"));
|
||||
|
||||
int arg_ofs = kernel_set_args(ckFilterDivideShadow, 0,
|
||||
kernel_set_args(ckFilterDivideShadow, 0,
|
||||
task->render_buffer.samples,
|
||||
tile_info_mem);
|
||||
cl_mem buffers[9];
|
||||
for(int i = 0; i < 9; i++) {
|
||||
buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]);
|
||||
arg_ofs += kernel_set_args(ckFilterDivideShadow, arg_ofs,
|
||||
buffers[i]);
|
||||
}
|
||||
kernel_set_args(ckFilterDivideShadow, arg_ofs,
|
||||
tiles_mem,
|
||||
a_mem,
|
||||
b_mem,
|
||||
sample_variance_mem,
|
||||
@@ -997,7 +991,7 @@ bool OpenCLDeviceBase::denoising_divide_shadow(device_ptr a_ptr,
|
||||
buffer_variance_mem,
|
||||
task->rect,
|
||||
task->render_buffer.pass_stride,
|
||||
task->render_buffer.offset);
|
||||
task->render_buffer.denoising_data_offset);
|
||||
enqueue_kernel(ckFilterDivideShadow,
|
||||
task->rect.z-task->rect.x,
|
||||
task->rect.w-task->rect.y);
|
||||
@@ -1014,27 +1008,20 @@ bool OpenCLDeviceBase::denoising_get_feature(int mean_offset,
|
||||
cl_mem mean_mem = CL_MEM_PTR(mean_ptr);
|
||||
cl_mem variance_mem = CL_MEM_PTR(variance_ptr);
|
||||
|
||||
cl_mem tile_info_mem = CL_MEM_PTR(task->tile_info_mem.device_pointer);
|
||||
cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer);
|
||||
|
||||
cl_kernel ckFilterGetFeature = denoising_program(ustring("filter_get_feature"));
|
||||
|
||||
int arg_ofs = kernel_set_args(ckFilterGetFeature, 0,
|
||||
kernel_set_args(ckFilterGetFeature, 0,
|
||||
task->render_buffer.samples,
|
||||
tile_info_mem);
|
||||
cl_mem buffers[9];
|
||||
for(int i = 0; i < 9; i++) {
|
||||
buffers[i] = CL_MEM_PTR(task->tile_info->buffers[i]);
|
||||
arg_ofs += kernel_set_args(ckFilterGetFeature, arg_ofs,
|
||||
buffers[i]);
|
||||
}
|
||||
kernel_set_args(ckFilterGetFeature, arg_ofs,
|
||||
tiles_mem,
|
||||
mean_offset,
|
||||
variance_offset,
|
||||
mean_mem,
|
||||
variance_mem,
|
||||
task->rect,
|
||||
task->render_buffer.pass_stride,
|
||||
task->render_buffer.offset);
|
||||
task->render_buffer.denoising_data_offset);
|
||||
enqueue_kernel(ckFilterGetFeature,
|
||||
task->rect.z-task->rect.x,
|
||||
task->rect.w-task->rect.y);
|
||||
@@ -1069,8 +1056,29 @@ bool OpenCLDeviceBase::denoising_detect_outliers(device_ptr image_ptr,
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising)
|
||||
bool OpenCLDeviceBase::denoising_set_tiles(device_ptr *buffers,
|
||||
DenoisingTask *task)
|
||||
{
|
||||
task->tiles_mem.copy_to_device();
|
||||
|
||||
cl_mem tiles_mem = CL_MEM_PTR(task->tiles_mem.device_pointer);
|
||||
|
||||
cl_kernel ckFilterSetTiles = denoising_program(ustring("filter_set_tiles"));
|
||||
|
||||
kernel_set_args(ckFilterSetTiles, 0, tiles_mem);
|
||||
for(int i = 0; i < 9; i++) {
|
||||
cl_mem buffer_mem = CL_MEM_PTR(buffers[i]);
|
||||
kernel_set_args(ckFilterSetTiles, i+1, buffer_mem);
|
||||
}
|
||||
|
||||
enqueue_kernel(ckFilterSetTiles, 1, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising, const DeviceTask &task)
|
||||
{
|
||||
denoising.functions.set_tiles = function_bind(&OpenCLDeviceBase::denoising_set_tiles, this, _1, &denoising);
|
||||
denoising.functions.construct_transform = function_bind(&OpenCLDeviceBase::denoising_construct_transform, this, &denoising);
|
||||
denoising.functions.reconstruct = function_bind(&OpenCLDeviceBase::denoising_reconstruct, this, _1, _2, _3, &denoising);
|
||||
denoising.functions.divide_shadow = function_bind(&OpenCLDeviceBase::denoising_divide_shadow, this, _1, _2, _3, _4, _5, &denoising);
|
||||
@@ -1082,7 +1090,16 @@ void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising)
|
||||
denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h);
|
||||
denoising.render_buffer.samples = rtile.sample;
|
||||
|
||||
denoising.run_denoising(&rtile);
|
||||
RenderTile rtiles[9];
|
||||
rtiles[4] = rtile;
|
||||
task.map_neighbor_tiles(rtiles, this);
|
||||
denoising.tiles_from_rendertiles(rtiles);
|
||||
|
||||
denoising.init_from_devicetask(task);
|
||||
|
||||
denoising.run_denoising();
|
||||
|
||||
task.unmap_neighbor_tiles(rtiles, this);
|
||||
}
|
||||
|
||||
void OpenCLDeviceBase::shader(DeviceTask& task)
|
||||
|
@@ -107,7 +107,7 @@ public:
|
||||
}
|
||||
else if(task->type == DeviceTask::RENDER) {
|
||||
RenderTile tile;
|
||||
DenoisingTask denoising(this, *task);
|
||||
DenoisingTask denoising(this);
|
||||
|
||||
/* Keep rendering tiles until done. */
|
||||
while(task->acquire_tile(this, tile)) {
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
}
|
||||
else if(tile.task == RenderTile::DENOISE) {
|
||||
tile.sample = tile.start_sample + tile.num_samples;
|
||||
denoise(tile, denoising);
|
||||
denoise(tile, denoising, *task);
|
||||
task->update_progress(&tile, tile.w*tile.h);
|
||||
}
|
||||
|
||||
|
@@ -129,7 +129,7 @@ public:
|
||||
}
|
||||
else if(task->type == DeviceTask::RENDER) {
|
||||
RenderTile tile;
|
||||
DenoisingTask denoising(this, *task);
|
||||
DenoisingTask denoising(this);
|
||||
|
||||
/* Allocate buffer for kernel globals */
|
||||
device_only_memory<KernelGlobalsDummy> kgbuffer(this, "kernel_globals");
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
}
|
||||
else if(tile.task == RenderTile::DENOISE) {
|
||||
tile.sample = tile.start_sample + tile.num_samples;
|
||||
denoise(tile, denoising);
|
||||
denoise(tile, denoising, *task);
|
||||
task->update_progress(&tile, tile.w*tile.h);
|
||||
}
|
||||
|
||||
|
@@ -831,15 +831,13 @@ void OpenCLInfo::get_usable_devices(vector<OpenCLPlatformDevice> *usable_devices
|
||||
FIRST_VLOG(2) << "Adding new device "
|
||||
<< readable_device_name << ".";
|
||||
string hardware_id = get_hardware_id(platform_name, device_id);
|
||||
string device_extensions = get_device_extensions(device_id);
|
||||
usable_devices->push_back(OpenCLPlatformDevice(
|
||||
platform_id,
|
||||
platform_name,
|
||||
device_id,
|
||||
device_type,
|
||||
readable_device_name,
|
||||
hardware_id,
|
||||
device_extensions));
|
||||
hardware_id));
|
||||
}
|
||||
else {
|
||||
FIRST_VLOG(2) << "Ignoring device " << device_name
|
||||
@@ -1049,40 +1047,6 @@ string OpenCLInfo::get_device_name(cl_device_id device_id)
|
||||
return device_name;
|
||||
}
|
||||
|
||||
bool OpenCLInfo::get_device_extensions(cl_device_id device_id,
|
||||
string *device_extensions,
|
||||
cl_int* error)
|
||||
{
|
||||
char buffer[1024];
|
||||
cl_int err;
|
||||
if((err = clGetDeviceInfo(device_id,
|
||||
CL_DEVICE_EXTENSIONS,
|
||||
sizeof(buffer),
|
||||
&buffer,
|
||||
NULL)) != CL_SUCCESS)
|
||||
{
|
||||
if(error != NULL) {
|
||||
*error = err;
|
||||
}
|
||||
*device_extensions = "";
|
||||
return false;
|
||||
}
|
||||
if(error != NULL) {
|
||||
*error = CL_SUCCESS;
|
||||
}
|
||||
*device_extensions = buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
string OpenCLInfo::get_device_extensions(cl_device_id device_id)
|
||||
{
|
||||
string device_extensions;
|
||||
if(!get_device_extensions(device_id, &device_extensions)) {
|
||||
return "";
|
||||
}
|
||||
return device_extensions;
|
||||
}
|
||||
|
||||
bool OpenCLInfo::get_device_type(cl_device_id device_id,
|
||||
cl_device_type *device_type,
|
||||
cl_int* error)
|
||||
|
@@ -200,3 +200,4 @@
|
||||
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.
|
||||
|
||||
|
@@ -26,3 +26,4 @@ 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.
|
||||
|
||||
|
@@ -33,3 +33,4 @@ 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.
|
||||
|
||||
|
@@ -25,3 +25,4 @@ 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.
|
||||
|
||||
|
@@ -26,3 +26,4 @@ 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.
|
||||
|
||||
|
@@ -13,3 +13,4 @@ MIT license
|
||||
|
||||
Boost License
|
||||
* Boost and OpenCL dynamic loading
|
||||
|
||||
|
@@ -20,3 +20,4 @@ include_directories(${INC})
|
||||
include_directories(SYSTEM ${INC_SYS})
|
||||
|
||||
cycles_add_library(cycles_graph ${SRC} ${SRC_HEADERS})
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user