Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add API for building attribute getter free functions. #1704

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d318962
Add API for building attribute getter free functions.
curtisblack Jun 23, 2023
1176fd4
Support all standard C++ types and ustring/ustringhash.
curtisblack Jul 21, 2023
c312d24
Fix different sign comparison.
curtisblack Jul 21, 2023
07bf09a
Fix memcpy error.
curtisblack Jul 21, 2023
6e352b6
Merge branch 'main' into getattribute_builder
curtisblack Jul 24, 2023
d3ec4fe
Disambiguate function call.
curtisblack Jul 24, 2023
637275d
Fix formatting.
curtisblack Jul 24, 2023
e4efe31
Fix formatting.
curtisblack Jul 24, 2023
4ad7c1d
Add helper functions and comments.
curtisblack Aug 17, 2023
9c929bd
Merge branch 'main' into getattribute_builder
curtisblack Aug 17, 2023
587fe5e
Use string params to ensure optimisation.
curtisblack Aug 18, 2023
46cc9e2
Merge branch 'main' into getattribute_builder
curtisblack Aug 18, 2023
9f05e03
Fix rebase conflict.
curtisblack Aug 18, 2023
02c4237
Convert return type to match virtual function signature.
curtisblack Aug 20, 2023
028aa6c
clang format
curtisblack Aug 20, 2023
e90f4e9
Fix incorrect indexing.
curtisblack Aug 21, 2023
0a1498d
Support userdata in attribute builder.
curtisblack Aug 21, 2023
0db9c26
Add missing derivatives argument.
curtisblack Aug 21, 2023
6c03cda
Fix typo.
curtisblack Aug 21, 2023
f914eeb
Use find_pv correctly.
curtisblack Aug 21, 2023
1577a8d
Merge branch 'main' into getattribute_builder
curtisblack Aug 21, 2023
630530f
Remove unused variable.
curtisblack Aug 21, 2023
a0dd0ed
clang format
curtisblack Aug 21, 2023
6f68b60
Fix some attribute types.
curtisblack Aug 21, 2023
651c7f9
Fix incorrect size.
curtisblack Aug 21, 2023
3edffb9
Cast to avoid ambiguity.
curtisblack Aug 25, 2023
697d1d3
Refactor for future reusability.
curtisblack Aug 25, 2023
217a238
Formatting.
curtisblack Aug 25, 2023
3006684
Fix template specialisations.
curtisblack Aug 25, 2023
3a0d66c
Formatting.
curtisblack Aug 25, 2023
74048bc
Remove templates.
curtisblack Aug 25, 2023
f8e449b
Fix asserts.
curtisblack Aug 25, 2023
c9cebdf
Fix type.
curtisblack Aug 25, 2023
8c5e57c
Merge branch 'main' into getattribute_builder
curtisblack Aug 28, 2023
e21087a
Use POD type with known size.
curtisblack Aug 28, 2023
7c62b2f
Update src/include/OSL/rendererservices.h
curtisblack Aug 31, 2023
c260dac
Make optional args const pointers.
curtisblack Sep 1, 2023
e72ddfb
clang format.
curtisblack Sep 1, 2023
2798354
clang format.
curtisblack Sep 1, 2023
c7971ef
constify ShaderGroup.
curtisblack Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ configure_package_config_file ("${PROJECT_SOURCE_DIR}/src/cmake/Config.cmake.in"
install (FILES "${OSL_PROJECT_CONFIG}" "${OSL_VERSION_CONFIG}"
DESTINATION "${OSL_CONFIG_INSTALL_DIR}")

install (FILES src/cmake/llvm_macros.cmake DESTINATION cmake)

set (PERMISSION_FLAGS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ)
install (FILES src/build-scripts/serialize-bc.py
DESTINATION build-scripts
PERMISSIONS ${PERMISSION_FLAGS})

# install targets files
install (EXPORT OSL_EXPORTED_TARGETS
DESTINATION ${OSL_CONFIG_INSTALL_DIR}
Expand Down
24 changes: 8 additions & 16 deletions src/cmake/llvm_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

# TODO: Use CMAKE_CURRENT_FUNCTION_LIST_DIR in cmake-3.17
set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")

function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_cpp extra_clang_args)
function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_cpp extra_clang_args include_dirs)

if (VERBOSE)
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP src_list=${src_list}")
Expand Down Expand Up @@ -75,12 +77,8 @@ function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_
# endif ()
#endif ()

