Merge branch 'release/v2_4_0'

This commit is contained in:
manuelk 2014-04-16 11:39:35 -07:00
commit ec19b2a45d
134 changed files with 5277 additions and 3410 deletions

View File

@ -44,7 +44,7 @@ message(STATUS "Using cmake version ${CMAKE_VERSION}")
#-------------------------------------------------------------------------------
# Specify the default install path
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
SET( CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/ )
SET( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/" )
endif()
if (NOT DEFINED CMAKE_INCDIR_BASE)
@ -67,37 +67,37 @@ if (NOT DEFINED CMAKE_DOCDIR_BASE)
set( CMAKE_DOCDIR_BASE share/doc/opensubdiv )
else()
if (IS_ABSOLUTE ${CMAKE_DOCDIR_BASE})
set( CMAKE_DOCDIR_BASE ${CMAKE_DOCDIR_BASE} )
set( CMAKE_DOCDIR_BASE "${CMAKE_DOCDIR_BASE}" )
else()
set( CMAKE_DOCDIR_BASE ${CMAKE_INSTALL_PREFIX}/${CMAKE_DOCDIR_BASE} )
set( CMAKE_DOCDIR_BASE "${CMAKE_INSTALL_PREFIX}/${CMAKE_DOCDIR_BASE}" )
endif()
endif()
# Allow install path to be overridden for cross-compile builds
if(LIBRARY_OUTPUT_PATH_ROOT)
SET( CMAKE_INSTALL_PREFIX ${LIBRARY_OUTPUT_PATH_ROOT}/ )
SET( CMAKE_INSTALL_PREFIX "${LIBRARY_OUTPUT_PATH_ROOT}/" )
endif()
# Set the directory where the executables will be stored.
set(EXECUTABLE_OUTPUT_PATH
${PROJECT_BINARY_DIR}/bin
"${PROJECT_BINARY_DIR}/bin"
CACHE PATH
"Directory where executables will be stored"
)
# Set the directory where the libraries will be stored.
set(LIBRARY_OUTPUT_PATH
${PROJECT_BINARY_DIR}/lib
"${PROJECT_BINARY_DIR}/lib"
CACHE PATH
"Directory where all libraries will be stored"
)
# Specify the list of directories to search for cmake modules.
set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
list(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
@ -463,19 +463,19 @@ add_custom_target( public_headers )
macro(_add_doxy_headers headers)
if (NOT NO_DOC AND DOXYGEN_FOUND)
file(RELATIVE_PATH path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
file(RELATIVE_PATH path "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" )
string(REPLACE "/" "_" targetpath ${path})
foreach (header ${headers})
set(infile ${CMAKE_CURRENT_SOURCE_DIR}/${header})
set(outfile ${CMAKE_BINARY_DIR}/public_headers/${path}/${header})
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
set(outfile "${CMAKE_BINARY_DIR}/public_headers/${path}/${header}")
set(targetname "${targetpath}_${header}")
add_custom_command(
OUTPUT
${outfile}
"${outfile}"
COMMAND
${CMAKE_COMMAND}
ARGS
@ -484,7 +484,7 @@ macro(_add_doxy_headers headers)
${infile}
)
add_custom_target(${targetname} DEPENDS ${outfile})
add_custom_target(${targetname} DEPENDS "${outfile}")
#set_target_properties(${targetname} PROPERTIES FOLDER "public_headers/")
@ -507,20 +507,20 @@ function(_stringify src_files varname)
foreach(src_file ${src_files})
string(REGEX REPLACE ".*[.](.*)" "\\1" extension ${src_file})
string(REGEX REPLACE ".*[.](.*)" "\\1" extension "${src_file}")
if(NOT ${extension} STREQUAL "cu")
string(REGEX REPLACE "(.*)[.].*" "\\1.gen.h" inc_file ${src_file})
list(APPEND inc_files ${inc_file})
string(REGEX REPLACE "(.*)[.].*" "\\1.gen.h" inc_file "${src_file}")
list(APPEND inc_files "${inc_file}")
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/${inc_file}
"${CMAKE_CURRENT_BINARY_DIR}/${inc_file}"
COMMAND
stringify ${CMAKE_CURRENT_SOURCE_DIR}/${src_file} ${CMAKE_CURRENT_BINARY_DIR}/${inc_file}
stringify "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}" "${CMAKE_CURRENT_BINARY_DIR}/${inc_file}"
DEPENDS
stringify ${CMAKE_CURRENT_SOURCE_DIR}/${src_file}
stringify "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}"
)
endif()
@ -549,7 +549,7 @@ macro(_add_possibly_cuda_executable target)
endif()
if(CMAKE_COMPILER_IS_ICC)
target_link_libraries(${target} ${ICC_LIBRARIES})
target_link_libraries(${target} "${ICC_LIBRARIES}")
endif()
endmacro()

View File

@ -38,10 +38,10 @@ if (WIN32)
NAMES
D3D11.h D3Dcompiler.h
PATHS
${DXSDK_LOCATION}/Include
$ENV{DXSDK_LOCATION}/Include
${DXSDK_ROOT}/Include
$ENV{DXSDK_ROOT}/Include
"${DXSDK_LOCATION}/Include"
"$ENV{DXSDK_LOCATION}/Include"
"${DXSDK_ROOT}/Include"
"$ENV{DXSDK_ROOT}/Include"
"C:/Program Files (x86)/Microsoft DirectX SDK*/Include"
"C:/Program Files/Microsoft DirectX SDK*/Include"
)
@ -55,10 +55,10 @@ if (WIN32)
find_path(LIBRARY_DIR
d3d11.lib
PATHS
${DXSDK_LOCATION}/Lib/${ARCH}
$ENV{DXSDK_LOCATION}/Lib/${ARCH}
${DXSDK_ROOT}/Lib/${ARCH}
$ENV{DXSDK_ROOT}/Lib/${ARCH}
"${DXSDK_LOCATION}/Lib/${ARCH}"
"$ENV{DXSDK_LOCATION}/Lib/${ARCH}"
"${DXSDK_ROOT}/Lib/${ARCH}"
"$ENV{DXSDK_ROOT}/Lib/${ARCH}"
"C:/Program Files (x86)/Microsoft DirectX SDK*/Lib/${ARCH}"
"C:/Program Files/Microsoft DirectX SDK*/Lib/${ARCH}"
)

View File

@ -37,21 +37,21 @@ if (WIN32)
NAMES
GL/glew.h
PATHS
${GLEW_LOCATION}/include
$ENV{GLEW_LOCATION}/include
$ENV{PROGRAMFILES}/GLEW/include
${PROJECT_SOURCE_DIR}/extern/glew/include
"${GLEW_LOCATION}/include"
"$ENV{GLEW_LOCATION}/include"
"$ENV{PROGRAMFILES}/GLEW/include"
"${PROJECT_SOURCE_DIR}/extern/glew/include"
DOC "The directory where GL/glew.h resides" )
find_library( GLEW_LIBRARY
NAMES
glew GLEW glew32s glew32
PATHS
${GLEW_LOCATION}/lib
$ENV{GLEW_LOCATION}/lib
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/extern/glew/bin
${PROJECT_SOURCE_DIR}/extern/glew/lib
"${GLEW_LOCATION}/lib"
"$ENV{GLEW_LOCATION}/lib"
"$ENV{PROGRAMFILES}/GLEW/lib"
"${PROJECT_SOURCE_DIR}/extern/glew/bin"
"${PROJECT_SOURCE_DIR}/extern/glew/lib"
DOC "The GLEW library")
endif ()
@ -60,8 +60,8 @@ if (${CMAKE_HOST_UNIX})
NAMES
GL/glew.h
PATHS
${GLEW_LOCATION}/include
$ENV{GLEW_LOCATION}/include
"${GLEW_LOCATION}/include"
"$ENV{GLEW_LOCATION}/include"
/usr/include
/usr/local/include
/sw/include
@ -73,8 +73,8 @@ if (${CMAKE_HOST_UNIX})
NAMES
GLEW glew
PATHS
${GLEW_LOCATION}/lib
$ENV{GLEW_LOCATION}/lib
"${GLEW_LOCATION}/lib"
"$ENV{GLEW_LOCATION}/lib"
/usr/lib64
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}

View File