list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
list (TRANSFORM OPENEXR_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OPENEXR_INCLUDES)
list (TRANSFORM OpenImageIO_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OpenImageIO_INCLUDES)
list (TRANSFORM include_dirs PREPEND -I
OUTPUT_VARIABLE ALL_INCLUDE_DIRS)

if (${LLVM_VERSION} VERSION_GREATER_EQUAL 15.0)
# Until we fully support opaque pointers, we need to disable
Expand All @@ -93,13 +91,7 @@ function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_
add_custom_command ( OUTPUT ${src_bc}
COMMAND ${LLVM_BC_GENERATOR}
${LLVM_COMPILE_FLAGS}
"-I${CMAKE_CURRENT_SOURCE_DIR}"
"-I${CMAKE_SOURCE_DIR}/src/include"
"-I${CMAKE_BINARY_DIR}/include"
${ALL_OpenImageIO_INCLUDES}
${ALL_IMATH_INCLUDES}
#"-isystem ${Boost_INCLUDE_DIRS}" #Does not pick up usr installed boost/thread/tss.hpp for oslexec_pvt.h
"-I${Boost_INCLUDE_DIRS}"
${ALL_INCLUDE_DIRS}
-DOSL_COMPILING_TO_BITCODE=1
-Wno-deprecated-register
# the following 2 warnings can be restored when all 3rd parties have fixed their export macros
Expand Down Expand Up @@ -131,9 +123,9 @@ function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_
# Serialize the linked bitcode into a CPP file
set ( src_bc_cpp "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.bc.cpp" )
add_custom_command ( OUTPUT ${src_bc_cpp}
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py"
COMMAND ${Python_EXECUTABLE} "${_THIS_MODULE_BASE_DIR}/../build-scripts/serialize-bc.py"
${linked_src_bc} ${src_bc_cpp} ${output_name}
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${linked_src_bc}
DEPENDS "${_THIS_MODULE_BASE_DIR}/../build-scripts/serialize-bc.py" ${linked_src_bc}
${exec_headers} ${PROJECT_PUBLIC_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )

Expand Down
10 changes: 8 additions & 2 deletions src/include/OSL/llvm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,17 @@ class OSLEXECPUBLIC LLVM_Util {
/// Return an llvm::Constant holding the given floating point constant.
llvm::Constant* constant(float f);

/// Return an llvm::Constant holding the given floating point constant.
llvm::Constant* constant64(double f);
AlexMWells marked this conversation as resolved.
Show resolved Hide resolved

/// Return an llvm::Constant holding the given integer constant.
llvm::Constant* constant(int i);
llvm::Constant* constant(int32_t i);
llvm::Constant* constant(uint32_t i);

/// Return an llvm::Constant holding the given integer constant.
llvm::Constant* constant8(int i);
llvm::Constant* constant8(int8_t i);
llvm::Constant* constant8(uint8_t i);
llvm::Constant* constant16(int16_t i);
llvm::Constant* constant16(uint16_t i);
llvm::Constant* constant64(uint64_t i);
llvm::Constant* constant128(uint64_t i);
Expand Down
12 changes: 12 additions & 0 deletions src/include/OSL/oslexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,18 @@ class OSLEXECPUBLIC ShadingSystem {
void add_symlocs(cspan<SymLocationDesc> symlocs);
void add_symlocs(ShaderGroup* group, cspan<SymLocationDesc> symlocs);

// Find the SymLocationDesc for this named param, returning its pointer
// or nullptr if that name is not found.
const SymLocationDesc* find_symloc(ustring name) const;
const SymLocationDesc* find_symloc(ShaderGroup* group, ustring name) const;

// Find the SymLocationDesc for this named param but only if it matches
// the arena type, returning its pointer or nullptr if that name is not
// found.
const SymLocationDesc* find_symloc(ustring name, SymArena arena) const;
const SymLocationDesc* find_symloc(ShaderGroup* group, ustring name,
SymArena arena) const;

Copy link
Contributor Author

@curtisblack curtisblack Jun 23, 2023

Choose a reason for hiding this comment

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

These additions are not strictly necessary for the rest of this PR to work, but it did seem to be useful to be able to query current symbol locations for a shader group inside the build_attribute_getter function.

/// Ensure that the group has been optimized and optionally JITed. The ctx pointer
/// supplies a ShadingContext to use.
void optimize_group(ShaderGroup* group, ShadingContext* ctx,
Expand Down
Loading
Loading