@ -35,10 +35,10 @@ find_path( GLFW_INCLUDE_DIR
GL/glfw.h
GLFW/glfw3.h
PATHS
${GLFW_LOCATION}/include
$ENV{GLFW_LOCATION}/include
$ENV{PROGRAMFILES}/GLFW/include
${OPENGL_INCLUDE_DIR}
"${GLFW_LOCATION}/include"
"$ENV{GLFW_LOCATION}/include"
"$ENV{PROGRAMFILES}/GLFW/include"
"${OPENGL_INCLUDE_DIR}"
/usr/openwin/share/include
/usr/openwin/include
/usr/X11R6/include
@ -58,10 +58,10 @@ if (WIN32)
NAMES
glfw32
PATHS
${GLFW_LOCATION}/lib
${GLFW_LOCATION}/lib/x64
$ENV{GLFW_LOCATION}/lib
${OPENGL_LIBRARY_DIR}
"${GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/x64"
"$ENV{GLFW_LOCATION}/lib"
"${OPENGL_LIBRARY_DIR}"
/usr/lib
/usr/lib/w32api
/usr/local/lib
@ -77,14 +77,14 @@ if (WIN32)
glfw
glfw3
PATHS
${GLFW_LOCATION}/lib
${GLFW_LOCATION}/lib/x64
${GLFW_LOCATION}/lib-msvc110
$ENV{GLFW_LOCATION}/lib
${PROJECT_SOURCE_DIR}/extern/glfw/bin
${PROJECT_SOURCE_DIR}/extern/glfw/lib
$ENV{PROGRAMFILES}/GLFW/lib
${OPENGL_LIBRARY_DIR}
"${GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/x64"
"${GLFW_LOCATION}/lib-msvc110"
"$ENV{GLFW_LOCATION}/lib"
"${PROJECT_SOURCE_DIR}/extern/glfw/bin"
"${PROJECT_SOURCE_DIR}/extern/glfw/lib"
"$ENV{PROGRAMFILES}/GLFW/lib"
"${OPENGL_LIBRARY_DIR}"
DOC
"The GLFW library"
)
@ -96,10 +96,10 @@ else ()
glfw
glfw3
PATHS
${GLFW_LOCATION}/lib
${GLFW_LOCATION}/lib/cocoa
$ENV{GLFW_LOCATION}/lib
$ENV{GLFW_LOCATION}/lib/cocoa
"${GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/cocoa"
"$ENV{GLFW_LOCATION}/lib"
"$ENV{GLFW_LOCATION}/lib/cocoa"
/usr/local/lib
)
set(GLFW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
@ -118,17 +118,17 @@ else ()
message(FATAL_ERROR "xf86vmode library not found - required for GLFW")
endif()
list(APPEND GLFW_x11_LIBRARY ${X11_Xrandr_LIB} ${X11_Xxf86vm_LIB})
list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}")
find_library( GLFW_glfw_LIBRARY
NAMES
glfw
glfw3
PATHS
${GLFW_LOCATION}/lib
$ENV{GLFW_LOCATION}/lib
${GLFW_LOCATION}/lib/x11
$ENV{GLFW_LOCATION}/lib/x11
"${GLFW_LOCATION}/lib"
"$ENV{GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/x11"
"$ENV{GLFW_LOCATION}/lib/x11"
/usr/lib64
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
@ -148,14 +148,14 @@ set( GLFW_FOUND "NO" )
if(GLFW_INCLUDE_DIR)
if(GLFW_glfw_LIBRARY)
set( GLFW_LIBRARIES ${GLFW_glfw_LIBRARY}
${GLFW_x11_LIBRARY}
${GLFW_cocoa_LIBRARY}
${GLFW_iokit_LIBRARY}
${GLFW_corevideo_LIBRARY} )
set( GLFW_LIBRARIES "${GLFW_glfw_LIBRARY}"
"${GLFW_x11_LIBRARY}"
"${GLFW_cocoa_LIBRARY}"
"${GLFW_iokit_LIBRARY}"
"${GLFW_corevideo_LIBRARY}" )
set( GLFW_FOUND "YES" )
set (GLFW_LIBRARY ${GLFW_LIBRARIES})
set (GLFW_INCLUDE_PATH ${GLFW_INCLUDE_DIR})
set (GLFW_LIBRARY "${GLFW_LIBRARIES}")
set (GLFW_INCLUDE_PATH "${GLFW_INCLUDE_DIR}")
endif(GLFW_glfw_LIBRARY)

View File

@ -41,7 +41,7 @@ IF(NOT DEFINED ILMBASE_LOCATION)
IF ( WIN32 )
# Note: This assumes that the Deploy directory has been copied
# back into the IlmBase root directory.
SET( ILMBASE_LOCATION $ENV{PROGRAMFILES}/ilmbase-1.0.1/Deploy )
SET( ILMBASE_LOCATION "$ENV{PROGRAMFILES}/ilmbase-1.0.1/Deploy" )
ENDIF()
ENDIF()
ENDIF()
@ -52,12 +52,12 @@ ELSE()
ENDIF()
SET(LIBRARY_PATHS
${ILMBASE_LOCATION}/lib
${ILMBASE_LOCATION}/lib/Release
${ILMBASE_LOCATION}/lib/x64/Release
$ENV{ILMBASE_LOCATION}/lib
$ENV{ILMBASE_LOCATION}/lib/Release
$ENV{ILMBASE_LOCATION}/lib/x64/Release
"${ILMBASE_LOCATION}/lib"
"${ILMBASE_LOCATION}/lib/Release"
"${ILMBASE_LOCATION}/lib/x64/Release"
"$ENV{ILMBASE_LOCATION}/lib"
"$ENV{ILMBASE_LOCATION}/lib/Release"
"$ENV{ILMBASE_LOCATION}/lib/x64/Release"
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
@ -70,10 +70,10 @@ SET(LIBRARY_PATHS
)
SET(INCLUDE_PATHS
${ILMBASE_LOCATION}/include/OpenEXR/
${ILMBASE_LOCATION}/include
$ENV{ILMBASE_LOCATION}/include/OpenEXR/
$ENV{ILMBASE_LOCATION}/include
"${ILMBASE_LOCATION}/include/OpenEXR/"
"${ILMBASE_LOCATION}/include"
"$ENV{ILMBASE_LOCATION}/include/OpenEXR/"
"$ENV{ILMBASE_LOCATION}/include"
~/Library/Frameworks
/Library/Frameworks
/usr/local/include/OpenEXR/
@ -88,45 +88,49 @@ SET(INCLUDE_PATHS
)
FIND_PATH( ILMBASE_INCLUDE_DIR ImathMath.h
PATHS
${INCLUDE_PATHS}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The directory where ImathMath.h resides" )
FIND_PATH( ILMBASE_INCLUDE_DIR
ImathMath.h
PATHS
"${INCLUDE_PATHS}"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The directory where ImathMath.h resides" )
FIND_LIBRARY( ILMBASE_IEX_LIB Iex
PATHS
${LIBRARY_PATHS}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The Iex library" )
FIND_LIBRARY( ILMBASE_IEX_LIB
Iex
PATHS
"${LIBRARY_PATHS}"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The Iex library" )
FIND_LIBRARY( ILMBASE_ILMTHREAD_LIB IlmThread
PATHS
${LIBRARY_PATHS}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The IlmThread library" )
FIND_LIBRARY( ILMBASE_ILMTHREAD_LIB
IlmThread
PATHS
"${LIBRARY_PATHS}"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The IlmThread library" )
FIND_LIBRARY( ILMBASE_IMATH_LIB Imath
PATHS
${LIBRARY_PATHS}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The Imath library" )
FIND_LIBRARY( ILMBASE_IMATH_LIB
Imath
PATHS
"${LIBRARY_PATHS}"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "The Imath library" )
IF ( ${ILMBASE_IEX_LIB} STREQUAL "ILMBASE_IEX_LIB-NOTFOUND" )
@ -146,9 +150,9 @@ IF ( ${ILMBASE_INCLUDE_DIR} STREQUAL "ILMBASE_INCLUDE_DIR-NOTFOUND" )
ENDIF()
SET( ILMBASE_LIBRARIES
${ILMBASE_IMATH_LIB}
${ILMBASE_ILMTHREAD_LIB}
${ILMBASE_IEX_LIB}
"${ILMBASE_IMATH_LIB}"
"${ILMBASE_ILMTHREAD_LIB}"
"${ILMBASE_IEX_LIB}"
)
INCLUDE(FindPackageHandleStandardArgs)

View File

@ -54,8 +54,8 @@ if(APPLE)
find_path(MAYA_BASE_DIR
../../devkit/include/maya/MFn.h
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"/Applications/Autodesk/maya2014/Maya.app/Contents"
"/Applications/Autodesk/maya2013.5/Maya.app/Contents"
"/Applications/Autodesk/maya2013/Maya.app/Contents"
@ -66,9 +66,9 @@ if(APPLE)
)
find_path(MAYA_LIBRARY_DIR libOpenMaya.dylib
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
Maya.app/contents/MacOS/
DOC
@ -80,8 +80,8 @@ if(UNIX)
find_path(MAYA_BASE_DIR
include/maya/MFn.h
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"/usr/autodesk/maya2013-x64"
"/usr/autodesk/maya2012.17-x64"
"/usr/autodesk/maya2012-x64"
@ -91,9 +91,9 @@ if(UNIX)
find_path(MAYA_LIBRARY_DIR
libOpenMaya.so
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
lib/
DOC
@ -105,8 +105,8 @@ if(WIN32)
find_path(MAYA_BASE_DIR
include/maya/MFn.h
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"C:/Program Files/Autodesk/Maya2013.5-x64"
"C:/Program Files/Autodesk/Maya2013.5"
"C:/Program Files (x86)/Autodesk/Maya2013.5"
@ -131,9 +131,9 @@ if(WIN32)
find_path(MAYA_LIBRARY_DIR
OpenMaya.lib
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
lib/
DOC
@ -144,9 +144,9 @@ endif(WIN32)
find_path(MAYA_INCLUDE_DIR
maya/MFn.h
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
../../devkit/include/
include/
@ -157,9 +157,9 @@ find_path(MAYA_INCLUDE_DIR
find_path(MAYA_LIBRARY_DIR
OpenMaya
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
../../devkit/include/
include/
@ -172,9 +172,9 @@ list(APPEND MAYA_INCLUDE_DIRS ${MAYA_INCLUDE_DIR})
find_path(MAYA_DEVKIT_INC_DIR
GL/glext.h
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
/devkit/plug-ins/
DOC
@ -199,9 +199,9 @@ foreach(MAYA_LIB
find_library(MAYA_${MAYA_LIB}_LIBRARY
${MAYA_LIB}
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
MacOS/
lib/
@ -218,9 +218,9 @@ endforeach(MAYA_LIB)
find_program(MAYA_EXECUTABLE
maya
HINTS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
"${MAYA_LOCATION}"
"$ENV{MAYA_LOCATION}"
"${MAYA_BASE_DIR}"
PATH_SUFFIXES
MacOS/
bin/

View File

@ -105,13 +105,13 @@ elseif (UNIX)
get_filename_component( OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH )
get_filename_component( _OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE )
get_filename_component( _OPENCL_INC_CAND "${OPENCL_LIB_DIR}/../../include" ABSOLUTE )
find_path( OPENCL_INCLUDE_DIRS
NAMES
CL/cl.h
PATHS
${_OPENCL_INC_CAND}
"${_OPENCL_INC_CAND}"
"/usr/local/cuda/include"
"/opt/AMDAPP/include"
ENV OpenCL_INCPATH
@ -121,7 +121,7 @@ elseif (UNIX)
NAMES
CL/cl.hpp
PATHS
${_OPENCL_INC_CAND}
"${_OPENCL_INC_CAND}"
"/usr/local/cuda/include"
"/opt/AMDAPP/include"
ENV OpenCL_INCPATH

View File

@ -30,20 +30,21 @@
# OPENGLES_LIBRARIES - Link these to use OpenGLES
if(ANDROID)
FIND_PATH(
OPENGLES_INCLUDE_DIR GLES2/gl2.h
${ANDROID_STANDALONE_TOOLCHAIN}/usr/include
FIND_PATH( OPENGLES_INCLUDE_DIR
GLES2/gl2.h
"${ANDROID_STANDALONE_TOOLCHAIN}/usr/include"
)
FIND_LIBRARY(
OPENGLES_LIBRARIES NAMES GLESv2
PATHS ${ANDROID_STANDALONE_TOOLCHAIN}/usr/lib
FIND_LIBRARY( OPENGLES_LIBRARIES
NAMES
GLESv2
PATHS
"${ANDROID_STANDALONE_TOOLCHAIN}/usr/lib"
)
elseif(IOS)
FIND_LIBRARY(
OPENGLES_FRAMEWORKS OpenGLES
)
FIND_LIBRARY( OPENGLES_FRAMEWORKS OpenGLES )
if(OPENGLES_FRAMEWORKS)
set( OPENGLES_LIBRARIES "-framework OpenGLES" )
endif()

View File

@ -35,18 +35,18 @@ if (WIN32)
NAMES
Ptexture.h
PATHS
${PTEX_LOCATION}/include
$ENV{PTEX_LOCATION}/include
$ENV{PROGRAMFILES}/Ptex/include
"${PTEX_LOCATION}/include"
"$ENV{PTEX_LOCATION}/include"
"$ENV{PROGRAMFILES}/Ptex/include"
/usr/include
DOC "The directory where Ptexture.h resides")
find_library( PTEX_LIBRARY
NAMES
Ptex32 Ptex32s Ptex
PATHS
${PTEX_LOCATION}/lib
$ENV{PTEX_LOCATION}/lib
$ENV{PROGRAMFILES}/Ptex/lib
"${PTEX_LOCATION}/lib"
"$ENV{PTEX_LOCATION}/lib"
"$ENV{PROGRAMFILES}/Ptex/lib"
/usr/lib
/usr/lib/w32api
/usr/local/lib
@ -57,25 +57,25 @@ elseif (APPLE)
NAMES
Ptexture.h
PATHS
${PTEX_LOCATION}/include
$ENV{PTEX_LOCATION}/include
"${PTEX_LOCATION}/include"
"$ENV{PTEX_LOCATION}/include"
DOC "The directory where Ptexture.h resides")
find_library( PTEX_LIBRARY
NAMES
Ptex libPtex.a
PATHS
${PTEX_LOCATION}/lib
$ENV{PTEX_LOCATION}/lib
"${PTEX_LOCATION}/lib"
"$ENV{PTEX_LOCATION}/lib"
DOC "The Ptex Library")
else ()
find_path( PTEX_INCLUDE_DIR
NAMES
Ptexture.h
PATHS
${PTEX_LOCATION}/include
${PTEX_LOCATION}/include/wdas
$ENV{PTEX_LOCATION}/include
$ENV{PTEX_LOCATION}/include/wdas
"${PTEX_LOCATION}/include"
"${PTEX_LOCATION}/include/wdas"
"$ENV{PTEX_LOCATION}/include"
"$ENV{PTEX_LOCATION}/include/wdas"
/usr/include
/usr/local/include
/usr/openwin/share/include
@ -87,8 +87,8 @@ else ()
NAMES
Ptex wdasPtex
PATHS
${PTEX_LOCATION}/lib
$ENV{PTEX_LOCATION}/lib
"${PTEX_LOCATION}/lib"
"$ENV{PTEX_LOCATION}/lib"
/usr/lib
/usr/local/lib
/usr/openwin/lib

View File

@ -35,9 +35,9 @@ if (WIN32)
NAMES
tbb/tbb.h
HINTS
${TBB_LOCATION}/include
$ENV{TBB_LOCATION}/include
$ENV{PROGRAMFILES}/Intel/TBB/include
"${TBB_LOCATION}/include"
"$ENV{TBB_LOCATION}/include"
"$ENV{PROGRAMFILES}/Intel/TBB/include"
/usr/include
DOC "The directory where TBB headers reside")
elseif (APPLE)
@ -45,16 +45,16 @@ elseif (APPLE)
NAMES
tbb/tbb.h
HINTS
${TBB_LOCATION}/include
$ENV{TBB_LOCATION}/include
"${TBB_LOCATION}/include"
"$ENV{TBB_LOCATION}/include"
DOC "The directory where TBB headers reside")
else ()
find_path(TBB_INCLUDE_DIR
NAMES
tbb/tbb.h
HINTS
${TBB_LOCATION}/include
$ENV{TBB_LOCATION}/include
"${TBB_LOCATION}/include"
"$ENV{TBB_LOCATION}/include"
/usr/include
/usr/local/include
/usr/openwin/share/include
@ -108,20 +108,20 @@ foreach(TBB_LIB tbb tbb_debug
NAMES
${TBB_LIB}
HINTS
${TBB_LOCATION}/lib
${TBB_LOCATION}/bin
$ENV{TBB_LOCATION}/lib
$ENV{TBB_LOCATION}/bin
$ENV{PROGRAMFILES}/TBB/lib
"${TBB_LOCATION}/lib"
"${TBB_LOCATION}/bin"
"$ENV{TBB_LOCATION}/lib"
"$ENV{TBB_LOCATION}/bin"
"$ENV{PROGRAMFILES}/TBB/lib"
/usr/lib
/usr/lib/w32api
/usr/local/lib
/usr/X11R6/lib
PATH_SUFFIXES
${TBB_LIB_ARCH}
${TBB_LIB_ARCH}/${TBB_COMPILER}
${TBB_LIB_ARCH}/gcc4.4
${TBB_LIB_ARCH}/gcc4.1
"${TBB_LIB_ARCH}"
"${TBB_LIB_ARCH}/${TBB_COMPILER}"
"${TBB_LIB_ARCH}/gcc4.4"
"${TBB_LIB_ARCH}/gcc4.1"
DOC "Intel's Threading Building Blocks library")
if (TBB_${TBB_LIB}_LIBRARY)

View File

@ -26,12 +26,12 @@
# Doxygen documentation
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/OpenSubdiv.doxy ${CMAKE_CURRENT_BINARY_DIR}/OpenSubdiv.doxy @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenSubdiv.doxy" "${CMAKE_CURRENT_BINARY_DIR}/OpenSubdiv.doxy" @ONLY)
add_custom_target(doc_doxy
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OpenSubdiv.doxy
${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/OpenSubdiv.doxy"
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/public_headers/
"${CMAKE_BINARY_DIR}/public_headers/"
DEPENDS
public_headers
COMMENT
@ -42,9 +42,9 @@ if (DOXYGEN_FOUND)
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/doxy_html
"${CMAKE_CURRENT_BINARY_DIR}/doxy_html"
DESTINATION
${CMAKE_DOCDIR_BASE}
"${CMAKE_DOCDIR_BASE}"
)
else()
@ -93,37 +93,37 @@ if (DOCUTILS_FOUND AND PYTHONINTERP_FOUND)
foreach(src ${RST_FILES})
get_filename_component(BASENAME ${src} NAME_WE)
set(infile ${CMAKE_CURRENT_SOURCE_DIR}/${src})
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}.html)
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}.html")
add_custom_command(
OUTPUT
${outfile}
"${outfile}"
COMMAND
${RST2HTML_EXECUTABLE}
"${RST2HTML_EXECUTABLE}"
ARGS
--date
--time
--no-xml-declaration
--initial-header-level=3
--strip-comments
--template=${CMAKE_CURRENT_SOURCE_DIR}/rst_template.txt
--template="${CMAKE_CURRENT_SOURCE_DIR}/rst_template.txt"
--stylesheet=css/rst.css
--link-stylesheet
${infile} ${outfile}
"${infile}" "${outfile}"
DEPENDS
${infile} rst_template.txt nav_template.txt
"${infile}" rst_template.txt nav_template.txt
)
add_custom_target(${src} DEPENDS ${outfile})
add_custom_target(${src} DEPENDS "${outfile}")
list(APPEND RST_TARGETS ${src})
install(
FILES
${outfile}
"${outfile}"
DESTINATION
${CMAKE_DOCDIR_BASE}
"${CMAKE_DOCDIR_BASE}"
PERMISSIONS
OWNER_READ GROUP_READ WORLD_READ
)
@ -132,27 +132,27 @@ if (DOCUTILS_FOUND AND PYTHONINTERP_FOUND)
# copy html files to the build area
foreach(src ${HTML_FILES})
set(infile ${CMAKE_CURRENT_SOURCE_DIR}/${src})
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/${src})
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${src}")
add_custom_command(
OUTPUT
${outfile}
"${outfile}"
COMMAND
${CMAKE_COMMAND}
"${CMAKE_COMMAND}"
ARGS
-E copy ${infile} ${outfile}
-E copy "${infile}" "${outfile}"
)
add_custom_target( ${src} DEPENDS ${outfile})
add_custom_target( ${src} DEPENDS "${outfile}")
list(APPEND HTML_TARGETS ${src})
install(
FILES
${outfile}
"${outfile}"
DESTINATION
${CMAKE_DOCDIR_BASE}
"${CMAKE_DOCDIR_BASE}"
)
endforeach()
@ -160,37 +160,37 @@ if (DOCUTILS_FOUND AND PYTHONINTERP_FOUND)
# documentation can be read without an install
add_custom_target(doc_html_images
COMMAND
${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/images ${CMAKE_CURRENT_BINARY_DIR}/images
"${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/images" "${CMAKE_CURRENT_BINARY_DIR}/images"
)
add_custom_target(doc_html_css
COMMAND
${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/css ${CMAKE_CURRENT_BINARY_DIR}/css
${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/css" "${CMAKE_CURRENT_BINARY_DIR}/css"
)
add_custom_target(doc_tipuesearch
COMMAND
${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/tipuesearch ${CMAKE_CURRENT_BINARY_DIR}/tipuesearch
${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tipuesearch" "${CMAKE_CURRENT_BINARY_DIR}/tipuesearch"
)
# build search index and insert navigation tab
add_custom_target(search_index
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/processHtml.py
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/nav_template.txt
"${PYTHON_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/processHtml.py"
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/nav_template.txt"
DEPENDS
${HTML_TARGETS}
${RST_TARGETS}
${HTML_TARGETS}
${RST_TARGETS}
doc_tipuesearch
)
add_custom_target(doc_html
DEPENDS
search_index
${HTML_TARGETS}
${RST_TARGETS}
${HTML_TARGETS}
${RST_TARGETS}
doc_html_images
doc_html_css
doc_tipuesearch
@ -198,24 +198,24 @@ if (DOCUTILS_FOUND AND PYTHONINTERP_FOUND)
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/tipuesearch
"${CMAKE_CURRENT_BINARY_DIR}/tipuesearch"
DESTINATION
${CMAKE_DOCDIR_BASE}
"${CMAKE_DOCDIR_BASE}"
)
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/images
"${CMAKE_CURRENT_BINARY_DIR}/images"
DESTINATION
${CMAKE_DOCDIR_BASE}
"${CMAKE_DOCDIR_BASE}"
)
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/css
"${CMAKE_CURRENT_BINARY_DIR}/css"
DESTINATION
${CMAKE_DOCDIR_BASE}
"${CMAKE_DOCDIR_BASE}"
)
list(APPEND DOC_TARGETS doc_html)

View File

@ -35,12 +35,12 @@ SYNOPSIS
.. parsed-literal::
:class: codefhead
**dxViewer** [**-f**] *objfile(s)*
**dxViewer** [**-d** *isolation level*] [**-c** *animation loops*] *objfile(s)*
DESCRIPTION
===========
``glViewer`` is a stand-alone application that showcases the application of
``dxViewer`` is a stand-alone application that showcases the application of
uniform and feature adaptive subdivision schemes to a collection of geometric
shapes. Multiple controls are available to experiment with the algorithms.
@ -54,9 +54,13 @@ shapes. Multiple controls are available to experiment with the algorithms.
OPTIONS
=======
**-f**
Launches the application in full-screen mode (if is supported by GLFW on the
OS)
**-d** *isolation level*
Select the desired isolation level of adaptive feature isolation. This can be
useful when trying to load large pieces of geometry.
**-c** *animation frequency*
Number of repetitions of the animtion loop (default=0 is infinite)
SEE ALSO
========

View File

@ -31,6 +31,48 @@ Release Notes
----
Release 2.4.0
=============
**New Features**
- Adding functionality to store uniform face-varying data across multiple levels of subdivision
- Add OsdUtilPatchPartitioner
It splits patcharray into subsets so that clients can draw partial surfaces
for both adaptive and uniform.
**Changes**
- Remove FarMesh dependency from Osd*Context.
- Use DSA APIs for GL buffer update (if available).
- Refactor Far API
- replace void- of all kernel applications with CONTEXT template parameter.
It eliminates many static_casts from void- for both far and osd classes.
- move the big switch-cases of far default kernel launches out of Refine so
that osd controllers can arbitrary mix default kernels and custom kernels.
- change FarKernelBatch::kernelType from enum to int, clients can add
custom kernel types.
- remove a back-pointer to farmesh from subdivision table.
- untemplate all subdivision table classes and template their compute methods
instead. Those methods take a typed vertex storage.
- remove an unused argument FarMesh from the constructor of subdivision
table factories.
- Refactor FarSubdivisionTables.
Delete scheme specialized subdivision tables. The base class FarSubdivisionTables
already has all tables, so we just need scheme enum to identify which scheme
the subdivision tables belong to. This brings a lot of code cleanups around far
factory classes.
- Move FarMultiMeshFactory to OsdUtil.
- Move table splicing functions of FarMultiMeshFactory into factories
- Change PxOsdUtil prefix to final OsdUtil prefix.
- Improve error reporting in osdutil refinement classes, and fix a build issue
**Bug Fixes**
- Fix another multi mesh splicing bug of face varying data.
- Make CMake path variables more robust
- Fixing a crash on Marvericks w/glew
- Update dxViewer example documentation
- Fix wrong logic in openSubdiv_setEvaluatorCoarsePositions
- Remove debug print from adaptive evaluator's initialization
Release 2.3.5
=============

View File

@ -320,21 +320,57 @@ the :blue:`655` th. face of the subdivision mesh.
Vertex Edits
************
XXXX
Vertex hierarchical edits can modify the value or the sharpness of primitive variables for vertices
and sub-vertices anywhere in the subdivision hierarchy.
.. image:: images/hedit_example1.png
:align: center
:height: 300
:target: images/hedit_example1.png
The edits are performed using either an "add" or a "set" operator. "set" indicates the primitive
variable value or sharpness is to be set directly to the values specified. "add" adds a value to the
normal result computed via standard subdivision rules. In other words, this operation allows value
offsets to be applied to the mesh at any level of the hierarchy.
.. image:: images/hedit_example2.png
:align: center
:height: 300
:target: images/hedit_example2.png
----
Edge Edits
**********
XXXX
Edge hierarchical edits can only modify the sharpness of primitive variables for edges
and sub-edges anywhere in the subdivision hierarchy.
.. image:: images/hedit_example4.png
:align: center
:height: 300
:target: images/hedit_example4.png
----
Face Edits
**********
XXXX
Face hierarchical edits can modify several properties of faces and sub-faces anywhere in the
subdivision hierarchy.
Modifiable properties include:
* The "set" or "add" operators modify the value of primitive variables associated with faces.
* The "hole" operation introduces holes (missing faces) into the subdivision mesh at any
level in the subdivision hierarchy. The faces will be deleted, and none of their children
will appear (you cannot "unhole" a face if any ancestor is a "hole"). This operation takes
no float or string arguments.
.. image:: images/hedit_example5.png
:align: center
:height: 300
:target: images/hedit_example5.png
----
@ -348,7 +384,9 @@ XXXX
Uniform Subdivision
===================
Applies a uniform refinement scheme to the coarse faces of a mesh.
Applies a uniform refinement scheme to the coarse faces of a mesh. This is the most
common solution employed to apply subdivision schemes to a control cage. The mesh
converges closer to the limit surface with each iteration of the algorithm.
.. image:: images/uniform.gif
:align: center
@ -360,15 +398,45 @@ Applies a uniform refinement scheme to the coarse faces of a mesh.
Feature Adaptive Subdivision
============================
Isolates extraordinary features by applying progressive refinement.
.. image:: images/subdiv_faceindex.png
:align: center
:target: images/subdiv_faceindex.png
Generates bi-cubic patches on the limit surface and applies a progressive refinement
scheme in order to isolate non-C2 continuous extraordinary features.
.. image:: images/adaptive.gif
:align: center
:width: 300
:target: images/adaptive.gif
----
Uniform or Adaptive ?
=====================
Main features comparison:
+-------------------------------------------------------+--------------------------------------------------------+
| Uniform | Feature Adaptive |
+=======================================================+========================================================+
| | |
| * Bilinear approximation | * Bicubic limit patches |
| * No tangents / no normals | * Analytical tangents / normals |
| * No smooth shading around creases | |
| * No animated displacements | |
| | |
+-------------------------------------------------------+--------------------------------------------------------+
| * Exponential geometry Growth | * Feature isolation growth close to linear |
| | |
+-------------------------------------------------------+--------------------------------------------------------+
| * Boundary interpolation rules supported: | * Boundary interpolation rules supported: |
| * All vertex & varying rules supported dynamically| * All vertex & varying rules supported dynamically |
| * All face-varying rules supported \ | * Bilinear face-varying interpolation \ |
| statically at vertex locations (there is no \ | supported statically |
| surface limit) | * Bi-cubic face-varying interpolation \ |
| | currently not supported |
| | |
+-------------------------------------------------------+--------------------------------------------------------+
| * No GPU shading implications | * Requires GPU composable shading |
| | |
+-------------------------------------------------------+--------------------------------------------------------+

View File

@ -33,6 +33,7 @@ if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
add_subdirectory(limitEval)
add_subdirectory(tessellateObjFile)
add_subdirectory(uvViewer)
add_subdirectory(facePartition)
if(OPENGL_4_3_FOUND AND (NOT APPLE))
add_subdirectory(paintTest)

View File

@ -50,10 +50,12 @@ if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
gl_hud.h
)
include_directories(${OPENGL_INCLUDE_DIR})
if (NOT "${OPENGL_INCLUDE_DIR}" STREQUAL "")
include_directories("${OPENGL_INCLUDE_DIR}")
endif()
if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIR})
include_directories("${GLEW_INCLUDE_DIR}")
endif()
endif()
@ -69,16 +71,16 @@ if(DXSDK_FOUND)
d3d11_hud.h
)
include_directories(${DXSDK_INCLUDE_DIR})
include_directories("${DXSDK_INCLUDE_DIR}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
"${PROJECT_SOURCE_DIR}/opensubdiv"
)
add_library(examples_common_obj

View File

@ -29,16 +29,16 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${DXSDK_LIBRARIES}
${PTEX_LIBRARY}
"${OSD_LINK_TARGET}"
"${DXSDK_LIBRARIES}"
"${PTEX_LIBRARY}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${DXSDK_INCLUDE_DIR}
${PTEX_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${DXSDK_INCLUDE_DIR}"
"${PTEX_INCLUDE_DIR}"
)
set(SOURCE_FILES
@ -47,12 +47,12 @@ set(SOURCE_FILES
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_possibly_cuda_executable(dxPtexViewer WIN32
${SOURCE_FILES}
${SHADER_FILES}
${INC_FILES}
"${SOURCE_FILES}"
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -60,4 +60,4 @@ target_link_libraries(dxPtexViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS dxPtexViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS dxPtexViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -29,14 +29,14 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${DXSDK_LIBRARIES}
"${OSD_LINK_TARGET}"
"${DXSDK_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${DXSDK_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${DXSDK_INCLUDE_DIR}"
)
set(SOURCE_FILES
@ -45,12 +45,12 @@ set(SOURCE_FILES
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_possibly_cuda_executable(dxViewer WIN32
${SOURCE_FILES}
${SHADER_FILES}
${INC_FILES}
"${SOURCE_FILES}"
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -58,4 +58,4 @@ target_link_libraries(dxViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS dxViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS dxViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -0,0 +1,69 @@
#
# Copyright 2014 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
# *** facePartition ***
set(SHADER_FILES
shader.glsl
)
set(PLATFORM_LIBRARIES
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLFW_LIBRARIES}"
)
include_directories(
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
#-------------------------------------------------------------------------------
_stringify("${SHADER_FILES}" INC_FILES)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_glfw_executable(facePartition
viewer.cpp
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
target_link_libraries(facePartition
${PLATFORM_LIBRARIES}
)
install(TARGETS facePartition DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -0,0 +1,327 @@
//
// Copyright 2014 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
//--------------------------------------------------------------
// Uniforms / Uniform Blocks
//--------------------------------------------------------------
layout(std140) uniform Transform {
mat4 ModelViewMatrix;
mat4 ProjectionMatrix;
mat4 ModelViewProjectionMatrix;
};
layout(std140) uniform Tessellation {
float TessLevel;
};
uniform int GregoryQuadOffsetBase;
uniform int PrimitiveIdBase;
//--------------------------------------------------------------
// Osd external functions
//--------------------------------------------------------------
mat4 OsdModelViewMatrix()
{
return ModelViewMatrix;
}
mat4 OsdProjectionMatrix()
{
return ProjectionMatrix;
}
mat4 OsdModelViewProjectionMatrix()
{
return ModelViewProjectionMatrix;
}
float OsdTessLevel()
{
return TessLevel;
}
int OsdGregoryQuadOffsetBase()
{
return GregoryQuadOffsetBase;
}
int OsdPrimitiveIdBase()
{
return PrimitiveIdBase;
}
//--------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------
#ifdef VERTEX_SHADER
layout (location=0) in vec4 position;
out block {
OutputVertex v;
} outpt;
void main()
{
outpt.v.position = ModelViewMatrix * position;
}
#endif
//--------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------
#ifdef GEOMETRY_SHADER
#ifdef PRIM_QUAD
layout(lines_adjacency) in;
#define EDGE_VERTS 4
#endif // PRIM_QUAD
#ifdef PRIM_TRI
layout(triangles) in;
#define EDGE_VERTS 3
#endif // PRIM_TRI
layout(triangle_strip, max_vertices = EDGE_VERTS) out;
in block {
OutputVertex v;
} inpt[EDGE_VERTS];
out block {
OutputVertex v;
noperspective out vec4 edgeDistance;
} outpt;
void emit(int index, vec3 normal)
{
outpt.v.position = inpt[index].v.position;
#ifdef SMOOTH_NORMALS
outpt.v.normal = inpt[index].v.normal;
#else
outpt.v.normal = normal;
#endif
gl_Position = ProjectionMatrix * inpt[index].v.position;
EmitVertex();
}
#if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE)
const float VIEWPORT_SCALE = 1024.0; // XXXdyu
float edgeDistance(vec4 p, vec4 p0, vec4 p1)
{
return VIEWPORT_SCALE *
abs((p.x - p0.x) * (p1.y - p0.y) -
(p.y - p0.y) * (p1.x - p0.x)) / length(p1.xy - p0.xy);
}
void emit(int index, vec3 normal, vec4 edgeVerts[EDGE_VERTS])
{
outpt.edgeDistance[0] =
edgeDistance(edgeVerts[index], edgeVerts[0], edgeVerts[1]);
outpt.edgeDistance[1] =
edgeDistance(edgeVerts[index], edgeVerts[1], edgeVerts[2]);
#ifdef PRIM_TRI
outpt.edgeDistance[2] =
edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[0]);
#endif
#ifdef PRIM_QUAD
outpt.edgeDistance[2] =
edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[3]);
outpt.edgeDistance[3] =
edgeDistance(edgeVerts[index], edgeVerts[3], edgeVerts[0]);
#endif
emit(index, normal);
}
#endif
void main()
{
gl_PrimitiveID = gl_PrimitiveIDIn;
#ifdef PRIM_QUAD
vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz;
vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz;
vec3 C = (inpt[2].v.position - inpt[1].v.position).xyz;
vec3 n0 = normalize(cross(B, A));
#if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE)
vec4 edgeVerts[EDGE_VERTS];
edgeVerts[0] = ProjectionMatrix * inpt[0].v.position;
edgeVerts[1] = ProjectionMatrix * inpt[1].v.position;
edgeVerts[2] = ProjectionMatrix * inpt[2].v.position;
edgeVerts[3] = ProjectionMatrix * inpt[3].v.position;
edgeVerts[0].xy /= edgeVerts[0].w;
edgeVerts[1].xy /= edgeVerts[1].w;
edgeVerts[2].xy /= edgeVerts[2].w;
edgeVerts[3].xy /= edgeVerts[3].w;
emit(0, n0, edgeVerts);
emit(1, n0, edgeVerts);
emit(3, n0, edgeVerts);
emit(2, n0, edgeVerts);
#else
emit(0, n0);
emit(1, n0);
emit(3, n0);
emit(2, n0);
#endif
#endif // PRIM_QUAD
#ifdef PRIM_TRI
vec3 A = (inpt[1].v.position - inpt[0].v.position).xyz;
vec3 B = (inpt[2].v.position - inpt[0].v.position).xyz;
vec3 n0 = normalize(cross(B, A));
#if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE)
vec4 edgeVerts[EDGE_VERTS];
edgeVerts[0] = ProjectionMatrix * inpt[0].v.position;
edgeVerts[1] = ProjectionMatrix * inpt[1].v.position;
edgeVerts[2] = ProjectionMatrix * inpt[2].v.position;
edgeVerts[0].xy /= edgeVerts[0].w;
edgeVerts[1].xy /= edgeVerts[1].w;
edgeVerts[2].xy /= edgeVerts[2].w;
emit(0, n0, edgeVerts);
emit(1, n0, edgeVerts);
emit(2, n0, edgeVerts);
#else
emit(0, n0);
emit(1, n0);
emit(2, n0);
#endif
#endif // PRIM_TRI
EndPrimitive();
}
#endif
//--------------------------------------------------------------
// Fragment Shader
//--------------------------------------------------------------
#ifdef FRAGMENT_SHADER
in block {
OutputVertex v;
noperspective in vec4 edgeDistance;
} inpt;
out vec4 outColor;
#define NUM_LIGHTS 2
struct LightSource {
vec4 position;
vec4 ambient;
vec4 diffuse;
vec4 specular;
};
layout(std140) uniform Lighting {
LightSource lightSource[NUM_LIGHTS];
};
uniform vec4 diffuseColor = vec4(1);
uniform vec4 ambientColor = vec4(1);
vec4
lighting(vec4 diffuse, vec3 Peye, vec3 Neye)
{
vec4 color = vec4(0);
for (int i = 0; i < NUM_LIGHTS; ++i) {
vec4 Plight = lightSource[i].position;
vec3 l = (Plight.w == 0.0)
? normalize(Plight.xyz) : normalize(Plight.xyz - Peye);
vec3 n = normalize(Neye);
vec3 h = normalize(l + vec3(0,0,1)); // directional viewer
float d = max(0.0, dot(n, l));
float s = pow(max(0.0, dot(n, h)), 500.0f);
color += lightSource[i].ambient * ambientColor
+ d * lightSource[i].diffuse * diffuse
+ s * lightSource[i].specular;
}
color.a = 1;
return color;
}
vec4
edgeColor(vec4 Cfill, vec4 edgeDistance)
{
#if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE)
#ifdef PRIM_TRI
float d =
min(inpt.edgeDistance[0], min(inpt.edgeDistance[1], inpt.edgeDistance[2]));
#endif
#ifdef PRIM_QUAD
float d =
min(min(inpt.edgeDistance[0], inpt.edgeDistance[1]),
min(inpt.edgeDistance[2], inpt.edgeDistance[3]));
#endif
vec4 Cedge = vec4(1.0, 1.0, 0.0, 1.0);
float p = exp2(-2 * d * d);
#if defined(GEOMETRY_OUT_WIRE)
if (p < 0.25) discard;
#endif
Cfill.rgb = mix(Cfill.rgb, Cedge.rgb, p);
#endif
return Cfill;
}
#if defined(PRIM_QUAD) || defined(PRIM_TRI)
void
main()
{
vec3 N = (gl_FrontFacing ? inpt.v.normal : -inpt.v.normal);
vec4 color = diffuseColor;
vec4 Cf = lighting(color, inpt.v.position.xyz, N);
#if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE)
Cf = edgeColor(Cf, inpt.edgeDistance);
#endif
outColor = Cf;
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -30,37 +30,37 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_glfw_executable(glBatchViewer
viewer.cpp
delegate.cpp
effect.cpp
effectRegistry.cpp
${SHADER_FILES}
${INC_FILES}
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -68,4 +68,4 @@ target_link_libraries(glBatchViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS glBatchViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS glBatchViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -25,28 +25,28 @@
# *** glStencilViewer ***
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
_add_glfw_executable(glStencilViewer
main.cpp
${INC_FILES}
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -54,4 +54,4 @@ target_link_libraries(glStencilViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS glStencilViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS glStencilViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -30,34 +30,34 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_glfw_executable(glViewer
viewer.cpp
${SHADER_FILES}
${INC_FILES}
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -65,4 +65,4 @@ target_link_libraries(glViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS glViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS glViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -25,28 +25,28 @@
# *** glViewer ***
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
_add_glfw_executable(limitEval
main.cpp
${INC_FILES}
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -54,4 +54,4 @@ target_link_libraries(limitEval
${PLATFORM_LIBRARIES}
)
install(TARGETS limitEval DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS limitEval DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -82,7 +82,7 @@ typedef HbrHalfedge<OsdVertex> OsdHbrHalfedge;
typedef FarMesh<OsdVertex> OsdFarMesh;
typedef FarMeshFactory<OsdVertex> OsdFarMeshFactory;
typedef FarSubdivisionTables<OsdVertex> OsdFarMeshSubdivision;
typedef FarSubdivisionTables OsdFarMeshSubdivision;
//------------------------------------------------------------------------------
struct SimpleShape {
@ -518,7 +518,7 @@ createOsdMesh( const std::string &shape, int level, Scheme scheme=kCatmark ) {
// Create a Compute context, used to "pose" the vertices
delete g_computeCtx;
g_computeCtx = OsdCpuComputeContext::Create(g_fmesh);
g_computeCtx = OsdCpuComputeContext::Create(g_fmesh->GetSubdivisionTables(), g_fmesh->GetVertexEditTables());
g_computeCtrl.Refine( g_computeCtx, g_fmesh->GetKernelBatches(), g_vertexData, g_varyingData );
@ -526,7 +526,7 @@ createOsdMesh( const std::string &shape, int level, Scheme scheme=kCatmark ) {
// Create eval context & data buffers
delete g_evalCtx;
g_evalCtx = OsdCpuEvalLimitContext::Create(g_fmesh, /*requireFVarData*/ true);
g_evalCtx = OsdCpuEvalLimitContext::Create(g_fmesh->GetPatchTables(), /*requireFVarData*/ true);
delete g_Q;
g_Q = OsdCpuGLVertexBuffer::Create(6,nsamples);

View File

@ -37,16 +37,16 @@ if(NOT MAYA_FOUND OR NOT PTEX_FOUND)
endif()
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLEW_LIBRARY}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLEW_LIBRARY}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${MAYA_INCLUDE_DIRS}
${GLEW_INCLUDE_DIR}
${PTEX_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${MAYA_INCLUDE_DIRS}"
"${GLEW_INCLUDE_DIR}"
"${PTEX_INCLUDE_DIR}"
)
set(SHADER_FILES
@ -93,11 +93,8 @@ endif(WIN32)
#-------------------------------------------------------------------------------
# CUDA code & dependencies
if( CUDA_FOUND )
list(APPEND SOURCE_FILES
cudaUtil.cpp
)
include_directories( ${CUDA_INCLUDE_DIRS}
)
list(APPEND SOURCE_FILES cudaUtil.cpp)
include_directories( ${CUDA_INCLUDE_DIRS} )
endif()
#-------------------------------------------------------------------------------
@ -115,10 +112,10 @@ foreach(shader_file ${SHADER_FILES})
list(APPEND INC_FILES ${inc_file})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}
COMMAND stringify ${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}
${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}
DEPENDS stringify ${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}"
COMMAND stringify "${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}"
"${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}"
DEPENDS stringify "${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}"
)
endforeach()
@ -128,10 +125,10 @@ add_definitions(
)
add_library(maya_ptex_plugin SHARED
${SOURCE_FILES}
${HEADER_FILES}
${SHADER_FILES}
${INC_FILES}
"${SOURCE_FILES}"
"${HEADER_FILES}"
"${SHADER_FILES}"
"${INC_FILES}"
)
set_target_properties(maya_ptex_plugin
@ -143,11 +140,11 @@ set_target_properties(maya_ptex_plugin
)
target_link_libraries(maya_ptex_plugin
${MAYA_Foundation_LIBRARY}
${MAYA_OpenMaya_LIBRARY}
${MAYA_OpenMayaRender_LIBRARY}
${MAYA_OpenMayaUI_LIBRARY}
${PLATFORM_LIBRARIES}
"${MAYA_Foundation_LIBRARY}"
"${MAYA_OpenMaya_LIBRARY}"
"${MAYA_OpenMayaRender_LIBRARY}"
"${MAYA_OpenMayaUI_LIBRARY}"
"${PLATFORM_LIBRARIES}"
)
install(TARGETS maya_ptex_plugin DESTINATION ${CMAKE_PLUGINDIR_BASE})
install(TARGETS maya_ptex_plugin DESTINATION "${CMAKE_PLUGINDIR_BASE}")

View File

@ -37,15 +37,15 @@ if(NOT MAYA_FOUND)
endif()
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLEW_LIBRARY}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLEW_LIBRARY}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${MAYA_INCLUDE_DIRS}
${GLEW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${MAYA_INCLUDE_DIRS}"
"${GLEW_INCLUDE_DIR}"
)
set(SHADER_FILES
@ -92,11 +92,8 @@ endif(WIN32)
#-------------------------------------------------------------------------------
# CUDA code & dependencies
if( CUDA_FOUND )
list(APPEND SOURCE_FILES
cudaUtil.cpp
)
include_directories( ${CUDA_INCLUDE_DIRS}
)
list(APPEND SOURCE_FILES cudaUtil.cpp)
include_directories(${CUDA_INCLUDE_DIRS})
endif()
#-------------------------------------------------------------------------------
@ -114,10 +111,10 @@ foreach(shader_file ${SHADER_FILES})
list(APPEND INC_FILES ${inc_file})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}
COMMAND stringify ${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}
${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}
DEPENDS stringify ${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}"
COMMAND stringify "${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}"
"${CMAKE_CURRENT_SOURCE_DIR}/${inc_file}"
DEPENDS stringify "${CMAKE_CURRENT_SOURCE_DIR}/${shader_file}"
)
endforeach()
@ -127,10 +124,10 @@ add_definitions(
)
add_library(maya_plugin SHARED
${SOURCE_FILES}
${HEADER_FILES}
${SHADER_FILES}
${INC_FILES}
"${SOURCE_FILES}"
"${HEADER_FILES}"
"${SHADER_FILES}"
"${INC_FILES}"
)
set_target_properties(maya_plugin
@ -142,11 +139,11 @@ set_target_properties(maya_plugin
)
target_link_libraries(maya_plugin
${MAYA_Foundation_LIBRARY}
${MAYA_OpenMaya_LIBRARY}
${MAYA_OpenMayaRender_LIBRARY}
${MAYA_OpenMayaUI_LIBRARY}
${PLATFORM_LIBRARIES}
"${MAYA_Foundation_LIBRARY}"
"${MAYA_OpenMaya_LIBRARY}"
"${MAYA_OpenMayaRender_LIBRARY}"
"${MAYA_OpenMayaUI_LIBRARY}"
"${PLATFORM_LIBRARIES}"
)
install(TARGETS maya_plugin DESTINATION ${CMAKE_PLUGINDIR_BASE})
install(TARGETS maya_plugin DESTINATION "${CMAKE_PLUGINDIR_BASE}")

View File

@ -37,12 +37,12 @@ if(NOT MAYA_FOUND)
endif()
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
"${OSD_LINK_TARGET}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${MAYA_INCLUDE_DIRS}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${MAYA_INCLUDE_DIRS}"
)
set(SOURCE_FILES
@ -96,27 +96,27 @@ set_target_properties(maya_polySmoothNode
)
target_link_libraries(maya_polySmoothNode
${MAYA_Foundation_LIBRARY}
${MAYA_OpenMaya_LIBRARY}
${MAYA_OpenMayaRender_LIBRARY}
${MAYA_OpenMayaUI_LIBRARY}
"${MAYA_Foundation_LIBRARY}"
"${MAYA_OpenMaya_LIBRARY}"
"${MAYA_OpenMayaRender_LIBRARY}"
"${MAYA_OpenMayaUI_LIBRARY}"
${PLATFORM_LIBRARIES}
)
install(TARGETS maya_polySmoothNode DESTINATION ${CMAKE_PLUGINDIR_BASE})
install(TARGETS maya_polySmoothNode DESTINATION "${CMAKE_PLUGINDIR_BASE}")
add_custom_target(maya_polySmoothNode_melScripts
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/osdPolySmooth.mel ${CMAKE_BINARY_DIR}/${CMAKE_LIBDIR_BASE}
${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/osdPolySmooth.mel" "${CMAKE_BINARY_DIR}/${CMAKE_LIBDIR_BASE}"
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/osdPolySmooth.mel
"${CMAKE_CURRENT_SOURCE_DIR}/osdPolySmooth.mel"
)
install(
FILES
${CMAKE_BINARY_DIR}/${CMAKE_LIBDIR_BASE}/osdPolySmooth.mel
"${CMAKE_BINARY_DIR}/${CMAKE_LIBDIR_BASE}/osdPolySmooth.mel"
DESTINATION
${CMAKE_PLUGINDIR_BASE}
"${CMAKE_PLUGINDIR_BASE}"
)
add_custom_target(osdPolySmoothNode

View File

@ -523,7 +523,7 @@ MStatus convertOsdFarToMayaMeshData(
int numPolygons = farPatchTables->GetNumFaces(); // use the highest level stored in the patch tables
const unsigned int *polygonConnects_orig = farPatchTables->GetFaceVertices(); // use the highest level stored in the patch tables
const OpenSubdiv::FarSubdivisionTables<OpenSubdiv::OsdVertex> *farSubdivTables = farMesh->GetSubdivisionTables();
const OpenSubdiv::FarSubdivisionTables *farSubdivTables = farMesh->GetSubdivisionTables();
unsigned int numVertices = farSubdivTables->GetNumVertices(subdivisionLevel);
unsigned int vertexOffset = farSubdivTables->GetFirstVertexOffset(subdivisionLevel);
@ -568,7 +568,7 @@ MStatus convertOsdFarToMayaMeshData(
// Attach UVs (if present)
// ASSUMPTION: Only tracking UVs as FVar data. Will need to change this
// ASSUMPTION: OSD has a unique UV for each face-vertex
int fvarTotalWidth = farMesh->GetTotalFVarWidth();
int fvarTotalWidth = farMesh->GetPatchTables()->GetFVarData().GetFVarWidth();
if (fvarTotalWidth > 0) {
@ -584,8 +584,8 @@ MStatus convertOsdFarToMayaMeshData(
int expectedFvarTotalWidth = numUVSets*2 + totalColorSetChannels;
assert(fvarTotalWidth == expectedFvarTotalWidth);
const OpenSubdiv::FarPatchTables::FVarDataTable &fvarDataTable = farPatchTables->GetFVarDataTable();
if (fvarDataTable.size() != expectedFvarTotalWidth*faceConnects.length()) {
std::vector<float> const &fvarData = farPatchTables->GetFVarData().GetAllData();
if (fvarData.size() != expectedFvarTotalWidth*faceConnects.length()) {
MCHECKERR(MS::kFailure, "Incorrect face-varying table length");
}
@ -602,8 +602,8 @@ MStatus convertOsdFarToMayaMeshData(
for(unsigned int vertid=0; vertid < faceConnects.length(); vertid++) {
int fvarItem = vertid*fvarTotalWidth + uvSetIndex*2; // stride per vertex is the fvarTotalWidth
uCoord[vertid] = fvarDataTable[fvarItem];
vCoord[vertid] = fvarDataTable[fvarItem+1];
uCoord[vertid] = fvarData[fvarItem];
vCoord[vertid] = fvarData[fvarItem+1];
}
// Assign UV buffer and map the uvids for each face-vertex
if (uvSetIndex > 0) {
@ -629,7 +629,7 @@ MStatus convertOsdFarToMayaMeshData(
int fvarItem = vertid*fvarTotalWidth + colorSetRelativeStartIndex;
int nchannels = colorSetChannels[colorSetIndex];
for (int channel=0; channel<nchannels; ++channel) {
colorArray[vertid][channel] = fvarDataTable[fvarItem+channel];
colorArray[vertid][channel] = fvarData[fvarItem+channel];
}
}
@ -843,7 +843,7 @@ MStatus OsdPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
static OpenSubdiv::OsdCpuComputeController computeController = OpenSubdiv::OsdCpuComputeController();
OpenSubdiv::OsdCpuComputeController::ComputeContext *computeContext =
OpenSubdiv::OsdCpuComputeController::ComputeContext::Create(farMesh);
OpenSubdiv::OsdCpuComputeController::ComputeContext::Create(farMesh->GetSubdivisionTables(), farMesh->GetVertexEditTables());
OpenSubdiv::OsdCpuVertexBuffer *vertexBuffer =
OpenSubdiv::OsdCpuVertexBuffer::Create(numVertexElements, numFarVerts );

View File

@ -30,31 +30,31 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLEW_LIBRARY}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLEW_LIBRARY}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLEW_INCLUDE_DIR}
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLEW_INCLUDE_DIR}"
"${GLFW_INCLUDE_DIR}"
)
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_glfw_executable(paintTest
main.cpp
${SHADER_FILES}
${INC_FILES}
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -62,4 +62,4 @@ target_link_libraries(paintTest
${PLATFORM_LIBRARIES}
)
install(TARGETS paintTest DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS paintTest DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -32,10 +32,10 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
${PTEX_LIBRARY}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLFW_LIBRARIES}"
"${PTEX_LIBRARY}"
)
if (APPLE)
@ -43,26 +43,26 @@ if (APPLE)
endif()
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
${PTEX_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
"${PTEX_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
# optional dependency - enables screenshots
find_package(PNG)
if (PNG_FOUND)
include_directories(${PNG_INCLUDE_DIRS})
list(APPEND PLATFORM_LIBRARIES ${PNG_LIBRARIES})
include_directories("${PNG_INCLUDE_DIRS}")
list(APPEND PLATFORM_LIBRARIES "${PNG_LIBRARIES}")
add_definitions(-DOPENSUBDIV_HAS_PNG)
endif()
@ -70,13 +70,13 @@ endif()
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
#-------------------------------------------------------------------------------
_add_glfw_executable(ptexViewer
viewer.cpp
${SHADER_FILES}
${INC_FILES}
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -84,4 +84,4 @@ target_link_libraries(ptexViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS ptexViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS ptexViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -29,27 +29,27 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
#-------------------------------------------------------------------------------
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_glfw_executable(simpleCpu
main.cpp
@ -62,5 +62,5 @@ target_link_libraries(simpleCpu
${PLATFORM_LIBRARIES}
)
install(TARGETS simpleCpu DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS simpleCpu DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -338,7 +338,8 @@ createOsdContext(int level)
g_farmesh = meshFactory.Create();
g_osdComputeContext = OpenSubdiv::OsdCpuComputeContext::Create(g_farmesh);
g_osdComputeContext = OpenSubdiv::OsdCpuComputeContext::Create(
g_farmesh->GetSubdivisionTables(), g_farmesh->GetVertexEditTables());
delete hmesh;

View File

@ -56,11 +56,11 @@
#
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
"${OSD_LINK_TARGET}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
"${PROJECT_SOURCE_DIR}/opensubdiv"
)
_add_executable(tessellateObjFile
@ -73,5 +73,5 @@ target_link_libraries(tessellateObjFile
${PLATFORM_LIBRARIES}
)
install(TARGETS tessellateObjFile DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS tessellateObjFile DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -81,7 +81,7 @@ static bool
uniformTessellate(char *inputFile, char *outputFile, std::string *errorMessage)
{
PxOsdUtilSubdivTopology topology;
OsdUtilSubdivTopology topology;
std::vector<float> pointPositions;
if (not topology.ReadFromObjFile(inputFile, &pointPositions, errorMessage)) {
@ -90,7 +90,7 @@ uniformTessellate(char *inputFile, char *outputFile, std::string *errorMessage)
topology.refinementLevel = 2;
PxOsdUtilUniformEvaluator uniformEvaluator;
OsdUtilUniformEvaluator uniformEvaluator;
// Create uniformEvaluator
if (not uniformEvaluator.Initialize(topology, errorMessage)) {
@ -107,7 +107,7 @@ uniformTessellate(char *inputFile, char *outputFile, std::string *errorMessage)
return false;
}
PxOsdUtilSubdivTopology refinedTopology;
OsdUtilSubdivTopology refinedTopology;
const float *positions = NULL;
if (not uniformEvaluator.GetRefinedTopology(
@ -129,7 +129,7 @@ static bool
blenderStyleTessellate(char *inputFile, char *outputFile, std::string *errorMessage)
{
PxOsdUtilSubdivTopology topology;
OsdUtilSubdivTopology topology;
std::vector<float> pointPositions;
if (not topology.ReadFromObjFile(inputFile, &pointPositions, errorMessage)) {
@ -138,7 +138,7 @@ blenderStyleTessellate(char *inputFile, char *outputFile, std::string *errorMess
topology.refinementLevel = 5;
PxOsdUtilAdaptiveEvaluator adaptiveEvaluator;
OsdUtilAdaptiveEvaluator adaptiveEvaluator;
// Create adaptiveEvaluator
if (not adaptiveEvaluator.Initialize(topology, errorMessage)) {
@ -156,7 +156,7 @@ blenderStyleTessellate(char *inputFile, char *outputFile, std::string *errorMess
return false;
}
PxOsdUtilSubdivTopology refinedTopology;
OsdUtilSubdivTopology refinedTopology;
std::vector<float> positions;
if (not adaptiveEvaluator.GetRefinedTopology(

View File

@ -29,36 +29,36 @@ set(SHADER_FILES
)
set(PLATFORM_LIBRARIES
${OSD_LINK_TARGET}
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
"${OSD_LINK_TARGET}"
"${OPENGL_LIBRARY}"
"${GLFW_LIBRARIES}"
)
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
${PROJECT_SOURCE_DIR}/regression
${GLFW_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/opensubdiv"
"${PROJECT_SOURCE_DIR}/regression"
"${GLFW_INCLUDE_DIR}"
)
if ( GLEW_FOUND )
include_directories(${GLEW_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
endif()
if( OPENCL_FOUND )
include_directories(${OPENCL_INCLUDE_DIRS})
include_directories("${OPENCL_INCLUDE_DIRS}")
endif()
#-------------------------------------------------------------------------------
_stringify("${SHADER_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
_add_glfw_executable(uvViewer
viewer.cpp
${SHADER_FILES}
${INC_FILES}
"${SHADER_FILES}"
"${INC_FILES}"
$<TARGET_OBJECTS:examples_common_obj>
)
@ -66,4 +66,4 @@ target_link_libraries(uvViewer
${PLATFORM_LIBRARIES}
)
install(TARGETS uvViewer DESTINATION ${CMAKE_BINDIR_BASE})
install(TARGETS uvViewer DESTINATION "${CMAKE_BINDIR_BASE}")

View File

@ -35,5 +35,9 @@ add_subdirectory(osd)
add_subdirectory(osdutil)
install( FILES version.h
DESTINATION ${CMAKE_INCDIR_BASE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
DESTINATION
"${CMAKE_INCDIR_BASE}"
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ )

View File

@ -24,18 +24,14 @@
#-------------------------------------------------------------------------------
set(PUBLIC_HEADER_FILES
bilinearSubdivisionTables.h
bilinearSubdivisionTablesFactory.h
catmarkSubdivisionTables.h
catmarkSubdivisionTablesFactory.h
dispatcher.h
kernelBatch.h
kernelBatchFactory.h
loopSubdivisionTables.h
loopSubdivisionTablesFactory.h
meshFactory.h
mesh.h
multiMeshFactory.h
patchParam.h
patchMap.h
patchTables.h
@ -51,8 +47,14 @@ set(PUBLIC_HEADER_FILES
#-------------------------------------------------------------------------------
_add_doxy_headers( "${PUBLIC_HEADER_FILES}" )
install( FILES ${PUBLIC_HEADER_FILES}
DESTINATION ${CMAKE_INCDIR_BASE}/far
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
install(
FILES
${PUBLIC_HEADER_FILES}
DESTINATION
"${CMAKE_INCDIR_BASE}/far"
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ )
#-------------------------------------------------------------------------------

View File

@ -1,163 +0,0 @@
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef FAR_BILINEAR_SUBDIVISION_TABLES_H
#define FAR_BILINEAR_SUBDIVISION_TABLES_H
#include "../version.h"
#include "../far/subdivisionTables.h"
#include <cassert>
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
/// \brief Bilinear subdivision scheme tables.
///
/// Bilinear tables store the indexing tables required in order to compute
/// the refined positions of a mesh without the help of a hierarchical data
/// structure. The advantage of this representation is its ability to be executed
/// in a massively parallel environment without data dependencies.
///
template <class U> class FarBilinearSubdivisionTables : public FarSubdivisionTables<U> {
public:
/// \brief Returns the number of indexing tables needed to represent this
/// particular subdivision scheme.
virtual int GetNumTables() const { return 7; }
/// \brief Returns the subdivision scheme of the tables
virtual typename FarSubdivisionTables<U>::Scheme GetScheme() const {
return FarSubdivisionTables<U>::BILINEAR;
}
private:
template <class X, class Y> friend class FarBilinearSubdivisionTablesFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
template <class CONTROLLER> friend class FarComputeController;
FarBilinearSubdivisionTables( FarMesh<U> * mesh, int maxlevel );
// Compute-kernel applied to vertices resulting from the refinement of a face.
void computeFacePoints(int vertexOffset, int tableOffset, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of an edge.
void computeEdgePoints(int vertexOffset, int tableOffset, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
void computeVertexPoints(int vertexOffset, int tableOffset, int start, int end, void * clientdata) const;
};
template <class U>
FarBilinearSubdivisionTables<U>::FarBilinearSubdivisionTables( FarMesh<U> * mesh, int maxlevel ) :
FarSubdivisionTables<U>(mesh, maxlevel)
{ }
//
// Face-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarBilinearSubdivisionTables<U>::computeFacePoints( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int h = this->_F_ITa[2*i ],
n = this->_F_ITa[2*i+1];
float weight = 1.0f/n;
for (int j=0; j<n; ++j) {
vdst->AddWithWeight( vsrc[ this->_F_IT[h+j] ], weight, clientdata );
vdst->AddVaryingWithWeight( vsrc[ this->_F_IT[h+j] ], weight, clientdata );
}
}
}
//
// Edge-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarBilinearSubdivisionTables<U>::computeEdgePoints( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int eidx0 = this->_E_IT[2*i+0],
eidx1 = this->_E_IT[2*i+1];
vdst->AddWithWeight( vsrc[eidx0], 0.5f, clientdata );
vdst->AddWithWeight( vsrc[eidx1], 0.5f, clientdata );
vdst->AddVaryingWithWeight( vsrc[eidx0], 0.5f, clientdata );
vdst->AddVaryingWithWeight( vsrc[eidx1], 0.5f, clientdata );
}
}
//
// Vertex-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarBilinearSubdivisionTables<U>::computeVertexPoints( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int p = this->_V_ITa[i]; // index of the parent vertex
vdst->AddWithWeight( vsrc[p], 1.0f, clientdata );
vdst->AddVaryingWithWeight( vsrc[p], 1.0f, clientdata );
}
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* FAR_BILINEAR_SUBDIVISION_TABLES_H */

View File

@ -27,7 +27,7 @@
#include "../version.h"
#include "../far/bilinearSubdivisionTables.h"
#include "../far/subdivisionTables.h"
#include "../far/meshFactory.h"
#include "../far/subdivisionTablesFactory.h"
@ -39,7 +39,7 @@ namespace OPENSUBDIV_VERSION {
template <class T, class U> class FarMeshFactory;
/// \brief A specialized factory for FarBilinearSubdivisionTables
/// \brief A specialized factory for bilinear FarSubdivisionTables
///
/// Separating the factory allows us to isolate Far data structures from Hbr dependencies.
///
@ -47,25 +47,23 @@ template <class T, class U> class FarBilinearSubdivisionTablesFactory {
protected:
template <class X, class Y> friend class FarMeshFactory;
/// \brief Creates a FarBilinearSubdivisiontables instance.
/// \brief Creates a FarSubdivisiontables instance.
///
/// @param meshFactory a valid FarMeshFactory instance
///
/// @param farMesh
///
/// @param batches a vector of Kernel refinement batches : the factory
/// will reserve and append refinement tasks
///
static FarBilinearSubdivisionTables<U> * Create( FarMeshFactory<T,U> * meshFactory, FarMesh<U> * farMesh, FarKernelBatchVector *batches );
static FarSubdivisionTables * Create( FarMeshFactory<T,U> * meshFactory, FarKernelBatchVector *batches );
};
// This factory walks the Hbr vertices and accumulates the weights and adjacency
// (valance) information specific to the bilinear subdivision scheme. The results
// are stored in a FarBilinearSubdivisionTable<U>
template <class T, class U> FarBilinearSubdivisionTables<U> *
FarBilinearSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory, FarMesh<U> * farMesh, FarKernelBatchVector * batches ) {
// are stored in a FarSubdivisionTable
template <class T, class U> FarSubdivisionTables *
FarBilinearSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory, FarKernelBatchVector * batches ) {
assert( meshFactory and farMesh );
assert( meshFactory );
int maxlevel = meshFactory->GetMaxLevel();
@ -73,7 +71,7 @@ FarBilinearSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFact
FarSubdivisionTablesFactory<T,U> tablesFactory( meshFactory->GetHbrMesh(), maxlevel, remap );
FarBilinearSubdivisionTables<U> * result = new FarBilinearSubdivisionTables<U>(farMesh, maxlevel);
FarSubdivisionTables * result = new FarSubdivisionTables(maxlevel, FarSubdivisionTables::BILINEAR);
// Allocate memory for the indexing tables
result->_F_ITa.resize(tablesFactory.GetNumFaceVerticesTotal(maxlevel)*2);

View File

@ -1,236 +0,0 @@
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef FAR_CATMARK_SUBDIVISION_TABLES_H
#define FAR_CATMARK_SUBDIVISION_TABLES_H
#include "../version.h"
#include "../far/subdivisionTables.h"
#include <cassert>
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
/// \brief Catmark subdivision scheme tables.
///
/// Catmull-Clark tables store the indexing tables required in order to compute
/// the refined positions of a mesh without the help of a hierarchical data
/// structure. The advantage of this representation is its ability to be executed
/// in a massively parallel environment without data dependencies.
///
template <class U> class FarCatmarkSubdivisionTables : public FarSubdivisionTables<U> {
public:
/// \brief Returns the number of indexing tables needed to represent this
/// particular subdivision scheme.
virtual int GetNumTables() const { return 7; }
/// \brief Returns the subdivision scheme of the tables
virtual typename FarSubdivisionTables<U>::Scheme GetScheme() const {
return FarSubdivisionTables<U>::CATMARK;
}
private:
template <class X, class Y> friend class FarCatmarkSubdivisionTablesFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
template <class CONTROLLER> friend class FarComputeController;
// Private constructor called by factory
FarCatmarkSubdivisionTables( FarMesh<U> * mesh, int maxlevel );
// Compute-kernel applied to vertices resulting from the refinement of a face.
void computeFacePoints(int offset, int level, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of an edge.
void computeEdgePoints(int offset, int level, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "A" Handles the k_Smooth and k_Dart rules
void computeVertexPointsA(int offset, bool pass, int level, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "B" Handles the k_Crease and k_Corner rules
void computeVertexPointsB(int offset, int level, int start, int end, void * clientdata) const;
};
template <class U>
FarCatmarkSubdivisionTables<U>::FarCatmarkSubdivisionTables( FarMesh<U> * mesh, int maxlevel ) :
FarSubdivisionTables<U>(mesh, maxlevel)
{ }
//
// Face-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarCatmarkSubdivisionTables<U>::computeFacePoints( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int h = this->_F_ITa[2*i ],
n = this->_F_ITa[2*i+1];
float weight = 1.0f/n;
for (int j=0; j<n; ++j) {
vdst->AddWithWeight( vsrc[ this->_F_IT[h+j] ], weight, clientdata );
vdst->AddVaryingWithWeight( vsrc[ this->_F_IT[h+j] ], weight, clientdata );
}
}
}
//
// Edge-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarCatmarkSubdivisionTables<U>::computeEdgePoints( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int eidx0 = this->_E_IT[4*i+0],
eidx1 = this->_E_IT[4*i+1],
eidx2 = this->_E_IT[4*i+2],
eidx3 = this->_E_IT[4*i+3];
float vertWeight = this->_E_W[i*2+0];
// Fully sharp edge : vertWeight = 0.5f
vdst->AddWithWeight( vsrc[eidx0], vertWeight, clientdata );
vdst->AddWithWeight( vsrc[eidx1], vertWeight, clientdata );
if (eidx2!=-1) {
// Apply fractional sharpness
float faceWeight = this->_E_W[i*2+1];
vdst->AddWithWeight( vsrc[eidx2], faceWeight, clientdata );
vdst->AddWithWeight( vsrc[eidx3], faceWeight, clientdata );
}
vdst->AddVaryingWithWeight( vsrc[eidx0], 0.5f, clientdata );
vdst->AddVaryingWithWeight( vsrc[eidx1], 0.5f, clientdata );
}
}
//
// Vertex-vertices compute Kernels "A" and "B" - completely re-entrant
//
// multi-pass kernel handling k_Crease and k_Corner rules
template <class U> void
FarCatmarkSubdivisionTables<U>::computeVertexPointsA( int offset, bool pass, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
if (not pass)
vdst->Clear(clientdata);
int n=this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p=this->_V_ITa[5*i+2], // index of the parent vertex
eidx0=this->_V_ITa[5*i+3], // index of the first crease rule edge
eidx1=this->_V_ITa[5*i+4]; // index of the second crease rule edge
float weight = pass ? this->_V_W[i] : 1.0f - this->_V_W[i];
// In the case of fractional weight, the weight must be inverted since
// the value is shared with the k_Smooth kernel (statistically the
// k_Smooth kernel runs much more often than this one)
if (weight>0.0f and weight<1.0f and n>0)
weight=1.0f-weight;
// In the case of a k_Corner / k_Crease combination, the edge indices
// won't be null, so we use a -1 valence to detect that particular case
if (eidx0==-1 or (pass==false and (n==-1)) ) {
// k_Corner case
vdst->AddWithWeight( vsrc[p], weight, clientdata );
} else {
// k_Crease case
vdst->AddWithWeight( vsrc[p], weight * 0.75f, clientdata );
vdst->AddWithWeight( vsrc[eidx0], weight * 0.125f, clientdata );
vdst->AddWithWeight( vsrc[eidx1], weight * 0.125f, clientdata );
}
vdst->AddVaryingWithWeight( vsrc[p], 1.0f, clientdata );
}
}
// multi-pass kernel handling k_Dart and k_Smooth rules
template <class U> void
FarCatmarkSubdivisionTables<U>::computeVertexPointsB( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int h = this->_V_ITa[5*i ], // offset of the vertices in the _V0_IT array
n = this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p = this->_V_ITa[5*i+2]; // index of the parent vertex
float weight = this->_V_W[i],
wp = 1.0f/(n*n),
wv = (n-2.0f)*n*wp;
vdst->AddWithWeight( vsrc[p], weight * wv, clientdata );
for (int j=0; j<n; ++j) {
vdst->AddWithWeight( vsrc[this->_V_IT[h+j*2 ]], weight * wp, clientdata );
vdst->AddWithWeight( vsrc[this->_V_IT[h+j*2+1]], weight * wp, clientdata );
}
vdst->AddVaryingWithWeight( vsrc[p], 1.0f, clientdata );
}
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* FAR_CATMARK_SUBDIVISION_TABLES_H */

View File

@ -30,7 +30,7 @@
#include "../version.h"
#include "../far/catmarkSubdivisionTables.h"
#include "../far/subdivisionTables.h"
#include "../far/meshFactory.h"
#include "../far/kernelBatchFactory.h"
#include "../far/subdivisionTablesFactory.h"
@ -40,7 +40,7 @@ namespace OPENSUBDIV_VERSION {
template <class T, class U> class FarMeshFactory;
/// \brief A specialized factory for FarCatmarkSubdivisionTables
/// \brief A specialized factory for catmark FarSubdivisionTables
///
/// Separating the factory allows us to isolate Far data structures from Hbr dependencies.
///
@ -48,25 +48,23 @@ template <class T, class U> class FarCatmarkSubdivisionTablesFactory {
protected:
template <class X, class Y> friend class FarMeshFactory;
/// \brief Creates a FarCatmarkSubdivisiontables instance.
/// \brief Creates a FarSubdivisiontables instance with Catmark scheme.
///
/// @param meshFactory a valid FarMeshFactory instance
///
/// @param farMesh
///
/// @param batches a vector of Kernel refinement batches : the factory
/// will reserve and append refinement tasks
///
static FarCatmarkSubdivisionTables<U> * Create( FarMeshFactory<T,U> * meshFactory, FarMesh<U> * farMesh, FarKernelBatchVector *batches );
static FarSubdivisionTables * Create( FarMeshFactory<T,U> * meshFactory, FarKernelBatchVector *batches );
};
// This factory walks the Hbr vertices and accumulates the weights and adjacency
// (valance) information specific to the catmark subdivision scheme. The results
// are stored in a FarCatmarkSubdivisionTable<U>.
template <class T, class U> FarCatmarkSubdivisionTables<U> *
FarCatmarkSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory, FarMesh<U> * farMesh, FarKernelBatchVector *batches ) {
// are stored in a FarSubdivisionTable.
template <class T, class U> FarSubdivisionTables *
FarCatmarkSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory, FarKernelBatchVector *batches ) {
assert( meshFactory and farMesh );
assert( meshFactory );
int maxlevel = meshFactory->GetMaxLevel();
@ -74,7 +72,7 @@ FarCatmarkSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFacto
FarSubdivisionTablesFactory<T,U> tablesFactory( meshFactory->GetHbrMesh(), maxlevel, remap );
FarCatmarkSubdivisionTables<U> * result = new FarCatmarkSubdivisionTables<U>(farMesh, maxlevel);
FarSubdivisionTables * result = new FarSubdivisionTables(maxlevel, FarSubdivisionTables::CATMARK);
// Allocate memory for the indexing tables
result->_F_ITa.resize(tablesFactory.GetNumFaceVerticesTotal(maxlevel)*2);

View File

@ -27,10 +27,7 @@
#include "../version.h"
#include "../far/mesh.h"
#include "../far/bilinearSubdivisionTables.h"
#include "../far/catmarkSubdivisionTables.h"
#include "../far/loopSubdivisionTables.h"
#include "../far/subdivisionTables.h"
#include "../far/vertexEditTables.h"
#include "../far/kernelBatch.h"
@ -54,72 +51,98 @@ namespace OPENSUBDIV_VERSION {
///
class FarDispatcher {
public:
/// \brief Launches the processing of a vector of kernel batches
/// \brief Launches the processing of a kernel batch
/// returns true if the batch is handled, otherwise returns false (i.e. user defined kernel)
///
/// @param controller refinement controller implementation
///
/// @param context refinement context implementation
///
/// @param batch a batch of kernel that need to be processed
///
template <class CONTROLLER, class CONTEXT>
static bool ApplyKernel(CONTROLLER const *controller, CONTEXT *context, FarKernelBatch const &batch);
/// \brief Launches the processing of a vector of kernel batches
/// this is a convenient API for controllers which don't have any user defined kernels.
///
/// @param controller refinement controller implementation
///
/// @param context refinement context implementation (vertex array and subdivision tables)
/// passed to the controller.
///
/// @param batches batches of kernels that need to be processed
///
/// @param maxlevel process vertex batches up to this level
///
/// @param clientdata custom client data passed to the controller
///
template <class CONTROLLER>
static void Refine(CONTROLLER const *controller, FarKernelBatchVector const & batches, int maxlevel, void * clientdata=0);
template <class CONTROLLER, class CONTEXT>
static void Refine(CONTROLLER const *controller, CONTEXT *context, FarKernelBatchVector const & batches, int maxlevel);
};
template <class CONTROLLER> void
FarDispatcher::Refine(CONTROLLER const *controller, FarKernelBatchVector const & batches, int maxlevel, void * clientdata) {
template <class CONTROLLER, class CONTEXT> bool
FarDispatcher::ApplyKernel(CONTROLLER const *controller, CONTEXT *context, FarKernelBatch const &batch) {
switch(batch.GetKernelType()) {
case FarKernelBatch::CATMARK_FACE_VERTEX:
controller->ApplyCatmarkFaceVerticesKernel(batch, context);
break;
case FarKernelBatch::CATMARK_EDGE_VERTEX:
controller->ApplyCatmarkEdgeVerticesKernel(batch, context);
break;
case FarKernelBatch::CATMARK_VERT_VERTEX_B:
controller->ApplyCatmarkVertexVerticesKernelB(batch, context);
break;
case FarKernelBatch::CATMARK_VERT_VERTEX_A1:
controller->ApplyCatmarkVertexVerticesKernelA1(batch, context);
break;
case FarKernelBatch::CATMARK_VERT_VERTEX_A2:
controller->ApplyCatmarkVertexVerticesKernelA2(batch, context);
break;
case FarKernelBatch::LOOP_EDGE_VERTEX:
controller->ApplyLoopEdgeVerticesKernel(batch, context);
break;
case FarKernelBatch::LOOP_VERT_VERTEX_B:
controller->ApplyLoopVertexVerticesKernelB(batch, context);
break;
case FarKernelBatch::LOOP_VERT_VERTEX_A1:
controller->ApplyLoopVertexVerticesKernelA1(batch, context);
break;
case FarKernelBatch::LOOP_VERT_VERTEX_A2:
controller->ApplyLoopVertexVerticesKernelA2(batch, context);
break;
case FarKernelBatch::BILINEAR_FACE_VERTEX:
controller->ApplyBilinearFaceVerticesKernel(batch, context);
break;
case FarKernelBatch::BILINEAR_EDGE_VERTEX:
controller->ApplyBilinearEdgeVerticesKernel(batch, context);
break;
case FarKernelBatch::BILINEAR_VERT_VERTEX:
controller->ApplyBilinearVertexVerticesKernel(batch, context);
break;
case FarKernelBatch::HIERARCHICAL_EDIT:
controller->ApplyVertexEdits(batch, context);
break;
default: // user defined kernel type
return false;
}
return true;
}
template <class CONTROLLER, class CONTEXT> void
FarDispatcher::Refine(CONTROLLER const *controller, CONTEXT *context, FarKernelBatchVector const & batches, int maxlevel) {
for (int i = 0; i < (int)batches.size(); ++i) {
const FarKernelBatch &batch = batches[i];
if (maxlevel >= 0 && batch.GetLevel() >= maxlevel) continue;
switch(batch.GetKernelType()) {
case FarKernelBatch::CATMARK_FACE_VERTEX:
controller->ApplyCatmarkFaceVerticesKernel(batch, clientdata);
break;
case FarKernelBatch::CATMARK_EDGE_VERTEX:
controller->ApplyCatmarkEdgeVerticesKernel(batch, clientdata);
break;
case FarKernelBatch::CATMARK_VERT_VERTEX_B:
controller->ApplyCatmarkVertexVerticesKernelB(batch, clientdata);
break;
case FarKernelBatch::CATMARK_VERT_VERTEX_A1:
controller->ApplyCatmarkVertexVerticesKernelA1(batch, clientdata);
break;
case FarKernelBatch::CATMARK_VERT_VERTEX_A2:
controller->ApplyCatmarkVertexVerticesKernelA2(batch, clientdata);
break;
case FarKernelBatch::LOOP_EDGE_VERTEX:
controller->ApplyLoopEdgeVerticesKernel(batch, clientdata);
break;
case FarKernelBatch::LOOP_VERT_VERTEX_B:
controller->ApplyLoopVertexVerticesKernelB(batch, clientdata);
break;
case FarKernelBatch::LOOP_VERT_VERTEX_A1:
controller->ApplyLoopVertexVerticesKernelA1(batch, clientdata);
break;
case FarKernelBatch::LOOP_VERT_VERTEX_A2:
controller->ApplyLoopVertexVerticesKernelA2(batch, clientdata);
break;
case FarKernelBatch::BILINEAR_FACE_VERTEX:
controller->ApplyBilinearFaceVerticesKernel(batch, clientdata);
break;
case FarKernelBatch::BILINEAR_EDGE_VERTEX:
controller->ApplyBilinearEdgeVerticesKernel(batch, clientdata);
break;
case FarKernelBatch::BILINEAR_VERT_VERTEX:
controller->ApplyBilinearVertexVerticesKernel(batch, clientdata);
break;
case FarKernelBatch::HIERARCHICAL_EDIT:
controller->ApplyVertexEdits(batch, clientdata);
break;
}
ApplyKernel(controller, context, batch);
}
}
@ -129,265 +152,252 @@ FarDispatcher::Refine(CONTROLLER const *controller, FarKernelBatchVector const &
///
/// This is Far's default implementation of a kernal batch controller.
///
template <class U>
class FarComputeController {
public:
void Refine(FarMesh<U> * mesh, int maxlevel=-1) const;
template <class CONTEXT>
void Refine(CONTEXT * context, int maxlevel=-1) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const;
template <class CONTEXT>
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
template <class CONTEXT>
void ApplyVertexEdits(FarKernelBatch const &batch, CONTEXT *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
static FarComputeController _DefaultController;
private:
};
template<class U> FarComputeController<U> FarComputeController<U>::_DefaultController;
template <class CONTEXT> void
FarComputeController::Refine(CONTEXT *context, int maxlevel) const {
template <class U> void
FarComputeController<U>::Refine(FarMesh<U> *mesh, int maxlevel) const {
FarDispatcher::Refine(this, context, context->GetKernelBatches(), maxlevel);
FarDispatcher::Refine(this, mesh->GetKernelBatches(), maxlevel, mesh);
}
template <class U> void
FarComputeController<U>::ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarBilinearSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarBilinearSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeFacePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeBilinearFacePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarBilinearSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarBilinearSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeEdgePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeBilinearEdgePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarBilinearSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarBilinearSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeBilinearVertexPoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarCatmarkSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarCatmarkSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeFacePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeCatmarkFacePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarCatmarkSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarCatmarkSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeEdgePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeCatmarkEdgePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarCatmarkSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarCatmarkSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPointsB( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeCatmarkVertexPointsB( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarCatmarkSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarCatmarkSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPointsA( batch.GetVertexOffset(),
false,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeCatmarkVertexPointsA( batch.GetVertexOffset(),
false,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarCatmarkSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarCatmarkSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPointsA( batch.GetVertexOffset(),
true,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeCatmarkVertexPointsA( batch.GetVertexOffset(),
true,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarLoopSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarLoopSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeEdgePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeLoopEdgePoints( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarLoopSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarLoopSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPointsB( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeLoopVertexPointsB( batch.GetVertexOffset(),
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarLoopSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarLoopSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPointsA( batch.GetVertexOffset(),
false,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
subdivision->computeLoopVertexPointsA( batch.GetVertexOffset(),
false,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
FarLoopSubdivisionTables<U> const * subdivision =
reinterpret_cast<FarLoopSubdivisionTables<U> const *>(mesh->GetSubdivisionTables());
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarSubdivisionTables const * subdivision = context->GetSubdivisionTables();
assert(subdivision);
subdivision->computeVertexPointsA( batch.GetVertexOffset(),
true,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata);
subdivision->computeLoopVertexPointsA( batch.GetVertexOffset(),
true,
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
vsrc );
}
template <class U> void
FarComputeController<U>::ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const {
template <class CONTEXT> void
FarComputeController::ApplyVertexEdits(FarKernelBatch const &batch, CONTEXT *context) const {
FarMesh<U> * mesh = static_cast<FarMesh<U> *>(clientdata);
typename CONTEXT::VertexType *vsrc = &context->GetVertices().at(0);
FarVertexEditTables<U> const * vertEdit = mesh->GetVertexEdit();
FarVertexEditTables const * vertEdit = context->GetVertexEditTables();
if (vertEdit)
vertEdit->computeVertexEdits( batch.GetTableIndex(),
@ -395,7 +405,7 @@ FarComputeController<U>::ApplyVertexEdits(FarKernelBatch const &batch, void * cl
batch.GetTableOffset(),
batch.GetStart(),
batch.GetEnd(),
clientdata );
vsrc );
}
} // end namespace OPENSUBDIV_VERSION

View File

@ -65,7 +65,7 @@ class FarKernelBatch {
public:
enum KernelType {
CATMARK_FACE_VERTEX,
CATMARK_FACE_VERTEX = 1,
CATMARK_EDGE_VERTEX,
CATMARK_VERT_VERTEX_A1,
CATMARK_VERT_VERTEX_A2,
@ -78,6 +78,7 @@ public:
BILINEAR_EDGE_VERTEX,
BILINEAR_VERT_VERTEX,
HIERARCHICAL_EDIT,
USER_DEFINED_KERNEL_START
};
/// \brief Constructor.
@ -98,7 +99,7 @@ public:
///
/// @param meshIndex XXXX
///
FarKernelBatch( KernelType kernelType,
FarKernelBatch( int kernelType,
int level,
int tableIndex,
int start,
@ -117,7 +118,7 @@ public:
}
/// \brief Returns the type of kernel to apply to the vertices in the batch.
KernelType GetKernelType() const {
int GetKernelType() const {
return _kernelType;
}
@ -190,9 +191,9 @@ public:
private:
friend class FarKernelBatchFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
template <class X, class Y> friend class FarSubdivisionTablesFactory;
KernelType _kernelType;
int _kernelType;
int _level;
int _tableIndex;
int _start;

View File

@ -1,202 +0,0 @@
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef FAR_LOOP_SUBDIVISION_TABLES_H
#define FAR_LOOP_SUBDIVISION_TABLES_H
#include "../version.h"
#include "../far/subdivisionTables.h"
#include <cassert>
#include <cmath>
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
/// \brief Loop subdivision scheme tables.
///
/// Loop tables store the indexing tables required in order to compute
/// the refined positions of a mesh without the help of a hierarchical data
/// structure. The advantage of this representation is its ability to be executed
/// in a massively parallel environment without data dependencies.
///
template <class U> class FarLoopSubdivisionTables : public FarSubdivisionTables<U> {
public:
/// \brief Returns the subdivision scheme of the tables
virtual typename FarSubdivisionTables<U>::Scheme GetScheme() const {
return FarSubdivisionTables<U>::LOOP;
}
private:
template <class X, class Y> friend class FarLoopSubdivisionTablesFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
template <class CONTROLLER> friend class FarComputeController;
FarLoopSubdivisionTables( FarMesh<U> * mesh, int maxlevel );
// Compute-kernel applied to vertices resulting from the refinement of an edge.
void computeEdgePoints(int offset, int level, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "A" Handles the k_Smooth and k_Dart rules
void computeVertexPointsA(int offset, bool pass, int level, int start, int end, void * clientdata) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "B" Handles the k_Crease and k_Corner rules
void computeVertexPointsB(int offset,int level, int start, int end, void * clientdata) const;
};
template <class U>
FarLoopSubdivisionTables<U>::FarLoopSubdivisionTables( FarMesh<U> * mesh, int maxlevel ) :
FarSubdivisionTables<U>(mesh, maxlevel)
{ }
//
// Edge-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarLoopSubdivisionTables<U>::computeEdgePoints( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int eidx0 = this->_E_IT[4*i+0],
eidx1 = this->_E_IT[4*i+1],
eidx2 = this->_E_IT[4*i+2],
eidx3 = this->_E_IT[4*i+3];
float endPtWeight = this->_E_W[i*2+0];
// Fully sharp edge : endPtWeight = 0.5f
vdst->AddWithWeight( vsrc[eidx0], endPtWeight, clientdata );
vdst->AddWithWeight( vsrc[eidx1], endPtWeight, clientdata );
if (eidx2!=-1) {
// Apply fractional sharpness
float oppPtWeight = this->_E_W[i*2+1];
vdst->AddWithWeight( vsrc[eidx2], oppPtWeight, clientdata );
vdst->AddWithWeight( vsrc[eidx3], oppPtWeight, clientdata );
}
vdst->AddVaryingWithWeight( vsrc[eidx0], 0.5f, clientdata );
vdst->AddVaryingWithWeight( vsrc[eidx1], 0.5f, clientdata );
}
}
//
// Vertex-vertices compute Kernels "A" and "B" - completely re-entrant
//
// multi-pass kernel handling k_Crease and k_Corner rules
template <class U> void
FarLoopSubdivisionTables<U>::computeVertexPointsA( int offset, bool pass, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
if (not pass)
vdst->Clear(clientdata);
int n=this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p=this->_V_ITa[5*i+2], // index of the parent vertex
eidx0=this->_V_ITa[5*i+3], // index of the first crease rule edge
eidx1=this->_V_ITa[5*i+4]; // index of the second crease rule edge
float weight = pass ? this->_V_W[i] : 1.0f - this->_V_W[i];
// In the case of fractional weight, the weight must be inverted since
// the value is shared with the k_Smooth kernel (statistically the
// k_Smooth kernel runs much more often than this one)
if (weight>0.0f and weight<1.0f and n>0)
weight=1.0f-weight;
// In the case of a k_Corner / k_Crease combination, the edge indices
// won't be null, so we use a -1 valence to detect that particular case
if (eidx0==-1 or (pass==false and (n==-1)) ) {
// k_Corner case
vdst->AddWithWeight( vsrc[p], weight, clientdata );
} else {
// k_Crease case
vdst->AddWithWeight( vsrc[p], weight * 0.75f, clientdata );
vdst->AddWithWeight( vsrc[eidx0], weight * 0.125f, clientdata );
vdst->AddWithWeight( vsrc[eidx1], weight * 0.125f, clientdata );
}
vdst->AddVaryingWithWeight( vsrc[p], 1.0f, clientdata );
}
}
// multi-pass kernel handling k_Dart and k_Smooth rules
template <class U> void
FarLoopSubdivisionTables<U>::computeVertexPointsB( int offset, int tableOffset, int start, int end, void * clientdata ) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0),
* vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear(clientdata);
int h = this->_V_ITa[5*i ], // offset of the vertices in the _V0_IT array
n = this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p = this->_V_ITa[5*i+2]; // index of the parent vertex
float weight = this->_V_W[i],
wp = 1.0f/n,
beta = 0.25f * cosf((float)M_PI * 2.0f * wp) + 0.375f;
beta = beta*beta;
beta = (0.625f-beta)*wp;
vdst->AddWithWeight( vsrc[p], weight * (1.0f-(beta*n)), clientdata);
for (int j=0; j<n; ++j)
vdst->AddWithWeight( vsrc[this->_V_IT[h+j]], weight * beta );
vdst->AddVaryingWithWeight( vsrc[p], 1.0f, clientdata );
}
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* FAR_LOOP_SUBDIVISION_TABLES_H */

View File

@ -27,7 +27,7 @@
#include "../version.h"
#include "../far/loopSubdivisionTables.h"
#include "../far/subdivisionTables.h"
#include "../far/meshFactory.h"
#include "../far/kernelBatchFactory.h"
#include "../far/subdivisionTablesFactory.h"
@ -40,7 +40,7 @@ namespace OPENSUBDIV_VERSION {
template <class T, class U> class FarMeshFactory;
/// \brief A specialized factory for FarLoopSubdivisionTables
/// \brief A specialized factory for loop FarSubdivisionTables
///
/// Separating the factory allows us to isolate Far data structures from Hbr dependencies.
///
@ -48,25 +48,23 @@ template <class T, class U> class FarLoopSubdivisionTablesFactory {
protected:
template <class X, class Y> friend class FarMeshFactory;
/// \brief Creates a FarLoopSubdivisiontables instance.
/// \brief Creates a FarSubdivisiontables instance with Loop scheme.
///
/// @param meshFactory a valid FarMeshFactory instance
///
/// @param farMesh
///
/// @param batches a vector of Kernel refinement batches : the factory
/// will reserve and append refinement tasks
///
static FarLoopSubdivisionTables<U> * Create( FarMeshFactory<T,U> * meshFactory, FarMesh<U> * farMesh, FarKernelBatchVector * batches );
static FarSubdivisionTables * Create( FarMeshFactory<T,U> * meshFactory, FarKernelBatchVector * batches );
};
// This factory walks the Hbr vertices and accumulates the weights and adjacency
// (valance) information specific to the loop subdivision scheme. The results
// are stored in a FarLoopSubdivisionTable<U>.
template <class T, class U> FarLoopSubdivisionTables<U> *
FarLoopSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory, FarMesh<U> * farMesh, FarKernelBatchVector * batches ) {
// are stored in a FarSubdivisionTable.
template <class T, class U> FarSubdivisionTables *
FarLoopSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory, FarKernelBatchVector * batches ) {
assert( meshFactory and farMesh );
assert( meshFactory );
int maxlevel = meshFactory->GetMaxLevel();
@ -74,7 +72,7 @@ FarLoopSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory,
FarSubdivisionTablesFactory<T,U> tablesFactory( meshFactory->GetHbrMesh(), maxlevel, remap );
FarLoopSubdivisionTables<U> * result = new FarLoopSubdivisionTables<U>(farMesh, maxlevel);
FarSubdivisionTables * result = new FarSubdivisionTables(maxlevel, FarSubdivisionTables::LOOP);
// Allocate memory for the indexing tables
result->_E_IT.resize(tablesFactory.GetNumEdgeVerticesTotal(maxlevel)*4);

View File

@ -48,11 +48,18 @@ namespace OPENSUBDIV_VERSION {
///
template <class U> class FarMesh {
public:
typedef U VertexType;
/// \brief Constructor. FarMesh takes ownership of input tables.
FarMesh(FarSubdivisionTables *subdivisionTables, FarPatchTables *patchTables,
FarVertexEditTables *vertexEditTables, FarKernelBatchVector const &batches) :
_subdivisionTables(subdivisionTables), _patchTables(patchTables),
_vertexEditTables(vertexEditTables), _batches(batches) { }
~FarMesh();
/// \brief Returns the subdivision method
FarSubdivisionTables<U> const * GetSubdivisionTables() const { return _subdivisionTables; }
FarSubdivisionTables const * GetSubdivisionTables() const { return _subdivisionTables; }
/// \brief Returns patch tables
FarPatchTables const * GetPatchTables() const { return _patchTables; }
@ -69,14 +76,8 @@ public:
///
U & GetVertex(int index) { return _vertices[index]; }
/// \brief Returns the width of the interleaved face-varying data
int GetTotalFVarWidth() const { return _totalFVarWidth; }
/// \brief Returns vertex edit tables
FarVertexEditTables<U> const * GetVertexEdit() const { return _vertexEditTables; }
/// \brief Returns the total number of vertices in the mesh across across all depths
int GetNumPtexFaces() const { return _numPtexFaces; }
FarVertexEditTables const * GetVertexEditTables() const { return _vertexEditTables; }
/// \brief True if the mesh tables support the feature-adaptive mode.
bool IsFeatureAdaptive() const { return _patchTables->IsFeatureAdaptive(); }
@ -90,7 +91,6 @@ private:
// Note : the vertex classes are renamed <X,Y> so as not to shadow the
// declaration of the templated vertex class U.
template <class X, class Y> friend class FarMeshFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
FarMesh() : _subdivisionTables(0), _patchTables(0), _vertexEditTables(0) { }
@ -99,23 +99,19 @@ private:
FarMesh<U> & operator = (FarMesh<U> const &);
// subdivision method used in this mesh
FarSubdivisionTables<U> * _subdivisionTables;
FarSubdivisionTables * _subdivisionTables;
// tables of vertex indices for feature adaptive patches
FarPatchTables * _patchTables;
// hierarchical vertex edit tables
FarVertexEditTables<U> * _vertexEditTables;
FarVertexEditTables * _vertexEditTables;
// kernel execution batches
FarKernelBatchVector _batches;
// list of vertices (up to N levels of subdivision)
std::vector<U> _vertices;
int _totalFVarWidth; // width of the face-varying data
int _numPtexFaces;
};
template <class U>

View File

@ -701,11 +701,11 @@ FarMeshFactory<T,U>::Create( bool requireFVarData ) {
FarMesh<U> * result = new FarMesh<U>();
if ( isBilinear( GetHbrMesh() ) ) {
result->_subdivisionTables = FarBilinearSubdivisionTablesFactory<T,U>::Create(this, result, &result->_batches);
result->_subdivisionTables = FarBilinearSubdivisionTablesFactory<T,U>::Create(this, &result->_batches);
} else if ( isCatmark( GetHbrMesh() ) ) {
result->_subdivisionTables = FarCatmarkSubdivisionTablesFactory<T,U>::Create(this, result, &result->_batches);
result->_subdivisionTables = FarCatmarkSubdivisionTablesFactory<T,U>::Create(this, &result->_batches);
} else if ( isLoop(GetHbrMesh()) ) {
result->_subdivisionTables = FarLoopSubdivisionTablesFactory<T,U>::Create(this, result, &result->_batches);
result->_subdivisionTables = FarLoopSubdivisionTablesFactory<T,U>::Create(this, &result->_batches);
} else
assert(0);
assert(result->_subdivisionTables);
@ -718,27 +718,21 @@ FarMeshFactory<T,U>::Create( bool requireFVarData ) {
copyVertex(result->_vertices[i], GetHbrMesh()->GetVertex(i)->GetData());
}
int fvarwidth = requireFVarData ? _hbrMesh->GetTotalFVarWidth() : 0;
// Create the element indices tables (patches for adaptive, quads for non-adaptive)
if (isAdaptive()) {
FarPatchTablesFactory<T> factory(GetHbrMesh(), _numFaces, _remapTable);
// XXXX: currently PatchGregory shader supports up to 29 valence
result->_patchTables = factory.Create(GetMaxLevel()+1, _maxValence, requireFVarData);
result->_patchTables = factory.Create(GetMaxLevel()+1, _maxValence, _numPtexFaces, fvarwidth);
} else {
result->_patchTables = FarPatchTablesFactory<T>::Create(GetHbrMesh(), _facesList, _remapTable, _firstlevel, requireFVarData );
result->_patchTables = FarPatchTablesFactory<T>::Create(GetHbrMesh(), _facesList, _remapTable, _firstlevel, _numPtexFaces, fvarwidth );
}
assert( result->_patchTables );
result->_numPtexFaces = _numPtexFaces;
if (requireFVarData) {
result->_totalFVarWidth = _hbrMesh->GetTotalFVarWidth();
} else {
result->_totalFVarWidth = 0;
}
// Create VertexEditTables if necessary
if (GetHbrMesh()->HasVertexEdits()) {
result->_vertexEditTables = FarVertexEditTablesFactory<T,U>::Create( this, result, &result->_batches, GetMaxLevel() );

View File

@ -1,648 +0,0 @@
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef FAR_MULTI_MESH_FACTORY_H
#define FAR_MULTI_MESH_FACTORY_H
#include "../version.h"
#include "../far/mesh.h"
#include "../far/bilinearSubdivisionTablesFactory.h"
#include "../far/catmarkSubdivisionTablesFactory.h"
#include "../far/loopSubdivisionTablesFactory.h"
#include "../far/patchTablesFactory.h"
#include "../far/vertexEditTablesFactory.h"
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
/// \brief A specialized factory for batching meshes
///
/// Because meshes require multiple draw calls in order to process the different
/// types of patches, it is useful to have the ability of grouping the tables of
/// multiple meshes into a single set of tables. This factory builds upon the
/// specialized Far factories in order to provide this batching functionality.
///
template <class T, class U=T> class FarMultiMeshFactory {
public:
typedef std::vector<FarMesh<U> const *> FarMeshVector;
/// \brief Constructor.
FarMultiMeshFactory() {}
/// \brief Splices a vector of Far meshes into a single Far mesh
///
/// @param meshes a vector of Far meshes to splice
///
/// @return the resulting spliced Far mesh
///
FarMesh<U> * Create(std::vector<FarMesh<U> const *> const &meshes);
std::vector<FarPatchTables::PatchArrayVector> const & GetMultiPatchArrays() {
return _multiPatchArrays;
}
private:
// splice subdivision tables
FarSubdivisionTables<U> * spliceSubdivisionTables(FarMesh<U> *farmesh, FarMeshVector const &meshes);
// splice patch tables
FarPatchTables * splicePatchTables(FarMeshVector const &meshes, bool hasFVarData);
// splice patch array
FarPatchTables::PTable::iterator splicePatch(FarPatchTables::Descriptor desc,
FarMeshVector const &meshes,
FarPatchTables::PatchArrayVector &result,
FarPatchTables::PTable::iterator dstIndexIt,
int *voffset, int *poffset, int *qoffset,
std::vector<int> const &vertexOffsets);
// splice hierarchical edit tables
FarVertexEditTables<U> * spliceVertexEditTables(FarMesh<U> *farmesh, FarMeshVector const &meshes);
int _maxlevel;
int _maxvalence;
bool _isLoop;
// patch arrays for each mesh
std::vector<FarPatchTables::PatchArrayVector> _multiPatchArrays;
};
template <class T, class U> FarMesh<U> *
FarMultiMeshFactory<T, U>::Create(std::vector<FarMesh<U> const *> const &meshes) {
if (meshes.empty()) return NULL;
int totalFVarWidth = meshes[0]->GetTotalFVarWidth();
typename FarSubdivisionTables<U>::Scheme scheme =
meshes[0]->GetSubdivisionTables()->GetScheme();
_maxlevel = 0;
_maxvalence = 0;
_isLoop = false;
for (size_t i = 0; i < meshes.size(); ++i) {
FarMesh<U> const *mesh = meshes[i];
// meshes have to have a same subdivision scheme
if (scheme != mesh->GetSubdivisionTables()->GetScheme()) {
assert(false);
return NULL;
}
_maxlevel = std::max(_maxlevel, mesh->GetSubdivisionTables()->GetMaxLevel()-1);
if (mesh->GetPatchTables()) {
_maxvalence = std::max(_maxvalence, mesh->GetPatchTables()->GetMaxValence());
}
// meshes have to have a same fvardata width
if (totalFVarWidth != mesh->GetTotalFVarWidth()) {
assert(false);
return NULL;
}
}
FarMesh<U> * result = new FarMesh<U>();
// splice subdivision tables
result->_subdivisionTables = spliceSubdivisionTables(result, meshes);
// splice patch/quad index tables
result->_patchTables = splicePatchTables(meshes, totalFVarWidth > 0);
// splice vertex edit tables
result->_vertexEditTables = spliceVertexEditTables(result, meshes);
// count total num vertices, numptex faces
int numVertices = 0, numPtexFaces = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
numVertices += meshes[i]->GetNumVertices();
numPtexFaces += meshes[i]->GetNumPtexFaces();
}
result->_vertices.resize(numVertices);
result->_numPtexFaces = numPtexFaces;
result->_totalFVarWidth = totalFVarWidth;
return result;
}
template <typename V, typename IT> static IT
copyWithOffset(IT dst_iterator, V const &src, int offset) {
return std::transform(src.begin(), src.end(), dst_iterator,
std::bind2nd(std::plus<typename V::value_type>(), offset));
}
template <typename V, typename IT> static IT
copyWithOffset(IT dst_iterator, V const &src, int start, int count, int offset) {
return std::transform(src.begin()+start, src.begin()+start+count, dst_iterator,
std::bind2nd(std::plus<typename V::value_type>(), offset));
}
template <typename V, typename IT> static IT
copyWithPtexFaceOffset(IT dst_iterator, V const &src, int start, int count, int offset) {
for (typename V::const_iterator it = src.begin()+start; it != src.begin()+start+count; ++it) {
typename V::value_type ptexCoord = *it;
ptexCoord.faceIndex += offset;
*dst_iterator++ = ptexCoord;
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetF_ITa(IT dst_iterator, V const &src, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end();) {
*dst_iterator++ = *it++ + offset; // offset to F_IT
*dst_iterator++ = *it++; // valence
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetE_IT(IT dst_iterator, V const &src, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end(); ++it) {
*dst_iterator++ = (*it == -1) ? -1 : (*it + offset);
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetV_ITa(IT dst_iterator, V const &src, int tableOffset, int vertexOffset) {
for (typename V::const_iterator it = src.begin(); it != src.end();) {
*dst_iterator++ = *it++ + tableOffset; // offset to V_IT
*dst_iterator++ = *it++; // valence
*dst_iterator++ = (*it == -1) ? -1 : (*it + vertexOffset); ++it;
*dst_iterator++ = (*it == -1) ? -1 : (*it + vertexOffset); ++it;
*dst_iterator++ = (*it == -1) ? -1 : (*it + vertexOffset); ++it;
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetVertexValence(IT dst_iterator, V const &src, int srcMaxValence, int dstMaxValence, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end(); ) {
int valence = *it++;
*dst_iterator++ = valence;
valence = abs(valence);
for (int i = 0; i < 2*dstMaxValence; ++i) {
if (i < 2*srcMaxValence) {
*dst_iterator++ = (i < 2*valence) ? *it + offset : 0;
++it;
} else {
*dst_iterator++ = 0;
}
}
}
return dst_iterator;
}
template <class T, class U> FarSubdivisionTables<U> *
FarMultiMeshFactory<T, U>::spliceSubdivisionTables(FarMesh<U> *farMesh, FarMeshVector const &meshes) {
// count total table size
size_t total_F_ITa = 0, total_F_IT = 0;
size_t total_E_IT = 0, total_E_W = 0;
size_t total_V_ITa = 0, total_V_IT = 0, total_V_W = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables<U> const * tables = meshes[i]->GetSubdivisionTables();
assert(tables);
total_F_ITa += tables->Get_F_ITa().size();
total_F_IT += tables->Get_F_IT().size();
total_E_IT += tables->Get_E_IT().size();
total_E_W += tables->Get_E_W().size();
total_V_ITa += tables->Get_V_ITa().size();
total_V_IT += tables->Get_V_IT().size();
total_V_W += tables->Get_V_W().size();
}
FarSubdivisionTables<U> *result = NULL;
typename FarSubdivisionTables<U>::Scheme scheme =
meshes[0]->GetSubdivisionTables()->GetScheme();
switch (scheme) {
case FarSubdivisionTables<U>::CATMARK:
result = new FarCatmarkSubdivisionTables<U>(farMesh, _maxlevel);
_isLoop = false;
break;
case FarSubdivisionTables<U>::LOOP:
result = new FarLoopSubdivisionTables<U>(farMesh, _maxlevel);
_isLoop = true;
break;
case FarSubdivisionTables<U>::BILINEAR:
result = new FarBilinearSubdivisionTables<U>(farMesh, _maxlevel);
_isLoop = false;
break;
default:
assert(0);
}
result->_F_ITa.resize(total_F_ITa);
result->_F_IT.resize(total_F_IT);
result->_E_IT.resize(total_E_IT);
result->_E_W.resize(total_E_W);
result->_V_ITa.resize(total_V_ITa);
result->_V_IT.resize(total_V_IT);
result->_V_W.resize(total_V_W);
// compute table offsets;
std::vector<int> vertexOffsets;
std::vector<int> fvOffsets;
std::vector<int> evOffsets;
std::vector<int> vvOffsets;
std::vector<int> F_IToffsets;
std::vector<int> V_IToffsets;
{
int vertexOffset = 0;
int F_IToffset = 0;
int V_IToffset = 0;
int fvOffset = 0;
int evOffset = 0;
int vvOffset = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables<U> const * tables = meshes[i]->GetSubdivisionTables();
assert(tables);
vertexOffsets.push_back(vertexOffset);
F_IToffsets.push_back(F_IToffset);
V_IToffsets.push_back(V_IToffset);
fvOffsets.push_back(fvOffset);
evOffsets.push_back(evOffset);
vvOffsets.push_back(vvOffset);
vertexOffset += meshes[i]->GetNumVertices();
F_IToffset += (int)tables->Get_F_IT().size();
fvOffset += (int)tables->Get_F_ITa().size()/2;
V_IToffset += (int)tables->Get_V_IT().size();
if (scheme == FarSubdivisionTables<U>::CATMARK or
scheme == FarSubdivisionTables<U>::LOOP) {
evOffset += (int)tables->Get_E_IT().size()/4;
vvOffset += (int)tables->Get_V_ITa().size()/5;
} else {
evOffset += (int)tables->Get_E_IT().size()/2;
vvOffset += (int)tables->Get_V_ITa().size();
}
}
}
// concat F_IT and V_IT
std::vector<unsigned int>::iterator F_IT = result->_F_IT.begin();
std::vector<unsigned int>::iterator V_IT = result->_V_IT.begin();
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables<U> const * tables = meshes[i]->GetSubdivisionTables();
int vertexOffset = vertexOffsets[i];
// remap F_IT, V_IT tables
F_IT = copyWithOffset(F_IT, tables->Get_F_IT(), vertexOffset);
V_IT = copyWithOffset(V_IT, tables->Get_V_IT(), vertexOffset);
}
// merge other tables
std::vector<int>::iterator F_ITa = result->_F_ITa.begin();
std::vector<int>::iterator E_IT = result->_E_IT.begin();
std::vector<float>::iterator E_W = result->_E_W.begin();
std::vector<float>::iterator V_W = result->_V_W.begin();
std::vector<int>::iterator V_ITa = result->_V_ITa.begin();
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables<U> const * tables = meshes[i]->GetSubdivisionTables();
// copy face tables
F_ITa = copyWithOffsetF_ITa(F_ITa, tables->Get_F_ITa(), F_IToffsets[i]);
// copy edge tables
E_IT = copyWithOffsetE_IT(E_IT, tables->Get_E_IT(), vertexOffsets[i]);
E_W = copyWithOffset(E_W, tables->Get_E_W(), 0);
// copy vert tables
if (scheme == FarSubdivisionTables<U>::CATMARK or
scheme == FarSubdivisionTables<U>::LOOP) {
V_ITa = copyWithOffsetV_ITa(V_ITa, tables->Get_V_ITa(), V_IToffsets[i], vertexOffsets[i]);
} else {
V_ITa = copyWithOffset(V_ITa, tables->Get_V_ITa(), vertexOffsets[i]);
}
V_W = copyWithOffset(V_W, tables->Get_V_W(), 0);
}
// merge batch, model by model
FarKernelBatchVector &batches = farMesh->_batches;
int editTableIndexOffset = 0;
for (int i = 0; i < (int)meshes.size(); ++i) {
for (int j = 0; j < (int)meshes[i]->_batches.size(); ++j) {
FarKernelBatch batch = meshes[i]->_batches[j];
batch._meshIndex = i;
batch._vertexOffset += vertexOffsets[i];
if (batch._kernelType == FarKernelBatch::CATMARK_FACE_VERTEX or
batch._kernelType == FarKernelBatch::BILINEAR_FACE_VERTEX) {
batch._tableOffset += fvOffsets[i];
} else if (batch._kernelType == FarKernelBatch::CATMARK_EDGE_VERTEX or
batch._kernelType == FarKernelBatch::LOOP_EDGE_VERTEX or
batch._kernelType == FarKernelBatch::BILINEAR_EDGE_VERTEX) {
batch._tableOffset += evOffsets[i];
} else if (batch._kernelType == FarKernelBatch::CATMARK_VERT_VERTEX_A1 or
batch._kernelType == FarKernelBatch::CATMARK_VERT_VERTEX_A2 or
batch._kernelType == FarKernelBatch::CATMARK_VERT_VERTEX_B or
batch._kernelType == FarKernelBatch::LOOP_VERT_VERTEX_A1 or
batch._kernelType == FarKernelBatch::LOOP_VERT_VERTEX_A2 or
batch._kernelType == FarKernelBatch::LOOP_VERT_VERTEX_B or
batch._kernelType == FarKernelBatch::BILINEAR_VERT_VERTEX) {
batch._tableOffset += vvOffsets[i];
} else if (batch._kernelType == FarKernelBatch::HIERARCHICAL_EDIT) {
batch._tableIndex += editTableIndexOffset;
}
batches.push_back(batch);
}
editTableIndexOffset += meshes[i]->_vertexEditTables ? meshes[i]->_vertexEditTables->GetNumBatches() : 0;
}
// count verts offsets
result->_vertsOffsets.resize(_maxlevel+2);
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables<U> const * tables = meshes[i]->GetSubdivisionTables();
for (size_t j = 0; j < tables->_vertsOffsets.size(); ++j) {
result->_vertsOffsets[j] += tables->_vertsOffsets[j];
}
}
return result;
}
template <class T, class U> FarPatchTables::PTable::iterator
FarMultiMeshFactory<T, U>::splicePatch(FarPatchTables::Descriptor desc,
FarMeshVector const &meshes,
FarPatchTables::PatchArrayVector &result,
FarPatchTables::PTable::iterator dstIndexIt,
int *voffset, int *poffset, int *qoffset,
std::vector<int> const &vertexOffsets)
{
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *patchTables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *srcPatchArray = patchTables->GetPatchArray(desc);
if (not srcPatchArray) continue;
// create new patcharray with offset
int vindex = srcPatchArray->GetVertIndex();
int npatch = srcPatchArray->GetNumPatches();
int nvertex = npatch * desc.GetNumControlVertices();
FarPatchTables::PatchArray patchArray(desc,
*voffset,
*poffset,
npatch,
*qoffset);
// append patch array
result.push_back(patchArray);
// also store into multiPatchArrays, will be used for partial drawing
// XXX: can be stored as indices. revisit here later
_multiPatchArrays[i].push_back(patchArray);
// increment offset
*voffset += nvertex;
*poffset += npatch;
*qoffset += (desc.GetType() == FarPatchTables::GREGORY ||
desc.GetType() == FarPatchTables::GREGORY_BOUNDARY) ? npatch * 4 : 0;
// copy index arrays [vindex, vindex+nvertex]
dstIndexIt = copyWithOffset(dstIndexIt,
patchTables->GetPatchTable(),
vindex,
nvertex,
vertexOffsets[i]);
}
return dstIndexIt;
}
template <class T, class U> FarPatchTables *
FarMultiMeshFactory<T, U>::splicePatchTables(FarMeshVector const &meshes, bool hasFVarData) {
FarPatchTables *result = new FarPatchTables(_maxvalence);
int totalQuadOffset0 = 0;
int totalQuadOffset1 = 0;
int totalFVarData = 0;
std::vector<int> vertexOffsets;
std::vector<int> gregoryQuadOffsets;
std::vector<int> numGregoryPatches;
int vertexOffset = 0;
int maxValence = 0;
int numTotalIndices = 0;
//result->_patchCounts.reserve(meshes.size());
//FarPatchCount totalCount;
typedef FarPatchTables::Descriptor Descriptor;
// note: see FarPatchTablesFactory<T>::Create
// feature adaptive refinement can generate un-connected face-vertices
// that have a valence of 0. The spliced vertex valence tables
// needs to be resized including such un-connected face-vertices.
int numVerticesInVertexValence = 0;
// count how many patches exist on each mesh
for (size_t i = 0; i < meshes.size(); ++i) {
const FarPatchTables *ptables = meshes[i]->GetPatchTables();
assert(ptables);
vertexOffsets.push_back(vertexOffset);
vertexOffset += meshes[i]->GetNumVertices();
// need to align maxvalence with the highest value
maxValence = std::max(maxValence, ptables->_maxValence);
FarPatchTables::PatchArray const *gregory = ptables->GetPatchArray(Descriptor(FarPatchTables::GREGORY, FarPatchTables::NON_TRANSITION, /*rot*/ 0));
FarPatchTables::PatchArray const *gregoryBoundary = ptables->GetPatchArray(Descriptor(FarPatchTables::GREGORY_BOUNDARY, FarPatchTables::NON_TRANSITION, /*rot*/ 0));
int nGregory = gregory ? gregory->GetNumPatches() : 0;
int nGregoryBoundary = gregoryBoundary ? gregoryBoundary->GetNumPatches() : 0;
totalQuadOffset0 += nGregory * 4;
totalQuadOffset1 += nGregoryBoundary * 4;
numGregoryPatches.push_back(nGregory);
gregoryQuadOffsets.push_back(totalQuadOffset0);
totalFVarData += (int)ptables->GetFVarDataTable().size();
numTotalIndices += ptables->GetNumControlVertices();
// note: some prims may not have vertex valence table, but still need a space
// in order to fill following prim's data at appropriate location.
numVerticesInVertexValence += ptables->_vertexValenceTable.empty()
? (int)meshes[i]->GetNumVertices()
: ptables->_vertexValenceTable.size()/(2*ptables->_maxValence+1);
}
// Allocate full patches
result->_patches.resize(numTotalIndices);
// Allocate vertex valence table, quad offset table
if (totalQuadOffset0 + totalQuadOffset1 > 0) {
result->_vertexValenceTable.resize((2*maxValence+1) * numVerticesInVertexValence);
result->_quadOffsetTable.resize(totalQuadOffset0 + totalQuadOffset1);
}
// Allocate fvardata table
result->_fvarTable.resize(totalFVarData);
// splice tables
// assuming input farmeshes have dense patchtables
_multiPatchArrays.resize(meshes.size());
int voffset = 0, poffset = 0, qoffset = 0;
FarPatchTables::PTable::iterator dstIndexIt = result->_patches.begin();
// splice patches : iterate over all descriptors, including points, lines, quads, etc.
// non-patches
for (int type = FarPatchTables::POINTS; type <= FarPatchTables::LOOP; ++type) {
dstIndexIt = splicePatch(FarPatchTables::Descriptor(type, 0, 0),
meshes, result->_patchArrays, dstIndexIt, &voffset, &poffset, &qoffset, vertexOffsets);
}
// patches
for (Descriptor::iterator it=Descriptor::begin(); it!=Descriptor::end(); ++it) {
dstIndexIt = splicePatch(*it, meshes, result->_patchArrays, dstIndexIt, &voffset, &poffset, &qoffset, vertexOffsets);
}
// merge vertexvalence and quadoffset tables
FarPatchTables::QuadOffsetTable::iterator Q0_IT = result->_quadOffsetTable.begin();
FarPatchTables::QuadOffsetTable::iterator Q1_IT = Q0_IT + totalQuadOffset0;
FarPatchTables::VertexValenceTable::iterator VV_IT = result->_vertexValenceTable.begin();
for (size_t i = 0; i < meshes.size(); ++i) {
const FarPatchTables *ptables = meshes[i]->GetPatchTables();
// merge vertex valence
// note: some prims may not have vertex valence table, but still need a space
// in order to fill following prim's data at appropriate location.
copyWithOffsetVertexValence(VV_IT,
ptables->_vertexValenceTable,
ptables->_maxValence,
maxValence,
vertexOffsets[i]);
VV_IT += meshes[i]->GetNumVertices() * (2 * maxValence + 1);
// merge quad offsets
// int nGregoryQuads = (int)ptables->_full._G_IT.first.size();
int nGregoryQuads = numGregoryPatches[i] * 4;
if (nGregoryQuads > 0) {
Q0_IT = std::copy(ptables->_quadOffsetTable.begin(),
ptables->_quadOffsetTable.begin()+nGregoryQuads,
Q0_IT);
}
if (nGregoryQuads < (int)ptables->_quadOffsetTable.size()) {
Q1_IT = std::copy(ptables->_quadOffsetTable.begin()+nGregoryQuads,
ptables->_quadOffsetTable.end(),
Q1_IT);
}
}
// merge ptexCoord table
for (FarPatchTables::Descriptor::iterator it(FarPatchTables::Descriptor(FarPatchTables::POINTS, FarPatchTables::NON_TRANSITION, 0));
it != FarPatchTables::Descriptor::end(); ++it) {
int ptexFaceOffset = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *ptables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *parray = ptables->GetPatchArray(*it);
if (parray) {
copyWithPtexFaceOffset(std::back_inserter(result->_paramTable),
ptables->_paramTable,
parray->GetPatchIndex(),
parray->GetNumPatches(), ptexFaceOffset);
}
ptexFaceOffset += meshes[i]->GetNumPtexFaces();
}
}
// merge fvardata table
if (hasFVarData) {
FarPatchTables::FVarDataTable::iterator FV_IT = result->_fvarTable.begin();
for (FarPatchTables::Descriptor::iterator it(FarPatchTables::Descriptor(FarPatchTables::POINTS, FarPatchTables::NON_TRANSITION, 0));
it != FarPatchTables::Descriptor::end(); ++it) {
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *ptables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *parray = ptables->GetPatchArray(*it);
if (parray) {
int nv = _isLoop ? 3 : 4;
int width = meshes[i]->GetTotalFVarWidth() * nv; // for each quads or tris
FarPatchTables::FVarDataTable::const_iterator begin =
ptables->_fvarTable.begin() + parray->GetPatchIndex() * width;
FarPatchTables::FVarDataTable::const_iterator end =
begin + parray->GetNumPatches() * width;
FV_IT = std::copy(begin, end, FV_IT);
}
}
}
}
return result;
}
template <class T, class U> FarVertexEditTables<U> *
FarMultiMeshFactory<T, U>::spliceVertexEditTables(FarMesh<U> *farMesh, FarMeshVector const &meshes) {
FarVertexEditTables<U> * result = new FarVertexEditTables<U>(farMesh);
// at this moment, don't merge vertex edit tables (separate batch)
for (size_t i = 0; i < meshes.size(); ++i) {
const FarVertexEditTables<U> *vertexEditTables = meshes[i]->GetVertexEdit();
if (not vertexEditTables) continue;
// copy each edit batch XXX:inefficient copy
result->_batches.insert(result->_batches.end(),
vertexEditTables->_batches.begin(),
vertexEditTables->_batches.end());
}
if (result->_batches.empty()) {
delete result;
return NULL;
}
return result;
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* FAR_MULTI_MESH_FACTORY_H */

View File

@ -50,7 +50,6 @@ public:
typedef std::vector<int> VertexValenceTable;
typedef std::vector<unsigned int> QuadOffsetTable;
typedef std::vector<FarPatchParam> PatchParamTable;
typedef std::vector<float> FVarDataTable;
enum Type {
NON_PATCH = 0, ///< undefined
@ -149,7 +148,14 @@ public:
/// \brief Descriptor Iterator
/// Iterates through the patches in the following preset order
///
/// Order:
/// ANY order:
/// POINTS
/// LINES
/// QUADS
/// TRIANGLES
/// LOOP
///
/// FEATURE_ADAPTIVE_CATMARK order:
///
/// NON_TRANSITION ( REGULAR
/// BOUNDARY
@ -170,8 +176,16 @@ public:
///
class iterator;
/// \brief Returns an iterator to the first type of patch (REGULAR NON_TRANSITION ROT0)
static iterator begin();
enum PrimType {
ANY,
FEATURE_ADAPTIVE_CATMARK,
};
/// \brief Returns a patch type iterator
/// @param type if type=ANY then the iterater points to type POINTS
/// if type=FEATURE_ADAPTIVE_CATMARK then the iterator
/// points to type NON_TRANSITION REGULAR
static iterator begin(PrimType type);
/// \brief Returns an iterator to the end of the list of patch types (NON_PATCH)
static iterator end();
@ -292,6 +306,8 @@ public:
///
/// @param fvarData Face varying data table
///
/// @param fvarWidth Primvar data width (number of floats)
///
/// @param maxValence Highest vertex valence allowed in the mesh
///
FarPatchTables(PatchArrayVector const & patchArrays,
@ -299,7 +315,8 @@ public:
VertexValenceTable const * vertexValences,
QuadOffsetTable const * quadOffsets,
PatchParamTable const * patchParams,
FVarDataTable const * fvarData,
std::vector<float> const * fvarData,
int fvarWidth,
int maxValence);
/// \brief Get the table of patch control vertices
@ -358,14 +375,6 @@ public:
/// \brief Returns a PatchParamTable for each type of patch
PatchParamTable const & GetPatchParamTable() const { return _paramTable; }
/// \brief Returns an FVarDataTable for each type of patch
/// The data is stored as a run of totalFVarWidth floats per-vertex per-face
/// e.g.: for UV data it has the structure of float[p][4][2] where
/// p=primitiveID and totalFVarWidth=2:
/// [ [ uv uv uv uv ] [ uv uv uv uv ] [ ... ] ]
/// prim 0 prim 1
FVarDataTable const & GetFVarDataTable() const { return _fvarTable; }
/// \brief Ringsize of Regular Patches in table.
static int GetRegularPatchRingsize() { return 16; }
@ -390,10 +399,67 @@ public:
/// \brief True if the patches are of feature adaptive types
bool IsFeatureAdaptive() const;
/// \brief Returns the total number of vertices in the mesh across across all depths
int GetNumPtexFaces() const { return _numPtexFaces; }
/// \brief Container for static face-varying primvar data
class FVarData {
public:
/// \brief Returns a vector of floats containing the face-varying data attached
/// to each patch.
///
/// The data is stored as a run of FVarWidth floats per-vertex per-face
/// e.g.: for UV data it has the structure of float[p][4][2] where
/// p=primitiveID and FVarWidth=2:
/// [ [ uv uv uv uv ] [ uv uv uv uv ] [ ... ] ]
/// prim 0 prim 1
///
/// In uniform mode the FarPatchTablesFactory can be set to generate either a
/// patch array containing the faces at the highest level of subdivision, or
/// a range of arrays, corresponding to multiple successive levels of subdivision.
///
/// Note : level '0' is not the coarse mesh. Currently there is no path in the
/// factories to convert the coarse mesh to FarPatchTables.
///
/// @param level the level of subdivision of the faces (returns the highest
/// level by default) **Uniform subdivision only**
///
float const * GetData(int level=0) const;
/// \brief Returns a vector of floats containing the face-varying data attached
std::vector<float> const & GetAllData() const {
return _data;
}
/// \brief Returns the width of the interleaved face-varying data
int GetFVarWidth() const {
return _fvarWidth;
}
private:
template <class T> friend class FarPatchTablesFactory;
friend class FarPatchTables;
FVarData() : _fvarWidth(0) { }
FVarData( std::vector<float> const * data, int fvarWidth );
std::vector<float> _data; // face-varying data stored per-face-per-vertex
std::vector<int> _offsets; // a vector of offsets if multiple leves of
// subdivision are stored in _data
int _fvarWidth; // width of the face-varying data
};
/// \brief Returns a container for face-varying data
FVarData const & GetFVarData() const { return _fvarData; }
private:
template <class T> friend class FarPatchTablesFactory;
template <class T, class U> friend class FarMultiMeshFactory;
// Returns the array of patches of type "desc", or NULL if there aren't any in the primitive
PatchArray * findPatchArray( Descriptor desc );
@ -412,11 +478,15 @@ private:
PatchParamTable _paramTable;
FVarDataTable _fvarTable;
FVarData _fvarData; // face-varying data
// highest vertex valence allowed in the mesh (used for Gregory
// vertexValance & quadOffset tables)
int _maxValence;
// number of total ptex faces in quads or triangles(loop)
int _numPtexFaces;
};
/// \brief Descriptor iterator class
@ -504,7 +574,12 @@ FarPatchTables::Descriptor::GetAllValidDescriptors() {
static std::vector<Descriptor> _descriptors;
if (_descriptors.empty()) {
_descriptors.reserve(50);
_descriptors.reserve(55);
// non-patch primitives
for (int i=POINTS; i<=LOOP; ++i) {
_descriptors.push_back( Descriptor(i, NON_TRANSITION, 0) );
}
// non-transition patches
for (int i=REGULAR; i<=GREGORY_BOUNDARY; ++i) {
@ -532,8 +607,15 @@ FarPatchTables::Descriptor::GetAllValidDescriptors() {
// Returns an iterator to the first type of patch (REGULAR NON_TRANSITION ROT0)
inline FarPatchTables::Descriptor::iterator
FarPatchTables::Descriptor::begin() {
return iterator( Descriptor(REGULAR, NON_TRANSITION, 0) );
FarPatchTables::Descriptor::begin(PrimType type) {
switch (type) {
case ANY:
return iterator( Descriptor(POINTS, NON_TRANSITION, 0) );
case FEATURE_ADAPTIVE_CATMARK:
return iterator( Descriptor(REGULAR, NON_TRANSITION, 0) );
default:
return iterator( Descriptor() );
}
}
// Returns an iterator to the end of the list of patch types (NON_PATCH)
@ -549,11 +631,14 @@ FarPatchTables::FarPatchTables(PatchArrayVector const & patchArrays,
VertexValenceTable const * vertexValences,
QuadOffsetTable const * quadOffsets,
PatchParamTable const * patchParams,
FVarDataTable const * fvarData,
std::vector<float> const * fvarData,
int fvarWidth,
int maxValence) :
_patchArrays(patchArrays),
_patches(patches),
_maxValence(maxValence) {
_fvarData(fvarData, fvarWidth),
_maxValence(maxValence),
_numPtexFaces(0) {
// copy other tables if exist
if (vertexValences)
@ -562,8 +647,6 @@ FarPatchTables::FarPatchTables(PatchArrayVector const & patchArrays,
_quadOffsetTable = *quadOffsets;
if (patchParams)
_paramTable = *patchParams;
if (fvarData)
_fvarTable = *fvarData;
}
inline bool
@ -693,6 +776,34 @@ FarPatchTables::GetNumControlVertices() const {
return result;
}
// Constructor
inline
FarPatchTables::FVarData::FVarData( std::vector<float> const * data, int fvarWidth ) :
_fvarWidth(fvarWidth) {
if (data) {
_data = *data;
}
}
// Returns a vector of float containing the face-varying data attached
inline float const *
FarPatchTables::FVarData::GetData(int level) const {
if ( (level-1)<(int)_offsets.size()) {
int offset = 0;
if ((level>0) and (not _offsets.empty()) ) {
offset = _offsets[level -1];
}
return &_data[offset];
}
return NULL;
}
} // end namespace OPENSUBDIV_VERSION

View File

@ -41,6 +41,17 @@ namespace OPENSUBDIV_VERSION {
///
template <class T> class FarPatchTablesFactory {
public:
typedef std::vector<FarMesh<T> const *> FarMeshVector;
typedef std::vector<FarPatchTables::PatchArrayVector> MultiPatchArrayVector;
/// \brief Splices patch tables from multiple meshes.
/// if non-null multPatchArrays is given, it returns subsets of patcharrays such that
/// corresponding input meshes are separately expressed.
/// Client code is responsible for deallocation.
static FarPatchTables *Splice(FarMeshVector const &meshes,
MultiPatchArrayVector *multiPatchArrays);
protected:
template <class X, class Y> friend class FarMeshFactory;
@ -60,11 +71,13 @@ protected:
///
/// @param maxvalence Maximum vertex valence in the mesh
///
/// @param requireFVarData Flag for generating face-varying data
/// @param numPtexFaces Number of ptex faces
///
/// @param fvarWidth The width of the interleaved face-varying data
///
/// @return A new instance of FarPatchTables
///
FarPatchTables * Create( int maxlevel, int maxvalence, bool requireFVarData=false );
FarPatchTables * Create( int maxlevel, int maxvalence, int numPtexFaces=0, int fvarWidth=0 );
typedef std::vector<std::vector< HbrFace<T> *> > FacesList;
@ -76,14 +89,16 @@ protected:
/// @param flist Vectors of pointers to HbrFace<T> for each level
/// of subdivision
///
/// @param requireFVarData Flag for generating face-varying data
/// @param remapTable Vertex remapping table generated by FarMeshFactory
///
/// @param firstLevel First level of subdivision to use when building the
/// PatchArrayVector (default -1 means only generate
/// a single patch array for the highest level of
/// subdivision)
///
/// @param remapTable Vertex remapping table generated by FarMeshFactory
/// @param numPtexFaces Number of ptex faces
///
/// @param fvarWidth The width of the interleaved face-varying data
///
/// @return A new instance of FarPatchTables
///
@ -91,7 +106,8 @@ protected:
FacesList const & flist,
std::vector<int> const & remapTable,
int firstLevel=-1,
bool requireFVarData=false );
int numPtexFaces=0,
int fvarWidth=0 );
private:
@ -136,7 +152,7 @@ private:
static int getNumPatches( FarPatchTables::PatchArrayVector const & parrays );
// Reserves tables based on the contents of the PatchArrayVector
static void allocateTables( FarPatchTables * tables, int fvarwidth );
static void allocateTables( FarPatchTables * tables, int nlevels, int fvarwidth );
// A convenience container for the different types of feature adaptive patches
template<class TYPE> struct PatchTypes {
@ -272,7 +288,7 @@ FarPatchTablesFactory<T>::computeCornerPatchRotation( HbrFace<T> * f ) {
// Reserves tables based on the contents of the PatchArrayVector
template <class T> void
FarPatchTablesFactory<T>::allocateTables( FarPatchTables * tables, int fvarwidth ) {
FarPatchTablesFactory<T>::allocateTables( FarPatchTables * tables, int nlevels, int fvarwidth ) {
int nverts = tables->GetNumControlVertices(),
npatches = getNumPatches(tables->GetPatchArrayVector());
@ -285,13 +301,17 @@ FarPatchTablesFactory<T>::allocateTables( FarPatchTables * tables, int fvarwidth
tables->_paramTable.resize( npatches );
if (fvarwidth>0) {
tables->_fvarTable.resize( npatches * 4 * fvarwidth );
tables->_fvarData._data.resize( npatches * 4 * fvarwidth );
if (nlevels >1) {
tables->_fvarData._offsets.resize( nlevels );
}
}
}
// Uniform mesh factory (static function because it requires no cached state)
template <class T> FarPatchTables *
FarPatchTablesFactory<T>::Create( HbrMesh<T> const * mesh, FacesList const & flist, std::vector<int> const & remapTable, int firstLevel, bool requireFVarData ) {
FarPatchTablesFactory<T>::Create( HbrMesh<T> const * mesh, FacesList const & flist, std::vector<int> const & remapTable, int firstLevel, int numPtexFaces, int fvarwidth ) {
if (flist.size()<2)
return 0;
@ -302,7 +322,8 @@ FarPatchTablesFactory<T>::Create( HbrMesh<T> const * mesh, FacesList const & fli
int nv = isLoop ? 3 : 4;
int firstArray = firstLevel > -1 ? firstLevel : (int)flist.size()-1;
int firstArray = firstLevel > -1 ? firstLevel : (int)flist.size()-1,
nlevels = (int)flist.size()-firstArray;
// Populate the patch array descriptors
@ -323,17 +344,18 @@ FarPatchTablesFactory<T>::Create( HbrMesh<T> const * mesh, FacesList const & fli
}
}
int fvarwidth = requireFVarData ? mesh->GetTotalFVarWidth() : 0;
result->_fvarData._fvarWidth = fvarwidth;
result->_numPtexFaces = numPtexFaces;
// Populate the patch / param / fvar tables
allocateTables( result, fvarwidth );
allocateTables( result, nlevels, fvarwidth );
unsigned int * iptr = &result->_patches[0];
FarPatchParam * pptr = &result->_paramTable[0];
float * fptr = fvarwidth>0 ? &result->_fvarTable[0] : 0;
float * fptr = fvarwidth>0 ? &result->_fvarData._data[0] : 0;
for (int level=firstArray; level<(int)flist.size(); ++level) {
for (int level=firstArray, fvarOffset=0; level<(int)flist.size(); ++level) {
for (int i=0; i<(int)flist[level].size(); ++i) {
HbrFace<T> * f = flist[level][i];
@ -348,12 +370,16 @@ FarPatchTablesFactory<T>::Create( HbrMesh<T> const * mesh, FacesList const & fli
if (fvarwidth>0)
fptr = computeFVarData(f, fvarwidth, fptr, /*isAdaptive=*/false);
}
if (fvarwidth>0 and (not result->_fvarData._offsets.empty())) {
result->_fvarData._offsets[level-firstArray] = (fvarOffset+=(int)flist[level].size()*4*fvarwidth);
}
}
return result;
}
// Feature adaptive mesh factory
// PatchTables Factory
template <class T>
FarPatchTablesFactory<T>::FarPatchTablesFactory( HbrMesh<T> const * mesh, int nfaces, std::vector<int> const & remapTable ) :
_mesh(mesh),
@ -648,8 +674,9 @@ FarPatchTablesFactory<T>::pushPatchArray( FarPatchTables::Descriptor desc,
}
}
// Uniform mesh factory
template <class T> FarPatchTables *
FarPatchTablesFactory<T>::Create( int maxlevel, int maxvalence, bool requireFVarData ) {
FarPatchTablesFactory<T>::Create( int maxlevel, int maxvalence, int numPtexFaces, int fvarwidth ) {
static const unsigned int remapRegular [16] = {5,6,10,9,4,0,1,2,3,7,11,15,14,13,12,8};
static const unsigned int remapRegularBoundary[12] = {1,2,6,5,0,3,7,11,10,9,8,4};
@ -666,14 +693,17 @@ FarPatchTablesFactory<T>::Create( int maxlevel, int maxvalence, bool requireFVar
int voffset=0, poffset=0, qoffset=0;
for (Descriptor::iterator it=Descriptor::begin(); it!=Descriptor::end(); ++it) {
for (Descriptor::iterator it=Descriptor::begin(Descriptor::FEATURE_ADAPTIVE_CATMARK);
it!=Descriptor::end(); ++it) {
pushPatchArray( *it, parray, _patchCtr.getValue(*it), &voffset, &poffset, &qoffset );
}
int fvarwidth = requireFVarData ? getMesh()->GetTotalFVarWidth() : 0;
result->_fvarData._fvarWidth = fvarwidth;
result->_numPtexFaces = numPtexFaces;
// Allocate various tables
allocateTables( result, fvarwidth );
allocateTables( result, 0, fvarwidth );
if ((_patchCtr.G > 0) or (_patchCtr.GB > 0)) { // Quad-offsets tables (for Gregory patches)
result->_quadOffsetTable.resize( _patchCtr.G*4 + _patchCtr.GB*4 );
@ -685,7 +715,8 @@ FarPatchTablesFactory<T>::Create( int maxlevel, int maxvalence, bool requireFVar
ParamPointers pptrs;
FVarPointers fptrs;
for (Descriptor::iterator it=Descriptor::begin(); it!=Descriptor::end(); ++it) {
for (Descriptor::iterator it=Descriptor::begin(Descriptor::FEATURE_ADAPTIVE_CATMARK);
it!=Descriptor::end(); ++it) {
FarPatchTables::PatchArray * pa = result->findPatchArray(*it);
@ -696,7 +727,7 @@ FarPatchTablesFactory<T>::Create( int maxlevel, int maxvalence, bool requireFVar
pptrs.getValue( *it ) = &result->_paramTable[pa->GetPatchIndex()];
if (fvarwidth>0)
fptrs.getValue( *it ) = &result->_fvarTable[pa->GetPatchIndex() * 4 * fvarwidth];
fptrs.getValue( *it ) = &result->_fvarData._data[pa->GetPatchIndex() * 4 * fvarwidth];
}
FarPatchTables::QuadOffsetTable::value_type *quad_G_C0_P = _patchCtr.G>0 ? &result->_quadOffsetTable[0] : 0;
@ -1192,6 +1223,278 @@ FarPatchTablesFactory<T>::computeFVarData(
return coord;
}
// splicing functions
template <typename V, typename IT> static IT
copyWithOffset(IT dst_iterator, V const &src, int start, int count, int offset) {
return std::transform(src.begin()+start, src.begin()+start+count, dst_iterator,
std::bind2nd(std::plus<typename V::value_type>(), offset));
}
template <typename V, typename IT> static IT
copyWithOffsetVertexValence(IT dst_iterator, V const &src, int srcMaxValence, int dstMaxValence, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end(); ) {
int valence = *it++;
*dst_iterator++ = valence;
valence = abs(valence);
for (int i = 0; i < 2*dstMaxValence; ++i) {
if (i < 2*srcMaxValence) {
*dst_iterator++ = (i < 2*valence) ? *it + offset : 0;
++it;
} else {
*dst_iterator++ = 0;
}
}
}
return dst_iterator;
}
template <class T> static FarPatchTables::PTable::iterator
splicePatch(FarPatchTables::Descriptor desc,
std::vector<FarMesh<T> const *> const &meshes,
FarPatchTables::PatchArrayVector &result,
std::vector<FarPatchTables::PatchArrayVector> *multiArrayResult,
FarPatchTables::PTable::iterator dstIndexIt,
int *voffset, int *poffset, int *qoffset,
std::vector<int> const &vertexOffsets) {
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *patchTables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *srcPatchArray = patchTables->GetPatchArray(desc);
if (not srcPatchArray) continue;
// create new patcharray with offset
int vindex = srcPatchArray->GetVertIndex();
int npatch = srcPatchArray->GetNumPatches();
int nvertex = npatch * desc.GetNumControlVertices();
FarPatchTables::PatchArray patchArray(desc,
*voffset,
*poffset,
npatch,
*qoffset);
// append patch array
result.push_back(patchArray);
// also store into multiPatchArrays, will be used for partial drawing
// XXX: can be stored as indices. revisit here later
if (multiArrayResult) {
(*multiArrayResult)[i].push_back(patchArray);
}
// increment offset
*voffset += nvertex;
*poffset += npatch;
*qoffset += (desc.GetType() == FarPatchTables::GREGORY ||
desc.GetType() == FarPatchTables::GREGORY_BOUNDARY) ? npatch * 4 : 0;
// copy index arrays [vindex, vindex+nvertex]
dstIndexIt = copyWithOffset(dstIndexIt,
patchTables->GetPatchTable(),
vindex,
nvertex,
vertexOffsets[i]);
}
return dstIndexIt;
}
template <class T> FarPatchTables *
FarPatchTablesFactory<T>::Splice(FarMeshVector const &meshes,
MultiPatchArrayVector *multiPatchArrays) {
int totalQuadOffset0 = 0;
int totalQuadOffset1 = 0;
int totalFVarData = 0;
int fvarWidth = 0;
std::vector<int> vertexOffsets;
std::vector<int> gregoryQuadOffsets;
std::vector<int> numGregoryPatches;
int vertexOffset = 0;
int maxValence = 0;
int numTotalIndices = 0;
//result->_patchCounts.reserve(meshes.size());
//FarPatchCount totalCount;
typedef FarPatchTables::Descriptor Descriptor;
// note: see FarPatchTablesFactory<T>::Create
// feature adaptive refinement can generate un-connected face-vertices
// that have a valence of 0. The spliced vertex valence tables
// needs to be resized including such un-connected face-vertices.
int numVerticesInVertexValence = 0;
// count how many patches exist on each mesh
for (size_t i = 0; i < meshes.size(); ++i) {
const FarPatchTables *ptables = meshes[i]->GetPatchTables();
assert(ptables);
vertexOffsets.push_back(vertexOffset);
vertexOffset += meshes[i]->GetNumVertices();
// need to align maxvalence with the highest value
maxValence = std::max(maxValence, ptables->_maxValence);
FarPatchTables::PatchArray const *gregory =
ptables->GetPatchArray(Descriptor(FarPatchTables::GREGORY,
FarPatchTables::NON_TRANSITION, /*rot*/ 0));
FarPatchTables::PatchArray const *gregoryBoundary =
ptables->GetPatchArray(Descriptor(FarPatchTables::GREGORY_BOUNDARY,
FarPatchTables::NON_TRANSITION, /*rot*/ 0));
int nGregory = gregory ? gregory->GetNumPatches() : 0;
int nGregoryBoundary = gregoryBoundary ? gregoryBoundary->GetNumPatches() : 0;
totalQuadOffset0 += nGregory * 4;
totalQuadOffset1 += nGregoryBoundary * 4;
numGregoryPatches.push_back(nGregory);
gregoryQuadOffsets.push_back(totalQuadOffset0);
totalFVarData += (int)ptables->GetFVarData()._data.size();
numTotalIndices += ptables->GetNumControlVertices();
// note: some prims may not have vertex valence table, but still need a space
// in order to fill following prim's data at appropriate location.
numVerticesInVertexValence += ptables->_vertexValenceTable.empty()
? (int)meshes[i]->GetNumVertices()
: (int)ptables->_vertexValenceTable.size()/(2*ptables->_maxValence+1);
// fvarWidth has to be same for all meshes.
fvarWidth = meshes[i]->GetPatchTables()->GetFVarData().GetFVarWidth();
}
FarPatchTables *result = new FarPatchTables(maxValence);
// Allocate full patches
result->_patches.resize(numTotalIndices);
// Allocate vertex valence table, quad offset table
if (totalQuadOffset0 + totalQuadOffset1 > 0) {
result->_vertexValenceTable.resize((2*maxValence+1) * numVerticesInVertexValence);
result->_quadOffsetTable.resize(totalQuadOffset0 + totalQuadOffset1);
}
// Allocate fvardata table
result->_fvarData._data.resize(totalFVarData);
// splice tables
// assuming input farmeshes have dense patchtables
if (multiPatchArrays)
multiPatchArrays->resize(meshes.size());
int voffset = 0, poffset = 0, qoffset = 0;
FarPatchTables::PTable::iterator dstIndexIt = result->_patches.begin();
// splice patches : iterate over all descriptors, including points, lines, quads, etc.
for (Descriptor::iterator it=Descriptor::begin(Descriptor::ANY); it!=Descriptor::end(); ++it) {
dstIndexIt = splicePatch(*it,
meshes,
result->_patchArrays,
multiPatchArrays,
dstIndexIt,
&voffset,
&poffset,
&qoffset,
vertexOffsets);
}
// merge vertexvalence and quadoffset tables
FarPatchTables::QuadOffsetTable::iterator Q0_IT = result->_quadOffsetTable.begin();
FarPatchTables::QuadOffsetTable::iterator Q1_IT = Q0_IT + totalQuadOffset0;
FarPatchTables::VertexValenceTable::iterator VV_IT = result->_vertexValenceTable.begin();
for (size_t i = 0; i < meshes.size(); ++i) {
const FarPatchTables *ptables = meshes[i]->GetPatchTables();
// merge vertex valence
// note: some prims may not have vertex valence table, but still need a space
// in order to fill following prim's data at appropriate location.
copyWithOffsetVertexValence(VV_IT,
ptables->_vertexValenceTable,
ptables->_maxValence,
maxValence,
vertexOffsets[i]);
VV_IT += meshes[i]->GetNumVertices() * (2 * maxValence + 1);
// merge quad offsets
int nGregoryQuads = numGregoryPatches[i] * 4;
if (nGregoryQuads > 0) {
Q0_IT = std::copy(ptables->_quadOffsetTable.begin(),
ptables->_quadOffsetTable.begin()+nGregoryQuads,
Q0_IT);
}
if (nGregoryQuads < (int)ptables->_quadOffsetTable.size()) {
Q1_IT = std::copy(ptables->_quadOffsetTable.begin()+nGregoryQuads,
ptables->_quadOffsetTable.end(),
Q1_IT);
}
}
// merge ptexCoord table
for (FarPatchTables::Descriptor::iterator it =
FarPatchTables::Descriptor::begin(FarPatchTables::Descriptor::ANY);
it != FarPatchTables::Descriptor::end(); ++it) {
int ptexFaceOffset = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *ptables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *parray = ptables->GetPatchArray(*it);
if (parray) {
copyWithPtexFaceOffset(std::back_inserter(result->_paramTable),
ptables->_paramTable,
parray->GetPatchIndex(),
parray->GetNumPatches(), ptexFaceOffset);
}
ptexFaceOffset += ptables->GetNumPtexFaces();
}
}
// count total num ptex faces
int numPtexFaces = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
numPtexFaces += meshes[i]->GetPatchTables()->GetNumPtexFaces();
}
result->_numPtexFaces = numPtexFaces;
// merge fvardata table
if (fvarWidth > 0) {
std::vector<float>::iterator FV_IT = result->_fvarData._data.begin();
for (FarPatchTables::Descriptor::iterator it =
FarPatchTables::Descriptor::begin(FarPatchTables::Descriptor::ANY);
it != FarPatchTables::Descriptor::end(); ++it) {
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *ptables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *parray = ptables->GetPatchArray(*it);
FarSubdivisionTables::Scheme scheme = meshes[i]->GetSubdivisionTables()->GetScheme();
if (parray) {
int nv = (scheme == FarSubdivisionTables::LOOP) ? 3 : 4;
int width = ptables->GetFVarData().GetFVarWidth() * nv; // for each quads or tris
std::vector<float>::const_iterator begin =
ptables->_fvarData._data.begin() + parray->GetPatchIndex() * width;
std::vector<float>::const_iterator end =
begin + parray->GetNumPatches() * width;
FV_IT = std::copy(begin, end, FV_IT);
}
}
}
// set fvarwidth
result->_fvarData._fvarWidth = fvarWidth;
}
return result;
}
} // end namespace OPENSUBDIV_VERSION

View File

@ -28,14 +28,13 @@
#include "../version.h"
#include <cassert>
#include <cmath>
#include <utility>
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
template <class U> class FarMesh;
/// \brief FarSubdivisionTables are a serialized topological data representation.
///
/// Subdivision tables store the indexing tables required in order to compute
@ -62,7 +61,7 @@ template <class U> class FarMesh;
/// For more details see : "Feature Adaptive GPU Rendering of Catmull-Clark
/// Subdivision Surfaces" (p.3 - par. 3.2)
///
template <class U> class FarSubdivisionTables {
class FarSubdivisionTables {
public:
@ -88,7 +87,7 @@ public:
};
/// \brief Destructor
virtual ~FarSubdivisionTables<U>() {}
~FarSubdivisionTables() {}
/// \brief Return the highest level of subdivision possible with these tables
int GetMaxLevel() const { return (int)(_vertsOffsets.size()-1); }
@ -96,11 +95,8 @@ public:
/// \brief Memory required to store the indexing tables
int GetMemoryUsed() const;
/// \brief Pointer back to the mesh owning the table
FarMesh<U> * GetMesh() { return _mesh; }
/// \brief The index of the first vertex that belongs to the level of subdivision
/// represented by this set of FarCatmarkSubdivisionTables
/// represented by this set of FarSubdivisionTables
int GetFirstVertexOffset( int level ) const;
/// \brief Returns the total number of vertex adressed by the tables (this is the
@ -138,20 +134,73 @@ public:
/// \brief Returns the subdivision scheme of the tables
/// (sidesteps typeinfo dependency)
virtual Scheme GetScheme() const { return UNDEFINED; }
Scheme GetScheme() const { return _scheme; }
/// \brief Returns the number of indexing tables needed to represent this particular
/// subdivision scheme.
virtual int GetNumTables() const { return 5; }
int GetNumTables() const;
// -------------------------------------------------------------------------
// Bilinear scheme
// Compute-kernel applied to vertices resulting from the refinement of a face.
template <class U>
void computeBilinearFacePoints(int vertexOffset, int tableOffset, int start, int end, U *vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of an edge.
template <class U>
void computeBilinearEdgePoints(int vertexOffset, int tableOffset, int start, int end, U *vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
template <class U>
void computeBilinearVertexPoints(int vertexOffset, int tableOffset, int start, int end, U *vsrc) const;
// -------------------------------------------------------------------------
// Catmark scheme
// Compute-kernel applied to vertices resulting from the refinement of a face.
template <class U>
void computeCatmarkFacePoints(int offset, int level, int start, int end, U * vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of an edge.
template <class U>
void computeCatmarkEdgePoints(int offset, int level, int start, int end, U * vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "A" Handles the k_Smooth and k_Dart rules
template <class U>
void computeCatmarkVertexPointsA(int offset, bool pass, int level, int start, int end, U * vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "B" Handles the k_Crease and k_Corner rules
template <class U>
void computeCatmarkVertexPointsB(int offset, int level, int start, int end, U * vsrc) const;
// -------------------------------------------------------------------------
// Loop scheme
// Compute-kernel applied to vertices resulting from the refinement of an edge.
template <class U>
void computeLoopEdgePoints(int offset, int level, int start, int end, U *vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "A" Handles the k_Smooth and k_Dart rules
template <class U>
void computeLoopVertexPointsA(int offset, bool pass, int level, int start, int end, U *vsrc) const;
// Compute-kernel applied to vertices resulting from the refinement of a vertex
// Kernel "B" Handles the k_Crease and k_Corner rules
template <class U>
void computeLoopVertexPointsB(int offset,int level, int start, int end, U *vsrc) const;
protected:
template <class X, class Y> friend class FarMeshFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
template <class X, class Y> friend class FarBilinearSubdivisionTablesFactory;
template <class X, class Y> friend class FarCatmarkSubdivisionTablesFactory;
template <class X, class Y> friend class FarLoopSubdivisionTablesFactory;
template <class X, class Y> friend class FarSubdivisionTablesFactory;
FarSubdivisionTables<U>( FarMesh<U> * mesh, int maxlevel );
// mesh that owns this subdivisionTable
FarMesh<U> * _mesh;
FarSubdivisionTables( int maxlevel, Scheme scheme );
std::vector<int> _F_ITa; // vertices from face refinement
std::vector<unsigned int> _F_IT; // indices of face vertices
@ -163,25 +212,26 @@ protected:
std::vector<unsigned int> _V_IT; // indices of adjacent vertices
std::vector<float> _V_W; // weights
std::vector<int> _vertsOffsets; // offset to the first vertex of each level
std::vector<int> _vertsOffsets; // offset to the first vertex of each level
Scheme _scheme; // subdivision scheme
};
template <class U>
FarSubdivisionTables<U>::FarSubdivisionTables( FarMesh<U> * mesh, int maxlevel ) :
_mesh(mesh),
_vertsOffsets(maxlevel+2, 0)
inline
FarSubdivisionTables::FarSubdivisionTables( int maxlevel, Scheme scheme ) :
_vertsOffsets(maxlevel+2, 0), _scheme(scheme)
{
assert( maxlevel > 0 );
}
template <class U> int
FarSubdivisionTables<U>::GetFirstVertexOffset( int level ) const {
inline int
FarSubdivisionTables::GetFirstVertexOffset( int level ) const {
assert(level>=0 and level<(int)_vertsOffsets.size());
return _vertsOffsets[level];
}
template <class U> int
FarSubdivisionTables<U>::GetNumVertices( ) const {
inline int
FarSubdivisionTables::GetNumVertices( ) const {
if (_vertsOffsets.empty()) {
return 0;
} else {
@ -191,20 +241,30 @@ FarSubdivisionTables<U>::GetNumVertices( ) const {
}
}
template <class U> int
FarSubdivisionTables<U>::GetNumVertices( int level ) const {
inline int
FarSubdivisionTables::GetNumVertices( int level ) const {
assert(level>=0 and level<((int)_vertsOffsets.size()-1));
return _vertsOffsets[level+1] - _vertsOffsets[level];
}
template <class U> int
FarSubdivisionTables<U>::GetNumVerticesTotal( int level ) const {
inline int
FarSubdivisionTables::GetNumVerticesTotal( int level ) const {
assert(level>=0 and level<((int)_vertsOffsets.size()-1));
return _vertsOffsets[level+1];
}
template <class U> int
FarSubdivisionTables<U>::GetMemoryUsed() const {
inline int
FarSubdivisionTables::GetNumTables() const {
switch (_scheme) {
case BILINEAR: return 7;
case CATMARK: return 7;
case LOOP: return 5;
default: return 0;
}
}
inline int
FarSubdivisionTables::GetMemoryUsed() const {
return (int)(_F_ITa.size() * sizeof(int) +
_F_IT.size() * sizeof(unsigned int) +
_E_IT.size() * sizeof(int) +
@ -214,6 +274,321 @@ FarSubdivisionTables<U>::GetMemoryUsed() const {
_V_W.size() * sizeof(float));
}
//
// Face-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarSubdivisionTables::computeBilinearFacePoints( int offset, int tableOffset, int start, int end, U *vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int h = this->_F_ITa[2*i ],
n = this->_F_ITa[2*i+1];
float weight = 1.0f/n;
for (int j=0; j<n; ++j) {
vdst->AddWithWeight( vsrc[ this->_F_IT[h+j] ], weight );
vdst->AddVaryingWithWeight( vsrc[ this->_F_IT[h+j] ], weight );
}
}
}
//
// Edge-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarSubdivisionTables::computeBilinearEdgePoints( int offset, int tableOffset, int start, int end, U *vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int eidx0 = this->_E_IT[2*i+0],
eidx1 = this->_E_IT[2*i+1];
vdst->AddWithWeight( vsrc[eidx0], 0.5f );
vdst->AddWithWeight( vsrc[eidx1], 0.5f );
vdst->AddVaryingWithWeight( vsrc[eidx0], 0.5f );
vdst->AddVaryingWithWeight( vsrc[eidx1], 0.5f );
}
}
//
// Vertex-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarSubdivisionTables::computeBilinearVertexPoints( int offset, int tableOffset, int start, int end, U *vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int p = this->_V_ITa[i]; // index of the parent vertex
vdst->AddWithWeight( vsrc[p], 1.0f );
vdst->AddVaryingWithWeight( vsrc[p], 1.0f );
}
}
//
// Face-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarSubdivisionTables::computeCatmarkFacePoints( int offset, int tableOffset, int start, int end, U * vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int h = this->_F_ITa[2*i ],
n = this->_F_ITa[2*i+1];
float weight = 1.0f/n;
for (int j=0; j<n; ++j) {
vdst->AddWithWeight( vsrc[ this->_F_IT[h+j] ], weight );
vdst->AddVaryingWithWeight( vsrc[ this->_F_IT[h+j] ], weight );
}
}
}
//
// Edge-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarSubdivisionTables::computeCatmarkEdgePoints( int offset, int tableOffset, int start, int end, U * vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int eidx0 = this->_E_IT[4*i+0],
eidx1 = this->_E_IT[4*i+1],
eidx2 = this->_E_IT[4*i+2],
eidx3 = this->_E_IT[4*i+3];
float vertWeight = this->_E_W[i*2+0];
// Fully sharp edge : vertWeight = 0.5f
vdst->AddWithWeight( vsrc[eidx0], vertWeight );
vdst->AddWithWeight( vsrc[eidx1], vertWeight );
if (eidx2!=-1) {
// Apply fractional sharpness
float faceWeight = this->_E_W[i*2+1];
vdst->AddWithWeight( vsrc[eidx2], faceWeight );
vdst->AddWithWeight( vsrc[eidx3], faceWeight );
}
vdst->AddVaryingWithWeight( vsrc[eidx0], 0.5f );
vdst->AddVaryingWithWeight( vsrc[eidx1], 0.5f );
}
}
//
// Vertex-vertices compute Kernels "A" and "B" - completely re-entrant
//
// multi-pass kernel handling k_Crease and k_Corner rules
template <class U> void
FarSubdivisionTables::computeCatmarkVertexPointsA( int offset, bool pass, int tableOffset, int start, int end, U * vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
if (not pass)
vdst->Clear();
int n=this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p=this->_V_ITa[5*i+2], // index of the parent vertex
eidx0=this->_V_ITa[5*i+3], // index of the first crease rule edge
eidx1=this->_V_ITa[5*i+4]; // index of the second crease rule edge
float weight = pass ? this->_V_W[i] : 1.0f - this->_V_W[i];
// In the case of fractional weight, the weight must be inverted since
// the value is shared with the k_Smooth kernel (statistically the
// k_Smooth kernel runs much more often than this one)
if (weight>0.0f and weight<1.0f and n>0)
weight=1.0f-weight;
// In the case of a k_Corner / k_Crease combination, the edge indices
// won't be null, so we use a -1 valence to detect that particular case
if (eidx0==-1 or (pass==false and (n==-1)) ) {
// k_Corner case
vdst->AddWithWeight( vsrc[p], weight );
} else {
// k_Crease case
vdst->AddWithWeight( vsrc[p], weight * 0.75f );
vdst->AddWithWeight( vsrc[eidx0], weight * 0.125f );
vdst->AddWithWeight( vsrc[eidx1], weight * 0.125f );
}
vdst->AddVaryingWithWeight( vsrc[p], 1.0f );
}
}
// multi-pass kernel handling k_Dart and k_Smooth rules
template <class U> void
FarSubdivisionTables::computeCatmarkVertexPointsB( int offset, int tableOffset, int start, int end, U * vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int h = this->_V_ITa[5*i ], // offset of the vertices in the _V0_IT array
n = this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p = this->_V_ITa[5*i+2]; // index of the parent vertex
float weight = this->_V_W[i],
wp = 1.0f/(n*n),
wv = (n-2.0f)*n*wp;
vdst->AddWithWeight( vsrc[p], weight * wv );
for (int j=0; j<n; ++j) {
vdst->AddWithWeight( vsrc[this->_V_IT[h+j*2 ]], weight * wp );
vdst->AddWithWeight( vsrc[this->_V_IT[h+j*2+1]], weight * wp );
}
vdst->AddVaryingWithWeight( vsrc[p], 1.0f );
}
}
//
// Edge-vertices compute Kernel - completely re-entrant
//
template <class U> void
FarSubdivisionTables::computeLoopEdgePoints( int offset, int tableOffset, int start, int end, U * vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int eidx0 = this->_E_IT[4*i+0],
eidx1 = this->_E_IT[4*i+1],
eidx2 = this->_E_IT[4*i+2],
eidx3 = this->_E_IT[4*i+3];
float endPtWeight = this->_E_W[i*2+0];
// Fully sharp edge : endPtWeight = 0.5f
vdst->AddWithWeight( vsrc[eidx0], endPtWeight );
vdst->AddWithWeight( vsrc[eidx1], endPtWeight );
if (eidx2!=-1) {
// Apply fractional sharpness
float oppPtWeight = this->_E_W[i*2+1];
vdst->AddWithWeight( vsrc[eidx2], oppPtWeight );
vdst->AddWithWeight( vsrc[eidx3], oppPtWeight );
}
vdst->AddVaryingWithWeight( vsrc[eidx0], 0.5f );
vdst->AddVaryingWithWeight( vsrc[eidx1], 0.5f );
}
}
//
// Vertex-vertices compute Kernels "A" and "B" - completely re-entrant
//
// multi-pass kernel handling k_Crease and k_Corner rules
template <class U> void
FarSubdivisionTables::computeLoopVertexPointsA( int offset, bool pass, int tableOffset, int start, int end, U * vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
if (not pass)
vdst->Clear();
int n=this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p=this->_V_ITa[5*i+2], // index of the parent vertex
eidx0=this->_V_ITa[5*i+3], // index of the first crease rule edge
eidx1=this->_V_ITa[5*i+4]; // index of the second crease rule edge
float weight = pass ? this->_V_W[i] : 1.0f - this->_V_W[i];
// In the case of fractional weight, the weight must be inverted since
// the value is shared with the k_Smooth kernel (statistically the
// k_Smooth kernel runs much more often than this one)
if (weight>0.0f and weight<1.0f and n>0)
weight=1.0f-weight;
// In the case of a k_Corner / k_Crease combination, the edge indices
// won't be null, so we use a -1 valence to detect that particular case
if (eidx0==-1 or (pass==false and (n==-1)) ) {
// k_Corner case
vdst->AddWithWeight( vsrc[p], weight );
} else {
// k_Crease case
vdst->AddWithWeight( vsrc[p], weight * 0.75f );
vdst->AddWithWeight( vsrc[eidx0], weight * 0.125f );
vdst->AddWithWeight( vsrc[eidx1], weight * 0.125f );
}
vdst->AddVaryingWithWeight( vsrc[p], 1.0f );
}
}
// multi-pass kernel handling k_Dart and k_Smooth rules
template <class U> void
FarSubdivisionTables::computeLoopVertexPointsB( int offset, int tableOffset, int start, int end, U *vsrc ) const {
U * vdst = vsrc + offset + start;
for (int i=start+tableOffset; i<end+tableOffset; ++i, ++vdst ) {
vdst->Clear();
int h = this->_V_ITa[5*i ], // offset of the vertices in the _V0_IT array
n = this->_V_ITa[5*i+1], // number of vertices in the _VO_IT array (valence)
p = this->_V_ITa[5*i+2]; // index of the parent vertex
float weight = this->_V_W[i],
wp = 1.0f/n,
beta = 0.25f * cosf((float)M_PI * 2.0f * wp) + 0.375f;
beta = beta*beta;
beta = (0.625f-beta)*wp;
vdst->AddWithWeight( vsrc[p], weight * (1.0f-(beta*n)));
for (int j=0; j<n; ++j)
vdst->AddWithWeight( vsrc[this->_V_IT[h+j]], weight * beta );
vdst->AddVaryingWithWeight( vsrc[p], 1.0f );
}
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;

View File

@ -27,8 +27,9 @@
#include "../version.h"
#include "../far/meshFactory.h"
// note: currently, this file has to be included from meshFactory.h
#include "../far/subdivisionTables.h"
#include "../far/kernelBatch.h"
#include <cassert>
#include <utility>
@ -47,6 +48,13 @@ template <class T, class U> class FarLoopSubdivisionTablesFactory;
///
template <class T, class U> class FarSubdivisionTablesFactory {
public:
typedef std::vector<FarMesh<U> const *> FarMeshVector;
/// \brief Splices subdivision tables and batches from multiple meshes and returns them
/// Client code is responsible for deallocation.
static FarSubdivisionTables *Splice(FarMeshVector const &meshes, FarKernelBatchVector *resultBatches);
protected:
friend class FarBilinearSubdivisionTablesFactory<T,U>;
friend class FarCatmarkSubdivisionTablesFactory<T,U>;
@ -350,6 +358,231 @@ FarSubdivisionTablesFactory<T,U>::compareVertices( HbrVertex<T> const * x, HbrVe
GetMaskRanking(py->GetMask(false), py->GetMask(true) );
}
// splice subdivision tables
template <typename V, typename IT> static IT
copyWithOffset(IT dst_iterator, V const &src, int offset) {
return std::transform(src.begin(), src.end(), dst_iterator,
std::bind2nd(std::plus<typename V::value_type>(), offset));
}
template <typename V, typename IT> static IT
copyWithPtexFaceOffset(IT dst_iterator, V const &src, int start, int count, int offset) {
for (typename V::const_iterator it = src.begin()+start; it != src.begin()+start+count; ++it) {
typename V::value_type ptexCoord = *it;
ptexCoord.faceIndex += offset;
*dst_iterator++ = ptexCoord;
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetF_ITa(IT dst_iterator, V const &src, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end();) {
*dst_iterator++ = *it++ + offset; // offset to F_IT
*dst_iterator++ = *it++; // valence
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetE_IT(IT dst_iterator, V const &src, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end(); ++it) {
*dst_iterator++ = (*it == -1) ? -1 : (*it + offset);
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetV_ITa(IT dst_iterator, V const &src, int tableOffset, int vertexOffset) {
for (typename V::const_iterator it = src.begin(); it != src.end();) {
*dst_iterator++ = *it++ + tableOffset; // offset to V_IT
*dst_iterator++ = *it++; // valence
*dst_iterator++ = (*it == -1) ? -1 : (*it + vertexOffset); ++it;
*dst_iterator++ = (*it == -1) ? -1 : (*it + vertexOffset); ++it;
*dst_iterator++ = (*it == -1) ? -1 : (*it + vertexOffset); ++it;
}
return dst_iterator;
}
template <class T, class U> FarSubdivisionTables*
FarSubdivisionTablesFactory<T,U>::Splice(FarMeshVector const &meshes, FarKernelBatchVector *batches ) {
// count total table size
size_t total_F_ITa = 0, total_F_IT = 0;
size_t total_E_IT = 0, total_E_W = 0;
size_t total_V_ITa = 0, total_V_IT = 0, total_V_W = 0;
FarSubdivisionTables::Scheme scheme = FarSubdivisionTables::UNDEFINED;
int maxLevel = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables const * tables = meshes[i]->GetSubdivisionTables();
assert(tables);
total_F_ITa += tables->Get_F_ITa().size();
total_F_IT += tables->Get_F_IT().size();
total_E_IT += tables->Get_E_IT().size();
total_E_W += tables->Get_E_W().size();
total_V_ITa += tables->Get_V_ITa().size();
total_V_IT += tables->Get_V_IT().size();
total_V_W += tables->Get_V_W().size();
maxLevel = std::max(maxLevel, tables->GetMaxLevel()-1);
if (scheme == FarSubdivisionTables::UNDEFINED) {
scheme = tables->GetScheme();
} else {
assert(scheme == tables->GetScheme());
}
}
FarSubdivisionTables *result = new FarSubdivisionTables(maxLevel, scheme);
result->_F_ITa.resize(total_F_ITa);
result->_F_IT.resize(total_F_IT);
result->_E_IT.resize(total_E_IT);
result->_E_W.resize(total_E_W);
result->_V_ITa.resize(total_V_ITa);
result->_V_IT.resize(total_V_IT);
result->_V_W.resize(total_V_W);
// compute table offsets;
std::vector<int> vertexOffsets;
std::vector<int> fvOffsets;
std::vector<int> evOffsets;
std::vector<int> vvOffsets;
std::vector<int> F_IToffsets;
std::vector<int> V_IToffsets;
{
int vertexOffset = 0;
int F_IToffset = 0;
int V_IToffset = 0;
int fvOffset = 0;
int evOffset = 0;
int vvOffset = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables const * tables = meshes[i]->GetSubdivisionTables();
assert(tables);
vertexOffsets.push_back(vertexOffset);
F_IToffsets.push_back(F_IToffset);
V_IToffsets.push_back(V_IToffset);
fvOffsets.push_back(fvOffset);
evOffsets.push_back(evOffset);
vvOffsets.push_back(vvOffset);
vertexOffset += meshes[i]->GetNumVertices();
F_IToffset += (int)tables->Get_F_IT().size();
fvOffset += (int)tables->Get_F_ITa().size()/2;
V_IToffset += (int)tables->Get_V_IT().size();
if (scheme == FarSubdivisionTables::CATMARK or
scheme == FarSubdivisionTables::LOOP) {
evOffset += (int)tables->Get_E_IT().size()/4;
vvOffset += (int)tables->Get_V_ITa().size()/5;
} else {
evOffset += (int)tables->Get_E_IT().size()/2;
vvOffset += (int)tables->Get_V_ITa().size();
}
}
}
// concat F_IT and V_IT
std::vector<unsigned int>::iterator F_IT = result->_F_IT.begin();
std::vector<unsigned int>::iterator V_IT = result->_V_IT.begin();
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables const * tables = meshes[i]->GetSubdivisionTables();
int vertexOffset = vertexOffsets[i];
// remap F_IT, V_IT tables
F_IT = copyWithOffset(F_IT, tables->Get_F_IT(), vertexOffset);
V_IT = copyWithOffset(V_IT, tables->Get_V_IT(), vertexOffset);
}
// merge other tables
std::vector<int>::iterator F_ITa = result->_F_ITa.begin();
std::vector<int>::iterator E_IT = result->_E_IT.begin();
std::vector<float>::iterator E_W = result->_E_W.begin();
std::vector<float>::iterator V_W = result->_V_W.begin();
std::vector<int>::iterator V_ITa = result->_V_ITa.begin();
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables const * tables = meshes[i]->GetSubdivisionTables();
// copy face tables
F_ITa = copyWithOffsetF_ITa(F_ITa, tables->Get_F_ITa(), F_IToffsets[i]);
// copy edge tables
E_IT = copyWithOffsetE_IT(E_IT, tables->Get_E_IT(), vertexOffsets[i]);
E_W = copyWithOffset(E_W, tables->Get_E_W(), 0);
// copy vert tables
if (scheme == FarSubdivisionTables::CATMARK or
scheme == FarSubdivisionTables::LOOP) {
V_ITa = copyWithOffsetV_ITa(V_ITa, tables->Get_V_ITa(), V_IToffsets[i], vertexOffsets[i]);
} else {
V_ITa = copyWithOffset(V_ITa, tables->Get_V_ITa(), vertexOffsets[i]);
}
V_W = copyWithOffset(V_W, tables->Get_V_W(), 0);
}
// merge batch, model by model
int editTableIndexOffset = 0;
for (int i = 0; i < (int)meshes.size(); ++i) {
int numBatches = (int)meshes[i]->GetKernelBatches().size();
for (int j = 0; j < numBatches; ++j) {
FarKernelBatch batch = meshes[i]->GetKernelBatches()[j];
batch._meshIndex = i;
batch._vertexOffset += vertexOffsets[i];
if (batch._kernelType == FarKernelBatch::CATMARK_FACE_VERTEX or
batch._kernelType == FarKernelBatch::BILINEAR_FACE_VERTEX) {
batch._tableOffset += fvOffsets[i];
} else if (batch._kernelType == FarKernelBatch::CATMARK_EDGE_VERTEX or
batch._kernelType == FarKernelBatch::LOOP_EDGE_VERTEX or
batch._kernelType == FarKernelBatch::BILINEAR_EDGE_VERTEX) {
batch._tableOffset += evOffsets[i];
} else if (batch._kernelType == FarKernelBatch::CATMARK_VERT_VERTEX_A1 or
batch._kernelType == FarKernelBatch::CATMARK_VERT_VERTEX_A2 or
batch._kernelType == FarKernelBatch::CATMARK_VERT_VERTEX_B or
batch._kernelType == FarKernelBatch::LOOP_VERT_VERTEX_A1 or
batch._kernelType == FarKernelBatch::LOOP_VERT_VERTEX_A2 or
batch._kernelType == FarKernelBatch::LOOP_VERT_VERTEX_B or
batch._kernelType == FarKernelBatch::BILINEAR_VERT_VERTEX) {
batch._tableOffset += vvOffsets[i];
} else if (batch._kernelType == FarKernelBatch::HIERARCHICAL_EDIT) {
batch._tableIndex += editTableIndexOffset;
}
batches->push_back(batch);
}
editTableIndexOffset += meshes[i]->GetVertexEditTables() ?
meshes[i]->GetVertexEditTables()->GetNumBatches() : 0;
}
// count verts offsets
result->_vertsOffsets.resize(maxLevel+2);
for (size_t i = 0; i < meshes.size(); ++i) {
FarSubdivisionTables const * tables = meshes[i]->GetSubdivisionTables();
for (size_t j = 0; j < tables->_vertsOffsets.size(); ++j) {
result->_vertsOffsets[j] += tables->_vertsOffsets[j];
}
}
return result;
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;

View File

@ -34,8 +34,6 @@
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
template <class U> class FarMesh;
/// \brief A serialized container for hierarchical edits.
///
/// Some of the hierarchical edits are resolved into the vertex weights computed
@ -66,7 +64,7 @@ public:
const float* GetEdit() const { return _edit; }
private:
template <class U> friend class FarVertexEditTables;
friend class FarVertexEditTables;
FarVertexEdit(Operation op, int index, int width) :
_op(op), _edit(0), _index(index), _width(width)
@ -80,13 +78,17 @@ private:
_width;
};
template <class U> class FarVertexEditTables {
class FarVertexEditTables {
public:
/// \brief Constructor
FarVertexEditTables( FarMesh<U> * mesh );
FarVertexEditTables( ) { }
// Note : Subtract type edits are converted into Adds in order to save kernel calls.
// Compute-kernel that applies the edits
template <class CONTEXT>
void computeVertexEdits(int tableIndex, int offset, int tableOffset, int start, int end, CONTEXT *context) const;
/// \brief This class holds an array of edits. each batch has unique index/width/operation
class VertexEditBatch {
public:
@ -97,6 +99,7 @@ public:
void Append(int level, int vertexID, const float *values, bool negate);
/// \brief Compute-kernel applied to vertices
template <class U>
void ApplyVertexEdits(U * vsrc, int offset, int tableOffset, int start, int end) const;
// Edit tables accessors
@ -118,7 +121,6 @@ public:
private:
template <class X, class Y> friend class FarVertexEditTablesFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
std::vector<unsigned int> _vertIndices; // absolute vertex index array for edits
std::vector<float> _edits; // edit values array
@ -143,14 +145,6 @@ public:
private:
template <class X, class Y> friend class FarVertexEditTablesFactory;
template <class X, class Y> friend class FarMultiMeshFactory;
template <class CONTROLLER> friend class FarComputeController;
// Compute-kernel that applies the edits
void computeVertexEdits(int tableIndex, int offset, int tableOffset, int start, int end, void *clientdata) const;
// mesh that owns this vertexEditTable
FarMesh<U> * _mesh;
#if defined(__GNUC__)
// XXX(dyu): seems like there is a compiler bug in g++ that requires
@ -160,16 +154,16 @@ public:
std::vector<VertexEditBatch> _batches;
};
template <class U>
FarVertexEditTables<U>::VertexEditBatch::VertexEditBatch(int index, int width, FarVertexEdit::Operation op) :
inline
FarVertexEditTables::VertexEditBatch::VertexEditBatch(int index, int width, FarVertexEdit::Operation operation) :
_primvarIndex(index),
_primvarWidth(width),
_op(op) {
_op(operation) {
}
template <class U>
void
FarVertexEditTables<U>::VertexEditBatch::ApplyVertexEdits(U * vsrc, int vertexOffset, int tableOffset, int start, int end) const
FarVertexEditTables::VertexEditBatch::ApplyVertexEdits(U * vsrc, int vertexOffset, int tableOffset, int start, int end) const
{
int primvarWidth = GetPrimvarWidth();
assert(tableOffset+end <= (int)_vertIndices.size());
@ -185,17 +179,8 @@ FarVertexEditTables<U>::VertexEditBatch::ApplyVertexEdits(U * vsrc, int vertexOf
}
}
template <class U>
FarVertexEditTables<U>::FarVertexEditTables( FarMesh<U> * mesh ) :
_mesh(mesh) {
}
template <class U> void
FarVertexEditTables<U>::computeVertexEdits(int tableIndex, int offset, int tableOffset, int start, int end, void *clientdata) const {
assert(this->_mesh);
U * vsrc = &this->_mesh->GetVertices().at(0);
FarVertexEditTables::computeVertexEdits(int tableIndex, int offset, int tableOffset, int start, int end, U * vsrc) const {
_batches[tableIndex].ApplyVertexEdits(vsrc, offset, tableOffset, start, end);
}

View File

@ -44,6 +44,13 @@ namespace OPENSUBDIV_VERSION {
///
template <class T, class U> class FarVertexEditTablesFactory {
public:
typedef std::vector<FarMesh<U> const *> FarMeshVector;
/// \brief Splices vertex edit tables from multiple meshes and returns it.
/// Client code is responsible for deallocation.
static FarVertexEditTables *Splice(FarMeshVector const &meshes);
protected:
template <class X, class Y> friend class FarMeshFactory;
@ -53,7 +60,7 @@ protected:
static void insertHEditBatch(FarKernelBatchVector *batches, int batchIndex, int batchLevel, int batchCount, int tableOffset);
/// \brief Creates a FarVertexEditTables instance.
static FarVertexEditTables<U> * Create( FarMeshFactory<T,U> const * factory, FarMesh<U> * mesh, FarKernelBatchVector *batches, int maxlevel );
static FarVertexEditTables * Create( FarMeshFactory<T,U> const * factory, FarMesh<U> * mesh, FarKernelBatchVector *batches, int maxlevel );
};
template <class T, class U> bool
@ -76,12 +83,12 @@ FarVertexEditTablesFactory<T,U>::insertHEditBatch(FarKernelBatchVector *batches,
batches->insert(it, FarKernelBatch( FarKernelBatch::HIERARCHICAL_EDIT, batchLevel+1, batchIndex, 0, batchCount, tableOffset, 0) );
}
template <class T, class U> FarVertexEditTables<U> *
template <class T, class U> FarVertexEditTables *
FarVertexEditTablesFactory<T,U>::Create( FarMeshFactory<T,U> const * factory, FarMesh<U> * mesh, FarKernelBatchVector *batches, int maxlevel ) {
assert( factory and mesh );
FarVertexEditTables<U> * result = new FarVertexEditTables<U>(mesh);
FarVertexEditTables* result = new FarVertexEditTables();
std::vector<HbrHierarchicalEdit<T>*> const & hEdits = factory->_hbrMesh->GetHierarchicalEdits();
@ -127,7 +134,7 @@ FarVertexEditTablesFactory<T,U>::Create( FarMeshFactory<T,U> const * factory, Fa
if (batchIndex == -1) {
// create new batch
batchIndex = (int)result->_batches.size();
result->_batches.push_back(typename FarVertexEditTables<U>::VertexEditBatch(vedit->GetIndex(), vedit->GetWidth(), op));
result->_batches.push_back(typename FarVertexEditTables::VertexEditBatch(vedit->GetIndex(), vedit->GetWidth(), op));
batchSizes.push_back(0);
}
batchSizes[batchIndex]++;
@ -162,7 +169,7 @@ FarVertexEditTablesFactory<T,U>::Create( FarMeshFactory<T,U> const * factory, Fa
int batchIndex = batchIndices[i];
int & batchLevel = currentLevels[batchIndex];
int & batchCount = currentCounts[batchIndex];
typename FarVertexEditTables<U>::VertexEditBatch &batch = result->_batches[batchIndex];
typename FarVertexEditTables::VertexEditBatch &batch = result->_batches[batchIndex];
// if a new batch is needed
if (batchLevel != level-1) {
@ -201,6 +208,31 @@ FarVertexEditTablesFactory<T,U>::Create( FarMeshFactory<T,U> const * factory, Fa
return result;
}
// splicing functions
template <class T, class U> FarVertexEditTables *
FarVertexEditTablesFactory<T, U>::Splice(FarMeshVector const &meshes) {
FarVertexEditTables * result = new FarVertexEditTables();
// at this moment, don't merge vertex edit tables (separate batch)
for (size_t i = 0; i < meshes.size(); ++i) {
const FarVertexEditTables *vertexEditTables = meshes[i]->GetVertexEditTables();
if (not vertexEditTables) continue;
// copy each edit batch XXX:inefficient copy
result->_batches.insert(result->_batches.end(),
vertexEditTables->_batches.begin(),
vertexEditTables->_batches.end());
}
if (result->_batches.empty()) {
delete result;
return NULL;
}
return result;
}
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;

View File

@ -46,8 +46,14 @@ set(PUBLIC_HEADER_FILES
#-------------------------------------------------------------------------------
_add_doxy_headers( "${PUBLIC_HEADER_FILES}" )
install( FILES ${PUBLIC_HEADER_FILES}
DESTINATION ${CMAKE_INCDIR_BASE}/hbr
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
install(
FILES
${PUBLIC_HEADER_FILES}
DESTINATION
"${CMAKE_INCDIR_BASE}/hbr"
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ )
#-------------------------------------------------------------------------------

View File

@ -24,28 +24,25 @@
#-------------------------------------------------------------------------------
include_directories(
${PROJECT_SOURCE_DIR}/opensubdiv
"${PROJECT_SOURCE_DIR}/opensubdiv"
)
if( DXSDK_FOUND )
include_directories(
${DXSDK_INCLUDE_DIR}
"${DXSDK_INCLUDE_DIR}"
)
endif()
if( OPENGL_FOUND )
include_directories(
${OPENGL_INCLUDE_DIR}
)
if (NOT "${OPENGL_INCLUDE_DIR}" STREQUAL "")
include_directories("${OPENGL_INCLUDE_DIR}")
endif()
if (GLEW_FOUND)
include_directories(
${GLEW_INCLUDE_DIR}
)
include_directories("${GLEW_INCLUDE_DIR}")
endif()
elseif( OPENGLES_FOUND )
include_directories(
${OPENGLES_INCLUDE_DIR}
)
include_directories("${OPENGLES_INCLUDE_DIR}")
endif()
#-------------------------------------------------------------------------------
@ -68,14 +65,11 @@ set(CPU_SOURCE_FILES
drawRegistry.cpp
)
set(GPU_SOURCE_FILES
)
set(GPU_SOURCE_FILES )
set(KERNEL_FILES
)
set(KERNEL_FILES )
set(INC_FILES
)
set(INC_FILES )
set(PRIVATE_HEADER_FILES
debug.h
@ -108,9 +102,7 @@ set(PUBLIC_HEADER_FILES
#-------------------------------------------------------------------------------
# platform dependent tweaks
if(APPLE OR UNIX)
set(PLATFORM_COMPILE_FLAGS
-fPIC
)
set(PLATFORM_COMPILE_FLAGS -fPIC)
elseif(WIN32)
endif()
@ -158,16 +150,13 @@ if( PTEX_FOUND )
${DX_PTEX_PUBLIC_HEADERS}
)
endif()
include_directories( ${PTEX_INCLUDE_DIR} )
include_directories( "${PTEX_INCLUDE_DIR}" )
list(APPEND PLATFORM_CPU_LIBRARIES
${PTEX_LIBRARY}
)
endif()
list(APPEND DOXY_HEADER_FILES
${GL_PTEX_PUBLIC_HEADERS}
${DX_PTEX_PUBLIC_HEADERS}
)
list(APPEND DOXY_HEADER_FILES ${GL_PTEX_PUBLIC_HEADERS} ${DX_PTEX_PUBLIC_HEADERS})
#-------------------------------------------------------------------------------
set(OPENMP_PUBLIC_HEADERS
@ -188,9 +177,7 @@ if( OPENMP_FOUND )
list(APPEND PUBLIC_HEADER_FILES ${OPENMP_PUBLIC_HEADERS})
if (CMAKE_COMPILER_IS_GNUCXX)
list(APPEND PLATFORM_CPU_LIBRARIES
gomp
)
list(APPEND PLATFORM_CPU_LIBRARIES gomp)
endif()
endif()
@ -198,9 +185,8 @@ list(APPEND DOXY_HEADER_FILES ${OPENMP_PUBLIC_HEADERS})
#-------------------------------------------------------------------------------
if( TBB_FOUND )
include_directories(
${TBB_INCLUDE_DIR}
)
include_directories("${TBB_INCLUDE_DIR}")
list(APPEND CPU_SOURCE_FILES
tbbKernel.cpp
tbbComputeController.cpp
@ -214,9 +200,7 @@ if( TBB_FOUND )
tbbSmoothNormalController.h
)
if (CMAKE_COMPILER_IS_GNUCXX)
list(APPEND PLATFORM_CPU_LIBRARIES
gomp
)
list(APPEND PLATFORM_CPU_LIBRARIES gomp)
endif()
list(APPEND PLATFORM_CPU_LIBRARIES
@ -386,14 +370,10 @@ if ( OPENCL_FOUND )
list(APPEND PLATFORM_GPU_LIBRARIES
${OPENCL_LIBRARIES}
)
include_directories( ${OPENCL_INCLUDE_DIRS} )
include_directories( "${OPENCL_INCLUDE_DIRS}" )
if ( OPENGL_FOUND )
list(APPEND GPU_SOURCE_FILES
clGLVertexBuffer.cpp
)
list(APPEND PUBLIC_HEADER_FILES
clGLVertexBuffer.h
)
list(APPEND GPU_SOURCE_FILES clGLVertexBuffer.cpp)
list(APPEND PUBLIC_HEADER_FILES clGLVertexBuffer.h)
endif()
endif()
@ -445,7 +425,7 @@ list(APPEND DOXY_HEADER_FILES ${CUDA_PUBLIC_HEADERS})
_stringify("${KERNEL_FILES}" INC_FILES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
#-------------------------------------------------------------------------------
source_group("Kernels" FILES ${KERNEL_FILES})
@ -494,8 +474,8 @@ if (NOT NO_LIB)
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
)
install( TARGETS osd_static_cpu DESTINATION ${CMAKE_LIBDIR_BASE} )
install( TARGETS osd_static_gpu DESTINATION ${CMAKE_LIBDIR_BASE} )
install( TARGETS osd_static_cpu DESTINATION "${CMAKE_LIBDIR_BASE}" )
install( TARGETS osd_static_gpu DESTINATION "${CMAKE_LIBDIR_BASE}" )
# Build dynamic libs ----------------------------------
if (NOT WIN32 AND NOT IOS)
@ -542,22 +522,34 @@ if (NOT NO_LIB)
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
)
install( TARGETS osd_dynamic_cpu LIBRARY DESTINATION ${CMAKE_LIBDIR_BASE} )
install( TARGETS osd_dynamic_gpu LIBRARY DESTINATION ${CMAKE_LIBDIR_BASE} )
install( TARGETS osd_dynamic_cpu LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}" )
install( TARGETS osd_dynamic_gpu LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}" )
endif()
endif()
_add_doxy_headers( "${DOXY_HEADER_FILES}" )
install( FILES ${PUBLIC_HEADER_FILES}
DESTINATION ${CMAKE_INCDIR_BASE}/osd
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
install(
FILES
${PUBLIC_HEADER_FILES}
DESTINATION
"${CMAKE_INCDIR_BASE}/osd"
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ )
if (ANDROID)
install( FILES Android.mk
DESTINATION ${LIBRARY_OUTPUT_PATH_ROOT}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
install(
FILES
Android.mk
DESTINATION
"${LIBRARY_OUTPUT_PATH_ROOT}"
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ )
endif()
#-------------------------------------------------------------------------------

View File

@ -22,7 +22,6 @@
// language governing permissions and limitations under the Apache License.
//
#include "../far/mesh.h"
#include "../osd/clComputeContext.h"
#include "../osd/clKernelBundle.h"
@ -52,7 +51,7 @@ OsdCLTable::GetDevicePtr() const {
// -----------------------------------------------------------------------------
OsdCLHEditTable::OsdCLHEditTable(
const FarVertexEditTables<OsdVertex>::VertexEditBatch &batch,
const FarVertexEditTables::VertexEditBatch &batch,
cl_context clContext)
: _primvarIndicesTable(new OsdCLTable(batch.GetVertexIndices(), clContext)),
_editValuesTable(new OsdCLTable(batch.GetValues(), clContext)) {
@ -100,35 +99,32 @@ OsdCLHEditTable::GetPrimvarWidth() const {
// ----------------------------------------------------------------------------
OsdCLComputeContext::OsdCLComputeContext(FarMesh<OsdVertex> const *farMesh,
cl_context clContext)
OsdCLComputeContext::OsdCLComputeContext(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
cl_context clContext)
: _clQueue(NULL), _kernelBundle(NULL) {
FarSubdivisionTables<OsdVertex> const * farTables =
farMesh->GetSubdivisionTables();
// allocate 5 or 7 tables
_tables.resize(farTables->GetNumTables(), 0);
_tables.resize(subdivisionTables->GetNumTables(), 0);
_tables[FarSubdivisionTables<OsdVertex>::E_IT] = new OsdCLTable(farTables->Get_E_IT(), clContext);
_tables[FarSubdivisionTables<OsdVertex>::V_IT] = new OsdCLTable(farTables->Get_V_IT(), clContext);
_tables[FarSubdivisionTables<OsdVertex>::V_ITa] = new OsdCLTable(farTables->Get_V_ITa(), clContext);
_tables[FarSubdivisionTables<OsdVertex>::E_W] = new OsdCLTable(farTables->Get_E_W(), clContext);
_tables[FarSubdivisionTables<OsdVertex>::V_W] = new OsdCLTable(farTables->Get_V_W(), clContext);
_tables[FarSubdivisionTables::E_IT] = new OsdCLTable(subdivisionTables->Get_E_IT(), clContext);
_tables[FarSubdivisionTables::V_IT] = new OsdCLTable(subdivisionTables->Get_V_IT(), clContext);
_tables[FarSubdivisionTables::V_ITa] = new OsdCLTable(subdivisionTables->Get_V_ITa(), clContext);
_tables[FarSubdivisionTables::E_W] = new OsdCLTable(subdivisionTables->Get_E_W(), clContext);
_tables[FarSubdivisionTables::V_W] = new OsdCLTable(subdivisionTables->Get_V_W(), clContext);
if (farTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = new OsdCLTable(farTables->Get_F_IT(), clContext);
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = new OsdCLTable(farTables->Get_F_ITa(), clContext);
if (subdivisionTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables::F_IT] = new OsdCLTable(subdivisionTables->Get_F_IT(), clContext);
_tables[FarSubdivisionTables::F_ITa] = new OsdCLTable(subdivisionTables->Get_F_ITa(), clContext);
}
// create hedit tables
FarVertexEditTables<OsdVertex> const *editTables = farMesh->GetVertexEdit();
if (editTables) {
int numEditBatches = editTables->GetNumBatches();
if (vertexEditTables) {
int numEditBatches = vertexEditTables->GetNumBatches();
_editTables.reserve(numEditBatches);
for (int i = 0; i < numEditBatches; ++i) {
const FarVertexEditTables<OsdVertex>::VertexEditBatch & edit =
editTables->GetBatch(i);
const FarVertexEditTables::VertexEditBatch & edit =
vertexEditTables->GetBatch(i);
_editTables.push_back(new OsdCLHEditTable(edit, clContext));
}
}
@ -199,9 +195,11 @@ OsdCLComputeContext::GetCommandQueue() const {
}
OsdCLComputeContext *
OsdCLComputeContext::Create(FarMesh<OsdVertex> const *farmesh, cl_context clContext) {
OsdCLComputeContext::Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
cl_context clContext) {
return new OsdCLComputeContext(farmesh, clContext);
return new OsdCLComputeContext(subdivisionTables, vertexEditTables, clContext);
}
} // end namespace OPENSUBDIV_VERSION

View File

@ -27,6 +27,7 @@
#include "../version.h"
#include "../far/subdivisionTables.h"
#include "../far/vertexEditTables.h"
#include "../osd/vertex.h"
#include "../osd/nonCopyable.h"
@ -64,7 +65,7 @@ private:
class OsdCLHEditTable : OsdNonCopyable<OsdCLHEditTable> {
public:
OsdCLHEditTable(const FarVertexEditTables<OsdVertex>::
OsdCLHEditTable(const FarVertexEditTables::
VertexEditBatch &batch, cl_context clContext);
virtual ~OsdCLHEditTable();
@ -102,11 +103,14 @@ class OsdCLComputeContext : public OsdNonCopyable<OsdCLComputeContext> {
public:
/// Creates an OsdCLComputeContext instance
///
/// @param farmesh the FarMesh used for this Context.
/// @param subdivisionTables the FarSubdivisionTables used for this Context.
///
/// @param vertexEditTables the FarVertexEditTables used for this Context.
///
/// @param clContext a valid active OpenCL context
///
static OsdCLComputeContext * Create(FarMesh<OsdVertex> const *farmesh,
static OsdCLComputeContext * Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
cl_context clContext);
/// Destructor
@ -169,7 +173,8 @@ public:
void SetCommandQueue(cl_command_queue queue);
protected:
explicit OsdCLComputeContext(FarMesh<OsdVertex> const *farMesh,
explicit OsdCLComputeContext(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
cl_context clContext);
private:

View File

@ -92,17 +92,15 @@ OsdCLComputeController::getKernelBundle(int numVertexElements,
void
OsdCLComputeController::ApplyBilinearFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
ApplyCatmarkFaceVerticesKernel(batch, clientdata);
ApplyCatmarkFaceVerticesKernel(batch, context);
}
void
OsdCLComputeController::ApplyBilinearEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -111,7 +109,7 @@ OsdCLComputeController::ApplyBilinearEdgeVerticesKernel(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem E_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetDevicePtr();
cl_mem E_IT = context->GetTable(FarSubdivisionTables::E_IT)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -128,10 +126,8 @@ OsdCLComputeController::ApplyBilinearEdgeVerticesKernel(
void
OsdCLComputeController::ApplyBilinearVertexVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -140,7 +136,7 @@ OsdCLComputeController::ApplyBilinearVertexVerticesKernel(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -157,10 +153,8 @@ OsdCLComputeController::ApplyBilinearVertexVerticesKernel(
void
OsdCLComputeController::ApplyCatmarkFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -169,8 +163,8 @@ OsdCLComputeController::ApplyCatmarkFaceVerticesKernel(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem F_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetDevicePtr();
cl_mem F_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetDevicePtr();
cl_mem F_IT = context->GetTable(FarSubdivisionTables::F_IT)->GetDevicePtr();
cl_mem F_ITa = context->GetTable(FarSubdivisionTables::F_ITa)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -189,10 +183,8 @@ OsdCLComputeController::ApplyCatmarkFaceVerticesKernel(
void
OsdCLComputeController::ApplyCatmarkEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -201,8 +193,8 @@ OsdCLComputeController::ApplyCatmarkEdgeVerticesKernel(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem E_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetDevicePtr();
cl_mem E_W = context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetDevicePtr();
cl_mem E_IT = context->GetTable(FarSubdivisionTables::E_IT)->GetDevicePtr();
cl_mem E_W = context->GetTable(FarSubdivisionTables::E_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -221,10 +213,8 @@ OsdCLComputeController::ApplyCatmarkEdgeVerticesKernel(
void
OsdCLComputeController::ApplyCatmarkVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -233,9 +223,9 @@ OsdCLComputeController::ApplyCatmarkVertexVerticesKernelB(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
cl_mem V_IT = context->GetTable(FarSubdivisionTables::V_IT)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables::V_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -255,10 +245,8 @@ OsdCLComputeController::ApplyCatmarkVertexVerticesKernelB(
void
OsdCLComputeController::ApplyCatmarkVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -268,8 +256,8 @@ OsdCLComputeController::ApplyCatmarkVertexVerticesKernelA1(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables::V_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -289,10 +277,8 @@ OsdCLComputeController::ApplyCatmarkVertexVerticesKernelA1(
void
OsdCLComputeController::ApplyCatmarkVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -302,8 +288,8 @@ OsdCLComputeController::ApplyCatmarkVertexVerticesKernelA2(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables::V_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -323,10 +309,8 @@ OsdCLComputeController::ApplyCatmarkVertexVerticesKernelA2(
void
OsdCLComputeController::ApplyLoopEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -335,8 +319,8 @@ OsdCLComputeController::ApplyLoopEdgeVerticesKernel(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem E_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetDevicePtr();
cl_mem E_W = context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetDevicePtr();
cl_mem E_IT = context->GetTable(FarSubdivisionTables::E_IT)->GetDevicePtr();
cl_mem E_W = context->GetTable(FarSubdivisionTables::E_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -355,10 +339,8 @@ OsdCLComputeController::ApplyLoopEdgeVerticesKernel(
void
OsdCLComputeController::ApplyLoopVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -367,9 +349,9 @@ OsdCLComputeController::ApplyLoopVertexVerticesKernelB(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
cl_mem V_IT = context->GetTable(FarSubdivisionTables::V_IT)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables::V_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -389,10 +371,8 @@ OsdCLComputeController::ApplyLoopVertexVerticesKernelB(
void
OsdCLComputeController::ApplyLoopVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -402,8 +382,8 @@ OsdCLComputeController::ApplyLoopVertexVerticesKernelA1(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables::V_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -423,10 +403,8 @@ OsdCLComputeController::ApplyLoopVertexVerticesKernelA1(
void
OsdCLComputeController::ApplyLoopVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;
@ -436,8 +414,8 @@ OsdCLComputeController::ApplyLoopVertexVerticesKernelA2(
cl_mem vertexBuffer = context->GetCurrentVertexBuffer();
cl_mem varyingBuffer = context->GetCurrentVaryingBuffer();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetDevicePtr();
cl_mem V_ITa = context->GetTable(FarSubdivisionTables::V_ITa)->GetDevicePtr();
cl_mem V_W = context->GetTable(FarSubdivisionTables::V_W)->GetDevicePtr();
clSetKernelArg(kernel, 0, sizeof(cl_mem), &vertexBuffer);
clSetKernelArg(kernel, 1, sizeof(cl_mem), &varyingBuffer);
@ -457,10 +435,8 @@ OsdCLComputeController::ApplyLoopVertexVerticesKernelA2(
void
OsdCLComputeController::ApplyVertexEdits(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCLComputeContext *context) const {
OsdCLComputeContext * context =
static_cast<OsdCLComputeContext*>(clientdata);
assert(context);
cl_int ciErrNum;

View File

@ -93,10 +93,9 @@ public:
context->SetKernelBundle(getKernelBundle(numVertexElements, numVaryingElements));
context->Bind(vertexBuffer, varyingBuffer, _clQueue);
FarDispatcher::Refine(this,
batches,
-1,
context);
FarDispatcher::Refine(this, context, batches, /*maxlevel*/-1);
context->Unbind();
}
@ -128,34 +127,34 @@ public:
protected:
friend class FarDispatcher;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
void ApplyVertexEdits(FarKernelBatch const &batch, ComputeContext *context) const;
OsdCLKernelBundle * getKernelBundle(int numVertexElements,

View File

@ -99,13 +99,21 @@ OsdCLGLVertexBuffer::allocate(cl_context clContext) {
// create GL buffer first
int size = _numElements * _numVertices * sizeof(float);
GLint prev = 0;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, prev);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT) {
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
} else {
#else
{
#endif
GLint prev = 0;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, prev);
}
// register vbo as cl memory
cl_int err;

View File

@ -22,10 +22,8 @@
// language governing permissions and limitations under the Apache License.
//
#include "../far/mesh.h"
#include "../far/dispatcher.h"
#include "../far/catmarkSubdivisionTables.h"
#include "../far/bilinearSubdivisionTables.h"
#include "../far/subdivisionTables.h"
#include "../osd/cpuComputeContext.h"
#include "../osd/cpuKernel.h"
@ -59,7 +57,7 @@ OsdCpuTable::GetBuffer() const {
// ----------------------------------------------------------------------------
OsdCpuHEditTable::OsdCpuHEditTable(
const FarVertexEditTables<OsdVertex>::VertexEditBatch &batch)
const FarVertexEditTables::VertexEditBatch &batch)
: _primvarIndicesTable(new OsdCpuTable(batch.GetVertexIndices())),
_editValuesTable(new OsdCpuTable(batch.GetValues())) {
@ -104,33 +102,30 @@ OsdCpuHEditTable::GetPrimvarWidth() const {
return _primvarWidth;
}
OsdCpuComputeContext::OsdCpuComputeContext(FarMesh<OsdVertex> const *farMesh) {
FarSubdivisionTables<OsdVertex> const * farTables =
farMesh->GetSubdivisionTables();
OsdCpuComputeContext::OsdCpuComputeContext(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables) {
// allocate 5 or 7 tables
_tables.resize(farTables->GetNumTables(), 0);
_tables.resize(subdivisionTables->GetNumTables(), 0);
_tables[FarSubdivisionTables<OsdVertex>::E_IT] = new OsdCpuTable(farTables->Get_E_IT());
_tables[FarSubdivisionTables<OsdVertex>::V_IT] = new OsdCpuTable(farTables->Get_V_IT());
_tables[FarSubdivisionTables<OsdVertex>::V_ITa] = new OsdCpuTable(farTables->Get_V_ITa());
_tables[FarSubdivisionTables<OsdVertex>::E_W] = new OsdCpuTable(farTables->Get_E_W());
_tables[FarSubdivisionTables<OsdVertex>::V_W] = new OsdCpuTable(farTables->Get_V_W());
_tables[FarSubdivisionTables::E_IT] = new OsdCpuTable(subdivisionTables->Get_E_IT());
_tables[FarSubdivisionTables::V_IT] = new OsdCpuTable(subdivisionTables->Get_V_IT());
_tables[FarSubdivisionTables::V_ITa] = new OsdCpuTable(subdivisionTables->Get_V_ITa());
_tables[FarSubdivisionTables::E_W] = new OsdCpuTable(subdivisionTables->Get_E_W());
_tables[FarSubdivisionTables::V_W] = new OsdCpuTable(subdivisionTables->Get_V_W());
if (farTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = new OsdCpuTable(farTables->Get_F_IT());
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = new OsdCpuTable(farTables->Get_F_ITa());
if (subdivisionTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables::F_IT] = new OsdCpuTable(subdivisionTables->Get_F_IT());
_tables[FarSubdivisionTables::F_ITa] = new OsdCpuTable(subdivisionTables->Get_F_ITa());
}
// create hedit tables
FarVertexEditTables<OsdVertex> const *editTables = farMesh->GetVertexEdit();
if (editTables) {
int numEditBatches = editTables->GetNumBatches();
if (vertexEditTables) {
int numEditBatches = vertexEditTables->GetNumBatches();
_editTables.reserve(numEditBatches);
for (int i = 0; i < numEditBatches; ++i) {
const FarVertexEditTables<OsdVertex>::VertexEditBatch & edit =
editTables->GetBatch(i);
const FarVertexEditTables::VertexEditBatch & edit =
vertexEditTables->GetBatch(i);
_editTables.push_back(new OsdCpuHEditTable(edit));
}
@ -180,9 +175,10 @@ OsdCpuComputeContext::GetCurrentVaryingBuffer() const {
}
OsdCpuComputeContext *
OsdCpuComputeContext::Create(FarMesh<OsdVertex> const *farmesh) {
OsdCpuComputeContext::Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables) {
return new OsdCpuComputeContext(farmesh);
return new OsdCpuComputeContext(subdivisionTables, vertexEditTables);
}
} // end namespace OPENSUBDIV_VERSION

View File

@ -59,8 +59,7 @@ private:
class OsdCpuHEditTable : OsdNonCopyable<OsdCpuHEditTable> {
public:
OsdCpuHEditTable(const FarVertexEditTables<OsdVertex>::
VertexEditBatch &batch);
OsdCpuHEditTable(const FarVertexEditTables::VertexEditBatch &batch);
virtual ~OsdCpuHEditTable();
@ -97,9 +96,12 @@ class OsdCpuComputeContext : OsdNonCopyable<OsdCpuComputeContext> {
public:
/// Creates an OsdCpuComputeContext instance
///
/// @param farmesh the FarMesh used for this Context.
/// @param subdivisionTables the FarSubdivisionTables used for this Context.
///
static OsdCpuComputeContext * Create(FarMesh<OsdVertex> const *farmesh);
/// @param vertexEditTables the FarVertexEditTables used for this Context.
///
static OsdCpuComputeContext * Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables);
/// Destructor
virtual ~OsdCpuComputeContext();
@ -160,7 +162,8 @@ public:
float * GetCurrentVaryingBuffer() const;
protected:
explicit OsdCpuComputeContext(FarMesh<OsdVertex> const *farMesh);
explicit OsdCpuComputeContext(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables);
private:
std::vector<OsdCpuTable*> _tables;

View File

@ -38,214 +38,188 @@ OsdCpuComputeController::~OsdCpuComputeController() {
void
OsdCpuComputeController::ApplyBilinearFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeFace(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyBilinearEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeBilinearEdge(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyBilinearVertexVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeBilinearVertex(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyCatmarkFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeFace(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyCatmarkEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeEdge(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyCatmarkVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeVertexB(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyCatmarkVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false);
}
void
OsdCpuComputeController::ApplyCatmarkVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true);
}
void
OsdCpuComputeController::ApplyLoopEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeEdge(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyLoopVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeLoopVertexB(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
}
void
OsdCpuComputeController::ApplyLoopVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false);
}
void
OsdCpuComputeController::ApplyLoopVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdCpuComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true);
}
void
OsdCpuComputeController::ApplyVertexEdits(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
const OsdCpuHEditTable *edit = context->GetEditTable(batch.GetTableIndex());

View File

@ -73,10 +73,9 @@ public:
if (batches.empty()) return;
context->Bind(vertexBuffer, varyingBuffer);
FarDispatcher::Refine(this,
batches,
-1,
context);
FarDispatcher::Refine(this, context, batches, /*maxlevel*/-1);
context->Unbind();
}
@ -101,34 +100,34 @@ public:
protected:
friend class FarDispatcher;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
void ApplyVertexEdits(FarKernelBatch const &batch, ComputeContext *context) const;
};

View File

@ -34,21 +34,20 @@ namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
OsdCpuEvalLimitContext *
OsdCpuEvalLimitContext::Create(FarMesh<OsdVertex> const * farmesh, bool requireFVarData) {
OsdCpuEvalLimitContext::Create(FarPatchTables const *patchTables, bool requireFVarData) {
assert(farmesh);
assert(patchTables);
// we do not support uniform yet
if (not farmesh->GetPatchTables())
if (not patchTables->IsFeatureAdaptive())
return NULL;
return new OsdCpuEvalLimitContext(farmesh, requireFVarData);
return new OsdCpuEvalLimitContext(patchTables, requireFVarData);
}
OsdCpuEvalLimitContext::OsdCpuEvalLimitContext(FarMesh<OsdVertex> const * farmesh, bool requireFVarData) :
OsdEvalLimitContext(farmesh) {
OsdCpuEvalLimitContext::OsdCpuEvalLimitContext(FarPatchTables const *patchTables, bool requireFVarData) :
OsdEvalLimitContext(patchTables) {
FarPatchTables const * patchTables = farmesh->GetPatchTables();
assert(patchTables);
// copy the data from the FarTables
@ -86,9 +85,9 @@ OsdCpuEvalLimitContext::OsdCpuEvalLimitContext(FarMesh<OsdVertex> const * farmes
// Copy the face-varying table if necessary
if (requireFVarData) {
_fvarwidth = farmesh->GetTotalFVarWidth();
_fvarwidth = patchTables->GetFVarData().GetFVarWidth();
if (_fvarwidth>0) {
_fvarData = patchTables->GetFVarDataTable();
_fvarData = patchTables->GetFVarData().GetAllData();
}
}

View File

@ -42,15 +42,15 @@ class OsdCpuEvalLimitContext : public OsdEvalLimitContext {
public:
/// \brief Factory
/// Returns an EvalLimitContext from the given farmesh.
/// Note : the farmesh is expected to be feature-adaptive and have ptex
/// Returns an EvalLimitContext from the given far patch tables.
/// Note : the patchtables is expected to be feature-adaptive and have ptex
/// coordinates tables.
///
/// @param farmesh a pointer to an initialized farmesh
/// @param patchTables a pointer to an initialized FarPatchTables
///
/// @param requireFVarData flag for generating face-varying data
///
static OsdCpuEvalLimitContext * Create(FarMesh<OsdVertex> const * farmesh,
static OsdCpuEvalLimitContext * Create(FarPatchTables const *patchTables,
bool requireFVarData=false);
virtual ~OsdCpuEvalLimitContext();
@ -295,7 +295,7 @@ public:
}
/// Returns the face-varying data patch table
FarPatchTables::FVarDataTable const & GetFVarData() const {
std::vector<float> const & GetFVarData() const {
return _fvarData;
}
@ -315,7 +315,7 @@ public:
}
protected:
explicit OsdCpuEvalLimitContext(FarMesh<OsdVertex> const * farmesh, bool requireFVarData);
explicit OsdCpuEvalLimitContext(FarPatchTables const *patchTables, bool requireFVarData);
private:
@ -327,7 +327,7 @@ private:
FarPatchTables::VertexValenceTable _vertexValenceTable; // extra Gregory patch data buffers
FarPatchTables::QuadOffsetTable _quadOffsetTable;
FarPatchTables::FVarDataTable _fvarData;
std::vector<float> _fvarData;
FarPatchMap * _patchMap; // map of the sub-patches given a face index

View File

@ -158,7 +158,7 @@ OsdCpuEvalLimitController::_EvalLimitSample( OpenSubdiv::OsdEvalCoords const & c
OsdCpuEvalLimitContext::FaceVaryingData & faceVaryingData = context->GetFaceVaryingData();
if (faceVaryingData.IsBound()) {
FarPatchTables::FVarDataTable const & fvarData = context->GetFVarData();
std::vector<float> const & fvarData = context->GetFVarData();
if (not fvarData.empty()) {

View File

@ -22,7 +22,6 @@
// language governing permissions and limitations under the Apache License.
//
#include "../far/mesh.h"
#include "../osd/cudaComputeContext.h"
#include <cuda_runtime.h>
@ -71,8 +70,7 @@ OsdCudaHEditTable::~OsdCudaHEditTable() {
}
OsdCudaHEditTable *
OsdCudaHEditTable::Create(const FarVertexEditTables<OsdVertex>::
VertexEditBatch &batch) {
OsdCudaHEditTable::Create(const FarVertexEditTables::VertexEditBatch &batch) {
OsdCudaHEditTable *result = new OsdCudaHEditTable();
@ -137,23 +135,21 @@ OsdCudaComputeContext::~OsdCudaComputeContext() {
}
bool
OsdCudaComputeContext::initialize(FarMesh<OsdVertex> const *farMesh) {
FarSubdivisionTables<OsdVertex> const * farTables =
farMesh->GetSubdivisionTables();
OsdCudaComputeContext::initialize(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables) {
// allocate 5 or 7 tables
_tables.resize(farTables->GetNumTables(), 0);
_tables.resize(subdivisionTables->GetNumTables(), 0);
_tables[FarSubdivisionTables<OsdVertex>::E_IT] = OsdCudaTable::Create(farTables->Get_E_IT());
_tables[FarSubdivisionTables<OsdVertex>::V_IT] = OsdCudaTable::Create(farTables->Get_V_IT());
_tables[FarSubdivisionTables<OsdVertex>::V_ITa] = OsdCudaTable::Create(farTables->Get_V_ITa());
_tables[FarSubdivisionTables<OsdVertex>::E_W] = OsdCudaTable::Create(farTables->Get_E_W());
_tables[FarSubdivisionTables<OsdVertex>::V_W] = OsdCudaTable::Create(farTables->Get_V_W());
_tables[FarSubdivisionTables::E_IT] = OsdCudaTable::Create(subdivisionTables->Get_E_IT());
_tables[FarSubdivisionTables::V_IT] = OsdCudaTable::Create(subdivisionTables->Get_V_IT());
_tables[FarSubdivisionTables::V_ITa] = OsdCudaTable::Create(subdivisionTables->Get_V_ITa());
_tables[FarSubdivisionTables::E_W] = OsdCudaTable::Create(subdivisionTables->Get_E_W());
_tables[FarSubdivisionTables::V_W] = OsdCudaTable::Create(subdivisionTables->Get_V_W());
if (farTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = OsdCudaTable::Create(farTables->Get_F_IT());
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = OsdCudaTable::Create(farTables->Get_F_ITa());
if (subdivisionTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables::F_IT] = OsdCudaTable::Create(subdivisionTables->Get_F_IT());
_tables[FarSubdivisionTables::F_ITa] = OsdCudaTable::Create(subdivisionTables->Get_F_ITa());
}
// error check
@ -164,13 +160,12 @@ OsdCudaComputeContext::initialize(FarMesh<OsdVertex> const *farMesh) {
}
// create hedit tables
FarVertexEditTables<OsdVertex> const *editTables = farMesh->GetVertexEdit();
if (editTables) {
int numEditBatches = editTables->GetNumBatches();
if (vertexEditTables) {
int numEditBatches = vertexEditTables->GetNumBatches();
_editTables.reserve(numEditBatches);
for (int i = 0; i < numEditBatches; ++i) {
const FarVertexEditTables<OsdVertex>::VertexEditBatch & edit =
editTables->GetBatch(i);
const FarVertexEditTables::VertexEditBatch & edit =
vertexEditTables->GetBatch(i);
_editTables.push_back(OsdCudaHEditTable::Create(edit));
}
@ -215,11 +210,12 @@ OsdCudaComputeContext::GetCurrentVaryingBuffer() const {
}
OsdCudaComputeContext *
OsdCudaComputeContext::Create(FarMesh<OsdVertex> const *farmesh) {
OsdCudaComputeContext::Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables) {
OsdCudaComputeContext *result = new OsdCudaComputeContext();
if (result->initialize(farmesh) == false) {
if (result->initialize(subdivisionTables, vertexEditTables) == false) {
delete result;
return NULL;
}

View File

@ -27,6 +27,7 @@
#include "../version.h"
#include "../far/subdivisionTables.h"
#include "../far/vertexEditTables.h"
#include "../osd/vertex.h"
#include "../osd/vertexDescriptor.h"
@ -64,8 +65,7 @@ private:
class OsdCudaHEditTable : OsdNonCopyable<OsdCudaHEditTable> {
public:
static OsdCudaHEditTable * Create(const FarVertexEditTables<OsdVertex>::
VertexEditBatch &batch);
static OsdCudaHEditTable * Create(const FarVertexEditTables::VertexEditBatch &batch);
virtual ~OsdCudaHEditTable();
@ -104,9 +104,12 @@ class OsdCudaComputeContext : public OsdNonCopyable<OsdCudaComputeContext> {
public:
/// Creates an OsdCudaComputeContext instance
///
/// @param farmesh the FarMesh used for this Context.
/// @param subdivisionTables the FarSubdivisionTables used for this Context.
///
static OsdCudaComputeContext * Create(FarMesh<OsdVertex> const *farmesh);
/// @param vertexEditTables the FarVertexEditTables used for this Context.
///
static OsdCudaComputeContext * Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables);
/// Destructor
virtual ~OsdCudaComputeContext();
@ -178,7 +181,8 @@ public:
protected:
OsdCudaComputeContext();
bool initialize(FarMesh<OsdVertex> const *farMesh);
bool initialize(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables);
private:
std::vector<OsdCudaTable*> _tables;

View File

@ -82,14 +82,12 @@ OsdCudaComputeController::~OsdCudaComputeController() {
void
OsdCudaComputeController::ApplyBilinearFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * F_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT);
const OsdCudaTable * F_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa);
const OsdCudaTable * F_IT = context->GetTable(FarSubdivisionTables::F_IT);
const OsdCudaTable * F_ITa = context->GetTable(FarSubdivisionTables::F_ITa);
assert(F_IT);
assert(F_ITa);
@ -105,13 +103,11 @@ OsdCudaComputeController::ApplyBilinearFaceVerticesKernel(
void
OsdCudaComputeController::ApplyBilinearEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * E_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT);
const OsdCudaTable * E_IT = context->GetTable(FarSubdivisionTables::E_IT);
assert(E_IT);
OsdCudaComputeBilinearEdge(
@ -125,13 +121,11 @@ OsdCudaComputeController::ApplyBilinearEdgeVerticesKernel(
void
OsdCudaComputeController::ApplyBilinearVertexVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
assert(V_ITa);
OsdCudaComputeBilinearVertex(
@ -145,14 +139,12 @@ OsdCudaComputeController::ApplyBilinearVertexVerticesKernel(
void
OsdCudaComputeController::ApplyCatmarkFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * F_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT);
const OsdCudaTable * F_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa);
const OsdCudaTable * F_IT = context->GetTable(FarSubdivisionTables::F_IT);
const OsdCudaTable * F_ITa = context->GetTable(FarSubdivisionTables::F_ITa);
assert(F_IT);
assert(F_ITa);
@ -168,14 +160,12 @@ OsdCudaComputeController::ApplyCatmarkFaceVerticesKernel(
void
OsdCudaComputeController::ApplyCatmarkEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * E_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT);
const OsdCudaTable * E_W = context->GetTable(FarSubdivisionTables<OsdVertex>::E_W);
const OsdCudaTable * E_IT = context->GetTable(FarSubdivisionTables::E_IT);
const OsdCudaTable * E_W = context->GetTable(FarSubdivisionTables::E_W);
assert(E_IT);
assert(E_W);
@ -191,15 +181,13 @@ OsdCudaComputeController::ApplyCatmarkEdgeVerticesKernel(
void
OsdCudaComputeController::ApplyCatmarkVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
const OsdCudaTable * V_IT = context->GetTable(FarSubdivisionTables::V_IT);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables::V_W);
assert(V_ITa);
assert(V_IT);
assert(V_W);
@ -217,14 +205,12 @@ OsdCudaComputeController::ApplyCatmarkVertexVerticesKernelB(
void
OsdCudaComputeController::ApplyCatmarkVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables::V_W);
assert(V_ITa);
assert(V_W);
@ -240,14 +226,12 @@ OsdCudaComputeController::ApplyCatmarkVertexVerticesKernelA1(
void
OsdCudaComputeController::ApplyCatmarkVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables::V_W);
assert(V_ITa);
assert(V_W);
@ -263,14 +247,12 @@ OsdCudaComputeController::ApplyCatmarkVertexVerticesKernelA2(
void
OsdCudaComputeController::ApplyLoopEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * E_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT);
const OsdCudaTable * E_W = context->GetTable(FarSubdivisionTables<OsdVertex>::E_W);
const OsdCudaTable * E_IT = context->GetTable(FarSubdivisionTables::E_IT);
const OsdCudaTable * E_W = context->GetTable(FarSubdivisionTables::E_W);
assert(E_IT);
assert(E_W);
@ -286,15 +268,13 @@ OsdCudaComputeController::ApplyLoopEdgeVerticesKernel(
void
OsdCudaComputeController::ApplyLoopVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_IT = context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
const OsdCudaTable * V_IT = context->GetTable(FarSubdivisionTables::V_IT);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables::V_W);
assert(V_ITa);
assert(V_IT);
assert(V_W);
@ -312,14 +292,12 @@ OsdCudaComputeController::ApplyLoopVertexVerticesKernelB(
void
OsdCudaComputeController::ApplyLoopVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables::V_W);
assert(V_ITa);
assert(V_W);
@ -335,14 +313,12 @@ OsdCudaComputeController::ApplyLoopVertexVerticesKernelA1(
void
OsdCudaComputeController::ApplyLoopVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables<OsdVertex>::V_W);
const OsdCudaTable * V_ITa = context->GetTable(FarSubdivisionTables::V_ITa);
const OsdCudaTable * V_W = context->GetTable(FarSubdivisionTables::V_W);
assert(V_ITa);
assert(V_W);
@ -358,10 +334,8 @@ OsdCudaComputeController::ApplyLoopVertexVerticesKernelA2(
void
OsdCudaComputeController::ApplyVertexEdits(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCudaComputeContext *context) const {
OsdCudaComputeContext * context =
static_cast<OsdCudaComputeContext*>(clientdata);
assert(context);
const OsdCudaHEditTable *edit = context->GetEditTable(batch.GetTableIndex());

View File

@ -73,10 +73,9 @@ public:
if (batches.empty()) return;
context->Bind(vertexBuffer, varyingBuffer);
FarDispatcher::Refine(this,
batches,
-1,
context);
FarDispatcher::Refine(this, context, batches, /*maxlevel*/-1);
context->Unbind();
}
@ -101,34 +100,34 @@ public:
protected:
friend class FarDispatcher;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
void ApplyVertexEdits(FarKernelBatch const &batch, ComputeContext *context) const;
};
} // end namespace OPENSUBDIV_VERSION

View File

@ -100,11 +100,20 @@ bool
OsdCudaGLVertexBuffer::allocate() {
int size = _numElements * _numVertices * sizeof(float);
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT) {
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
} else {
#else
{
#endif
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
// register vbo as cuda resource
cudaError_t err = cudaGraphicsGLRegisterBuffer(

View File

@ -22,8 +22,8 @@
// language governing permissions and limitations under the Apache License.
//
#include "../far/mesh.h"
#include "../far/subdivisionTables.h"
#include "../far/vertexEditTables.h"
#include "../osd/debug.h"
#include "../osd/error.h"
#include "../osd/d3d11ComputeContext.h"
@ -97,7 +97,7 @@ OsdD3D11ComputeTable::GetSRV() const {
// ----------------------------------------------------------------------------
OsdD3D11ComputeHEditTable::OsdD3D11ComputeHEditTable(
const FarVertexEditTables<OsdVertex>::VertexEditBatch &batch, ID3D11DeviceContext *deviceContext)
const FarVertexEditTables::VertexEditBatch &batch, ID3D11DeviceContext *deviceContext)
: _primvarIndicesTable(new OsdD3D11ComputeTable(batch.GetVertexIndices(), deviceContext, DXGI_FORMAT_R32_UINT)),
_editValuesTable(new OsdD3D11ComputeTable(batch.GetValues(), deviceContext, DXGI_FORMAT_R32_FLOAT)) {
@ -145,41 +145,39 @@ OsdD3D11ComputeHEditTable::GetPrimvarWidth() const {
// ----------------------------------------------------------------------------
OsdD3D11ComputeContext::OsdD3D11ComputeContext(
FarMesh<OsdVertex> const *farMesh, ID3D11DeviceContext *deviceContext)
FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
ID3D11DeviceContext *deviceContext)
: _deviceContext(deviceContext),
_currentVertexBufferUAV(0), _currentVaryingBufferUAV(0) {
FarSubdivisionTables<OsdVertex> const * farTables =
farMesh->GetSubdivisionTables();
// allocate 5 or 7 tables
// XXXtakahito: Although _tables size depends on table type, F_IT is set
// to NULL even in loop case, to determine the condition in
// bindShaderStorageBuffer()...
_tables.resize(7, 0);
_tables[FarSubdivisionTables<OsdVertex>::E_IT] = new OsdD3D11ComputeTable(farTables->Get_E_IT(), deviceContext, DXGI_FORMAT_R32_SINT);
_tables[FarSubdivisionTables<OsdVertex>::V_IT] = new OsdD3D11ComputeTable(farTables->Get_V_IT(), deviceContext, DXGI_FORMAT_R32_UINT);
_tables[FarSubdivisionTables<OsdVertex>::V_ITa] = new OsdD3D11ComputeTable(farTables->Get_V_ITa(), deviceContext, DXGI_FORMAT_R32_SINT);
_tables[FarSubdivisionTables<OsdVertex>::E_W] = new OsdD3D11ComputeTable(farTables->Get_E_W(), deviceContext, DXGI_FORMAT_R32_FLOAT);
_tables[FarSubdivisionTables<OsdVertex>::V_W] = new OsdD3D11ComputeTable(farTables->Get_V_W(), deviceContext, DXGI_FORMAT_R32_FLOAT);
_tables[FarSubdivisionTables::E_IT] = new OsdD3D11ComputeTable(subdivisionTables->Get_E_IT(), deviceContext, DXGI_FORMAT_R32_SINT);
_tables[FarSubdivisionTables::V_IT] = new OsdD3D11ComputeTable(subdivisionTables->Get_V_IT(), deviceContext, DXGI_FORMAT_R32_UINT);
_tables[FarSubdivisionTables::V_ITa] = new OsdD3D11ComputeTable(subdivisionTables->Get_V_ITa(), deviceContext, DXGI_FORMAT_R32_SINT);
_tables[FarSubdivisionTables::E_W] = new OsdD3D11ComputeTable(subdivisionTables->Get_E_W(), deviceContext, DXGI_FORMAT_R32_FLOAT);
_tables[FarSubdivisionTables::V_W] = new OsdD3D11ComputeTable(subdivisionTables->Get_V_W(), deviceContext, DXGI_FORMAT_R32_FLOAT);
if (farTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = new OsdD3D11ComputeTable(farTables->Get_F_IT(), deviceContext, DXGI_FORMAT_R32_UINT);
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = new OsdD3D11ComputeTable(farTables->Get_F_ITa(), deviceContext, DXGI_FORMAT_R32_SINT);
if (subdivisionTables->GetNumTables() > 5) {
_tables[FarSubdivisionTables::F_IT] = new OsdD3D11ComputeTable(subdivisionTables->Get_F_IT(), deviceContext, DXGI_FORMAT_R32_UINT);
_tables[FarSubdivisionTables::F_ITa] = new OsdD3D11ComputeTable(subdivisionTables->Get_F_ITa(), deviceContext, DXGI_FORMAT_R32_SINT);
} else {
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = NULL;
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = NULL;
_tables[FarSubdivisionTables::F_IT] = NULL;
_tables[FarSubdivisionTables::F_ITa] = NULL;
}
// create hedit tables
FarVertexEditTables<OsdVertex> const *editTables = farMesh->GetVertexEdit();
if (editTables) {
int numEditBatches = editTables->GetNumBatches();
if (vertexEditTables) {
int numEditBatches = vertexEditTables->GetNumBatches();
_editTables.reserve(numEditBatches);
for (int i = 0; i < numEditBatches; ++i) {
const FarVertexEditTables<OsdVertex>::VertexEditBatch & edit =
editTables->GetBatch(i);
const FarVertexEditTables::VertexEditBatch & edit =
vertexEditTables->GetBatch(i);
_editTables.push_back(new OsdD3D11ComputeHEditTable(edit, deviceContext));
}
}
@ -249,9 +247,11 @@ OsdD3D11ComputeContext::SetDeviceContext(ID3D11DeviceContext *deviceContext) {
}
OsdD3D11ComputeContext *
OsdD3D11ComputeContext::Create(FarMesh<OsdVertex> const *farmesh, ID3D11DeviceContext *deviceContext) {
OsdD3D11ComputeContext::Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
ID3D11DeviceContext *deviceContext) {
return new OsdD3D11ComputeContext(farmesh, deviceContext);
return new OsdD3D11ComputeContext(subdivisionTables, vertexEditTables, deviceContext);
}
void
@ -294,20 +294,20 @@ OsdD3D11ComputeContext::bindShaderStorageBuffers() {
_deviceContext->CSSetUnorderedAccessViews(1, 1, &_currentVaryingBufferUAV, 0); // u1
// XXX: should be better handling for loop subdivision.
if (_tables[FarSubdivisionTables<OsdVertex>::F_IT]) {
if (_tables[FarSubdivisionTables::F_IT]) {
ID3D11ShaderResourceView *SRViews[] = {
_tables[FarSubdivisionTables<OsdVertex>::F_IT]->GetSRV(),
_tables[FarSubdivisionTables<OsdVertex>::F_ITa]->GetSRV(),
_tables[FarSubdivisionTables::F_IT]->GetSRV(),
_tables[FarSubdivisionTables::F_ITa]->GetSRV(),
};
_deviceContext->CSSetShaderResources(2, 2, SRViews); // t2-t3
}
ID3D11ShaderResourceView *SRViews[] = {
_tables[FarSubdivisionTables<OsdVertex>::E_IT]->GetSRV(),
_tables[FarSubdivisionTables<OsdVertex>::V_IT]->GetSRV(),
_tables[FarSubdivisionTables<OsdVertex>::V_ITa]->GetSRV(),
_tables[FarSubdivisionTables<OsdVertex>::E_W]->GetSRV(),
_tables[FarSubdivisionTables<OsdVertex>::V_W]->GetSRV(),
_tables[FarSubdivisionTables::E_IT]->GetSRV(),
_tables[FarSubdivisionTables::V_IT]->GetSRV(),
_tables[FarSubdivisionTables::V_ITa]->GetSRV(),
_tables[FarSubdivisionTables::E_W]->GetSRV(),
_tables[FarSubdivisionTables::V_W]->GetSRV(),
};
_deviceContext->CSSetShaderResources(4, 5, SRViews); // t4-t8
}

View File

@ -27,6 +27,7 @@
#include "../version.h"
#include "../far/subdivisionTables.h"
#include "../far/vertexEditTables.h"
#include "../osd/vertex.h"
#include "../osd/vertexDescriptor.h"
@ -67,8 +68,8 @@ private:
class OsdD3D11ComputeHEditTable : OsdNonCopyable<OsdD3D11ComputeHEditTable> {
public:
OsdD3D11ComputeHEditTable(const FarVertexEditTables<OsdVertex>::
VertexEditBatch &batch, ID3D11DeviceContext *deviceContext);
OsdD3D11ComputeHEditTable(const FarVertexEditTables::VertexEditBatch &batch,
ID3D11DeviceContext *deviceContext);
virtual ~OsdD3D11ComputeHEditTable();
@ -104,11 +105,14 @@ class OsdD3D11ComputeContext : public OsdNonCopyable<OsdD3D11ComputeContext> {
public:
/// Creates an OsdD3D11ComputeContext instance
///
/// @param farmesh the FarMesh used for this Context.
/// @param subdivisionTables the FarSubdivisionTables used for this Context.
///
/// @param vertexEditTables the FarVertexEditTables used for this Context.
///
/// @param deviceContext D3D device
///
static OsdD3D11ComputeContext * Create(FarMesh<OsdVertex> const *farmesh,
static OsdD3D11ComputeContext * Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
ID3D11DeviceContext *deviceContext);
/// Destructor
@ -184,7 +188,9 @@ public:
void UnbindEditShaderStorageBuffers();
protected:
explicit OsdD3D11ComputeContext(FarMesh<OsdVertex> const *farMesh, ID3D11DeviceContext *deviceContext);
explicit OsdD3D11ComputeContext(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables,
ID3D11DeviceContext *deviceContext);
void bindShaderStorageBuffers();

View File

@ -91,10 +91,8 @@ OsdD3D11ComputeController::getKernels(int numVertexElements,
void
OsdD3D11ComputeController::ApplyBilinearFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -105,10 +103,8 @@ OsdD3D11ComputeController::ApplyBilinearFaceVerticesKernel(
void
OsdD3D11ComputeController::ApplyBilinearEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -119,10 +115,8 @@ OsdD3D11ComputeController::ApplyBilinearEdgeVerticesKernel(
void
OsdD3D11ComputeController::ApplyBilinearVertexVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -133,10 +127,8 @@ OsdD3D11ComputeController::ApplyBilinearVertexVerticesKernel(
void
OsdD3D11ComputeController::ApplyCatmarkFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -149,10 +141,8 @@ OsdD3D11ComputeController::ApplyCatmarkFaceVerticesKernel(
void
OsdD3D11ComputeController::ApplyCatmarkEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -163,10 +153,8 @@ OsdD3D11ComputeController::ApplyCatmarkEdgeVerticesKernel(
void
OsdD3D11ComputeController::ApplyCatmarkVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -177,10 +165,8 @@ OsdD3D11ComputeController::ApplyCatmarkVertexVerticesKernelB(
void
OsdD3D11ComputeController::ApplyCatmarkVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -191,10 +177,8 @@ OsdD3D11ComputeController::ApplyCatmarkVertexVerticesKernelA1(
void
OsdD3D11ComputeController::ApplyCatmarkVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -205,10 +189,8 @@ OsdD3D11ComputeController::ApplyCatmarkVertexVerticesKernelA2(
void
OsdD3D11ComputeController::ApplyLoopEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -219,10 +201,8 @@ OsdD3D11ComputeController::ApplyLoopEdgeVerticesKernel(
void
OsdD3D11ComputeController::ApplyLoopVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -233,10 +213,8 @@ OsdD3D11ComputeController::ApplyLoopVertexVerticesKernelB(
void
OsdD3D11ComputeController::ApplyLoopVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -247,10 +225,8 @@ OsdD3D11ComputeController::ApplyLoopVertexVerticesKernelA1(
void
OsdD3D11ComputeController::ApplyLoopVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -261,10 +237,8 @@ OsdD3D11ComputeController::ApplyLoopVertexVerticesKernelA2(
void
OsdD3D11ComputeController::ApplyVertexEdits(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdD3D11ComputeContext *context) const {
OsdD3D11ComputeContext * context =
static_cast<OsdD3D11ComputeContext*>(clientdata);
assert(context);
OsdD3D11ComputeKernelBundle * kernelBundle = context->GetKernelBundle();

View File

@ -89,9 +89,9 @@ public:
context->SetKernelBundle(getKernels(numVertexElements, numVaryingElements));
context->Bind(vertexBuffer, varyingBuffer);
FarDispatcher::Refine(this,
context,
batches,
-1,
context);
-1);
context->Unbind();
}
@ -116,34 +116,34 @@ public:
protected:
friend class FarDispatcher;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
void ApplyVertexEdits(FarKernelBatch const &batch, ComputeContext *context) const;
OsdD3D11ComputeKernelBundle * getKernels(int numVertexElements,
int numVaryingElements);

View File

@ -23,7 +23,6 @@
//
#include "../far/dispatcher.h"
#include "../far/loopSubdivisionTables.h"
#include "../osd/d3d11DrawContext.h"
#include <D3D11.h>

View File

@ -27,7 +27,7 @@
#include "../version.h"
#include "../far/mesh.h"
#include "../far/patchTables.h"
#include "../osd/drawContext.h"
#include "../osd/vertex.h"

View File

@ -27,7 +27,7 @@
#include "../version.h"
#include "../far/mesh.h"
#include "../far/patchTables.h"
#include "../osd/drawRegistry.h"
#include "../osd/vertex.h"

View File

@ -72,7 +72,8 @@ public:
_vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices, pd3d11Device);
if (numVaryingElements)
_vertexBuffer = VertexBuffer::Create(numVaryingElements, numVertices, pd3d11Device);
_computeContext = ComputeContext::Create(_farMesh);
_computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(),
_farMesh->GetVertexEditTables());
_drawContext = DrawContext::Create(_farMesh->GetPatchTables(),
_pd3d11DeviceContext,
bits.test(MeshFVarData));
@ -158,7 +159,9 @@ public:
_vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices, pd3d11Device);
if (numVaryingElements)
_varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices, pd3d11Device);
_computeContext = ComputeContext::Create(_farMesh, _pd3d11DeviceContext);
_computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(),
_farMesh->GetVertexEditTables(),
_pd3d11DeviceContext);
_drawContext = DrawContext::Create(_farMesh->GetPatchTables(),
_pd3d11DeviceContext,
bits.test(MeshFVarData));

View File

@ -64,7 +64,7 @@ OsdDrawContext::ConvertPatchArrays(FarPatchTables::PatchArrayVector const &farPa
#if defined(GL_ES_VERSION_2_0)
// XXX: farmesh should have FarDensePatchTable for dense mesh indices.
// instead of GetFaceVertices().
const FarSubdivisionTables<OsdVertex> *tables = farMesh->GetSubdivisionTables();
const FarSubdivisionTables *tables = farMesh->GetSubdivisionTables();
int level = tables->GetMaxLevel();
const std::vector<int> &indices = farMesh->GetFaceVertices(level-1);

View File

@ -28,9 +28,9 @@
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
OsdEvalLimitContext::OsdEvalLimitContext(FarMesh<OsdVertex> const * farmesh) {
OsdEvalLimitContext::OsdEvalLimitContext(FarPatchTables const *patchTables) {
_adaptive = farmesh->GetPatchTables()->IsFeatureAdaptive();
_adaptive = patchTables->IsFeatureAdaptive();
}
OsdEvalLimitContext::~OsdEvalLimitContext() {

View File

@ -27,7 +27,7 @@
#include "../version.h"
#include "../far/mesh.h"
#include "../far/patchTables.h"
#include "../osd/nonCopyable.h"
#include "../osd/vertex.h"
@ -70,7 +70,7 @@ public:
virtual ~OsdEvalLimitContext();
protected:
explicit OsdEvalLimitContext(FarMesh<OsdVertex> const * farmesh);
explicit OsdEvalLimitContext(FarPatchTables const *patchTables);
private:
bool _adaptive;

View File

@ -36,226 +36,200 @@ OsdGcdComputeController::OsdGcdComputeController() {
void
OsdGcdComputeController::ApplyBilinearFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeFace(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyBilinearEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeBilinearEdge(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyBilinearVertexVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeBilinearVertex(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyCatmarkFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeFace(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_IT)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::F_ITa)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyCatmarkEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeEdge(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeVertexB(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false,
_gcd_queue);
}
void
OsdGcdComputeController::ApplyCatmarkVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true,
_gcd_queue);
}
void
OsdGcdComputeController::ApplyLoopEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeEdge(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::E_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::E_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyLoopVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeLoopVertexB(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_IT)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(),
_gcd_queue);
}
void
OsdGcdComputeController::ApplyLoopVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false,
_gcd_queue);
}
void
OsdGcdComputeController::ApplyLoopVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
OsdGcdComputeVertexA(
context->GetVertexDescriptor(),
context->GetCurrentVertexBuffer(),
context->GetCurrentVaryingBuffer(),
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
(const int*)context->GetTable(FarSubdivisionTables::V_ITa)->GetBuffer(),
(const float*)context->GetTable(FarSubdivisionTables::V_W)->GetBuffer(),
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true,
_gcd_queue);
}
void
OsdGcdComputeController::ApplyVertexEdits(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdCpuComputeContext *context) const {
OsdCpuComputeContext * context =
static_cast<OsdCpuComputeContext*>(clientdata);
assert(context);
const OsdCpuHEditTable *edit = context->GetEditTable(batch.GetTableIndex());

View File

@ -73,10 +73,9 @@ public:
if (batches.empty()) return;
context->Bind(vertexBuffer, varyingBuffer);
FarDispatcher::Refine(this,
batches,
-1,
context);
FarDispatcher::Refine(this, context, batches, /*maxlevel*/-1);
context->Unbind();
}
@ -101,34 +100,34 @@ public:
protected:
friend class FarDispatcher;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
void ApplyVertexEdits(FarKernelBatch const &batch, ComputeContext *context) const;
private:
dispatch_queue_t _gcd_queue;

View File

@ -23,7 +23,6 @@
//
#include "../far/dispatcher.h"
#include "../far/loopSubdivisionTables.h"
#include "../osd/glDrawRegistry.h"
#include "../osd/glDrawContext.h"
@ -71,15 +70,27 @@ createTextureBuffer(T const &data, GLint format, int offset=0)
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
glGenTextures(1, &texture);
glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, (data.size()-offset) * sizeof(typename T::value_type),
&data[offset], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_BUFFER, texture);
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
glBindTexture(GL_TEXTURE_BUFFER, 0);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT and glTextureBufferEXT) {
glNamedBufferDataEXT(buffer, (data.size()-offset) * sizeof(typename T::value_type),
&data[offset], GL_STATIC_DRAW);
glTextureBufferEXT(texture, GL_TEXTURE_BUFFER, format, buffer);
} else {
#else
{
#endif
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, (data.size()-offset) * sizeof(typename T::value_type),
&data[offset], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_BUFFER, texture);
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
glBindTexture(GL_TEXTURE_BUFFER, 0);
}
glDeleteBuffers(1, &buffer);
#endif
return texture;
@ -112,59 +123,24 @@ OsdGLDrawContext::create(FarPatchTables const * patchTables, bool requireFVarDat
FarPatchTables::PTable const & ptables = patchTables->GetPatchTable();
glGenBuffers(1, &_patchIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _patchIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT) {
glNamedBufferDataEXT(_patchIndexBuffer,
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
} else {
#else
{
#endif
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _patchIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
ptables.size() * sizeof(unsigned int), &ptables[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
OsdDrawContext::ConvertPatchArrays(patchTables->GetPatchArrayVector(),
patchArrays, patchTables->GetMaxValence(), 0);
/*
#if defined(GL_ES_VERSION_2_0)
// XXX: farmesh should have FarDensePatchTable for dense mesh indices.
// instead of GetFaceVertices().
const FarSubdivisionTables<OsdVertex> *tables = farMesh->GetSubdivisionTables();
int level = tables->GetMaxLevel();
const std::vector<int> &indices = farMesh->GetFaceVertices(level-1);
int numIndices = (int)indices.size();
// Allocate and fill index buffer.
glGenBuffers(1, &_patchIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _patchIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
numIndices * sizeof(unsigned int), &(indices[0]), GL_STATIC_DRAW);
// OpenGLES 2 supports only triangle topologies for filled
// primitives i.e. not QUADS or PATCHES or LINES_ADJACENCY
// For the convenience of clients build build a triangles
// index buffer by splitting quads.
int numQuads = indices.size() / 4;
int numTrisIndices = numQuads * 6;
std::vector<short> trisIndices;
trisIndices.reserve(numTrisIndices);
for (int i=0; i<numQuads; ++i) {
const int * quad = &indices[i*4];
trisIndices.push_back(short(quad[0]));
trisIndices.push_back(short(quad[1]));
trisIndices.push_back(short(quad[2]));
trisIndices.push_back(short(quad[2]));
trisIndices.push_back(short(quad[3]));
trisIndices.push_back(short(quad[0]));
}
// Allocate and fill triangles index buffer.
glGenBuffers(1, &patchTrianglesIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, patchTrianglesIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
numTrisIndices * sizeof(short), &(trisIndices[0]), GL_STATIC_DRAW);
#endif
*/
// allocate and initialize additional buffer data
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
@ -197,11 +173,11 @@ OsdGLDrawContext::create(FarPatchTables const * patchTables, bool requireFVarDat
// create fvar data buffer if requested
FarPatchTables::FVarDataTable const &
fvarTables = patchTables->GetFVarDataTable();
std::vector<float> const &
fvarData = patchTables->GetFVarData().GetAllData();
if (requireFVarData and not fvarTables.empty())
_fvarDataTextureBuffer = createTextureBuffer(fvarTables, GL_R32F);
if (requireFVarData and not fvarData.empty())
_fvarDataTextureBuffer = createTextureBuffer(fvarData, GL_R32F);
glBindBuffer(GL_TEXTURE_BUFFER, 0);
#endif
@ -213,9 +189,19 @@ void
OsdGLDrawContext::updateVertexTexture(GLuint vbo, int numVertexElements)
{
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
glBindTexture(GL_TEXTURE_BUFFER, _vertexTextureBuffer);
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, vbo);
glBindTexture(GL_TEXTURE_BUFFER, 0);
#if defined(GL_EXT_direct_state_access)
if (glTextureBufferEXT) {
glTextureBufferEXT(_vertexTextureBuffer, GL_TEXTURE_BUFFER, GL_R32F, vbo);
} else {
#else
{
#endif
glBindTexture(GL_TEXTURE_BUFFER, _vertexTextureBuffer);
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, vbo);
glBindTexture(GL_TEXTURE_BUFFER, 0);
}
#endif
// XXX: consider moving this proc to base class

View File

@ -27,7 +27,7 @@
#include "../version.h"
#include "../far/mesh.h"
#include "../far/patchTables.h"
#include "../osd/drawContext.h"
#include "../osd/drawRegistry.h"
#include "../osd/vertex.h"

View File

@ -27,7 +27,6 @@
#include "../version.h"
#include "../far/mesh.h"
#include "../osd/drawRegistry.h"
#include "../osd/vertex.h"

View File

@ -143,7 +143,7 @@ private:
_vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices);
if (numVaryingElements)
_varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices);
_computeContext = ComputeContext::Create(_farMesh);
_computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(), _farMesh->GetVertexEditTables());
_drawContext = DrawContext::Create(_farMesh->GetPatchTables(), bits.test(MeshFVarData));
_drawContext->UpdateVertexTexture(_vertexBuffer);
}
@ -264,7 +264,7 @@ private:
_vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices, _clContext);
if (numVaryingElements)
_varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices, _clContext);
_computeContext = ComputeContext::Create(_farMesh, _clContext);
_computeContext = ComputeContext::Create(_farMesh->GetSubdivisionTables(), _farMesh->GetVertexEditTables(), _clContext);
_drawContext = DrawContext::Create(_farMesh->GetPatchTables(), bits.test(MeshFVarData));
_drawContext->UpdateVertexTexture(_vertexBuffer);
}

View File

@ -51,15 +51,28 @@ genTextureBuffer(GLenum format, GLsizeiptr size, GLvoid const * data)
{
GLuint buffer, result;
glGenBuffers(1, &buffer);
glBindBuffer(GL_TEXTURE_BUFFER, buffer);
glBufferData(GL_TEXTURE_BUFFER, size, data, GL_STATIC_DRAW);
glGenTextures(1, & result);
glBindTexture(GL_TEXTURE_BUFFER, result);
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
// need to reset texture binding before deleting the source buffer.
glBindTexture(GL_TEXTURE_BUFFER, 0);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT) {
glNamedBufferDataEXT(buffer, size, data, GL_STATIC_DRAW);
glTextureBufferEXT(result, GL_TEXTURE_BUFFER, format, buffer);
} else {
#else
{
#endif
glBindBuffer(GL_TEXTURE_BUFFER, buffer);
glBufferData(GL_TEXTURE_BUFFER, size, data, GL_STATIC_DRAW);
glBindTexture(GL_TEXTURE_BUFFER, result);
glTexBuffer(GL_TEXTURE_BUFFER, format, buffer);
// need to reset texture binding before deleting the source buffer.
glBindTexture(GL_TEXTURE_BUFFER, 0);
glBindBuffer(GL_TEXTURE_BUFFER, 0);
}
glDeleteBuffers(1, &buffer);
return result;

View File

@ -54,10 +54,18 @@ OsdGLVertexBuffer::Create(int numElements, int numVertices) {
void
OsdGLVertexBuffer::UpdateData(const float *src, int startVertex, int numVertices) {
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
int size = numVertices * _numElements * sizeof(float);
glBufferSubData(GL_ARRAY_BUFFER, startVertex * _numElements * sizeof(float), size, src);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferSubDataEXT) {
glNamedBufferSubDataEXT(_vbo, startVertex * _numElements * sizeof(float), size, src);
} else {
#else
{
#endif
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferSubData(GL_ARRAY_BUFFER, startVertex * _numElements * sizeof(float), size, src);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}
int
@ -82,13 +90,22 @@ bool
OsdGLVertexBuffer::allocate() {
int size = _numElements * _numVertices * sizeof(float);
GLint prev = 0;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, prev);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT) {
glNamedBufferDataEXT(_vbo, size, 0, GL_DYNAMIC_DRAW);
} else {
#else
{
#endif
GLint prev = 0;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, prev);
}
return true;
}

View File

@ -22,7 +22,6 @@
// language governing permissions and limitations under the Apache License.
//
#include "../far/mesh.h"
#include "../osd/debug.h"
#include "../osd/error.h"
#include "../osd/glslComputeContext.h"
@ -36,16 +35,25 @@ namespace OPENSUBDIV_VERSION {
void
OsdGLSLComputeTable::createBuffer(size_t size, const void *ptr) {
GLint prev = 0;
glGenBuffers(1, &_devicePtr);
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _devicePtr);
glBufferData(GL_SHADER_STORAGE_BUFFER, size, ptr, GL_STATIC_DRAW);
#if defined(GL_EXT_direct_state_access)
if (glNamedBufferDataEXT) {
glNamedBufferDataEXT(_devicePtr, size, ptr, GL_STATIC_DRAW);
} else {
#else
{
#endif
GLint prev = 0;
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _devicePtr);
glBufferData(GL_SHADER_STORAGE_BUFFER, size, ptr, GL_STATIC_DRAW);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, prev);
}
/*
CHECK_GL_ERROR("UpdateTable tableIndex %d, size %ld, buffer =%d\n",
tableIndex, size, _tableBuffers[tableIndex]);
*/
glBindBuffer(GL_SHADER_STORAGE_BUFFER, prev);
}
OsdGLSLComputeTable::~OsdGLSLComputeTable() {
@ -62,7 +70,7 @@ OsdGLSLComputeTable::GetBuffer() const {
// ----------------------------------------------------------------------------
OsdGLSLComputeHEditTable::OsdGLSLComputeHEditTable(
const FarVertexEditTables<OsdVertex>::VertexEditBatch &batch)
const FarVertexEditTables::VertexEditBatch &batch)
: _primvarIndicesTable(new OsdGLSLComputeTable(batch.GetVertexIndices())),
_editValuesTable(new OsdGLSLComputeTable(batch.GetValues())) {
@ -110,42 +118,39 @@ OsdGLSLComputeHEditTable::GetPrimvarWidth() const {
// ----------------------------------------------------------------------------
OsdGLSLComputeContext::OsdGLSLComputeContext(
FarMesh<OsdVertex> const *farMesh)
FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables)
: _vertexTexture(0), _varyingTexture(0) {
FarSubdivisionTables<OsdVertex> const * farTables =
farMesh->GetSubdivisionTables();
// allocate 5 or 7 tables
// XXXtakahito: Although _tables size depends on table type, F_IT is set
// to NULL even in loop case, to determine the condition in
// bindShaderStorageBuffer()...
_tables.resize(7, 0);
_tables[FarSubdivisionTables<OsdVertex>::E_IT] = new OsdGLSLComputeTable(farTables->Get_E_IT());
_tables[FarSubdivisionTables<OsdVertex>::V_IT] = new OsdGLSLComputeTable(farTables->Get_V_IT());
_tables[FarSubdivisionTables<OsdVertex>::V_ITa] = new OsdGLSLComputeTable(farTables->Get_V_ITa());
_tables[FarSubdivisionTables<OsdVertex>::E_W] = new OsdGLSLComputeTable(farTables->Get_E_W());
_tables[FarSubdivisionTables<OsdVertex>::V_W] = new OsdGLSLComputeTable(farTables->Get_V_W());
_tables[FarSubdivisionTables::E_IT] = new OsdGLSLComputeTable(subdivisionTables->Get_E_IT());
_tables[FarSubdivisionTables::V_IT] = new OsdGLSLComputeTable(subdivisionTables->Get_V_IT());
_tables[FarSubdivisionTables::V_ITa] = new OsdGLSLComputeTable(subdivisionTables->Get_V_ITa());
_tables[FarSubdivisionTables::E_W] = new OsdGLSLComputeTable(subdivisionTables->Get_E_W());
_tables[FarSubdivisionTables::V_W] = new OsdGLSLComputeTable(subdivisionTables->Get_V_W());
if (farTables->GetNumTables() > 5) {
if (subdivisionTables->GetNumTables() > 5) {
// catmark, bilinear
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = new OsdGLSLComputeTable(farTables->Get_F_IT());
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = new OsdGLSLComputeTable(farTables->Get_F_ITa());
_tables[FarSubdivisionTables::F_IT] = new OsdGLSLComputeTable(subdivisionTables->Get_F_IT());
_tables[FarSubdivisionTables::F_ITa] = new OsdGLSLComputeTable(subdivisionTables->Get_F_ITa());
} else {
// loop
_tables[FarSubdivisionTables<OsdVertex>::F_IT] = NULL;
_tables[FarSubdivisionTables<OsdVertex>::F_ITa] = NULL;
_tables[FarSubdivisionTables::F_IT] = NULL;
_tables[FarSubdivisionTables::F_ITa] = NULL;
}
// create hedit tables
FarVertexEditTables<OsdVertex> const *editTables = farMesh->GetVertexEdit();
if (editTables) {
int numEditBatches = editTables->GetNumBatches();
if (vertexEditTables) {
int numEditBatches = vertexEditTables->GetNumBatches();
_editTables.reserve(numEditBatches);
for (int i = 0; i < numEditBatches; ++i) {
const FarVertexEditTables<OsdVertex>::VertexEditBatch & edit =
editTables->GetBatch(i);
const FarVertexEditTables::VertexEditBatch & edit =
vertexEditTables->GetBatch(i);
_editTables.push_back(new OsdGLSLComputeHEditTable(edit));
}
}
@ -205,9 +210,10 @@ OsdGLSLComputeContext::SetKernelBundle(
}
OsdGLSLComputeContext *
OsdGLSLComputeContext::Create(FarMesh<OsdVertex> const *farmesh) {
OsdGLSLComputeContext::Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables) {
return new OsdGLSLComputeContext(farmesh);
return new OsdGLSLComputeContext(subdivisionTables, vertexEditTables);
}
void
@ -242,23 +248,23 @@ OsdGLSLComputeContext::bindShaderStorageBuffers() {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, _currentVaryingBuffer);
// XXX: should be better handling for loop subdivision.
if (_tables[FarSubdivisionTables<OsdVertex>::F_IT]) {
if (_tables[FarSubdivisionTables::F_IT]) {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2,
_tables[FarSubdivisionTables<OsdVertex>::F_IT]->GetBuffer());
_tables[FarSubdivisionTables::F_IT]->GetBuffer());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3,
_tables[FarSubdivisionTables<OsdVertex>::F_ITa]->GetBuffer());
_tables[FarSubdivisionTables::F_ITa]->GetBuffer());
}
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4,
_tables[FarSubdivisionTables<OsdVertex>::E_IT]->GetBuffer());
_tables[FarSubdivisionTables::E_IT]->GetBuffer());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5,
_tables[FarSubdivisionTables<OsdVertex>::V_IT]->GetBuffer());
_tables[FarSubdivisionTables::V_IT]->GetBuffer());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6,
_tables[FarSubdivisionTables<OsdVertex>::V_ITa]->GetBuffer());
_tables[FarSubdivisionTables::V_ITa]->GetBuffer());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7,
_tables[FarSubdivisionTables<OsdVertex>::E_W]->GetBuffer());
_tables[FarSubdivisionTables::E_W]->GetBuffer());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 8,
_tables[FarSubdivisionTables<OsdVertex>::V_W]->GetBuffer());
_tables[FarSubdivisionTables::V_W]->GetBuffer());
}
void
@ -266,7 +272,7 @@ OsdGLSLComputeContext::unbindShaderStorageBuffers() {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
if (_tables[FarSubdivisionTables<OsdVertex>::F_IT]) {
if (_tables[FarSubdivisionTables::F_IT]) {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, 0);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, 0);
}

View File

@ -27,6 +27,8 @@
#include "../version.h"
#include "../far/subdivisionTables.h"
#include "../far/vertexEditTables.h"
#include "../far/vertexEditTables.h"
#include "../osd/vertex.h"
#include "../osd/vertexDescriptor.h"
@ -62,7 +64,7 @@ private:
class OsdGLSLComputeHEditTable : OsdNonCopyable<OsdGLSLComputeHEditTable> {
public:
OsdGLSLComputeHEditTable(const FarVertexEditTables<OsdVertex>::
OsdGLSLComputeHEditTable(const FarVertexEditTables::
VertexEditBatch &batch);
virtual ~OsdGLSLComputeHEditTable();
@ -101,9 +103,12 @@ class OsdGLSLComputeContext {
public:
/// Creates an OsdGLSLComputeContext instance
///
/// @param farmesh the FarMesh used for this Context.
/// @param subdivisionTables the FarSubdivisionTables used for this Context.
///
static OsdGLSLComputeContext * Create(FarMesh<OsdVertex> const *farmesh);
/// @param vertexEditTables the FarVertexEditTables used for this Context.
///
static OsdGLSLComputeContext * Create(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables);
/// Destructor
virtual ~OsdGLSLComputeContext();
@ -196,7 +201,8 @@ public:
void UnbindEditShaderStorageBuffers();
protected:
explicit OsdGLSLComputeContext(FarMesh<OsdVertex> const *farMesh);
explicit OsdGLSLComputeContext(FarSubdivisionTables const *subdivisionTables,
FarVertexEditTables const *vertexEditTables);
void bindShaderStorageBuffers();

View File

@ -73,10 +73,8 @@ OsdGLSLComputeController::getKernels(int numVertexElements,
void
OsdGLSLComputeController::ApplyBilinearFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -87,10 +85,8 @@ OsdGLSLComputeController::ApplyBilinearFaceVerticesKernel(
void
OsdGLSLComputeController::ApplyBilinearEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -101,10 +97,8 @@ OsdGLSLComputeController::ApplyBilinearEdgeVerticesKernel(
void
OsdGLSLComputeController::ApplyBilinearVertexVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -115,10 +109,8 @@ OsdGLSLComputeController::ApplyBilinearVertexVerticesKernel(
void
OsdGLSLComputeController::ApplyCatmarkFaceVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -131,10 +123,8 @@ OsdGLSLComputeController::ApplyCatmarkFaceVerticesKernel(
void
OsdGLSLComputeController::ApplyCatmarkEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -145,10 +135,8 @@ OsdGLSLComputeController::ApplyCatmarkEdgeVerticesKernel(
void
OsdGLSLComputeController::ApplyCatmarkVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -159,10 +147,8 @@ OsdGLSLComputeController::ApplyCatmarkVertexVerticesKernelB(
void
OsdGLSLComputeController::ApplyCatmarkVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -173,10 +159,8 @@ OsdGLSLComputeController::ApplyCatmarkVertexVerticesKernelA1(
void
OsdGLSLComputeController::ApplyCatmarkVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -187,10 +171,8 @@ OsdGLSLComputeController::ApplyCatmarkVertexVerticesKernelA2(
void
OsdGLSLComputeController::ApplyLoopEdgeVerticesKernel(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -201,10 +183,8 @@ OsdGLSLComputeController::ApplyLoopEdgeVerticesKernel(
void
OsdGLSLComputeController::ApplyLoopVertexVerticesKernelB(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -215,10 +195,8 @@ OsdGLSLComputeController::ApplyLoopVertexVerticesKernelB(
void
OsdGLSLComputeController::ApplyLoopVertexVerticesKernelA1(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -229,10 +207,8 @@ OsdGLSLComputeController::ApplyLoopVertexVerticesKernelA1(
void
OsdGLSLComputeController::ApplyLoopVertexVerticesKernelA2(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();
@ -243,10 +219,8 @@ OsdGLSLComputeController::ApplyLoopVertexVerticesKernelA2(
void
OsdGLSLComputeController::ApplyVertexEdits(
FarKernelBatch const &batch, void * clientdata) const {
FarKernelBatch const &batch, OsdGLSLComputeContext *context) const {
OsdGLSLComputeContext * context =
static_cast<OsdGLSLComputeContext*>(clientdata);
assert(context);
OsdGLSLComputeKernelBundle * kernelBundle = context->GetKernelBundle();

View File

@ -82,10 +82,9 @@ public:
context->SetKernelBundle(getKernels(numVertexElements, numVaryingElements));
context->Bind(vertexBuffer, varyingBuffer);
FarDispatcher::Refine(this,
batches,
-1,
context);
FarDispatcher::Refine(this, context, batches, /*maxlevel*/-1);
context->Unbind();
}
@ -110,34 +109,34 @@ public:
protected:
friend class FarDispatcher;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyBilinearVertexVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkFaceVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyCatmarkVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopEdgeVerticesKernel(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelB(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA1(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, void * clientdata) const;
void ApplyLoopVertexVerticesKernelA2(FarKernelBatch const &batch, ComputeContext *context) const;
void ApplyVertexEdits(FarKernelBatch const &batch, void * clientdata) const;
void ApplyVertexEdits(FarKernelBatch const &batch, ComputeContext *context) const;
OsdGLSLComputeKernelBundle * getKernels(int numVertexElements,
int numVaryingElements);

View File

@ -135,13 +135,13 @@ OsdGLSLComputeKernelBundle::Compile(int numVertexElements, int numVaryingElement
_uniformIndexStart = glGetUniformLocation(_program, "indexStart");
_uniformIndexEnd = glGetUniformLocation(_program, "indexEnd");
_tableUniforms[FarSubdivisionTables<OsdVertex>::F_IT] = glGetUniformLocation(_program, "_F0_IT");
_tableUniforms[FarSubdivisionTables<OsdVertex>::F_ITa] = glGetUniformLocation(_program, "_F0_ITa");
_tableUniforms[FarSubdivisionTables<OsdVertex>::E_IT] = glGetUniformLocation(_program, "_E0_IT");
_tableUniforms[FarSubdivisionTables<OsdVertex>::V_IT] = glGetUniformLocation(_program, "_V0_IT");
_tableUniforms[FarSubdivisionTables<OsdVertex>::V_ITa] = glGetUniformLocation(_program, "_V0_ITa");
_tableUniforms[FarSubdivisionTables<OsdVertex>::E_W] = glGetUniformLocation(_program, "_E0_S");
_tableUniforms[FarSubdivisionTables<OsdVertex>::V_W] = glGetUniformLocation(_program, "_V0_S");
_tableUniforms[FarSubdivisionTables::F_IT] = glGetUniformLocation(_program, "_F0_IT");
_tableUniforms[FarSubdivisionTables::F_ITa] = glGetUniformLocation(_program, "_F0_ITa");
_tableUniforms[FarSubdivisionTables::E_IT] = glGetUniformLocation(_program, "_E0_IT");
_tableUniforms[FarSubdivisionTables::V_IT] = glGetUniformLocation(_program, "_V0_IT");
_tableUniforms[FarSubdivisionTables::V_ITa] = glGetUniformLocation(_program, "_V0_ITa");
_tableUniforms[FarSubdivisionTables::E_W] = glGetUniformLocation(_program, "_E0_S");
_tableUniforms[FarSubdivisionTables::V_W] = glGetUniformLocation(_program, "_V0_S");
// set unfiorm locations for edit
_subEditAdd = glGetSubroutineIndex(_program,

View File

@ -105,7 +105,7 @@ protected:
GLuint _program;
// uniform locations for compute
GLuint _tableUniforms[FarSubdivisionTables<OsdVertex>::TABLE_TYPES_COUNT];
GLuint _tableUniforms[FarSubdivisionTables::TABLE_TYPES_COUNT];
GLuint _uniformVertexPass;
GLuint _uniformVertexOffset;
GLuint _uniformTableOffset;

Some files were not shown because too many files have changed in this diff Show More