Compare commits
228
Commits
dev-1.12.2.0
...
analysis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4db549061 | ||
|
|
4debd96adc | ||
|
|
30a4a95b7e | ||
|
|
a38aa58c0e | ||
|
|
e126a20df7 | ||
|
|
52cf2ee418 | ||
|
|
83a1e7e74b | ||
|
|
6069b7cfc0 | ||
|
|
41cc6d78db | ||
|
|
8561a817ea | ||
|
|
cfaf643d0e | ||
|
|
c505c4ca5f | ||
|
|
318f0e488e | ||
|
|
b22c9b7c84 | ||
|
|
bd491d025e | ||
|
|
6140c72aa6 | ||
|
|
7fcdc3f71c | ||
|
|
22feb208c2 | ||
|
|
ab65bbad4b | ||
|
|
64c66949e7 | ||
|
|
2fe18079a3 | ||
|
|
e0a66c7bc6 | ||
|
|
e4e5088ed6 | ||
|
|
aea281dcad | ||
|
|
b5aba16147 | ||
|
|
4ba1678561 | ||
|
|
8417f8eb04 | ||
|
|
55029e388f | ||
|
|
89c033bda9 | ||
|
|
0b57ae6b03 | ||
|
|
6588caafa6 | ||
|
|
b11fb97626 | ||
|
|
7a885c68b6 | ||
|
|
32278d3f77 | ||
|
|
c8dd33f5a3 | ||
|
|
1a7670600c | ||
|
|
a6ff40b0b2 | ||
|
|
54cf8b209c | ||
|
|
2e941e612f | ||
|
|
051f2bfe2f | ||
|
|
f13463e6b6 | ||
|
|
cd2fa1650d | ||
|
|
c23da3df34 | ||
|
|
95c1408d27 | ||
|
|
e278f4c24a | ||
|
|
365f2c4b2b | ||
|
|
ac59af9bd1 | ||
|
|
9d5d6203b9 | ||
|
|
1a66a2b8dd | ||
|
|
3b97ecef47 | ||
|
|
ed5b5a2a0c | ||
|
|
37cbab5bad | ||
|
|
11127b72b5 | ||
|
|
d5d87f1e64 | ||
|
|
fa6f228b87 | ||
|
|
21f1a2f47e | ||
|
|
5be7c6bd4e | ||
|
|
9f8e92ce93 | ||
|
|
4bbaca7fe5 | ||
|
|
cf1b4ef3e6 | ||
|
|
c3e36affa8 | ||
|
|
e9a614ba53 | ||
|
|
d57a462462 | ||
|
|
ac114aded4 | ||
|
|
74fc27de12 | ||
|
|
826b6767c9 | ||
|
|
89d5db2b5c | ||
|
|
1dd33050da | ||
|
|
0879638dda | ||
|
|
8a7b9b96ba | ||
|
|
23ea0644f8 | ||
|
|
bd6d856b0e | ||
|
|
6424177e3a | ||
|
|
0b92d2b03b | ||
|
|
bf04610296 | ||
|
|
ff9560f401 | ||
|
|
e0d6a21438 | ||
|
|
da794de6fd | ||
|
|
a1e941c43b | ||
|
|
3bb41960fd | ||
|
|
95fa78d3fd | ||
|
|
eff3dede3a | ||
|
|
7b4c7cffd7 | ||
|
|
8281721bde | ||
|
|
2ece55aa97 | ||
|
|
88c471a315 | ||
|
|
11afddc8da | ||
|
|
f7cac87979 | ||
|
|
5401e8417b | ||
|
|
c61a85e217 | ||
|
|
08cda36387 | ||
|
|
caa8a2d252 | ||
|
|
21eac9d921 | ||
|
|
d75384da6d | ||
|
|
008907161d | ||
|
|
102430c835 | ||
|
|
ce0e6e1d4f | ||
|
|
8c6ffdd911 | ||
|
|
a5a8f9d745 | ||
|
|
1c715483b4 | ||
|
|
08706b7cba | ||
|
|
c1045f2c28 | ||
|
|
46d451ce74 | ||
|
|
1c57fc61d8 | ||
|
|
e56851056d | ||
|
|
28399fefc8 | ||
|
|
7f2e83794e | ||
|
|
1f73b075c9 | ||
|
|
b4026fd169 | ||
|
|
efeb577933 | ||
|
|
fdd8ff04a3 | ||
|
|
89cc2374c7 | ||
|
|
5fc4ee50f6 | ||
|
|
d8a9993f63 | ||
|
|
96fe1eff44 | ||
|
|
033dae3772 | ||
|
|
5efe15a79e | ||
|
|
3d00dbcd55 | ||
|
|
10b72648a8 | ||
|
|
e5dd190874 | ||
|
|
880b44620a | ||
|
|
0a55421f34 | ||
|
|
b7a87285a1 | ||
|
|
b0d8cb82a2 | ||
|
|
9cfca9397b | ||
|
|
a056e181c2 | ||
|
|
d8000dfc2c | ||
|
|
8feaff41fe | ||
|
|
97d5337283 | ||
|
|
87913529e1 | ||
|
|
4e96ab13dd | ||
|
|
2e1c0a95c2 | ||
|
|
096fab8da7 | ||
|
|
aeba1f2db4 | ||
|
|
7e34ce27c7 | ||
|
|
8589d4dd7b | ||
|
|
20bcc714b9 | ||
|
|
a1dc6d7c87 | ||
|
|
e493510d81 | ||
|
|
9b3f15b170 | ||
|
|
8c52d48965 | ||
|
|
9b33a7af3b | ||
|
|
2a186f8bc4 | ||
|
|
2ab1c5e322 | ||
|
|
7366046f47 | ||
|
|
1773995dbc | ||
|
|
2bdd9b567a | ||
|
|
9ee6b08f76 | ||
|
|
77df61003c | ||
|
|
701dcab948 | ||
|
|
97a4ac8338 | ||
|
|
c2b1d86c69 | ||
|
|
0392aea57e | ||
|
|
89207ef83a | ||
|
|
d34c3f584c | ||
|
|
72d530702e | ||
|
|
bf185d1245 | ||
|
|
58a25f1bea | ||
|
|
b816c21b19 | ||
|
|
c476b4727d | ||
|
|
f7fccf6a3a | ||
|
|
72acb7caf1 | ||
|
|
40223e513b | ||
|
|
e71dfec941 | ||
|
|
0e4a7e6f90 | ||
|
|
7baa2937b0 | ||
|
|
c79e4a7a4b | ||
|
|
7f40f3687c | ||
|
|
4c7c3922ea | ||
|
|
6814224f0e | ||
|
|
0b8ddec6d9 | ||
|
|
5c43516282 | ||
|
|
450a9e37cf | ||
|
|
7e2bcbb122 | ||
|
|
535b560b0d | ||
|
|
eb35c6185a | ||
|
|
4faeda1234 | ||
|
|
15e0273eec | ||
|
|
5b775c7fc7 | ||
|
|
e7ca0926c9 | ||
|
|
a33abee2ad | ||
|
|
9d42d4a6f7 | ||
|
|
81dacc2e3b | ||
|
|
1e84fc03ce | ||
|
|
5ec96f37a7 | ||
|
|
748b895e05 | ||
|
|
1ff9aec2f1 | ||
|
|
47ddafda31 | ||
|
|
0fedeb4212 | ||
|
|
95def2d57b | ||
|
|
41f645902f | ||
|
|
2120647911 | ||
|
|
75d06a6c94 | ||
|
|
ac544e8c9c | ||
|
|
6b6637e271 | ||
|
|
0f44f46973 | ||
|
|
bf02d4a98b | ||
|
|
03a31f506e | ||
|
|
1d9eec69ab | ||
|
|
e26a597e3f | ||
|
|
bee949cd3b | ||
|
|
0d1d2de350 | ||
|
|
54727f9dee | ||
|
|
1d7362b331 | ||
|
|
7b2cdacdea | ||
|
|
ea550aa5c8 | ||
|
|
4f169d8b38 | ||
|
|
8682211d0b | ||
|
|
15c81df232 | ||
|
|
8f9206ab46 | ||
|
|
3f87e75821 | ||
|
|
f471ab5e0c | ||
|
|
22105d2982 | ||
|
|
879545c359 | ||
|
|
1b05f9a6a0 | ||
|
|
cb3bdb4b4e | ||
|
|
692c9b4498 | ||
|
|
e901657f81 | ||
|
|
881c704d11 | ||
|
|
df18d97283 | ||
|
|
30d2a4a089 | ||
|
|
06c9d0d1c7 | ||
|
|
d4f54bc76a | ||
|
|
92a6055ab9 | ||
|
|
e3f40d764e | ||
|
|
79cc3a3268 | ||
|
|
0406e48cef | ||
|
|
4bfdefdba5 |
@@ -6,3 +6,40 @@ bdb473cbdb119f3d9060d48f75f965cbd45f6d7a
|
||||
|
||||
# More clang-format: liboslquery, oslinfo, oslc, osl.imageio, osltoy (#1220)
|
||||
bf366d7a90c46599b82071dac6dbef7c5e3ca157
|
||||
|
||||
# Turn on clang-format for cpp files in testsuite (#1269)
|
||||
00c895fc642eb89685797c292048bdff15d675e7
|
||||
5e848fb761261521a3ee7cd8a4f6814f32fe4a47
|
||||
|
||||
# CI: Change our clang-format standard to clang11 (#1372)
|
||||
91d22ebe2f65d4ed0599e421172a15d99fe0e1b4
|
||||
|
||||
# More clang-format (this time, testrender and liboslnoise) (#1511)
|
||||
08706b7cbac781b6a9389780428016be985d9d89
|
||||
|
||||
# clang-format #1509
|
||||
b4026fd1695c08532557b3ba1c2142323087ccf9
|
||||
1f73b075c99861afa42fac44567b37f797bc72f2
|
||||
7f2e83794e6fa63d5180653cffb77be2cc38b32b
|
||||
28399fefc890442b5ac020e7a90cee0d5bf9f03c
|
||||
e56851056d33233b0bb8324faac251907099961a
|
||||
1c57fc61d8ab7c3f309be4335e4c71c26399edd4
|
||||
46d451ce74d00e904874df476ebeca19bb119ea9
|
||||
c1045f2c2845a98e661c7181932a031eb3c76063
|
||||
|
||||
# More clang-format (#1512)
|
||||
8c6ffdd911b9eb7db4adf41ab88891360452d7c5
|
||||
|
||||
# style: more clang-format (#1515)
|
||||
102430c83554fe7e328cd8c3317db00507bcfaba
|
||||
|
||||
# Revert some formatting (#1518)
|
||||
21eac9d9215d071b0a7b9ce2c32f189ed0c62c4a
|
||||
|
||||
# Another round of clang-format (#1540)
|
||||
38015b6be28643254aea530154b7860136cf5e15
|
||||
89d5db2b5c5fda79184d8245d903e580fc6a4e9c
|
||||
|
||||
# clang-format: the very last piece of the puzzle (#1555)
|
||||
4ee62cd2ef05543f818f4d95a19efc1d684a7381
|
||||
5be7c6bd4e7bd2e560cb6be8c06f11985384a87a
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
# Copyright 2008-present Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
name: Analysis
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run nightly while we're still working our way through the warnings
|
||||
- cron: "0 8 * * *"
|
||||
# Run unconditionally once weekly
|
||||
# - cron: "0 0 * * 0"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- '*analysis*'
|
||||
# Allow manual kicking off of the workflow from github.com
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: read-all
|
||||
|
||||
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
|
||||
jobs:
|
||||
|
||||
aswf:
|
||||
name: "SonarCloud Analysis"
|
||||
if: |
|
||||
github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- desc: sonar gcc9/C++14 llvm13 py3.9 boost1.76 exr3.1 oiio2.3 avx2
|
||||
nametag: static-analysis-sonar
|
||||
os: ubuntu-20.04-8c-32g-300h
|
||||
# os: ubuntu-latest
|
||||
vfxyear: 2022
|
||||
vfxsuffix: -clang13
|
||||
cxx_std: 14
|
||||
openimageio_ver: master
|
||||
python_ver: 3.9
|
||||
pybind11_ver: v2.9.0
|
||||
simd: avx2,f16c
|
||||
batched: b8_AVX2,b16_AVX512
|
||||
coverage: 1
|
||||
# skip_tests: 1
|
||||
sonar: 1
|
||||
setenvs: export SONAR_SCANNER_VERSION=4.7.0.2747
|
||||
SONAR_SERVER_URL="https://sonarcloud.io"
|
||||
BUILD_WRAPPER_OUT_DIR=bw_output
|
||||
OSL_CMAKE_BUILD_WRAPPER="build-wrapper-linux-x86-64 --out-dir bw_output"
|
||||
CMAKE_BUILD_TYPE=Debug
|
||||
CMAKE_UNITY_BUILD=OFF
|
||||
CODECOV=1
|
||||
TESTRENDER_AA=1
|
||||
OSL_TESTSUITE_SKIP_DIFF=1
|
||||
CTEST_TEST_TIMEOUT=1200
|
||||
OSL_CMAKE_FLAGS="-DOSL_TEST_BIG_TIMEOUT=1200 -DUSE_QT=0"
|
||||
CTEST_EXCLUSIONS="broken|noise-reg.regress|noise-gabor-reg.regress"
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
container:
|
||||
image: aswf/ci-osl:${{matrix.vfxyear}}${{matrix.vfxsuffix}}
|
||||
env:
|
||||
CXX: ${{matrix.cxx_compiler}}
|
||||
CC: ${{matrix.cc_compiler}}
|
||||
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
|
||||
FMT_VERSION: ${{matrix.fmt_ver}}
|
||||
OPENEXR_VERSION: ${{matrix.openexr_ver}}
|
||||
OPENIMAGEIO_VERSION: ${{matrix.openimageio_ver}}
|
||||
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
|
||||
PYTHON_VERSION: ${{matrix.python_ver}}
|
||||
USE_BATCHED: ${{matrix.batched}}
|
||||
USE_SIMD: ${{matrix.simd}}
|
||||
PARALLEL: 24
|
||||
# DEBUG_CI: 1
|
||||
steps:
|
||||
# We would like to use harden-runner, but it flags too many false
|
||||
# positives, every time we download a dependency. We should use it only
|
||||
# on CI runs where we are producing artifacts that users might rely on.
|
||||
# - name: Harden Runner
|
||||
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
|
||||
# with:
|
||||
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
|
||||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- name: Prepare ccache timestamp
|
||||
id: ccache_cache_keys
|
||||
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
|
||||
- name: ccache
|
||||
id: ccache
|
||||
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
|
||||
with:
|
||||
path: /tmp/ccache
|
||||
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
|
||||
restore-keys: ${{github.job}}-
|
||||
- name: Build setup
|
||||
run: |
|
||||
${{matrix.setenvs}}
|
||||
src/build-scripts/ci-startup.bash
|
||||
- name: Remove existing OIIO
|
||||
if: matrix.openimageio_ver != ''
|
||||
run: |
|
||||
sudo rm -rf /usr/local/include/OpenImageIO
|
||||
sudo rm -rf /usr/local/lib*/cmake/OpenImageIO
|
||||
sudo rm -rf /usr/local/lib*/libOpenImageIO*
|
||||
sudo rm -rf /usr/local/lib*/python3.9/site-packages/OpenImageIO*
|
||||
- name: Dependencies
|
||||
run: |
|
||||
${{matrix.depcmds}}
|
||||
src/build-scripts/gh-installdeps.bash
|
||||
- name: Build
|
||||
run: src/build-scripts/ci-build.bash
|
||||
- name: Testsuite
|
||||
if: matrix.skip_tests != '1'
|
||||
run: src/build-scripts/ci-test.bash
|
||||
- name: Code coverage
|
||||
if: matrix.coverage == '1'
|
||||
run: src/build-scripts/ci-coverage.bash
|
||||
- name: Sonar-scanner
|
||||
if: matrix.sonar == 1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
run: |
|
||||
sonar-scanner -X --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="build/bw_output" --define sonar.cfamily.gcov.reportsPath="_coverage"
|
||||
+405
-619
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
name: Scorecards supply-chain security
|
||||
on:
|
||||
# Only the default branch is supported.
|
||||
branch_protection_rule:
|
||||
schedule:
|
||||
- cron: '44 20 * * 6'
|
||||
push:
|
||||
branches: [ "main", "scorecard" ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecards analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Used to receive a badge. (Upcoming feature)
|
||||
id-token: write
|
||||
# Needs for private repositories.
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@3e15ea8318eee9b333819ec77a36aca8d39df13e # v1.1.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecards on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
||||
|
||||
# Publish the results for public repositories to enable scorecard badges. For more details, see
|
||||
# https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories, `publish_results` will automatically be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -8,3 +8,6 @@ build
|
||||
\#*\#
|
||||
*.pyc
|
||||
*.log
|
||||
.vscode
|
||||
.envrc
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ must comply with the terms of this Charter.
|
||||
|
||||
- **i.** All new inbound code contributions to the Project must be made
|
||||
using the BSD 3-Clause License (available here:
|
||||
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/LICENSE)
|
||||
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/LICENSE.md)
|
||||
(the "Project License").
|
||||
|
||||
- **ii.** All new inbound code contributions must:
|
||||
|
||||
@@ -50,4 +50,4 @@ This is a checklist for TSC's to review as part of the intake process. The TSC s
|
||||
- [X] License scan completed and no issues found
|
||||
- Minor issues were found but already fixed in PR https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1145
|
||||
- [X] Code repository imported to ASWF GitHub organization
|
||||
- [ ] Developer Certificate of Origin past commit signoff done and DCO Probot enabled.
|
||||
- [X] Developer Certificate of Origin post commit signoff done and DCO Probot enabled.
|
||||
|
||||
+285
-15
@@ -1,24 +1,116 @@
|
||||
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
|
||||
<!-- Copyright Contributors to the Open Shading Language Project. -->
|
||||
|
||||
Release 1.12 -- ?? (compared to 1.11)
|
||||
Release 1.13 -- ?? 2023 ?? (compared to 1.12)
|
||||
--------------------------------------------------
|
||||
Dependency and standards requirements changes:
|
||||
* OpenImageIO 2.1-2.3: Support for OIIO 2.0 has been dropped.
|
||||
* OptiX 6.0 support has been removed. For GPU rendering with OptiX, a minimum
|
||||
of OptiX 7.0 is required.
|
||||
* The minimum version OpenImageIO has been raised from 2.2 to 2.3. #1591
|
||||
(1.13.0.3)
|
||||
|
||||
OSL Language and oslc compiler:
|
||||
* Bug fix: shader params whose default values involve "init ops" could be
|
||||
incorrectly initialized if their values came from instance parameters set to
|
||||
zero. #1578 (1.13.0.2)
|
||||
|
||||
OSL Standard library:
|
||||
|
||||
API changes, new options, new ShadingSystem features (for renderer writers):
|
||||
* A new `shadingStateUniform` pointer field was added to ShaderGlobals for
|
||||
planned future expansion and improved GPU support. #1585 (1.13.1.0)
|
||||
|
||||
SIMD batched shading mode:
|
||||
* Fix some array overruns (asymptomatic, but still potentially buggy) in
|
||||
common_ancestor_between. #1577 (1.13.0.2)
|
||||
|
||||
OptiX rendering:
|
||||
* OptiX 6.0 support has been removed. For GPU rendering with OptiX, a minimum
|
||||
of OptiX 7.0 is required.
|
||||
* Big overhaul/simplification of how strings are represented on the GPU: the
|
||||
extra level of indirection to global variables is removed, and strings are
|
||||
simply represented in ordinary variables as the hash of their characters.
|
||||
#1531 (1.13.0.0) #1553 (1.13.0.1)
|
||||
* Better PTX cache hit rate by eliminating several sources of not being
|
||||
strictly deterministic in the PTX text we were generating. #1566 #1570
|
||||
(1.13.0.1)
|
||||
|
||||
Performance improvements:
|
||||
|
||||
Bug fixes and other improvements (internals):
|
||||
* Fix memory leak in oslc ASTvariable_declaration. #1576 (1.13.0.2)
|
||||
* Fix memory leaks in LPE code in error conditions. #1593 #1594 (1.13.0.3)
|
||||
|
||||
Internals/developer concerns:
|
||||
* platform.h:
|
||||
- New `OSL_ALLOCA` macro to allocate on the stack. #1589 (1.13.0.3)
|
||||
|
||||
Build & test system improvements:
|
||||
* CMake build system and scripts:
|
||||
- The version number is now a cache variable, and so can be overridden at
|
||||
build time using `-DOSL_VERSION=...`. Use with extreme caution! #1579
|
||||
(1.13.0.2)
|
||||
* Dependency version support:
|
||||
- Fix some issues that came up with the new icx 2022.0 compiler. #1601
|
||||
(1.13.1.0)
|
||||
* Testing and Continuous integration (CI) systems:
|
||||
- Dynamic analysis using address and leak sanitizers. #1581 (1.13.0.3)
|
||||
- `testshade --help` now prints TextureSystem options and all hardware
|
||||
information. #1584 (1.13.0.3)
|
||||
- Improvements to SonarCloud and coverage analysis. #1596 (1.13.0.3)
|
||||
* Platform support:
|
||||
|
||||
Documentation:
|
||||
* `doc/RELEASING.md` documents our release process and versioning policies.
|
||||
#1572 (1.13.0.2)
|
||||
|
||||
|
||||
Release 1.12 -- 1 Oct 2022 (compared to 1.11)
|
||||
----------------------------------------------
|
||||
Big Deal Changes:
|
||||
* **Batch shading**: A fully operational "batch shading" support when using
|
||||
CPUs supporting the Intel AVX2 or AVX512 instruction set architectures,
|
||||
allows shading 8 or 16 points at a time, accelerated by using SIMD
|
||||
instructions. (Changes contributed by Intel.)
|
||||
* **OptiX**: A reasonable subset of the OSL language can run on NVIDIA GPUs
|
||||
for Cuda or OptiX-based renderers.
|
||||
* **Standardized material closures**: Synchronize with MaterialX on a minimum
|
||||
standard set of material closures. This is reflected in both the OSL spec as
|
||||
well as reference implementations of those closures in testrender. #1533
|
||||
#1536 #1537 #1538 #1539 #1541 #1542 #1547 #1557
|
||||
|
||||
Dependency and standards requirements changes:
|
||||
* The minimum (and default) compilation mode is now C++14. C++17 and 20 are
|
||||
also supported. #1362 #1369 (1.12.2)
|
||||
* Minimum compilers are now gcc 6.1 (no more support for gcc 4.8), MSVS
|
||||
2017 or newer (no more support for 2015).
|
||||
* Minimum LLVM is now 9.0. Support for LLVM 7 and 8 have ben dropped.
|
||||
#1441 (1.12.3)
|
||||
* Minimum OpenImageIO is now 2.2: Support for OIIO 2.0 and 2.1 have been
|
||||
dropped. #1426 (1.12.3)
|
||||
* Minimum OpenEXR version is now 2.3 (raised from 2.0). #1406 (1.12.3)
|
||||
|
||||
OSL Language and oslc compiler:
|
||||
* `#pragma error "message"` and `#pragma warning "message"` can be used to
|
||||
conditionally inject a compile-time error or warning. #1300 (1.12.1)
|
||||
* Check for errors when when writing oso files (for example, disk volume
|
||||
full). #1360 (1.12.2/1.11.14)
|
||||
* A new flavor of `gettextureinfo(texturename, paramname, s, t, destination)`
|
||||
allows for querying of texture metadata about the particular UDIM tile
|
||||
that will be used for particular (s,t) texture coordinates. #1398 (1.12.3)
|
||||
* Better error detection when OSL user functions write to function parameters
|
||||
that are not marked as output. #1417 (1.12.3)
|
||||
* Detect and better error message when using a type name where a variable
|
||||
identifier should be. #1457 (1.12.4.2)
|
||||
|
||||
OSL Standard library:
|
||||
* vector2.h is updated with a mod() function for vector2. #1312 (1.12.1/1.11.12)
|
||||
* Preliminary work for adding standard MaterialX closures. 31371 (1.12.2)
|
||||
* Fix previously-broken color conversions from RGB to xyY. #1410 (1.12.3)
|
||||
* Fully removed MaterialX shaders (get those from the MaterialX project).
|
||||
#1450 (1.12.3)
|
||||
* Fix incorrect implementation of `matrix4 * vector4` in vector4.h #1513
|
||||
(1.12.5.0)
|
||||
|
||||
API changes, new options, new ShadingSystem features (for renderer writers):
|
||||
* Custom experimental llvm optimization levels 10, 11, 12, and 13. These
|
||||
@@ -26,30 +118,52 @@ API changes, new options, new ShadingSystem features (for renderer writers):
|
||||
-O1, -O2, -O3) but we think for shaders are just as performant but with
|
||||
lower JIT time. These are currently experimental, but we are benchmarking
|
||||
to determine if they should be the new defaults. #1250 (1.12.0.0)
|
||||
* ShadingSystem attribute "searcpath:library" gives a searchpath for finding
|
||||
runtime-loadable implementation modules for ISA-optimized operaionts.
|
||||
* ShadingSystem attribute "searchpath:library" gives a searchpath for finding
|
||||
runtime-loadable implementation modules for ISA-optimized operations.
|
||||
#1310 (1.12.1)
|
||||
* Output variable placement -- now you can designate where shader outputs
|
||||
should go and the shader will put resuls there, intead of the app using
|
||||
should go and the shader will put results there, instead of the app using
|
||||
find_symbol() and symbol_address after the shader is executed. #1328 (1.12.2)
|
||||
* Userdata input placement -- now you can designate where interpolated
|
||||
userdata should be copied from directly, rather then via callbacks to
|
||||
RendererServices::get_userdata(). #1391 (1.12.3)
|
||||
* Better hiding of the Matrix22 class, which was never actually part of the
|
||||
public APIs. #1480 (1.12.4.5)
|
||||
* Add ACES2065-1 and ACEScg as shading system color spaces (#1486) (1.12.4.6)
|
||||
* Expanded warnings (via enabling the "opt_warnings" attribute of the
|
||||
ShadingSystem) for operations that try to create new strings mid-shader, or
|
||||
that need to access the characters of strings mid-shader. These are only
|
||||
triggered for those cases that cannot be resolved by the end of the "runtime
|
||||
optimization" phase. #1497 (1.12.4.6)
|
||||
|
||||
Continued work on experimental SIMD batched shading mode:
|
||||
SIMD batched shading mode:
|
||||
* Added support for masked operations to LLVMUtil. #1248 #1250 (1.12.0.0)
|
||||
* Add interface to ShadingSystem for batched execution. #1272 (1.12.0.1)
|
||||
* Add interface to batched RendererServices. #1276 (1.12.0.1)
|
||||
* Batched testshade. #1298 (1.12.1)
|
||||
* ShadingSystem plumbing to support batched execution. #1301 (1.12.1)
|
||||
* Batched analsys to figure out which symbols need to be varying or uniform,
|
||||
* Batched analysis to figure out which symbols need to be varying or uniform,
|
||||
and which operations require masking. #1313 #1318 #1322 (1.12.1)
|
||||
* Additional infrastructure for batched analsys. #1316 (1.12.1)
|
||||
* Additional infrastructure for batched analysis. #1316 (1.12.1)
|
||||
* Add implementation for BatchedBackendLLVM. #1330 (1.12.1)
|
||||
* ISA-specific modules. #1345 (1.12.2)
|
||||
* Introduction of CI testing of batched mode. #1357 #1367 (1.12.2)
|
||||
* Control flow and string ops. #1372 (1.12.2)
|
||||
* Matrix operations. #1378 (1.12.2)
|
||||
* Matrix operations. #1378 (1.12.2) #1485 (1.12.4.6)
|
||||
* Batched algebraic, trig, and transcendental functions. #1385 (1.12.2)
|
||||
* Batched noise. #1394 (1.12.3)
|
||||
* Batched implementation of all color operations. #1408 (1.12.3)
|
||||
* Batched bitwise ops. #1413 (1.12.3)
|
||||
* Batched spline and spline inverse. #1422 (1.12.3)
|
||||
* Batched texture, gettextureinfo, texture3d, environment. #1436 (1.12.3)
|
||||
* Batched dictionary functionality (dict_find, etc.) #1445 (1.12.3)
|
||||
* Enable batched execution of most testsuite. #1453 (1.12.4.1)
|
||||
* Batched isnan, isinf, isfinite. #1456 (1.12.4.2)
|
||||
* Batched userdata and output placement. #1455 (1.12.4.2)
|
||||
* Batched pointcloud functions. #1464 (1.12.4.4)
|
||||
* Batched closures (#1500)
|
||||
|
||||
Continued work on experimental OptiX rendering:
|
||||
OptiX rendering:
|
||||
* Explicitly set the OptiX pipeline stack size. #1254 (1.12.0.0)
|
||||
* CI tests now at least compile and build with USE_OPTIX=1 (though not yet
|
||||
run the tests). #1281 (1.12.0.1)
|
||||
@@ -58,8 +172,20 @@ Continued work on experimental OptiX rendering:
|
||||
* Overhaul in how strings are communicated to the GPU side. #1309 (1.12.1)
|
||||
* Removal of runtime compilation of Cuda (libnvrtc dependency eliminated).
|
||||
#1309 (1.12.1)
|
||||
* Fix problems with unresolved symbols on GPU, particularly when multiple
|
||||
shaders call certain functions like printf. #1401 (1.12.3)
|
||||
* Changed prototype of osl_get_attribute callback to work properly on
|
||||
GPU. #1404 (1.12.3)
|
||||
* Fix missing hostdevice modifier on some matrix operators. #1409 (1.12.3)
|
||||
* Fix race conditions when compiling for OptiX 7. #1411 (1.12.3)
|
||||
* osl_get_attribute() uses device strings when compiling for OptiX.
|
||||
#1435 (1.12.3)
|
||||
* Fix issue with OptiX + clang 14 with duplicate symbols. #1561 (1.12.6.0)
|
||||
|
||||
Performance improvements:
|
||||
* Less mutex locking around use and retrieval of ColorSystem related to
|
||||
doing color transforms. #1405 (1.12.3)
|
||||
* Constant folding of `startswith()`. #1507 (1.12.5.0)
|
||||
|
||||
Bug fixes and other improvements (internals):
|
||||
* Fix derivatives of texture calls when only derivatives of the "alpha"
|
||||
@@ -86,6 +212,25 @@ Bug fixes and other improvements (internals):
|
||||
outputs (the semantics of doing so are very fishy). #1296 (1.12.1)
|
||||
* Eliminate unnecessary error messages to stderr for broken point clouds.
|
||||
#1333 (1.12.1/1.11.13)
|
||||
* Fix undefined behavior that could result in crashes that resulted from
|
||||
the Symbol class having no virtual destructor. #1397 (1.12.3)
|
||||
* Fix in runtime optimizer where tracking of messages and unknown messages
|
||||
relied on uninitialized variables. #1447 (1.11.17/1.12.3)
|
||||
* Stop internally using OIIO::string_view::c_str(), which will someday be
|
||||
removed. #1458 (1.12.4.2)
|
||||
* Correctly track that the backfacing() function requires N and I shader
|
||||
globals. #1462 (1.12.4.4)
|
||||
* Print all 4 levels of version numbers in help messages. #1477 (1.12.4.4)
|
||||
* Fix GPU code generation crash. #1479 (1.12.4.4)
|
||||
* Work to transition internals to use modern std::format notation for
|
||||
formatted output. #1487 #1490 (1.12.4.6) #1504 #1506 (1.12.5.0)
|
||||
* testrender improvements:
|
||||
* Fix testrender memory error on teardown. #1499 (1.12.4.6)
|
||||
* Modernize the sampler in testrender, improving quality and performance.
|
||||
#1534 (1.12.6.0)
|
||||
* Switch to cone tracing for derivatives. #1543 (1.12.6.0)
|
||||
* Fix error that prevented correct typecheck of ternary operator. #1552
|
||||
(1.12.6.0)
|
||||
|
||||
Internals/developer concerns:
|
||||
* Use the `final` keyword in certain internal classes where applicable.
|
||||
@@ -95,6 +240,26 @@ Internals/developer concerns:
|
||||
#1317 (1.11.11/1.12.1)
|
||||
* The "archive_groupname" handling is now careful to sanitize the filenames
|
||||
it deals with, closing some security and safety holes. #1383 (1.12.2)
|
||||
* More migration of string formatting to new std::format style. #1389 (1.12.3)
|
||||
#1469 #1470 (1.12.4.4)
|
||||
* llvm_util: Switch some uses of ptr+len to span. #1390 (1.12.3)
|
||||
* OSL no longer uses sscanf internally (which has icky locale-dependent
|
||||
behavior), and instead use locale-independent OIIO::Strutil utilities
|
||||
whenever we need to parse strings. #1432 (1.12.3)
|
||||
* Avoid use of OIIO::string_view::str() which is not corresponding to the
|
||||
official C++17 std::string_view. #1467 (1.12.4.4)
|
||||
* Prototype of "free function" approach that will someday mostly supplant
|
||||
the way we use RendererServices, and will help to unlock feature completion
|
||||
for GPU and other back ends. This experimental feature is not expected
|
||||
to be used in OSL 1.12. #1494 (1.12.5.0)
|
||||
* Work on gradually converting printf-style formatted strings to fmt /
|
||||
std::format style. #1493 (1.12.5.0)
|
||||
* LLVM_Util: allow naming of llvm symbols to help with IR debugging. #1530
|
||||
(1.12.6.0)
|
||||
* clang-format the code base. #1508 #1509 #1511 #1512 #1515 #1518 #1540
|
||||
(1.12.5.0) #1555 #1562 #1568 (1.12.6.0)
|
||||
* A round of spell-checking all the comments in the code base. #1550
|
||||
(1.12.5.0)
|
||||
|
||||
Build & test system improvements:
|
||||
* CMake build system and scripts:
|
||||
@@ -111,25 +276,59 @@ Build & test system improvements:
|
||||
- Make the CMake build scripts more friendly to being a subproject.
|
||||
#1304 #1319 (1.11.11/1.12.1)
|
||||
- We weren't properly hiding non-public symbols. #1337 (1.12.1/1.11.12)
|
||||
- Fully split oslquery and oslnoise libraries from oslxec, no more
|
||||
- Fully split oslquery and oslnoise libraries from oslexec, no more
|
||||
redundant modules put into both. #1346 #1348 (1.12.1)
|
||||
- Support for CMake 3.20 #1354 (1.12.2/1.11.14)
|
||||
- Important change to `Makefile` wrapper: We have a 'Makefile' that just
|
||||
wraps cmake for ease of use. This has changed its practice of putting
|
||||
builds in `build/ARCH` to just `build` (and local installs from
|
||||
`dist/ARCH` to `dist`) to better match common cmake practice. So where
|
||||
your local builds end up may shift a bit. #1396 (1.12.3)
|
||||
- Be more careful about not writing over a sensitive install area
|
||||
unless CMAKE_INSTALL_PREFIX is explicitly set. #1421 (1.12.3)
|
||||
- PROJECT_VERSION_RELEASE_TYPE and OSL_SUPPORTED_RELEASE are now
|
||||
cache variables that can have build-time overrides. #1443 (1.12.3)
|
||||
- Use PROJECT_IS_TOP_LEVEL (not OSL_IS_SUBPROJECT) to confirm with
|
||||
CMake 21 conventions. #1443 (1.12.3)
|
||||
- New TIME_COMMANDS option, when enabled, can help debug performance of
|
||||
the build. #1443 (1.12.3)
|
||||
- New CMake variable `DOWNSTREAM_CXX_STANDARD` sets the downstream
|
||||
minimum C++ requirement, separately from `CMAKE_CXX_STANDARD` which sets
|
||||
what we build OSL itself with. Clarify that currently, OSL can be used
|
||||
downstream by C++14, even if it is built with C++17 or higher. #1454
|
||||
(1.12.4.1)
|
||||
- Make exported cmake configs relocatable by using relative paths. #1466
|
||||
(1.12.4.4)
|
||||
* Dependency version support:
|
||||
- Build properly against Cuda 11 and OptiX 7.1. #1232 (1.12.0.1)
|
||||
and up to OptiX 7.4 #1559 (1.12.6.0)
|
||||
- PugiXML build fixes on some systems. #1262 (1.12.0.1/1.11.8)
|
||||
- Cuda/OptiX back end: Add `__CUDADEVRT_INTERNAL__` define to bitcode
|
||||
generation, needed to avoid duplicate cudaMalloc symbols with CUDA9+
|
||||
#1271 (1.12.0.1)
|
||||
- Build against LLVM 11 #1274 (1.12.0.1) and LLVM 12 #1351 (1.12.1.0).
|
||||
- Build against LLVM 11 #1274 (1.12.0.1), LLVM 12 #1351 (1.12.1.0)
|
||||
#1412 (1.12.3), LLVM 13 #1420 (1.12.3), LLVM 14 #1492 (1.12.4.6)
|
||||
LLVM 15 #1592 (1.12.6.2)
|
||||
- Fix build break against recent OIIO master change where m_mutex field
|
||||
was removed from ImageInput. #1281 (1.12.0.1/1.11.9)
|
||||
- Work to ensure that OIIO will build correctly against the upcoming
|
||||
Imath 3.0 and OpenEXR 3.0. #1299 (1.11.10/1.12.1) #1332 (1.11.11/1.12.1)
|
||||
#1341 (1.11.12/1.12.1) #1356 #1368 (1.11.13/1.12.2)
|
||||
#1341 (1.11.12/1.12.1) #1356 #1368 (1.11.13/1.12.2) #1489 (1.12.4.6)
|
||||
- Improved finding of llvm components when using static libraries. #1375
|
||||
(1.12.2)
|
||||
- No longer use boost regex, completely rely on std::regex now that OSL
|
||||
is C++14 minimum. #1377. (1.12.2)
|
||||
- Support for OpenImageIO 2.3 changes. #1393 (1.12.3)
|
||||
- Some rearrangement of `#include` and other trickery ensures that OSL
|
||||
always includes headers from its favored version of Imath, rather than
|
||||
the ones that OIIO prefers (in cases where OIIO and OSL were each based
|
||||
on different Imath versions). #1460 (1.12.4.2)
|
||||
- Various fixes for functionality and warnings for Intel icc and icx
|
||||
compilers. #1459 #1473 #1475. (1.12.4.4)
|
||||
- Fixes for recent OIIO TextureSystem changes that hide Imath types.
|
||||
#1476 (1.12.4.4)
|
||||
- Changes to work correctly with OpenImageIO 2.4 and its master being
|
||||
the start of 2.5. #1569 (1.12.6.0)
|
||||
* Testing and Continuous integration (CI) systems:
|
||||
- Eliminate the old Travis CI and Appveyor. #1334 #1338 (1.12.1)
|
||||
- Use ccache + GitHub 'cache' action to greatly speed up CI runs. #1335
|
||||
@@ -138,10 +337,38 @@ Build & test system improvements:
|
||||
scripts for CentOS and Ubuntu ito a single script. #1338 (1.12.1)
|
||||
- CI tests clang11, also batched shading with clang. #1379 (1.12.2)
|
||||
- CI speeds up OIIO builds by not building its tests. #1380 (1.12.2)
|
||||
- CI tests gcc11. #1381 (1.12.2)
|
||||
- CI tests gcc11 #1381 (1.12.2) and gcc12 #1565 (1.12.6)
|
||||
- Deal with OpenColorIO changing its master branch to "main". #1429
|
||||
(1.12.3)
|
||||
- Fix tests for texture3d now that OIIO has dropped support for Field3D.
|
||||
#1437 (1.12.3)
|
||||
- Test against LLVM13/clang13 for the VFX Platform 2022 tests. #1434
|
||||
(1.12.3)
|
||||
- CI test against MacOS-11 #1434 (1.12.3) and MacOS-12 #1554 (1.12.6)
|
||||
#1522 (1.12.5)
|
||||
- Add testsuite coverage of environment(). #1438 (1.12.3)
|
||||
- Use a project-specific environment variable `OSL_CI` instead of the more
|
||||
generic `CI` to avoid clashes with other systems. #1446 (1.12.3)
|
||||
- Deal with OpenEXR and Imath changing its master branch to "main". #1463
|
||||
(1.12.4.4)
|
||||
- testrender fix sphere tangents, per MaterialX suggestion. #1465
|
||||
(1.12.4.4)
|
||||
- Allow testsuite tests to use oiiotool for image diffs instead of idiff.
|
||||
#1472 (1.12.4.4)
|
||||
- Allow `-Werror` to be disabled even on CI branches. #1471 (1.12.4.4)
|
||||
- CI Tests against the Intel icc and icx compilers! #1459 #1473 (1.12.4.4)
|
||||
#1501 (1.12.5.0)
|
||||
- Overhaul of GHA ci.yml to use strategy matrix. #1474 (1.12.4.4)
|
||||
- Test against clang 14 and fix new warnings. #1498 (1.12.5.0)
|
||||
- Test against clang 15 and fix new warnings. #1586 (1.12.6.2)
|
||||
- A scorecards workflow guards against a variety of security issues of
|
||||
the CI system itself. #1529 (1.12.6.0)
|
||||
- Enable SonarCloud static analysis. #1551 #1556 #1563 (1.12.6.0)
|
||||
* Platform support:
|
||||
- Various Windows compile fixes. #1263 #1285 (1.12.0.1)
|
||||
- Windows+Cuda build fixes. #1292 (1.12.0.1)
|
||||
- Fix warnings about pointer casts on Windows. #1484 (1.12.4.5)
|
||||
- Various Windows build fixes. #1502 (1.12.5.0)
|
||||
* The oso and osl lexers/parsers are now given internal symbol names that
|
||||
are fully versioned, to avoid possible clash if multiple OSL releases are
|
||||
both linked into the same application. #1255 (1.12.0.0)
|
||||
@@ -154,9 +381,52 @@ Documentation:
|
||||
(1.11.11/1.12.1)
|
||||
* First steps in new documentation and scripts for building OSL on Windows.
|
||||
#1326 (1.12.1)
|
||||
* Fix missing explanation of the optional "errormessage" parameter to
|
||||
environment() and texture3d(). #1442 (1.12.3/1.11.17)
|
||||
* A SECURITY.md file explains how to confidentially report vulnerabilities.
|
||||
#1529 (1.12.6)
|
||||
* Document all the new MaterialX closures. #1564
|
||||
|
||||
|
||||
|
||||
Release 1.11.17.0 -- 7 Jan 2022 (compared to 1.11.16.0)
|
||||
-------------------------------------------------------
|
||||
* Fix in runtime optimizer where tracking of messages and unknown messages
|
||||
relied on uninitialized variables. #1447
|
||||
* Minor changes related to OpenColorIO changing their master branch name to
|
||||
"main". #1431
|
||||
* Testing: Get texture3d tests operational again. #1437
|
||||
* Docs: Fix missing "errormessage" explanation for environment() and
|
||||
texture3d(). #1442
|
||||
* Build/cmake fixes: Make PROJECT_VERSION_RELEASE_TYPE and
|
||||
OSL_SUPPORTED_RELEASE be cache strings, so they can be overridden; change
|
||||
OSL_IS_SUBPROJECT to PROJECT_IS_TOP_LEVEL (and change its sense) to match
|
||||
CMake 21+ behavior; add a TIME_COMMANDS option to help debug performance of
|
||||
the build. #1443
|
||||
|
||||
Release 1.11.16.0 -- 1 Nov 2021 (compared to 1.11.15.0)
|
||||
-------------------------------------------------------
|
||||
* Fixes to work with LLVM 13, and to compile with clang 13. #1412 #1420
|
||||
|
||||
Release 1.11.15.0 -- 1 Sep 2021 (compared to 1.11.14.2)
|
||||
-------------------------------------------------------
|
||||
* Changes for compatibility with OpenImageIO 2.3. #1393 #1388
|
||||
* Fix potential crashes (or at least undefined behavior) due to missing
|
||||
virtual destructor of internal Symbol type. #1397
|
||||
|
||||
Release 1.11.14.2 -- 1 Jul 2021 (compared to 1.11.14.1)
|
||||
-------------------------------------------------------
|
||||
* Fix warnings that occur when compiling with clang and C++17 mode. #1379
|
||||
* CI/testing: Additional CI tests for clang+c++17 (#1379), gcc11 (#1381),
|
||||
llvm 12 (#1381), speed up CI builds by not building the testing components
|
||||
of OIIO (#1380).
|
||||
|
||||
Release 1.11.14.1 -- 1 Jun 2021 (compared to 1.11.14.0)
|
||||
-------------------------------------------------------
|
||||
* Fix library setup for LLVM installations consisting of static libraries.
|
||||
This fixes a build problem that can crop up on MacOS using
|
||||
Homebrew-installed LLVM 12. #1375
|
||||
|
||||
Release 1.11.14 -- 10 May 2021 (compared to 1.11.13)
|
||||
----------------------------------------------------
|
||||
* oslc/OSLCompiler: Check for errors when when writing oso (for example,
|
||||
@@ -583,7 +853,7 @@ Build & test system improvements:
|
||||
use clang library components for preprocessing. #1089 (1.11.3)
|
||||
* Add an optional build-time `EXTRA_WARNINGS` option (default: OFF) that
|
||||
enables even more picky than usual warnings. Fix many warnings that cropped
|
||||
up during testing, mostly related to unused function paramters. #1106 (1.11.3)
|
||||
up during testing, mostly related to unused function parameters. #1106 (1.11.3)
|
||||
* The testsuite can run in parallel, with a number of threads set by the
|
||||
environment variable `CTEST_PARALLEL_LEVEL`. #1119 (1.11.4)
|
||||
* oslconfig.h is now generated by a cmake configure_file step, from
|
||||
|
||||
+49
-15
@@ -3,28 +3,47 @@
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
cmake_minimum_required (VERSION 3.12)
|
||||
project (OSL VERSION 1.12.2.0
|
||||
|
||||
set (OSL_VERSION "1.13.1.0" CACHE STRING "Version")
|
||||
project (OSL VERSION ${OSL_VERSION}
|
||||
LANGUAGES CXX C
|
||||
HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/OpenShadingLanguage")
|
||||
set (PROJ_NAME ${PROJECT_NAME}) # short name
|
||||
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
|
||||
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
|
||||
set (PROJECT_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
|
||||
set (PROJECT_VERSION_RELEASE_TYPE "dev" CACHE STRING
|
||||
"Build type, for example: dev, beta2, RC1 (empty string for normal release)")
|
||||
set (${PROJECT_NAME}_VERSION_RELEASE_TYPE ${PROJECT_VERSION_RELEASE_TYPE})
|
||||
set (${PROJECT_NAME}_SUPPORTED_RELEASE 0) # Change to 1 for release branch
|
||||
set (${PROJECT_NAME}_DEV_RELEASE 1) # Change to 0 for release branch
|
||||
set (PROJECT_AUTHORS "Contributors to the Open Shading Language project")
|
||||
option (${PROJECT_NAME}_SUPPORTED_RELEASE
|
||||
"Set ON for supported release branch, OFF for master" OFF)
|
||||
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
|
||||
set (${PROJECT_NAME}_DEV_RELEASE OFF)
|
||||
else ()
|
||||
set (${PROJECT_NAME}_DEV_RELEASE ON)
|
||||
endif ()
|
||||
|
||||
# Identify whether this is included as a subproject of something else
|
||||
if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
|
||||
set (${PROJECT_NAME}_IS_SUBPROJECT ON)
|
||||
message (STATUS "${PROJECT_NAME} is configuring as a CMake subproject")
|
||||
# Set PROJECT_IS_TOP_LEVEL to ON if if this is the top level project (not
|
||||
# if this is included as a subproject of something else). Note that this is
|
||||
# handled automatically for CMake >= 3.21.
|
||||
if (CMAKE_VERSION VERSION_LESS 3.21)
|
||||
if ("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
|
||||
set (PROJECT_IS_TOP_LEVEL ON)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set (CMAKE_BUILD_TYPE "Release")
|
||||
endif ()
|
||||
|
||||
# If the user hasn't configured cmake with an explicit
|
||||
# -DCMAKE_INSTALL_PREFIX=..., then set it to safely install into ./dist, to
|
||||
# help prevent the user from accidentally writing over /usr/local or whatever.
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND PROJECT_IS_TOP_LEVEL)
|
||||
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist" CACHE PATH
|
||||
"Installation location" FORCE)
|
||||
endif()
|
||||
|
||||
message (STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
|
||||
message (STATUS "CMake ${CMAKE_VERSION}")
|
||||
message (STATUS "CMake system = ${CMAKE_SYSTEM}")
|
||||
@@ -72,7 +91,6 @@ else ()
|
||||
endif ()
|
||||
option (OSL_BUILD_PLUGINS "Bool OSL plugins, for example OIIO plugin" ON)
|
||||
option (OSL_BUILD_SHADERS "Build shaders" ON)
|
||||
option (OSL_BUILD_MATERIALX "Build MaterialX shaders" OFF)
|
||||
option (USE_OPTIX "Include OptiX support" OFF)
|
||||
set (OPTIX_EXTRA_LIBS CACHE STRING "Extra lib targets needed for OptiX")
|
||||
set (CUDA_EXTRA_LIBS CACHE STRING "Extra lib targets needed for CUDA")
|
||||
@@ -105,6 +123,9 @@ if (USE_OPTIX)
|
||||
add_definitions ("-DOSL_USE_OPTIX=1")
|
||||
endif ()
|
||||
|
||||
# Define OSL_INTERNAL symbol only when building OSL itself, will not be
|
||||
# defined for downstream projects using OSL.
|
||||
add_definitions (-DOSL_INTERNAL=1)
|
||||
|
||||
# Set the default namespace. For symbol hiding reasons, it's important that
|
||||
# the project name is a subset of the namespace name.
|
||||
@@ -142,9 +163,10 @@ include (pythonutils)
|
||||
include (externalpackages)
|
||||
include (flexbison)
|
||||
include (cuda_macros)
|
||||
include (llvm_macros)
|
||||
|
||||
# Include all our testing apparatus and utils, but not if it's a subproject
|
||||
if (${PROJECT_NAME}_BUILD_TESTS AND NOT ${PROJECT_NAME}_IS_SUBPROJECT)
|
||||
if (${PROJECT_NAME}_BUILD_TESTS AND PROJECT_IS_TOP_LEVEL)
|
||||
include (testing)
|
||||
endif ()
|
||||
|
||||
@@ -159,6 +181,21 @@ include_directories (
|
||||
)
|
||||
|
||||
|
||||
# Make sure our math calculations are consistent,
|
||||
# especially division. Different compilers may have choose to use
|
||||
# reciprocal division losing precision causing slightly different
|
||||
# results which can lead to aliasing differences when running the testsuite
|
||||
# Disable reciprocal division
|
||||
if (CMAKE_COMPILER_IS_INTEL)
|
||||
if (MSVC)
|
||||
add_compile_options("/Qprec-div")
|
||||
else ()
|
||||
add_compile_options("-prec-div")
|
||||
endif ()
|
||||
elseif (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG OR CMAKE_COMPILER_IS_INTELCLANG)
|
||||
add_compile_options("-fno-reciprocal-math")
|
||||
endif ()
|
||||
|
||||
# Tell CMake to process the sub-directories
|
||||
add_subdirectory (src/include)
|
||||
add_subdirectory (src/liboslcomp)
|
||||
@@ -183,9 +220,6 @@ endif ()
|
||||
|
||||
if (OSL_BUILD_SHADERS)
|
||||
add_subdirectory (src/shaders)
|
||||
if (OSL_BUILD_MATERIALX)
|
||||
add_subdirectory (src/shaders/MaterialX)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
option (INSTALL_DOCS "Install documentation" ON)
|
||||
@@ -252,10 +286,10 @@ install (EXPORT OSL_EXPORTED_TARGETS
|
||||
FILE ${OSL_TARGETS_EXPORT_NAME}
|
||||
NAMESPACE ${PROJECT_NAME}::)
|
||||
|
||||
if (${PROJECT_NAME}_BUILD_TESTS AND NOT ${PROJECT_NAME}_IS_SUBPROJECT)
|
||||
if (${PROJECT_NAME}_BUILD_TESTS AND PROJECT_IS_TOP_LEVEL)
|
||||
osl_add_all_tests()
|
||||
endif ()
|
||||
|
||||
if (NOT ${PROJECT_NAME}_IS_SUBPROJECT)
|
||||
if (PROJECT_IS_TOP_LEVEL)
|
||||
include (packaging)
|
||||
endif ()
|
||||
|
||||
+13
-9
@@ -173,9 +173,16 @@ it really only applies to the particular file in which it appears.
|
||||
|
||||
#### Formatting
|
||||
|
||||
NEVER alter somebody else's code to reformat just because you found
|
||||
something that violates the rules. Let the group/author/leader know, and
|
||||
resist the temptation to change it yourself.
|
||||
We use clang-format to enforce formatting rules for the vast majority of the
|
||||
code base. It is automatically run during CI and is a CI failure if the code
|
||||
does not conform. There are, however, parts of the code base that are not
|
||||
clang-formatted, either because we have not yet put them under the
|
||||
clang-format regime, or because individual modules were deemed to be less
|
||||
clear with clang-format than with hand formatting.
|
||||
|
||||
For non-clang-format regions of code, NEVER alter somebody else's code to
|
||||
reformat just because you found something that violates the rules. Let the
|
||||
group/author/leader know, and resist the temptation to change it yourself.
|
||||
|
||||
Each line of text in your code should be at most 80 characters long.
|
||||
Exceptions are allowed for those rare cases where letting a line be longer
|
||||
@@ -217,13 +224,10 @@ Function calls should have a space between the function name and the opening
|
||||
parenthesis, NO space inside the parenthesis, except for a single blank
|
||||
space between each argument. For example:
|
||||
|
||||
x = foo (a, b); // Yes, this is always ok
|
||||
x = foo(a, b); // Yes
|
||||
|
||||
x = foo ( a, b ); // No
|
||||
x = foo (a,b); // No
|
||||
x = foo(a, b); // No
|
||||
x = foo(a); // Occasionally, this just looks better, when the function name is short,
|
||||
// and there's just one very short argument. What can I say, I do it too.
|
||||
|
||||
Function declarations: function names should begin at column 0 for a full
|
||||
function definition. (It's ok to violate this rule for very short inline
|
||||
@@ -233,7 +237,7 @@ functions within class definitions.)
|
||||
Here is a short code fragment that shows some of these rules in action:
|
||||
|
||||
static int
|
||||
function (int a, int b)
|
||||
function(int a, int b)
|
||||
{
|
||||
int x = a + b;
|
||||
if (a == 0 || b == 0) {
|
||||
@@ -244,7 +248,7 @@ Here is a short code fragment that shows some of these rules in action:
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
x += a * i;
|
||||
x *= foo (i); // function call
|
||||
x *= foo(i); // function call
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
+2
-1
@@ -134,11 +134,12 @@ Current voting members of the TSC are:
|
||||
* Eric Enderton - NVIDIA
|
||||
* Stephen Friedman - Pixar
|
||||
* Nicolas Guiard - Isotropix
|
||||
* Derek Haase - DNEG
|
||||
* Clint Hanson - DNEG
|
||||
* Adrien Herubel - Autodesk
|
||||
* Lee Kerley - Sony Pictures Imageworks
|
||||
* Mitch Prater - Laika
|
||||
* Brecht Van Lommel - Blender
|
||||
* Alex Wells - Intel
|
||||
|
||||
### TSC Nomination and Succession
|
||||
|
||||
|
||||
+31
-30
@@ -12,15 +12,16 @@ Dependencies
|
||||
OSL requires the following dependencies or tools.
|
||||
NEW or CHANGED dependencies since the last major release are **bold**.
|
||||
|
||||
* Build system: [CMake](https://cmake.org/) 3.12 or newer (tested through 3.20)
|
||||
* Build system: [CMake](https://cmake.org/) 3.12 or newer (tested through 3.24)
|
||||
|
||||
* A suitable **C++14 or C++17** compiler to build OSL itself, which may be any of:
|
||||
- **GCC 6.1 or newer** (tested through gcc 11)
|
||||
- Clang 3.4 or newer (tested through clang 12)
|
||||
- Microsoft Visual Studio **2017 or newer**
|
||||
- Intel C++ compiler icc **version 17 or newer**
|
||||
* A suitable C++14 or C++17 compiler to build OSL itself, which may be any of:
|
||||
- GCC 6.1 or newer (tested through gcc 12.1)
|
||||
- Clang 3.4 or newer (tested through clang 15)
|
||||
- Microsoft Visual Studio 2017 or newer
|
||||
- Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler
|
||||
version 2022 or newer.
|
||||
|
||||
* **[OpenImageIO](http://openimageio.org) 2.1 or newer** (tested through 2.2)
|
||||
* **[OpenImageIO](http://openimageio.org) 2.3 or newer** (tested through 2.4)
|
||||
|
||||
OSL uses OIIO both for its texture mapping functionality as well as
|
||||
numerous utility classes. If you are integrating OSL into an existing
|
||||
@@ -39,11 +40,16 @@ NEW or CHANGED dependencies since the last major release are **bold**.
|
||||
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
|
||||
DYLD_LIBRARY_PATH on OS X).
|
||||
|
||||
* **[LLVM](http://www.llvm.org) 7, 8, 9, 10, 11, or 12**, including clang
|
||||
libraries.
|
||||
* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, or 15, including
|
||||
clang libraries.
|
||||
|
||||
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.75)
|
||||
* [Ilmbase or Imath](http://openexr.com/downloads.html) 2.0 or newer (tested through 3.0)
|
||||
* (optional) For GPU rendering on NVIDIA GPUs:
|
||||
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.
|
||||
* [Cuda](https://developer.nvidia.com/cuda-downloads) 8.0 or higher.
|
||||
|
||||
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.80)
|
||||
* [Ilmbase or Imath](https://github.com/AcademySoftwareFoundation/openexr) 2.3
|
||||
or newer (recommended: 2.4 or higher; tested through 3.1)
|
||||
* [Flex](https://github.com/westes/flex) 2.5.35 or newer and
|
||||
[GNU Bison](https://www.gnu.org/software/bison/) 2.7 or newer.
|
||||
Note that on some MacOS/xcode releases, the system-installed Bison is too
|
||||
@@ -54,10 +60,10 @@ NEW or CHANGED dependencies since the last major release are **bold**.
|
||||
If it is not found at build time, the OSL `pointcloud` functions will not
|
||||
be operative.
|
||||
* (optional) Python: If you are building the Python bindings or running the
|
||||
testsuite:
|
||||
* Python >= 2.7 (tested against 2.7, 3.6, 3.7, 3.8, 3.9)
|
||||
* pybind11 >= 2.4.2 (Tested through 2.6)
|
||||
* NumPy
|
||||
testsuite:
|
||||
* Python >= 2.7 (tested against 2.7, 3.7, 3.8, 3.9, 3.10)
|
||||
* pybind11 >= 2.4.2 (Tested through 2.10)
|
||||
* NumPy
|
||||
* (optional) Qt >= 5.6 (tested through 5.15). If not found at build time,
|
||||
the `osltoy` application will be disabled.
|
||||
|
||||
@@ -68,13 +74,13 @@ Build process
|
||||
|
||||
Here are the steps to check out, build, and test the OSL distribution:
|
||||
|
||||
0. Install and build dependencies.
|
||||
1. Install and build dependencies.
|
||||
|
||||
1. Check out a copy of the source code from the Git repository:
|
||||
2. Check out a copy of the source code from the Git repository:
|
||||
|
||||
git clone https://github.com/AcademySoftwareFoundation/OpenShadingLanguage.git osl
|
||||
|
||||
2. Change to the distribution directory and 'make'
|
||||
3. Change to the distribution directory and 'make'
|
||||
|
||||
cd osl
|
||||
make
|
||||
@@ -90,22 +96,17 @@ Here are the steps to check out, build, and test the OSL distribution:
|
||||
"make STOP_ON_WARNING=0", that create a build that will only stop for
|
||||
full errors, not warnings.
|
||||
|
||||
3. After compilation, you'll end up with a full OSL distribution in
|
||||
dist/ARCH, where ARCH is the architecture you are building on, one of
|
||||
"linux", "linux64", "macosx", "windows", or "windows64".
|
||||
4. After compilation, you'll end up with a full OSL distribution in
|
||||
dist/
|
||||
|
||||
Note: The default is to make an optimized "release" build. If
|
||||
instead type 'make debug' at the top level, you will end up with
|
||||
a debug build (no optimization, full symbols) in "dist/ARCH.debug".
|
||||
|
||||
4. Add the "dist/ARCH/bin" to your $PATH, and "dist/ARCH/lib" to your
|
||||
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on OS X), or copy the contents
|
||||
5. Add the "dist/bin" to your $PATH, and "dist/lib" to your
|
||||
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on MacOS), or copy the contents
|
||||
of those files to appropriate directories. Public include files
|
||||
(those needed when building applications that incorporate OSL)
|
||||
can be found in "dist/ARCH/include", and documentation can be found
|
||||
in "dist/ARCH/share/doc".
|
||||
can be found in "dist/include", and documentation can be found
|
||||
in "dist/share/doc".
|
||||
|
||||
5. After building (and setting your library path), you can run the
|
||||
6. After building (and setting your library path), you can run the
|
||||
test suite with:
|
||||
|
||||
make test
|
||||
|
||||
@@ -22,15 +22,6 @@ working_dir := ${shell pwd}
|
||||
# Figure out which architecture we're on
|
||||
include ${working_dir}/src/make/detectplatform.mk
|
||||
|
||||
# Presence of make variables DEBUG and PROFILE cause us to make special
|
||||
# builds, which we put in their own areas.
|
||||
ifdef DEBUG
|
||||
variant +=.debug
|
||||
endif
|
||||
ifdef PROFILE
|
||||
variant +=.profile
|
||||
endif
|
||||
|
||||
MY_MAKE_FLAGS ?=
|
||||
MY_NINJA_FLAGS ?=
|
||||
MY_CMAKE_FLAGS ?=
|
||||
@@ -47,10 +38,8 @@ endif
|
||||
|
||||
# Set up variables holding the names of platform-dependent directories --
|
||||
# set these after evaluating site-specific instructions
|
||||
top_build_dir ?= build
|
||||
build_dir ?= ${top_build_dir}/${platform}${variant}
|
||||
top_dist_dir ?= dist
|
||||
dist_dir ?= ${top_dist_dir}/${platform}${variant}
|
||||
build_dir ?= build
|
||||
dist_dir ?= dist
|
||||
|
||||
INSTALL_PREFIX ?= ${working_dir}/${dist_dir}
|
||||
|
||||
@@ -124,10 +113,6 @@ ifneq (${OSL_BUILD_SHADERS},)
|
||||
MY_CMAKE_FLAGS += -DOSL_BUILD_SHADERS:BOOL=${OSL_BUILD_SHADERS}
|
||||
endif
|
||||
|
||||
ifneq (${OSL_BUILD_MATERIALX},)
|
||||
MY_CMAKE_FLAGS += -DOSL_BUILD_MATERIALX:BOOL=${OSL_BUILD_MATERIALX}
|
||||
endif
|
||||
|
||||
ifdef DEBUG
|
||||
CMAKE_BUILD_TYPE=Debug
|
||||
endif
|
||||
@@ -171,6 +156,10 @@ ifneq (${USE_BATCHED},)
|
||||
MY_CMAKE_FLAGS += -DUSE_BATCHED:STRING="${USE_BATCHED}"
|
||||
endif
|
||||
|
||||
ifneq (${VEC_REPORT},)
|
||||
MY_CMAKE_FLAGS += -DVEC_REPORT:BOOL="${VEC_REPORT}"
|
||||
endif
|
||||
|
||||
ifneq (${TEST},)
|
||||
TEST_FLAGS += -R ${TEST}
|
||||
endif
|
||||
@@ -251,7 +240,7 @@ endif
|
||||
#########################################################################
|
||||
# Top-level documented targets
|
||||
|
||||
all: dist
|
||||
all: install
|
||||
|
||||
# 'make debug' is implemented via recursive make setting DEBUG
|
||||
debug:
|
||||
@@ -271,7 +260,7 @@ config:
|
||||
cd ${build_dir} ; \
|
||||
${CMAKE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
|
||||
${MY_CMAKE_FLAGS} ../.. ; \
|
||||
${MY_CMAKE_FLAGS} ${working_dir} ; \
|
||||
fi)
|
||||
|
||||
|
||||
@@ -309,7 +298,7 @@ clang-format: config
|
||||
)
|
||||
|
||||
|
||||
# 'make dist' is just a synonym for 'make install'
|
||||
# DEPRECATED: 'make dist' is just a synonym for 'make install'
|
||||
dist : install
|
||||
|
||||
TEST_FLAGS += --force-new-ctest-process --output-on-failure
|
||||
@@ -341,10 +330,10 @@ clean:
|
||||
realclean: clean
|
||||
${CMAKE} -E remove_directory ${dist_dir}
|
||||
|
||||
# 'make nuke' blows away the build and dist areas for all platforms
|
||||
# DEPRECATED: use 'make realclean'
|
||||
nuke:
|
||||
${CMAKE} -E remove_directory ${top_build_dir}
|
||||
${CMAKE} -E remove_directory ${top_dist_dir}
|
||||
${CMAKE} -E remove_directory ${build_dir}
|
||||
${CMAKE} -E remove_directory ${dist_dir}
|
||||
|
||||
#########################################################################
|
||||
|
||||
@@ -361,7 +350,6 @@ help:
|
||||
@echo " make profile Build and install for profiling"
|
||||
@echo " make clean Remove the temporary files in ${build_dir}"
|
||||
@echo " make realclean Remove both ${build_dir} AND ${dist_dir}"
|
||||
@echo " make nuke Remove ALL of build and dist (not just ${platform})"
|
||||
@echo " make test Run tests"
|
||||
@echo " make testall Run all tests, even broken ones"
|
||||
@echo " make clang-format Run clang-format on all the source files"
|
||||
@@ -372,7 +360,7 @@ help:
|
||||
@echo " STOP_ON_WARNING=0 Do not stop building if compiler warns"
|
||||
@echo " OSL_SITE=xx Use custom site build mods"
|
||||
@echo " MYCC=xx MYCXX=yy Use custom compilers"
|
||||
@echo " CMAKE_CXX_STANDARD=14 Compile in C++14 mode (default is C++11)"
|
||||
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)"
|
||||
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
|
||||
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
|
||||
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"
|
||||
@@ -395,7 +383,7 @@ help:
|
||||
@echo " BOOST_ROOT=path Custom Boost installation"
|
||||
@echo " USE_QT=0 Skip anything that needs Qt"
|
||||
@echo " LLVM-related options:"
|
||||
@echo " LLVM_VERSION=7.0 Specify which LLVM version to use"
|
||||
@echo " LLVM_VERSION=12.0 Specify which LLVM version to use"
|
||||
@echo " LLVM_DIRECTORY=xx Specify where LLVM lives"
|
||||
@echo " LLVM_NAMESPACE=xx Specify custom LLVM namespace"
|
||||
@echo " LLVM_STATIC=1 Use static LLVM libraries"
|
||||
@@ -406,7 +394,6 @@ help:
|
||||
@echo " USE_FAST_MATH=1 Use faster, but less accurate math (set to 0 for libm defaults)"
|
||||
@echo " OSL_BUILD_TESTS=0 Don't build unit tests, testshade, testrender"
|
||||
@echo " OSL_BUILD_SHADERS=0 Don't build any shaders"
|
||||
@echo " OSL_BUILD_MATERIALX=1 Build MaterialX shaders"
|
||||
@echo " USE_SIMD=arch Build with SIMD support (comma-separated choices:"
|
||||
@echo " 0, sse2, sse3, ssse3, sse4.1, sse4.2, f16c,"
|
||||
@echo " avx, avx2, avx512f)"
|
||||
@@ -415,6 +402,7 @@ help:
|
||||
@echo " 0, b8_AVX, b8_AVX2, b8_AVX2_noFMA,"
|
||||
@echo " b8_AVX512, b8_AVX512_noFMA,"
|
||||
@echo " b16_AVX512, b16_AVX512_noFMA)"
|
||||
@echo " VEC_REPORT=0 Generate compiler vectorization reports"
|
||||
@echo " make test, extra options:"
|
||||
@echo " TEST=regex Run only tests matching the regex"
|
||||
@echo ""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div align="center">
|
||||
<img src="https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/src/doc/Figures/osl-short.png" width=256 height=128>
|
||||
<img src="https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/doc/Figures/osl-short.png" width=256 height=128>
|
||||
|
||||
<H1>Open Shading Language</H1>
|
||||
</div>
|
||||
@@ -226,6 +226,7 @@ adding OSL support):
|
||||
* [Chaos Group: V-Ray](https://www.chaosgroup.com/)
|
||||
* [Pixar: PhotoRealistic RenderMan RIS](https://renderman.pixar.com)
|
||||
* [Isotropix: Clarisse](http://www.isotropix.com/clarisse)
|
||||
* [Isotropix: Angie](http://www.isotropix.com/angie)
|
||||
* [Autodesk Beast](http://www.autodesk.com/products/beast/overview)
|
||||
* [Appleseed](http://appleseedhq.net)
|
||||
* [Animal Logic: Glimpse renderer](https://www.fxguide.com/featured/a-glimpse-at-animal-logic/)
|
||||
@@ -234,6 +235,7 @@ adding OSL support):
|
||||
* Ubisoft motion picture group's proprietary renderer
|
||||
* [Autodesk/SolidAngle: Arnold](https://www.solidangle.com/arnold/)
|
||||
* [Autodesk: 3DS Max 2019](https://help.autodesk.com/view/3DSMAX/2019/ENU/?guid=__developer_3ds_max_sdk_features_rendering_osl_html)
|
||||
* [Maxon: Redshift](https://www.maxon.net/en/redshift)
|
||||
|
||||
Films using OSL (grouped by year of release date):
|
||||
* **(2012)**
|
||||
@@ -369,7 +371,7 @@ Films using OSL (grouped by year of release date):
|
||||
Wonder Woman 1984,
|
||||
Soul,
|
||||
The Mandalorian (S2)
|
||||
* **(2021 / upcoming)**
|
||||
* **(2021)**
|
||||
Chaos Walking,
|
||||
Peter Rabbit 2: The Runaway,
|
||||
The Falcon and the Winder Soldier,
|
||||
@@ -379,6 +381,30 @@ Films using OSL (grouped by year of release date):
|
||||
Jupiter's Legacy,
|
||||
Luca,
|
||||
F9,
|
||||
Vivo,
|
||||
Jungle Cruise,
|
||||
Dune,
|
||||
No Time To Die,
|
||||
Ron's Gone Wrong,
|
||||
Venom: Let There Be Carnage,
|
||||
Last Night in Soho,
|
||||
Ghostbusters: Afterlife,
|
||||
Spider-Man 3: No Way Home,
|
||||
Matrix Resurrections
|
||||
* **(2022 / upcoming)**
|
||||
Hotel Transylvania 4: Transformania,
|
||||
Death on the Nile,
|
||||
Uncharted,
|
||||
Turning Red,
|
||||
The Adam Project,
|
||||
Doctor Strange in the Multiverse of Madness,
|
||||
Love, Death, and Robots: In Vaulted Halls Entombed,
|
||||
Jurassic World: Dominion,
|
||||
Lightyear,
|
||||
Thor: Love and Thunder,
|
||||
The Sea Beast,
|
||||
DC League of Super Pets,
|
||||
Bullet Train,
|
||||
...
|
||||
|
||||
|
||||
@@ -413,9 +439,13 @@ certain is a legit problem in the code, and for which you can give clear
|
||||
instructions for how to reproduce, should be [reported as
|
||||
issues](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues).
|
||||
|
||||
If confidentiality precludes a public question or issue, you may contact the
|
||||
project administrator privately at [lg@imageworks.com](lg@imageworks.com),
|
||||
including for security-related issues.
|
||||
If you think you've found a potential vulnerability in OSL, please
|
||||
confidentially report it by emailing the project administrators at
|
||||
[security@openshadinglanguage.org](security@openshadinglanguage.org).
|
||||
|
||||
If any other issue requires confidentiality that precludes a public question
|
||||
or issue, you may contact the project administrator privately at
|
||||
[lg@larrygritz.com](lg@larrygritz.com).
|
||||
|
||||
|
||||
Contributing
|
||||
@@ -434,12 +464,11 @@ Contacts, Links, and References
|
||||
|
||||
[Read or subscribe to the OSL development mail list](https://lists.aswf.io/g/osl-dev)
|
||||
|
||||
[Most recent PDF of the OSL language specification](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/src/doc/osl-languagespec.pdf
|
||||
[Most recent PDF of the OSL language specification](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/doc/osl-languagespec.pdf
|
||||
)
|
||||
|
||||
[OSL home page at SPI](http://openshadinglanguage.org)
|
||||
[OSL home page](http://openshadinglanguage.org)
|
||||
|
||||
[Sony Pictures Imageworks main open source page](http://opensource.imageworks.com)
|
||||
|
||||
|
||||
|
||||
@@ -452,16 +481,17 @@ The current project leadership is documented in the
|
||||
Many people have contributed features, bug fixes, and other changes to OSL
|
||||
over the years: Steve Agland, Shane Ambler, Martijn Berger, Farchad
|
||||
Bidgolirad, Nicholas Bishop, Solomon Boulos, Stefan Bruens, Stefan Büttner,
|
||||
Matthaus G. Chajdas, Clark Chen, Alejandro Conty, Thomas Dinges, Mads
|
||||
Drøschler, Luke Emrose, Louis Feng, Mark Final, Henri Fousse, Syoyo Fujita,
|
||||
Tim Grant, Larry Gritz, Derek Haase, Sven-Hendrik Haase, John Haddon,
|
||||
Daniel Heckenberg, Thiago Ize, Niklas Harrysson, Matt Johnson, Ronan
|
||||
Keryell, Chris Kulla, Elvic Liang, Max Liani, Adam Martinez, John Mertic,
|
||||
Bastien Montagne, Steena Monteiro, Alexis Oblet, Erich Ocean, Mikko
|
||||
Ohtamaa, Jino Park, Alexei Pawlow, Jay Reynolds, Declan Russell, Patrick
|
||||
Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Sandip Shukla,
|
||||
Cliff Stein, Stephan Steinbach, Esteban Tovagliari, Brecht Van Lommel,
|
||||
Alexander von Knorring, Alex Wells, Roman Zulak.(Listed alphabetically; if
|
||||
Matthaus G. Chajdas, Clark Chen, Alejandro Conty, Dieter De Baets, Thomas
|
||||
Dinges, Mads Drøschler, Luke Emrose, Louis Feng, Mark Final, Henri Fousse,
|
||||
Stephen Friedman, Syoyo Fujita, Tim Grant, Larry Gritz, Nicolas Guiard, Euan
|
||||
Haahr, Derek Haase, Sven-Hendrik Haase, John Haddon, Niklas Harrysson, Daniel
|
||||
Heckenberg, Adrien Herubel, Thiago Ize, Matt Johnson, Ronan Keryell, Chris
|
||||
Kulla, Elvic Liang, Max Liani, Adam Martinez, John Mertic, Bastien Montagne,
|
||||
Steena Monteiro, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park, Alexei
|
||||
Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick Scheibe, Alex
|
||||
Schworer, Jonathan Scruggs, Sergey Sharybin, Sandip Shukla, Cliff Stein,
|
||||
Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, Brecht Van Lommel,
|
||||
Alexander von Knorring, Alex Wells, Roman Zulak. (Listed alphabetically; if
|
||||
we've left anybody out, it is inadvertent, please let us know.)
|
||||
|
||||
We cannot possibly express sufficient gratitude to the managers at Sony
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
This gives guidance about which branches are supported with patches to
|
||||
security vulnerabilities.
|
||||
|
||||
| Version / branch | Supported |
|
||||
| --------- | ---------------------------------------------------- |
|
||||
| main | :white_check_mark: :construction: ALL fixes immediately, but this is a branch under development with a frequently unstable ABI and occasionally unstable API. |
|
||||
| 1.12.x | :white_check_mark: All fixes that can be backported without breaking ABI compatibility. New tagged releases monthly. |
|
||||
| 1.11.x | :warning: Only the most critical fixes, only if they can be easily backported. |
|
||||
| <= 1.10.x | :x: No longer receiving patches of any kind. |
|
||||
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you think you've found a potential vulnerability in OSL, please report it
|
||||
by emailing the project administrators at
|
||||
[security@openshadinglanguage.org](security@openshadinglanguage.org). Only the
|
||||
project administrators have access to these messages. Include detailed steps to
|
||||
reproduce the issue, and any other information that could aid an
|
||||
investigation. Our policy is to respond to vulnerability reports within 14
|
||||
days.
|
||||
|
||||
Our policy is to address critical security vulnerabilities rapidly and post
|
||||
patches as quickly as possible.
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
The OSL Documentation Project is a work in progress.
|
||||
|
||||
The plan is to adopt the OCIO Documentation Project's methodology for maintaining and building documention of various kinds as it becomes the blueprint for the ASWF.
|
||||
The plan is to adopt the OCIO Documentation Project's methodology for maintaining and building documentation of various kinds as it becomes the blueprint for the ASWF.
|
||||
|
||||
There is much work to be done here.
|
||||
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
|
||||
<!-- Copyright Contributors to the Open Shading Language Project. -->
|
||||
|
||||
# Release Procedures for Open Shading Language
|
||||
|
||||
## Version nomenclature and release cadence
|
||||
|
||||
### The meaning of the version parts
|
||||
|
||||
Our release numbers are of the form `MAJOR.MINOR.PATCH.TWEAK`, and we follow
|
||||
an almost-semantic-versioning scheme.
|
||||
|
||||
MAJOR changes are those that break backward-compatibility of the public APIs,
|
||||
requiring existing application code to change their source code where it calls
|
||||
OSL API functions in order to compile and work correctly.
|
||||
|
||||
MINOR changes guarantee API backward-compatibility with prior releases that
|
||||
have the same major number, but can introduce ABI or link incompatibilities.
|
||||
Applications using OSL need to be recompiled to move to a new minor release,
|
||||
but should not need to change their source code. Minor releases are allowed
|
||||
to drop support for sufficiently old compilers and dependencies.
|
||||
|
||||
PATCH changes guarantee both API and ABI/link backward-compatibility with
|
||||
prior releases that have the same minor number. Features and new public API
|
||||
calls may be added (thus deviating from strict semantic versioning), but only
|
||||
if they preserve ABI/link compatibility. This means that standalone functions
|
||||
or static methods may be added, but existing functions will not change their
|
||||
parameters, and no new virtual methods or struct data layouts change for patch
|
||||
releases (for classes in public header files). Application code can be
|
||||
re-linked to a new patch release without needing to be recompiled. We also
|
||||
guarantee that any compilers or dependencies supported for the first release
|
||||
of a minor series will continue to be supported for all patches to that minor
|
||||
series.
|
||||
|
||||
TWEAK changes are restricted to critical bug fixes or build breaks that do
|
||||
not alter public APIs in any way.
|
||||
|
||||
### Cadence of releases
|
||||
|
||||
Major (arbitrarily incompatible) releases happen rarely, usually with multiple
|
||||
years between them.
|
||||
|
||||
Minor (API backward-compatible) releases are scheduled annually, targeted at
|
||||
late summer (SIGGRAPH time) to be in beta, and early autumn for a full
|
||||
release.
|
||||
|
||||
Patch (API and ABI backward-compatible) releases are scheduled monthly,
|
||||
usually aiming for the first day of each month.
|
||||
|
||||
Tweak (fully forward and backward compatible) releases are not regularly
|
||||
scheduled, and only happen sporadically, when a critical fix is needed in
|
||||
between scheduled patch releases.
|
||||
|
||||
### Things are different in "main"
|
||||
|
||||
The "main" branch is where ongoing development occurs without any
|
||||
compatibility guarantees. We don't always know if the next year's release from
|
||||
main will turn out to be major (API breaking) or minor (only ABI breaking).
|
||||
|
||||
Some studios or products need the most up-to-date enhancements, and thus tend
|
||||
to build OSL from the "main" branch rather than using tagged releases. For
|
||||
these users, we try to set version numbers and occasionally tag in main, to
|
||||
send a signal about which points in main seem safe to rely on various
|
||||
compatibility levels. However, the rules are slightly different than we use
|
||||
for releases.
|
||||
|
||||
In the "main" branch:
|
||||
|
||||
- TWEAK changes within "main" only guarantee ABI back-compatibility, but may
|
||||
have additions or non-bug-fix behavior changes (akin to patch releases
|
||||
within a release branch).
|
||||
- PATCH changes within "main" are allowed to break ABI or API (changes that
|
||||
would require minor or major releases, if they were not in "main").
|
||||
- Beware of unmarked breaks in compatibility of commits in main that are
|
||||
in between developer preview tags.
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Branch and tag names
|
||||
|
||||
**Branches** are places where commits containing new development may be added
|
||||
(and thus the branch markers will move over time). Branch names obey the
|
||||
following conventions:
|
||||
|
||||
- `main` is the area for arbitrary changes intended for the next year's major
|
||||
or minor release.
|
||||
- `dev-1.2` are the areas for staging additions to the next month's patch
|
||||
release for the designated minor version series.
|
||||
- `release` is a special branch marker that is always set to the latest tag of
|
||||
the currently supported, stable release family. People can count on
|
||||
"release" always being the latest stable release, whatever that may be at
|
||||
the time.
|
||||
|
||||
**Tags** indicate releases or developer previews, and once a commit is
|
||||
tagged, it is permanent and will never be moved. Tag names obey the following
|
||||
conventions:
|
||||
|
||||
- `v1.2.3.4` is a specific public stable release, corresponding to official
|
||||
major, minor, public, or tweak releases.
|
||||
- `v1.2.3.4-alpha`, `v1.2.3.4-beta`, or `v1.2.3.4-RC1` are pre-releases for an
|
||||
upcoming public stable release, at the alpha, beta, or release candidate
|
||||
stages, respectively.
|
||||
- `v1.2.3.4-dev` is a "developer preview" within "main." It is not an official
|
||||
supported release, and while the numbering may indicate compatibility versus
|
||||
other recent developer previews, they should not be assumed to be compatible
|
||||
with any prior official stable releases.
|
||||
|
||||
*Very* occasionally, other branch or tag names (with custom suffixes or
|
||||
different naming schemes) may be used for special purposes by particular
|
||||
developers or users, but should not be considered reliable or permanent, and
|
||||
in general should be ignored by anyone who didn't make the tag or branch.
|
||||
|
||||
---
|
||||
|
||||
## Release Procedures
|
||||
|
||||
### Soft freeze for monthly tweak releases:
|
||||
|
||||
We freely backport *safe*, non-ABI-breaking changes by cherry-picking them
|
||||
from main to the supported branch continually throughout most of the month.
|
||||
|
||||
In the seven days before the new month, we do a "soft freeze" where only
|
||||
important bug fixes are backported. Hold on to any other patches you wish to
|
||||
backport until after the monthly patch release (i.e., save them for the next
|
||||
month's release so you never have a release that contains changes that are
|
||||
only a few days old, and therefore not as well tested). You may, of course,
|
||||
continue to backport fixes to documentation or other non-code parts of the
|
||||
project during this soft freeze.
|
||||
|
||||
### Branching for annual major/minor releases
|
||||
|
||||
By mid-June (about 1-2 months before the beta of a new annual big release),
|
||||
you should branch and mark it as an alpha.
|
||||
|
||||
At the tip of "main," create a new branch named `dev-MAJOR.MINOR` that will be
|
||||
the staging area for the next release.
|
||||
|
||||
Customarily, at that point we add a commit to main (but not to the new
|
||||
dev-MAJ.MIN branch) that bumps main's version to the next minor level, to
|
||||
avoid any confusion between builds from main versus what will be the next
|
||||
release branch. This starts the divergence between main and the release
|
||||
branch, and henceforth, any big or compatibility-breaking changes will only be
|
||||
committed to main and not backported to the release branch. (Though we are
|
||||
loose about this rule during the alpha period and allow continued breaking
|
||||
changes in the alpha, but by the time we call it beta, we allow no more
|
||||
breaking changes.)
|
||||
|
||||
|
||||
### Prior to a release
|
||||
|
||||
1. Update CI dependencies: Ensure that the "latest" CI test specifies the
|
||||
current releases of the dependencies and compilers (check their home
|
||||
pages), and that the [INSTALL.md](../INSTALL.md) file correctly documents
|
||||
the version ranges that we expect to work and that we actively test.
|
||||
|
||||
2. Release notes: [CHANGES.md](../CHANGES.md) should be updated to reflect
|
||||
all the new features and fixes. Looking at the notes from older releases
|
||||
should provide a good example of what we're aiming for.
|
||||
|
||||
- Patch and tweak releases can be brief one-line descriptions (often the
|
||||
first line of the commit messages involved), presented in a single
|
||||
section in either chronological or any other order that seems right.
|
||||
- Minor or major releases have a much more extensive, prose-based
|
||||
description of all changes since the last minor release, broken into
|
||||
sections (dependency changes, major new features, enhancements and fixes,
|
||||
internals and developer goodies, testing/CI/ports, etc.) and ordered for
|
||||
readability and relevance.
|
||||
|
||||
3. Ensure docs are up to date:
|
||||
|
||||
- Actually read the [README.md](../README.md), [INSTALL.md](../INSTALL.md),
|
||||
and other repository docs and make sure all the information is up to
|
||||
date. Check the "contributor credits" in the README against the recent
|
||||
repo history to be sure new contributors are listed. Also check the
|
||||
list of films and make sure it includes any recent productions that are
|
||||
known to have used OSL.
|
||||
- Skim the primary user documentation to look for any obvious errors,
|
||||
especially the parts that describe new features. In the case of PDF docs
|
||||
(such as osl-languagespec.pdf), make sure that a new PDF book is built if
|
||||
the documentation source has been changed since the last release.
|
||||
- If we are using any online docs (like readthedocs), make sure it is
|
||||
building and looks correct on the web site.
|
||||
|
||||
4. Make sure the the top-level CMakeLists.txt file is updated:
|
||||
|
||||
- The version on the `project()` call should be correct.
|
||||
- The `PROJECT_VERSION_RELEASE_TYPE` variable should be set to "alpha" or
|
||||
"beta" if appropriate, "RC" for release candidate, or empty string `""`
|
||||
for most supported releases, and "dev" only for the main branch or
|
||||
developer previews.
|
||||
- The `${PROJECT_NAME}_SUPPORTED_RELEASE` variable should be `ON` for any
|
||||
release branch, `OFF` for main.
|
||||
|
||||
5. Make sure everything passes the usual CI workflow. Also check the daily or
|
||||
weekly "analysis" workflows to make sure there aren't any important
|
||||
warnings that should be fixed.
|
||||
|
||||
|
||||
### Staging alpha / beta / release candidate (annual minor/major releases only)
|
||||
|
||||
For monthly patch releases, we don't have any formal alpha/beta/RC stages.
|
||||
|
||||
For the annual minor or major releases we have a staged release:
|
||||
|
||||
- `alpha` is everything after we have branched, in which we think all the big
|
||||
new features have been added, and while we will make continued changes and
|
||||
fixes, we are aiming for increased stability and to minimize additional
|
||||
breaking changes prior to the release.
|
||||
- `beta` should be about one month prior to the final release date. We create
|
||||
a tag `v1.2.3.4-beta` and announce the beta (see below "Making the
|
||||
release"). Once we tag a beta, we try very hard not to allow any further
|
||||
changes that change the API or are not ABI-compatible (i.e., safe fixes
|
||||
only).
|
||||
- `RC` or release candidates around one week prior to the final release date.
|
||||
This is a trial run, hopefully identical to the final release (except for
|
||||
removing the RC label and making a new tag). The only changes allowed after
|
||||
RC are fixes to the most critical bugs or build breaks that would be bad for
|
||||
users to encounter. If critical problems are found with RC1, they should be
|
||||
fixed and immediately re-tagged as RC2, etc. All other fixes should be
|
||||
postponed until the next month's patch release.
|
||||
|
||||
### Making the release
|
||||
|
||||
A final release is made on the scheduled date, provided the latest RC has
|
||||
survived for at least a few days of testing without finding any critical
|
||||
problems. Don't make the release final until you are sure there are no
|
||||
truly critical bugs or build breaks that users will encounter.
|
||||
|
||||
The following are the steps for making the release:
|
||||
|
||||
1. Edit the top-level CMakeLists.txt to remove any RC designation
|
||||
(i.e., `PROJECT_VERSION_RELEASE_TYPE` should be set to `""`).
|
||||
|
||||
2. Edit CHANGES.md to reflect the correct date of the release and ensure it
|
||||
includes any last-minute changes that were made during beta or release
|
||||
candidate stages.
|
||||
|
||||
3. Push it to **your** GitHub, make sure it passes CI.
|
||||
|
||||
4. Tag the release: `git tag v1.2.3.4` (no more beta, RC, or dev suffix).
|
||||
|
||||
5. If this will now be the recommended stable release, move the `release`
|
||||
branch marker to the same position.
|
||||
|
||||
6. Push it to GitHub: `git push aswf release --tags`
|
||||
|
||||
(This example assumes "aswf" is the name of the remote for the GitHub
|
||||
`AcademySoftwareFoundation/OpenShadingLanguage` repo.)
|
||||
|
||||
7. Draft a release on GitHub: On
|
||||
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/releases
|
||||
select "Draft a new release." Choose the new tag you just pushed. Make the
|
||||
release title "Open Shading Language v1.2.3.4" (and beta, etc., designation
|
||||
if applicable). In the description, paste the release notes for this
|
||||
release (from Changes.md). If this is a beta or release candidate, check
|
||||
"this is a pre-release" box at the bottom.
|
||||
|
||||
8. Announce the release on the [osl-dev mail list](https://lists.aswf.io/g/osl-dev)
|
||||
with the subject "Release: OSL v1.2.3.4" and using one of these templates
|
||||
for the body of the email.
|
||||
|
||||
For a monthly patch release:
|
||||
|
||||
> We have tagged v1.2.3.4 as the latest production release and moved the
|
||||
> "release" branch marker to that point. This is guaranteed to be API,
|
||||
> ABI, and link back-compatible with prior 1.2 releases. Release notes
|
||||
> are below.
|
||||
>
|
||||
> (Paste the full set of 1.2 changes here, just copy the appropriate
|
||||
> part of CHANGES.md)
|
||||
|
||||
For an annual major/minor release:
|
||||
|
||||
> OSL version 1.2 has been released! Officially tagged as "v1.2.3.4", we
|
||||
> have also moved the "release" branch tag to this position. Henceforth,
|
||||
> 1.2 is the supported production release family. The API is now frozen --
|
||||
> we promise that subsequent 1.2.x releases (which should happen monthly)
|
||||
> will not break back-compatibility of API, ABI, or linkage, compared to
|
||||
> this release. Please note that this release is *not* ABI or link
|
||||
> compatible with 1.1 or older releases.
|
||||
>
|
||||
> Release notes for 1.2 outlining all the changes since last year's
|
||||
> release are below.
|
||||
>
|
||||
> Please note that a few of the build and runtime dependencies have
|
||||
> changed their minimum supported versions. (List here any important
|
||||
> changes to dependencies, compilers, or C++ standard that users should be
|
||||
> aware of.)
|
||||
>
|
||||
> (List here anything else that people should know about this release
|
||||
> family that may be surprising if they haven't followed the last year of
|
||||
> development closely, or that they must know even if they are too lazy to
|
||||
> read the release notes. If this is a major release that is not
|
||||
> backward-compatible with prior versions, warn about that here.)
|
||||
>
|
||||
> Enjoy, and please report any problems. We will continue to make patch
|
||||
> releases to the 1.2 family roughly monthly, which will contain bug fixes
|
||||
> and non-breaking enhancements.
|
||||
>
|
||||
> The older 1.1 series of releases is now considered obsolete. We will
|
||||
> continue for now to make 1.1 patch releases, but over time, these will
|
||||
> become less frequent and be reserved for only the most critical bug
|
||||
> fixes.
|
||||
>
|
||||
> The "main" branch is now progressing toward an eventual 1.3 release next
|
||||
> summer. As usual, you are welcome to use main for real work, but we do
|
||||
> not make any compatibility guarantees and don't guarantee continuing API
|
||||
> compatibility in main.
|
||||
>
|
||||
> (Paste the full set of 1.2 changes here, just copy the appropriate
|
||||
> part of CHANGES.md)
|
||||
|
||||
For a beta leading up to the annual major/minor release:
|
||||
|
||||
> OSL version 1.2 is now in beta, tagged as "v1.2.3.4-beta". We
|
||||
> will try very hard not to make any further API or ABI changes between
|
||||
> now and the final release (unless it is absolutely necessary to fix
|
||||
> an important problem identified during beta testing). The final 1.2
|
||||
> release is scheduled for [DATE GOES HERE], so please try building and
|
||||
> testing the beta so we are sure to find any problems.
|
||||
>
|
||||
> Release notes for 1.2 outlining all the changes since last year's
|
||||
> release are below.
|
||||
>
|
||||
> (Paste the full set of 1.2 changes here, just copy the appropriate
|
||||
> part of CHANGES.md)
|
||||
|
||||
|
||||
### After the release
|
||||
|
||||
Odds and ends to do after the tag is pushed and the announcements are sent:
|
||||
|
||||
- Re-read RELEASING.md and ensure that the instructions match what you
|
||||
have done. Update as necessary.
|
||||
|
||||
- For annual beta releases, post a short message to the "Open Shading
|
||||
Language" channel of the ASWF slack. It can be a one-line announcement and
|
||||
then just a link to the GitHub release page for this version.
|
||||
|
||||
|
||||
+18
-255
@@ -7,94 +7,31 @@ ifneq (${VERBOSE},)
|
||||
$(info Including spi/Makefile-bits)
|
||||
endif
|
||||
|
||||
# For SpComp2 builds, do:
|
||||
#
|
||||
# make OSL_SPCOMP2=1 spcomp2_install
|
||||
# or
|
||||
# make OSL_SPCOMP2=1 SPCOMP2_LOCAL_PATH=/test/path spcomp2_install_local
|
||||
#
|
||||
# For Arnold builds, do:
|
||||
#
|
||||
# make OSL_ARNOLD=1
|
||||
#
|
||||
# For a Rez-bound build, do:
|
||||
#
|
||||
# make OSL_SPIREZ=1
|
||||
#
|
||||
# (Options: OSL_REZ_NAME=blah REZ_PACKAGE_ROOT=path)
|
||||
#
|
||||
# Otherwise a default 'make' will make a fully generic OSL build.
|
||||
|
||||
OSL_SPCOMP2 ?= 0
|
||||
OSL_ARNOLD ?= 0
|
||||
OSL_SPIREZ ?= 0
|
||||
OSL_REZ_NAME ?= OSL
|
||||
OSL_VERS = $(shell grep "OSL VERSION" CMakeLists.txt | egrep -o "[0-9.]+")
|
||||
ONEVERS = $(shell site/spi/format_version.py ${OSL_VERS})
|
||||
OSL_SPCOMP2_VERSION ?= ${ONEVERS}
|
||||
|
||||
ifeq (${OSL_SPCOMP2},1)
|
||||
$(info Building for SpComp2)
|
||||
OSL_ARNOLD := 0
|
||||
NAMESPACE ?= 'OSL_SpComp2'
|
||||
SOVERSION ?= ${OSL_SPCOMP2_VERSION}
|
||||
PYLIB_LIB_PREFIX ?= 1
|
||||
PYLIB_INCLUDE_SONAME ?= 1
|
||||
OPENIMAGEIO_SPCOMP2_VERSION ?= 20103
|
||||
OPENEXR_VERSION ?= 2.2.0
|
||||
else ifeq (${OSL_ARNOLD},1)
|
||||
$(info Building for Arnold)
|
||||
NAMESPACE ?= 'OSL_Arnold'
|
||||
PYLIB_LIB_PREFIX ?= 0
|
||||
PYLIB_INCLUDE_SONAME ?= 0
|
||||
OPENEXR_VERSION ?= 2.4.0
|
||||
else ifeq (${OSL_SPIREZ},1)
|
||||
$(info Building for Rez distribution)
|
||||
NAMESPACE ?= 'OSL'
|
||||
PYLIB_LIB_PREFIX ?= 0
|
||||
PYLIB_INCLUDE_SONAME ?= 0
|
||||
MY_CMAKE_FLAGS += -DOSL_SPIREZ=1 -DOSL_REZ_PACKAGE_NAME=${OSL_REZ_NAME}
|
||||
MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
|
||||
OPENIMAGEIO_VERSION ?= 2.2.0.0
|
||||
OPENEXR_VERSION ?= 2.4.0
|
||||
$(info Building against OpenImageIO ${OPENIMAGEIO_VERSION})
|
||||
else
|
||||
$(info Building generic OSL)
|
||||
NAMESPACE ?= 'OSL'
|
||||
PYLIB_LIB_PREFIX ?= 0
|
||||
PYLIB_INCLUDE_SONAME ?= 0
|
||||
endif
|
||||
$(info Building generic OSL)
|
||||
PYLIB_LIB_PREFIX ?= 0
|
||||
PYLIB_INCLUDE_SONAME ?= 0
|
||||
#$(info MAKECMDGOALS = $(MAKECMDGOALS))
|
||||
|
||||
|
||||
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
|
||||
## Detect which SPI platform and set $platform, $COMPILER,
|
||||
## and PYTHON_VERSION. Lots of other decisions are based on these.
|
||||
ifeq (${SP_OS}, rhel7)
|
||||
# Rhel7 (current)
|
||||
platform := rhel7
|
||||
SPI_COMPILER_PLATFORM ?= gcc-6.3
|
||||
ifeq (${SPI_COMPILER_PLATFORM},gcc-6.3)
|
||||
SPCOMP2_COMPILER ?= gcc63
|
||||
CMAKE_CXX_STANDARD ?= 14
|
||||
endif
|
||||
SP_PLATFORM ?= linux
|
||||
SP_PROC ?= x86_64
|
||||
SP_REZ_OS ?= CentOS-7
|
||||
LLVM_VERSION ?= 12.0.0
|
||||
else ifeq (${platform}, macosx)
|
||||
# Generic OSX machines (including LG's laptop)
|
||||
COMPILER ?= clang
|
||||
SPCOMP2_COMPILER ?= clang
|
||||
SP_OS ?= macosx
|
||||
SP_PLATFORM ?= macosx
|
||||
SP_PROC ?= x86_64
|
||||
SP_REZ_OS ?= MacOS
|
||||
else
|
||||
$(error Unknown SP_OS=${SP_OS} platform=${platform})
|
||||
endif # endif ${SP_OS}
|
||||
|
||||
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS} -DSP_PLATFORM=${SP_PLATFORM}
|
||||
MY_CMAKE_FLAGS += -DSP_PROC=${SP_PROC} -DSP_REZ_OS=${SP_REZ_OS}
|
||||
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS}
|
||||
MY_CMAKE_FLAGS += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
|
||||
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOSL_SPI=1" -DOSL_SITE:STRING=spi
|
||||
MY_CMAKE_FLAGS += -DSPI_TESTS=1
|
||||
@@ -117,13 +54,6 @@ ifeq (${SP_OS}, rhel7)
|
||||
export CCACHE_CPP2 ?= 1
|
||||
# Override lib64 and use SPI convention of lib
|
||||
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_LIBDIR="${INSTALL_PREFIX}/lib"
|
||||
ifeq (${OSL_SPCOMP2},1)
|
||||
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
|
||||
else ifeq (${OSL_SPIREZ},1)
|
||||
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
|
||||
else ifeq (${OSL_ARNOLD},1)
|
||||
OSL_LIBNAME_SUFFIX ?= _Arnold
|
||||
endif
|
||||
|
||||
#
|
||||
# Compilers:
|
||||
@@ -144,7 +74,7 @@ ifeq (${SP_OS}, rhel7)
|
||||
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/11.0.0/${SPI_COMPILER_PLATFORM}
|
||||
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
|
||||
else ifeq (${COMPILER},clang11)
|
||||
else ifeq (${COMPILER},clang12)
|
||||
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/12.0.0-final/${SPI_COMPILER_PLATFORM}
|
||||
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
|
||||
@@ -172,16 +102,9 @@ ifeq (${SP_OS}, rhel7)
|
||||
# Boost
|
||||
#
|
||||
BOOSTVERS ?= 1.70
|
||||
BOOSTSPSUFFIX ?=
|
||||
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
|
||||
MY_CMAKE_FLAGS += -DBOOST_VERS_SP=${BOOSTVERSSP}
|
||||
# $(info BOOSTVERSSP ${BOOSTVERSSP})
|
||||
# Our Boost >= 1.61 setup is MUCH simpler and more standard
|
||||
SPBOOST_INC_DIR := /usr/include/boostroot/boost${BOOSTVERSSP}.0
|
||||
SPBOOST_LIB_DIR := /usr/lib64/boostroot/boost${BOOSTVERSSP}.0
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DBOOST_INCLUDEDIR=${SPBOOST_INC_DIR} \
|
||||
-DBOOST_LIBRARYDIR=${SPBOOST_LIB_DIR}
|
||||
-DBOOST_INCLUDEDIR=/usr/include/boostroot/boost${BOOSTVERS}.0 \
|
||||
-DBOOST_LIBRARYDIR=/usr/lib64/boostroot/boost${BOOSTVERS}.0
|
||||
|
||||
#
|
||||
# Python
|
||||
@@ -212,28 +135,13 @@ ifeq (${SP_OS}, rhel7)
|
||||
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
|
||||
|
||||
Partio_VERSION ?= 1.10.6
|
||||
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
|
||||
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
|
||||
MY_CMAKE_FLAGS += -Dpartio_ROOT="${partio_ROOT}"
|
||||
|
||||
pugixml_VERSION ?= 1.10.0
|
||||
pugixml_ROOT ?= ${REZ_PACKAGE_ROOT}/pugixml/${pugixml_VERSION}/${SPI_COMPILER_PLATFORM}
|
||||
MY_CMAKE_FLAGS += -Dpugixml_ROOT="${pugixml_ROOT}"
|
||||
|
||||
# set up OSL distribution environment
|
||||
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
|
||||
|
||||
ifeq (${OSL_SPIREZ},1)
|
||||
OpenImageIO_ROOT := ${REZ_PACKAGE_ROOT}/OpenImageIO/${OPENIMAGEIO_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
|
||||
$(info OpenImageIO_ROOT ${OpenImageIO_ROOT})
|
||||
|
||||
|
||||
else ifeq (${OSL_SPCOMP2},1)
|
||||
OpenImageIO_ROOT := $(SPCOMP2_ROOT)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)
|
||||
else ifeq (${OSL_ARNOLD},1)
|
||||
OpenImageIO_ROOT ?= ${working_dir}/../OpenImageIO_local/dist/${platform}${variant}/
|
||||
else ifneq (${OpenImageIO_ROOT},)
|
||||
# User supplied something
|
||||
endif
|
||||
ifneq ($(OpenImageIO_ROOT),)
|
||||
MY_CMAKE_FLAGS += -DOpenImageIO_ROOT=${OpenImageIO_ROOT}
|
||||
endif
|
||||
@@ -258,9 +166,9 @@ else ifeq (${platform}, macosx)
|
||||
CMAKE_CXX_STANDARD ?= 14
|
||||
USE_SIMD ?= sse4.2
|
||||
MY_CMAKE_FLAGS += -DCMAKE_BUILD_WITH_INSTALL_RPATH=1
|
||||
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
|
||||
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/lib"
|
||||
|
||||
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
|
||||
BOOSTVERS=${BOOSTVERS}${BOOSTSPSUFFIX}
|
||||
LLVM_DIRECTORY ?= /usr/local/opt/llvm
|
||||
|
||||
# A variety of tags can be used to try specific versions of gcc or
|
||||
@@ -269,22 +177,18 @@ else ifeq (${platform}, macosx)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER}, gcc8)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER}, gcc9)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER},clang11)
|
||||
else ifeq (${COMPILER},clang14)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@11/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@11/bin/clang++
|
||||
else ifeq (${COMPILER},clang12)
|
||||
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
|
||||
else ifeq (${COMPILER},clang15)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@12/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@12/bin/clang++
|
||||
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++
|
||||
else ifeq (${COMPILER},clang)
|
||||
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
||||
else ifeq (${COMPILER},gcc)
|
||||
@@ -304,151 +208,10 @@ else ifeq (${platform}, macosx)
|
||||
# end generic OSX
|
||||
|
||||
else
|
||||
$(error Unknown SP_OS=${SP_OS} platform=${platform})
|
||||
$(error Unknown SP_OS=${SP_OS})
|
||||
endif # endif ${SP_OS}
|
||||
|
||||
|
||||
|
||||
ifeq (${OSL_SPIREZ},1)
|
||||
# Rpath touch-ups
|
||||
# NOTE: This MUST match the order and naming of the Rez variants
|
||||
# set in rez/package.py.in
|
||||
REZ_INSTALL_PATH := ${REZ_PACKAGE_ROOT}/${OSL_REZ_NAME}/${OSL_VERS}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}/cuda-${CUDA_VERSION}/optix-${OPTIX_VERSION}
|
||||
MY_CMAKE_FLAGS += -DOSL_REZ_INSTALL_PATH=${REZ_INSTALL_PATH}
|
||||
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_RPATH="${REZ_INSTALL_PATH}/lib;@executable_path/../lib;${OpenImageIO_ROOT}/lib"
|
||||
INSTALL_PREFIX := ${working_dir}/dist/${platform}
|
||||
endif
|
||||
|
||||
|
||||
ifneq (${VERBOSE},)
|
||||
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
|
||||
endif
|
||||
|
||||
|
||||
|
||||
############################################################################
|
||||
# SpComp2 magic incantations follow. Here be dragons.
|
||||
############################################################################
|
||||
|
||||
|
||||
CPPSTDSUFFIX=
|
||||
SPCOMP2_INSTALL_ROOT ?= $(SPCOMP2_ROOT)
|
||||
BOOSTVERSSP?=${BOOSTVERS}${BOOSTSPSUFFIX}
|
||||
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
|
||||
OIIO_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OpenImageIO/${SPARCH}/v${OPENIMAGEIO_SPCOMP2_VERSION}
|
||||
# $(info New rhel7 OIIO_SPCOMP2_PATH is ${OIIO_SPCOMP2_PATH})
|
||||
|
||||
PYVERNOSPACE=${shell echo ${PYTHON_VERSION} | sed "s/\\.//"}
|
||||
SPPYARCH=$(SPARCH)-py$(PYVERNOSPACE)
|
||||
|
||||
|
||||
|
||||
all: dist
|
||||
|
||||
local: dist
|
||||
|
||||
.PHONY: spcomp2_install spcomp2_install_local clean all
|
||||
|
||||
spi: MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
|
||||
spi: debug dist
|
||||
|
||||
|
||||
|
||||
spcomp2_install_local: SPCOMP2_INSTALL_ROOT = $(SPCOMP2_LOCAL_PATH)
|
||||
spcomp2_install_local: spcomp2_install
|
||||
|
||||
comma:= ,
|
||||
empty:=
|
||||
space:= $(empty) $(empty)
|
||||
|
||||
#OSL_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OSL/${SP_OS}-${SPCOMP2_COMPILER}$(CPPSTDSUFFIX)-boost${SPCOMP2_BOOSTVERS_SUFFIX}/v${OSL_SPCOMP2_VERSION}
|
||||
#$(info New rhel7 OSL_SPCOMP2_PATH is ${OSL_SPCOMP2_PATH})
|
||||
|
||||
#INSTALL_SPCOMP2_CURRENT = $(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)
|
||||
#INSTALL_BIN_LOCATION = $(INSTALL_SPCOMP2_CURRENT)/bin
|
||||
|
||||
SPCOMP2_RPATH_OPT ?= ${OpenImageIO_ROOT}/lib:${partio_ROOT}/lib
|
||||
SPCOMP2_RPATH_DEBUG ?= ${OpenImageIO_ROOT}/lib:${partio_ROOT}/lib/debug
|
||||
#PYSPCOMP2_RPATH_OPT ?= ${SPCOMP2_RPATH_OPT}:${OSL_SPCOMP2_PATH}/lib:${PYTHON_LIBRARY_DIR}
|
||||
#PYSPCOMP2_RPATH_DEBUG ?= ${SPCOMP2_RPATH_DEBUG}:${OSL_SPCOMP2_PATH}/lib/debug:${PYTHON_LIBRARY_DIR}
|
||||
|
||||
|
||||
|
||||
spcomp2: MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
|
||||
-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)/lib \
|
||||
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
|
||||
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
|
||||
-DPYLIB_LIB_PREFIX:BOOL=ON \
|
||||
-DPYMODULE_SUFFIX="V${OSL_SPCOMP2_VERSION}"
|
||||
|
||||
spcomp2: dist
|
||||
|
||||
spcomp2_debug: MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
|
||||
-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)/lib \
|
||||
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
|
||||
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
|
||||
-DPYLIB_LIB_PREFIX:BOOL=ON \
|
||||
-DPYMODULE_SUFFIX="V${OSL_SPCOMP2_VERSION}"
|
||||
|
||||
spcomp2_debug: debug
|
||||
|
||||
spcomp2_install_fixup_rhel7: spcomp2 spcomp2_debug
|
||||
echo $(SPCOMP2_INSTALL_ROOT)
|
||||
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslexec${OSL_LIBNAME_SUFFIX}.so
|
||||
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslexec.so
|
||||
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslcomp${OSL_LIBNAME_SUFFIX}.so
|
||||
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslcomp.so
|
||||
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslquery${OSL_LIBNAME_SUFFIX}.so
|
||||
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslquery.so
|
||||
# patchelf --set-rpath ${PYSPCOMP2_RPATH_OPT} ${dist_dir}/python/libPyOSL.so
|
||||
# patchelf --set-rpath ${PYSPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/python/libPyOSL.so
|
||||
|
||||
# This goal can't start with 'install' because something elsewhere picks
|
||||
# it up and starts doing bad things
|
||||
spcomp2_install: spcomp2_install_fixup_${SP_OS}
|
||||
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
|
||||
--project=oslexec \
|
||||
--version=$(OSL_SPCOMP2_VERSION) \
|
||||
--root=$(SPCOMP2_INSTALL_ROOT) \
|
||||
--arch=$(SPARCH) \
|
||||
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
|
||||
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
|
||||
--namespace=${NAMESPACE} \
|
||||
--srcdir=${dist_dir}/lib \
|
||||
--builddir_o=${dist_dir}/lib \
|
||||
--builddir_d=${dist_dir}.debug/lib
|
||||
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
|
||||
--project=oslquery \
|
||||
--version=$(OSL_SPCOMP2_VERSION) \
|
||||
--root=$(SPCOMP2_INSTALL_ROOT) \
|
||||
--arch=$(SPARCH) \
|
||||
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
|
||||
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
|
||||
--namespace=${NAMESPACE} \
|
||||
--srcdir=${dist_dir}/lib \
|
||||
--builddir_o=${dist_dir}/lib \
|
||||
--builddir_d=${dist_dir}.debug/lib
|
||||
#perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
|
||||
# --project=oslcomp \
|
||||
# --version=$(OSL_SPCOMP2_VERSION) \
|
||||
# --root=$(SPCOMP2_INSTALL_ROOT) \
|
||||
# --arch=$(SPARCH) \
|
||||
# --headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
|
||||
# --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
|
||||
# --namespace=${NAMESPACE} \
|
||||
# --srcdir=${dist_dir}/lib \
|
||||
# --builddir_o=${dist_dir}/lib \
|
||||
# --builddir_d=${dist_dir}.debug/lib
|
||||
#perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
|
||||
# --project=PyOSL \
|
||||
# --version=$(OSL_SPCOMP2_VERSION) \
|
||||
# --root=$(SPCOMP2_INSTALL_ROOT) \
|
||||
# --arch=$(SPPYARCH) \
|
||||
# --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread"\
|
||||
# --namespace=${NAMESPACE} \
|
||||
# --srcdir=${dist_dir}/python \
|
||||
# --builddir_o=${dist_dir}/python \
|
||||
# --builddir_d=${dist_dir}.debug/python
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
|
||||
<!-- Copyright Contributors to the Open Shading Language Project. -->
|
||||
|
||||
Build a variant for Rez/general use
|
||||
-----------------------------------
|
||||
|
||||
Skip this section if you are instead building for SpComp2.
|
||||
|
||||
Note: For testing or to make your own local rez package, you can customize
|
||||
either the rez package name, or the rez install location name, with make
|
||||
flags `OSL_REZ_NAME=blah REZ_PACKAGE_ROOT=/path/to/my/rez/pkgs` appended
|
||||
to the `make` commands of any of the variants listed below. For example,
|
||||
|
||||
make OSL_SPIREZ=1 OSL_REZ_NAME=oiio_test REZ_PACKAGE_ROOT=/path/to/my/rez/pkgs
|
||||
|
||||
|
||||
Variants:
|
||||
|
||||
# C++11/gcc4.8 compat, Python 2.7, Boost 1.55, OptiX 6, Cuda 10.1
|
||||
# OIIO 2.2.0.0, OpenEXR 2.2
|
||||
make nuke
|
||||
make spi OSL_SPIREZ=1 BOOSTVERS=1.55 USE_OPTIX=1 CUDA_VERSION=10.1 OPTIX_VERSION=6.0.0 OPENIMAGEIO_VERSION=2.2.0.0 OPENEXR_VERSION=2.2.0 PYTHON_VERSION=2.7
|
||||
|
||||
# C++11/gcc6.3 compat, Python 2.7, Boost 1.70, OptiX 6, Cuda 10.1
|
||||
# OIIO 2.2.0.0, OpenEXR 2.4
|
||||
make nuke
|
||||
make spi OSL_SPIREZ=1 SPI_COMPILER_PLATFORM=gcc-6.3 BOOSTVERS=1.70 USE_OPTIX=1 CUDA_VERSION=10.1 OPTIX_VERSION=6.0.0 OPENIMAGEIO_VERSION=2.2.0.0 OPENEXR_VERSION=2.4.0 PYTHON_VERSION=2.7
|
||||
|
||||
|
||||
|
||||
You can do any of these on your local machine.
|
||||
|
||||
|
||||
Rez/general release (do for each variant)
|
||||
-----------------------------------------
|
||||
|
||||
This must be done from compile42 (for correct write permissions on certain
|
||||
shared directories), even if you did the build itself locally.
|
||||
|
||||
For any of the variants that you built above:
|
||||
|
||||
( cd dist/rhel7 ; rez release --skip-repo-errors )
|
||||
|
||||
That command will release the dist to the studio.
|
||||
|
||||
|
||||
Appwrapper binary releases
|
||||
--------------------------
|
||||
|
||||
We don't currently do this.
|
||||
|
||||
<!---
|
||||
This step is for the ONE general/rez variant that we believe is the
|
||||
canonical source of command line oslc and oslinfo. After building and
|
||||
releasing as above,
|
||||
|
||||
cp dist/rhel7/OSL_*.xml /shots/spi/home/lib/app_cfg/OSL
|
||||
|
||||
That will make appcfg aware of the release.
|
||||
|
||||
To also make this release the new facility default:
|
||||
|
||||
db-any spi/home/OSL.bin highest /shots/spi/home/lib/app_cfg/OSL/OSL_A.B.C.D.xml
|
||||
|
||||
where A.B.C.D is the version.
|
||||
--->
|
||||
|
||||
|
||||
SpComp2 build and release
|
||||
-------------------------
|
||||
|
||||
Phasing out support for this.
|
||||
@@ -3,18 +3,7 @@
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
option (${PROJ_NAME}_SPIREZ "Enable extra bits for building for SPI Rez install" OFF)
|
||||
set (${PROJ_NAME}_REZ_PACKAGE_NAME CACHE STRING "${PROJECT_NAME}")
|
||||
|
||||
if (${PROJ_NAME}_SPIREZ)
|
||||
message (STATUS "Creating package.py from package.py.in")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/rez/package.py.in" "${CMAKE_BINARY_DIR}/package.py")
|
||||
|
||||
set (appcfg_filename "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}.xml")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/appcfg.xml.in" "${appcfg_filename}")
|
||||
|
||||
install (FILES ${CMAKE_BINARY_DIR}/package.py
|
||||
"${PROJECT_SOURCE_DIR}/site/spi/rez/CMakeLists.txt"
|
||||
${appcfg_filename}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
COMPONENT developer)
|
||||
endif ()
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(OSL)
|
||||
|
||||
include(RezBuild)
|
||||
|
||||
rez_install_dirs(
|
||||
include lib share
|
||||
# python
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
# Bin specified separately so it can be marked as EXECUTABLE, otherwise it
|
||||
# installs with only read permissions.
|
||||
rez_install_dirs(
|
||||
bin
|
||||
DESTINATION .
|
||||
EXECUTABLE
|
||||
)
|
||||
|
||||
rez_install_cmake(
|
||||
DESTINATION .
|
||||
INCLUDE_DIRS include
|
||||
LIBRARY_DIRS lib
|
||||
LIBRARIES oslexec oslcomp oslquery
|
||||
oslexec_d oslcomp_d oslquery_d
|
||||
)
|
||||
@@ -1,59 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
#
|
||||
# Documentation on packages and available attributes can be found at:
|
||||
# https://github.com/nerdvegas/rez/wiki/Package-Definition-Guide
|
||||
|
||||
|
||||
name = '@OSL_REZ_PACKAGE_NAME@'
|
||||
|
||||
version = '@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@'
|
||||
|
||||
description = \
|
||||
"""
|
||||
Rez package of Open Shading Language (OSL)
|
||||
"""
|
||||
|
||||
authors = ['Larry Gritz <lg@imageworks.com>']
|
||||
|
||||
# Add dependencies to other Rez packages here
|
||||
requires = [
|
||||
'platform-@SP_PLATFORM@', 'arch-@SP_PROC@', 'os-@SP_REZ_OS@',
|
||||
'OpenImageIO-@OPENIMAGEIO_VERSION_MAJOR@.@OPENIMAGEIO_VERSION_MINOR@.@OPENIMAGEIO_VERSION_PATCH@'
|
||||
]
|
||||
|
||||
#build_command = 'python {root}/build.py'
|
||||
|
||||
# Rez has a limitation where it is not possible to add variants to a package that
|
||||
# does not have any: https://github.com/nerdvegas/rez/wiki/Variants#single-variants.
|
||||
# Unless you are 100% certain that your package will NEVER require any variants,
|
||||
# you should define your package with at least one variant.
|
||||
variants = [
|
||||
[
|
||||
'@SPI_COMPILER_PLATFORM@',
|
||||
'python-@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@',
|
||||
'boost-@BOOST_VERS_SP@',
|
||||
'cuda-@CUDA_VERSION@',
|
||||
'optix-@OPTIX_VERSION@'
|
||||
],
|
||||
]
|
||||
|
||||
def commands():
|
||||
# Add import statements here, not at the top of the file!
|
||||
|
||||
# Uncomment if you have executables under bin/
|
||||
env.PATH.append("{root}/bin")
|
||||
env.LD_LIBRARY_PATH.append("{root}/lib")
|
||||
|
||||
# Uncomment if you have Python code under python/
|
||||
env.PYTHONPATH.append("{root}/python")
|
||||
|
||||
# For SpImport.Packages, append the python directory
|
||||
#env.SPIMPORT_PACKAGES.append("{root}/python")
|
||||
|
||||
if building:
|
||||
env.CMAKE_MODULE_PATH.append('{root}')
|
||||
# Add env vars or custom code you want executed only at build time
|
||||
@@ -0,0 +1,28 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright Contributors to the Open Shading Language Project.
|
||||
|
||||
sonar.host.url=https://sonarcloud.io
|
||||
|
||||
# Required metadata
|
||||
sonar.organization=academysoftwarefoundation
|
||||
sonar.projectName=OpenShadingLanguage
|
||||
sonar.projectVersion=1.12
|
||||
sonar.projectKey=AcademySoftwareFoundation_OpenShadingLanguage
|
||||
|
||||
# Project links
|
||||
sonar.links.homepage=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
sonar.links.ci=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/actions
|
||||
sonar.links.scm=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
sonar.links.issue=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues
|
||||
|
||||
# Source properties
|
||||
sonar.sources=src
|
||||
sonar.sourceEncoding=UTF-8
|
||||
sonar.exclusions=src/include/OSL/Imath/*.h,src/build-scripts/*
|
||||
|
||||
# C/C++ analyzer properties
|
||||
sonar.cfamily.build-wrapper-output=build/bw_output
|
||||
sonar.cfamily.gcov.reportsPath=_coverage
|
||||
|
||||
sonar.cfamily.cache.enabled=true
|
||||
sonar.cfamily.cache.path=/tmp/sonarcache
|
||||
@@ -1,273 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
PROJECT (openexr)
|
||||
|
||||
SET(OPENEXR_VERSION_MAJOR "2")
|
||||
SET(OPENEXR_VERSION_MINOR "2")
|
||||
SET(OPENEXR_VERSION_PATCH "0")
|
||||
|
||||
SET(OPENEXR_VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH})
|
||||
SET(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
|
||||
|
||||
|
||||
# enable the tests
|
||||
ENABLE_TESTING()
|
||||
|
||||
|
||||
# distro building
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENEXR_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "${OPENEXR_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "${OPENEXR_VERSION_PATCH}")
|
||||
SET(CPACK_SOURCE_GENERATOR "TGZ")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
||||
"${CMAKE_PROJECT_NAME}-${OPENEXR_VERSION}"
|
||||
)
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
"/.git*;/.cvs*;${CPACK_SOURCE_IGNORE_FILES}")
|
||||
INCLUDE ( CPack )
|
||||
|
||||
|
||||
|
||||
# Allow the developer to select if Dynamic or Static libraries are built
|
||||
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON)
|
||||
OPTION (USE_ZLIB_WINAPI "Use ZLib Win API" OFF)
|
||||
OPTION (NAMESPACE_VERSIONING "Use Namespace Versioning" ON)
|
||||
OPTION (BUILD_UTILS "Build the binary/utility programs" ON)
|
||||
OPTION (BUILD_TESTS "Build the tests" ON)
|
||||
|
||||
# Setup osx rpathing
|
||||
SET (CMAKE_MACOSX_RPATH 1)
|
||||
SET (BUILD_WITH_INSTALL_RPATH 1)
|
||||
|
||||
ADD_DEFINITIONS ( -DHAVE_CONFIG_H -DILM_IMF_TEST_IMAGEDIR="${CMAKE_SOURCE_DIR}/IlmImfTest/" )
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config
|
||||
IlmImf
|
||||
IlmImfUtil
|
||||
exrmaketiled
|
||||
exrenvmap
|
||||
exrmakepreview
|
||||
exrmultiview
|
||||
IlmImfFuzzTest
|
||||
)
|
||||
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
|
||||
IF (NOT WIN32)
|
||||
SET ( PTHREAD_LIB pthread )
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/include/OpenEXR )
|
||||
LINK_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/lib )
|
||||
MESSAGE ( "ILMBASE_PACKAGE_PREFIX = " ${ILMBASE_PACKAGE_PREFIX})
|
||||
|
||||
SET (LIB_TYPE STATIC)
|
||||
IF (BUILD_SHARED_LIBS)
|
||||
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
|
||||
SET (LIB_TYPE SHARED)
|
||||
IF (WIN32)
|
||||
ADD_DEFINITIONS(-DOPENEXR_DLL)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF (USE_ZLIB_WINAPI)
|
||||
ADD_DEFINITIONS(-DZLIB_WINAPI)
|
||||
ENDIF ()
|
||||
|
||||
# Test for GCC-style inline asm support with AVX instructions
|
||||
INCLUDE (CheckCXXSourceCompiles)
|
||||
CHECK_CXX_SOURCE_COMPILES (
|
||||
"
|
||||
int main()
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__SSE2__)
|
||||
int n = 0;
|
||||
int eax = 0;
|
||||
int edx = 0;
|
||||
__asm__(
|
||||
\"xgetbv ;\"
|
||||
\"vzeroupper \"
|
||||
: \"=a\"(eax), \"=d\"(edx) : \"c\"(n) : );
|
||||
#else
|
||||
#error No GCC style inline asm supported for AVX instructions
|
||||
#endif
|
||||
}
|
||||
" HAVE_GCC_INLINE_ASM_AVX)
|
||||
|
||||
# Check if sysconf(_SC_NPROCESSORS_ONLN) can be used for CPU count
|
||||
CHECK_CXX_SOURCE_COMPILES (
|
||||
"
|
||||
#include <unistd.h>
|
||||
int main()
|
||||
{
|
||||
sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
" HAVE_SYSCONF_NPROCESSORS_ONLN)
|
||||
|
||||
|
||||
##########################
|
||||
# OpenEXRConfig.h generation
|
||||
##########################
|
||||
IF (WIN32)
|
||||
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
|
||||
ELSEIF (APPLE)
|
||||
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_DARWIN 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#include <string.h>\n" )
|
||||
ELSE ()
|
||||
# Linux
|
||||
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LINUX_PROCFS 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LARGE_STACK 1\n" )
|
||||
ENDIF()
|
||||
|
||||
IF (NAMESPACE_VERSIONING)
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1\n")
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf_${OPENEXR_VERSION_API}\n\n" )
|
||||
ELSE ()
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 0\n")
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf\n\n" )
|
||||
ENDIF ()
|
||||
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_VERSION_STRING \"${OPENEXR_VERSION}\"\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_PACKAGE_STRING \"OpenEXR ${OPENEXR_VERSION}\"\n" )
|
||||
|
||||
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
|
||||
#define OPENEXR_VERSION_MAJOR ${OPENEXR_VERSION_MAJOR}
|
||||
#define OPENEXR_VERSION_MINOR ${OPENEXR_VERSION_MINOR}
|
||||
#define OPENEXR_VERSION_PATCH ${OPENEXR_VERSION_PATCH}
|
||||
")
|
||||
|
||||
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
|
||||
// Version as a single hex number, e.g. 0x01000300 == 1.0.3
|
||||
#define OPENEXR_VERSION_HEX ((OPENEXR_VERSION_MAJOR << 24) | \\
|
||||
(OPENEXR_VERSION_MINOR << 16) | \\
|
||||
(OPENEXR_VERSION_PATCH << 8))\n
|
||||
")
|
||||
|
||||
IF (HAVE_GCC_INLINE_ASM_AVX)
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX 1\n" )
|
||||
ENDIF()
|
||||
|
||||
IF (HAVE_SYSCONF_NPROCESSORS_ONLN)
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN 1\n" )
|
||||
ENDIF()
|
||||
|
||||
SET (OPENEXR_LIBSUFFIX "")
|
||||
SET (ILMBASE_LIBSUFFIX "")
|
||||
IF (NAMESPACE_VERSIONING)
|
||||
SET ( OPENEXR_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
|
||||
# assume same NAMESPACE_VERSION setting for IlmBase for now
|
||||
SET ( ILMBASE_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
|
||||
ENDIF ()
|
||||
|
||||
##########################
|
||||
# IlmImf library
|
||||
##########################
|
||||
ADD_SUBDIRECTORY ( IlmImf )
|
||||
|
||||
SET_TARGET_PROPERTIES ( IlmImf
|
||||
PROPERTIES
|
||||
VERSION 22.0.0
|
||||
SOVERSION 22
|
||||
OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}"
|
||||
)
|
||||
|
||||
##########################
|
||||
# IlmImfUtil library
|
||||
##########################
|
||||
ADD_SUBDIRECTORY ( IlmImfUtil )
|
||||
|
||||
SET_TARGET_PROPERTIES ( IlmImfUtil
|
||||
PROPERTIES
|
||||
VERSION 22.0.0
|
||||
SOVERSION 22
|
||||
OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}"
|
||||
)
|
||||
|
||||
##########################
|
||||
# Example Code
|
||||
##########################
|
||||
ADD_SUBDIRECTORY ( IlmImfExamples )
|
||||
|
||||
|
||||
##########################
|
||||
# Tests
|
||||
##########################
|
||||
if (BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY ( IlmImfTest )
|
||||
ADD_SUBDIRECTORY ( IlmImfUtilTest )
|
||||
ADD_SUBDIRECTORY ( IlmImfFuzzTest )
|
||||
endif ()
|
||||
|
||||
|
||||
##########################
|
||||
# Binaries / Utilities
|
||||
##########################
|
||||
if (BUILD_UTILS)
|
||||
ADD_SUBDIRECTORY ( exrheader )
|
||||
ADD_SUBDIRECTORY ( exrmaketiled )
|
||||
ADD_SUBDIRECTORY ( exrstdattr )
|
||||
ADD_SUBDIRECTORY ( exrmakepreview )
|
||||
ADD_SUBDIRECTORY ( exrenvmap )
|
||||
ADD_SUBDIRECTORY ( exrmultiview )
|
||||
ADD_SUBDIRECTORY ( exrmultipart )
|
||||
endif ()
|
||||
|
||||
|
||||
##########################
|
||||
# Installation
|
||||
##########################
|
||||
|
||||
INSTALL ( FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
|
||||
)
|
||||
|
||||
# Documentation
|
||||
INSTALL ( FILES
|
||||
doc/TechnicalIntroduction.pdf
|
||||
doc/ReadingAndWritingImageFiles.pdf
|
||||
doc/OpenEXRFileLayout.pdf
|
||||
doc/MultiViewOpenEXR.pdf
|
||||
doc/InterpretingDeepPixels.pdf
|
||||
doc/TheoryDeepPixels.pdf
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}
|
||||
)
|
||||
|
||||
# Examples
|
||||
INSTALL ( FILES
|
||||
IlmImfExamples/main.cpp
|
||||
IlmImfExamples/drawImage.cpp
|
||||
IlmImfExamples/rgbaInterfaceExamples.cpp
|
||||
IlmImfExamples/rgbaInterfaceTiledExamples.cpp
|
||||
IlmImfExamples/generalInterfaceExamples.cpp
|
||||
IlmImfExamples/lowLevelIoExamples.cpp
|
||||
IlmImfExamples/previewImageExamples.cpp
|
||||
IlmImfExamples/generalInterfaceTiledExamples.cpp
|
||||
IlmImfExamples/generalInterfaceTiledExamples.h
|
||||
IlmImfExamples/drawImage.h
|
||||
IlmImfExamples/rgbaInterfaceExamples.h
|
||||
IlmImfExamples/generalInterfaceExamples.h
|
||||
IlmImfExamples/rgbaInterfaceTiledExamples.h
|
||||
IlmImfExamples/lowLevelIoExamples.h
|
||||
IlmImfExamples/previewImageExamples.h
|
||||
IlmImfExamples/namespaceAlias.h
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}/examples
|
||||
)
|
||||
|
||||
|
||||
# LG additions
|
||||
if (DEFINED ENV{APPVEYOR})
|
||||
add_definitions ("/W0")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /W0")
|
||||
endif ()
|
||||
@@ -1,273 +0,0 @@
|
||||
# yue.nicholas@gmail.com
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
|
||||
|
||||
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h")
|
||||
ADD_EXECUTABLE ( b44ExpLogTable
|
||||
b44ExpLogTable.cpp
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( b44ExpLogTable
|
||||
Half
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
IlmThread${ILMBASE_LIBSUFFIX}
|
||||
${PTHREAD_LIB}
|
||||
)
|
||||
|
||||
ADD_CUSTOM_COMMAND (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/b44ExpLogTable > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
DEPENDS b44ExpLogTable
|
||||
)
|
||||
else ()
|
||||
message (STATUS "Skipping build of b44ExpLogTable.h")
|
||||
endif ()
|
||||
|
||||
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h")
|
||||
ADD_EXECUTABLE ( dwaLookups
|
||||
dwaLookups.cpp
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( dwaLookups
|
||||
Half
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
IlmThread${ILMBASE_LIBSUFFIX}
|
||||
${PTHREAD_LIB}
|
||||
)
|
||||
|
||||
ADD_CUSTOM_COMMAND (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/dwaLookups > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
DEPENDS dwaLookups
|
||||
)
|
||||
else ()
|
||||
message (STATUS "Skipping build of dwaLookups.h")
|
||||
endif ()
|
||||
|
||||
SET ( ILMIMF_SRCS
|
||||
ImfAttribute.cpp
|
||||
ImfBoxAttribute.cpp
|
||||
ImfCRgbaFile.cpp
|
||||
ImfChannelList.cpp
|
||||
ImfChannelListAttribute.cpp
|
||||
ImfFloatAttribute.cpp
|
||||
ImfFrameBuffer.cpp
|
||||
ImfHeader.cpp
|
||||
ImfIO.cpp
|
||||
ImfInputFile.cpp
|
||||
ImfIntAttribute.cpp
|
||||
ImfLineOrderAttribute.cpp
|
||||
ImfMatrixAttribute.cpp
|
||||
ImfOpaqueAttribute.cpp
|
||||
ImfOutputFile.cpp
|
||||
ImfRgbaFile.cpp
|
||||
ImfStringAttribute.cpp
|
||||
ImfVecAttribute.cpp
|
||||
ImfHuf.cpp
|
||||
ImfThreading.cpp
|
||||
ImfWav.cpp
|
||||
ImfLut.cpp
|
||||
ImfCompressor.cpp
|
||||
ImfRleCompressor.cpp
|
||||
ImfZipCompressor.cpp
|
||||
ImfPizCompressor.cpp
|
||||
ImfB44Compressor.cpp
|
||||
ImfDwaCompressor.cpp
|
||||
ImfMisc.cpp
|
||||
ImfCompressionAttribute.cpp
|
||||
ImfDoubleAttribute.cpp
|
||||
ImfConvert.cpp
|
||||
ImfPreviewImage.cpp
|
||||
ImfPreviewImageAttribute.cpp
|
||||
ImfVersion.cpp
|
||||
ImfChromaticities.cpp
|
||||
ImfChromaticitiesAttribute.cpp
|
||||
ImfKeyCode.cpp
|
||||
ImfKeyCodeAttribute.cpp
|
||||
ImfTimeCode.cpp
|
||||
ImfTimeCodeAttribute.cpp
|
||||
ImfRational.cpp
|
||||
ImfRationalAttribute.cpp
|
||||
ImfFramesPerSecond.cpp
|
||||
ImfStandardAttributes.cpp
|
||||
ImfStdIO.cpp
|
||||
ImfEnvmap.cpp
|
||||
ImfEnvmapAttribute.cpp
|
||||
ImfScanLineInputFile.cpp
|
||||
ImfTiledInputFile.cpp
|
||||
ImfTiledMisc.cpp
|
||||
ImfTiledOutputFile.cpp
|
||||
ImfTiledRgbaFile.cpp
|
||||
ImfTileDescriptionAttribute.cpp
|
||||
ImfTileOffsets.cpp
|
||||
ImfRgbaYca.cpp
|
||||
ImfPxr24Compressor.cpp
|
||||
ImfTestFile.cpp
|
||||
ImfStringVectorAttribute.cpp
|
||||
ImfMultiView.cpp
|
||||
ImfAcesFile.cpp
|
||||
ImfMultiPartOutputFile.cpp
|
||||
ImfGenericOutputFile.cpp
|
||||
ImfOutputPartData.cpp
|
||||
ImfMultiPartInputFile.cpp
|
||||
ImfGenericInputFile.cpp
|
||||
ImfPartType.cpp
|
||||
ImfInputPartData.cpp
|
||||
ImfOutputPart.cpp
|
||||
ImfTiledOutputPart.cpp
|
||||
ImfInputPart.cpp
|
||||
ImfTiledInputPart.cpp
|
||||
ImfDeepScanLineInputPart.cpp
|
||||
ImfDeepScanLineOutputPart.cpp
|
||||
ImfDeepScanLineInputFile.cpp
|
||||
ImfDeepScanLineOutputFile.cpp
|
||||
ImfDeepTiledInputPart.cpp
|
||||
ImfDeepTiledOutputPart.cpp
|
||||
ImfDeepTiledInputFile.cpp
|
||||
ImfDeepTiledOutputFile.cpp
|
||||
ImfDeepFrameBuffer.cpp
|
||||
ImfDeepCompositing.cpp
|
||||
ImfCompositeDeepScanLine.cpp
|
||||
ImfDeepImageStateAttribute.cpp
|
||||
ImfFastHuf.cpp
|
||||
ImfFloatVectorAttribute.cpp
|
||||
ImfRle.cpp
|
||||
ImfSystemSpecific.cpp
|
||||
ImfZip.cpp
|
||||
)
|
||||
|
||||
IF (BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DILMIMF_EXPORTS)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY ( IlmImf ${LIB_TYPE}
|
||||
${ILMIMF_SRCS}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( IlmImf
|
||||
Half
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
Imath${ILMBASE_LIBSUFFIX}
|
||||
IlmThread${ILMBASE_LIBSUFFIX}
|
||||
${PTHREAD_LIB} ${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
ADD_DEPENDENCIES ( IlmImf b44ExpLogTable )
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES (
|
||||
ImfB44Compressor.cpp
|
||||
PROPERTIES
|
||||
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
)
|
||||
|
||||
|
||||
ADD_DEPENDENCIES ( IlmImf dwaLookups )
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES (
|
||||
ImfDwaCompressor.cpp
|
||||
PROPERTIES
|
||||
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
)
|
||||
|
||||
# Libraries
|
||||
|
||||
INSTALL ( TARGETS
|
||||
IlmImf
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
# Headers
|
||||
INSTALL ( FILES
|
||||
ImfForward.h
|
||||
ImfExport.h
|
||||
ImfAttribute.h
|
||||
ImfBoxAttribute.h
|
||||
ImfCRgbaFile.h
|
||||
ImfChannelList.h
|
||||
ImfChannelListAttribute.h
|
||||
ImfCompressionAttribute.h
|
||||
ImfDoubleAttribute.h
|
||||
ImfFloatAttribute.h
|
||||
ImfFrameBuffer.h
|
||||
ImfHeader.h
|
||||
ImfIO.h
|
||||
ImfInputFile.h
|
||||
ImfIntAttribute.h
|
||||
ImfLineOrderAttribute.h
|
||||
ImfMatrixAttribute.h
|
||||
ImfOpaqueAttribute.h
|
||||
ImfOutputFile.h
|
||||
ImfRgbaFile.h
|
||||
ImfStringAttribute.h
|
||||
ImfVecAttribute.h
|
||||
ImfHuf.h
|
||||
ImfWav.h
|
||||
ImfLut.h
|
||||
ImfArray.h
|
||||
ImfCompression.h
|
||||
ImfLineOrder.h
|
||||
ImfName.h
|
||||
ImfPixelType.h
|
||||
ImfVersion.h
|
||||
ImfXdr.h
|
||||
ImfConvert.h
|
||||
ImfPreviewImage.h
|
||||
ImfPreviewImageAttribute.h
|
||||
ImfChromaticities.h
|
||||
ImfChromaticitiesAttribute.h
|
||||
ImfKeyCode.h
|
||||
ImfKeyCodeAttribute.h
|
||||
ImfTimeCode.h
|
||||
ImfTimeCodeAttribute.h
|
||||
ImfRational.h
|
||||
ImfRationalAttribute.h
|
||||
ImfFramesPerSecond.h
|
||||
ImfStandardAttributes.h
|
||||
ImfEnvmap.h
|
||||
ImfEnvmapAttribute.h
|
||||
ImfInt64.h
|
||||
ImfRgba.h
|
||||
ImfTileDescription.h
|
||||
ImfTileDescriptionAttribute.h
|
||||
ImfTiledInputFile.h
|
||||
ImfTiledOutputFile.h
|
||||
ImfTiledRgbaFile.h
|
||||
ImfRgbaYca.h
|
||||
ImfTestFile.h
|
||||
ImfThreading.h
|
||||
ImfB44Compressor.h
|
||||
ImfStringVectorAttribute.h
|
||||
ImfMultiView.h
|
||||
ImfAcesFile.h
|
||||
ImfMultiPartOutputFile.h
|
||||
ImfGenericOutputFile.h
|
||||
ImfMultiPartInputFile.h
|
||||
ImfGenericInputFile.h
|
||||
ImfPartType.h
|
||||
ImfPartHelper.h
|
||||
ImfOutputPart.h
|
||||
ImfTiledOutputPart.h
|
||||
ImfInputPart.h
|
||||
ImfTiledInputPart.h
|
||||
ImfDeepScanLineOutputFile.h
|
||||
ImfDeepScanLineOutputPart.h
|
||||
ImfDeepScanLineInputFile.h
|
||||
ImfDeepScanLineInputPart.h
|
||||
ImfDeepTiledInputFile.h
|
||||
ImfDeepTiledInputPart.h
|
||||
ImfDeepTiledOutputFile.h
|
||||
ImfDeepTiledOutputPart.h
|
||||
ImfDeepFrameBuffer.h
|
||||
ImfDeepCompositing.h
|
||||
ImfCompositeDeepScanLine.h
|
||||
ImfNamespace.h
|
||||
ImfMisc.h
|
||||
ImfDeepImageState.h
|
||||
ImfDeepImageStateAttribute.h
|
||||
ImfFloatVectorAttribute.h
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
|
||||
)
|
||||
|
||||
Binary file not shown.
@@ -14,7 +14,7 @@ uname
|
||||
|
||||
|
||||
if [[ `uname` == "Linux" ]] ; then
|
||||
LLVM_VERSION=${LLVM_VERSION:=8.0.0}
|
||||
LLVM_VERSION=${LLVM_VERSION:=13.0.0}
|
||||
LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR:=${PWD}/llvm-install}
|
||||
if [[ "$GITHUB_WORKFLOW" != "" ]] ; then
|
||||
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=ubuntu-18.04}
|
||||
@@ -29,7 +29,10 @@ if [[ `uname` == "Linux" ]] ; then
|
||||
fi
|
||||
LLVMTAR=clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-${LLVM_DISTRO_NAME}.tar.xz
|
||||
echo LLVMTAR = $LLVMTAR
|
||||
if [[ "$LLVM_VERSION" == "10.0.0" ]] || [[ "$LLVM_VERSION" == "11.0.0" ]] || [[ "$LLVM_VERSION" == "11.1.0" ]] || [[ "$LLVM_VERSION" == "12.0.0" ]] ; then
|
||||
if [[ "$LLVM_VERSION" == "10.0.0" ]] || [[ "$LLVM_VERSION" == "11.0.0" ]] \
|
||||
|| [[ "$LLVM_VERSION" == "11.1.0" ]] || [[ "$LLVM_VERSION" == "12.0.0" ]] \
|
||||
|| [[ "$LLVM_VERSION" == "13.0.0" ]] || [[ "$LLVM_VERSION" == "14.0.0" ]] ;
|
||||
then
|
||||
# new
|
||||
curl --location https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/${LLVMTAR} -o $LLVMTAR
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v1.1.1}
|
||||
|
||||
# Where to install the final results
|
||||
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
|
||||
OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
|
||||
OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_SOURCE_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
|
||||
OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build}
|
||||
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
|
||||
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
|
||||
@@ -25,7 +25,7 @@ OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
|
||||
-DOCIO_BUILD_GPU_TESTS=OFF \
|
||||
-DOCIO_BUILD_PYTHON=OFF -DOCIO_BUILD_PYGLUE=OFF \
|
||||
-DOCIO_BUILD_JAVA=OFF \
|
||||
-DOCIO_BUILD_STATIC=${OCIO_BUILD_STATIC:=OFF}"
|
||||
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"
|
||||
BASEDIR=`pwd`
|
||||
pwd
|
||||
echo "OpenColorIO install dir will be: ${OPENCOLORIO_INSTALL_DIR}"
|
||||
@@ -34,20 +34,20 @@ mkdir -p ${LOCAL_DEPS_DIR}
|
||||
pushd ${LOCAL_DEPS_DIR}
|
||||
|
||||
# Clone OpenColorIO project from GitHub and build
|
||||
if [[ ! -e OpenColorIO ]] ; then
|
||||
echo "git clone ${OPENCOLORIO_REPO} OpenColorIO"
|
||||
git clone ${OPENCOLORIO_REPO} OpenColorIO
|
||||
if [[ ! -e ${OPENCOLORIO_SOURCE_DIR} ]] ; then
|
||||
echo "git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}"
|
||||
git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}
|
||||
fi
|
||||
cd OpenColorIO
|
||||
cd ${OPENCOLORIO_SOURCE_DIR}
|
||||
|
||||
echo "git checkout ${OPENCOLORIO_VERSION} --force"
|
||||
git checkout ${OPENCOLORIO_VERSION} --force
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p ${OPENCOLORIO_BUILD_DIR}
|
||||
cd ${OPENCOLORIO_BUILD_DIR}
|
||||
time cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
|
||||
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
|
||||
${OPENCOLORIO_BUILDOPTS} ..
|
||||
${OPENCOLORIO_BUILDOPTS} ${OPENCOLORIO_SOURCE_DIR}
|
||||
time cmake --build . --config Release --target install
|
||||
popd
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
set -ex
|
||||
|
||||
# Which OpenEXR to retrieve, how to build it
|
||||
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/openexr/openexr.git}
|
||||
OPENEXR_VERSION=${OPENEXR_VERSION:=v2.4.1}
|
||||
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/AcademySoftwareFoundation/openexr.git}
|
||||
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.1.1}
|
||||
|
||||
# Where to install the final results
|
||||
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
|
||||
@@ -20,7 +20,6 @@ OPENEXR_SOURCE_DIR=${OPENEXR_SOURCE_DIR:=${LOCAL_DEPS_DIR}/openexr}
|
||||
OPENEXR_BUILD_DIR=${OPENEXR_BUILD_DIR:=${LOCAL_DEPS_DIR}/openexr-build}
|
||||
OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
|
||||
OPENEXR_BUILD_TYPE=${OPENEXR_BUILD_TYPE:=Release}
|
||||
CMAKE_GENERATOR=${CMAKE_GENERATOR:="Unix Makefiles"}
|
||||
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
|
||||
OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
|
||||
BASEDIR=$PWD
|
||||
@@ -29,49 +28,24 @@ pwd
|
||||
echo "Building OpenEXR ${OPENEXR_VERSION}"
|
||||
echo "OpenEXR build dir will be: ${OPENEXR_BUILD_DIR}"
|
||||
echo "OpenEXR install dir will be: ${OPENEXR_INSTALL_DIR}"
|
||||
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
|
||||
echo "OpenEXR Build type is ${OPENEXR_BUILD_TYPE}"
|
||||
|
||||
if [[ "$CMAKE_GENERATOR" == "" ]] ; then
|
||||
OPENEXR_GENERATOR_CMD="-G \"$CMAKE_GENERATOR\""
|
||||
fi
|
||||
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
|
||||
|
||||
# Clone OpenEXR project (including IlmBase) from GitHub and build
|
||||
if [[ ! -e ${OPENEXR_SOURCE_DIR} ]] ; then
|
||||
echo "git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}"
|
||||
git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}
|
||||
fi
|
||||
|
||||
mkdir -p ${OPENEXR_INSTALL_DIR} && true
|
||||
mkdir -p ${OPENEXR_BUILD_DIR} && true
|
||||
|
||||
pushd ${OPENEXR_SOURCE_DIR}
|
||||
git checkout ${OPENEXR_VERSION} --force
|
||||
|
||||
if [[ ${OPENEXR_VERSION} == "v2.2.0" ]] || [[ ${OPENEXR_VERSION} == "v2.2.1" ]] \
|
||||
|| [[ ${OPENEXR_VERSION} == "v2.2.2" ]] ; then
|
||||
mkdir -p ${OPENEXR_BUILD_DIR}/IlmBase && true
|
||||
mkdir -p ${OPENEXR_BUILD_DIR}/OpenEXR && true
|
||||
cd ${OPENEXR_BUILD_DIR}/IlmBase
|
||||
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} ${OPENEXR_GENERATOR_CMD} \
|
||||
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
|
||||
-DCMAKE_CXX_STANDARD=11 \
|
||||
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/IlmBase
|
||||
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
|
||||
cd ${OPENEXR_BUILD_DIR}/OpenEXR
|
||||
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} ${OPENEXR_GENERATOR_CMD} \
|
||||
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}\;${OPENEXR_INSTALL_DIR}" \
|
||||
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
-DBUILD_UTILS=0 -DBUILD_TESTS=0 \
|
||||
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
|
||||
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/OpenEXR
|
||||
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
|
||||
elif [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
|
||||
if [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
|
||||
# Simplified setup for 2.3+
|
||||
cd ${OPENEXR_BUILD_DIR}
|
||||
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
|
||||
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
|
||||
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
@@ -84,7 +58,7 @@ elif [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
|
||||
else
|
||||
# Simplified setup for 2.4+
|
||||
cd ${OPENEXR_BUILD_DIR}
|
||||
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
|
||||
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
|
||||
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
|
||||
@@ -112,5 +86,3 @@ export ILMBASE_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
|
||||
export OPENEXR_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
|
||||
export LD_LIBRARY_PATH=$OPENEXR_ROOT/lib:$LD_LIBRARY_PATH
|
||||
|
||||
export ILMBASE_ROOT_DIR=$OPENEXR_INSTALL_DIR
|
||||
export OPENEXR_ROOT_DIR=$OPENEXR_INSTALL_DIR
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
set -ex
|
||||
|
||||
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=OpenImageIO/oiio}
|
||||
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=master}
|
||||
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=release}
|
||||
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
|
||||
OPENIMAGEIO_SRCDIR=${OPENIMAGEIO_SRCDIR:=${LOCAL_DEPS_DIR}/OpenImageIO}
|
||||
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build/$PLATFORM}
|
||||
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build}
|
||||
OPENIMAGEIO_INSTALLDIR=${OPENIMAGEIO_INSTALLDIR:=${LOCAL_DEPS_DIR}/dist}
|
||||
OPENIMAGEIO_CMAKE_FLAGS=${OPENIMAGEIO_CMAKE_FLAGS:=""}
|
||||
OPENIMAGEIO_BUILD_TYPE=${OPENIMAGEIO_BUILD_TYPE:=Release}
|
||||
@@ -42,7 +42,7 @@ fi
|
||||
|
||||
# if [[ "$ARCH" == "windows64" ]] ; then
|
||||
pushd ${OPENIMAGEIO_BUILD_DIR}
|
||||
cmake ../.. -G "$CMAKE_GENERATOR" \
|
||||
cmake .. -G "$CMAKE_GENERATOR" \
|
||||
-DCMAKE_BUILD_TYPE="$OPENIMAGEIO_BUILD_TYPE" \
|
||||
-DCMAKE_INSTALL_PREFIX="$OPENIMAGEIO_INSTALLDIR" \
|
||||
-DPYTHON_VERSION="$PYTHON_VERSION" \
|
||||
|
||||
@@ -11,7 +11,7 @@ set -ex
|
||||
|
||||
# Repo and branch/tag/commit of pybind11 to download if we don't have it yet
|
||||
PYBIND11_REPO=${PYBIND11_REPO:=https://github.com/pybind/pybind11.git}
|
||||
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.4.3}
|
||||
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.8.1}
|
||||
|
||||
# Where to put pybind11 repo source (default to the ext area)
|
||||
PYBIND11_SRC_DIR=${PYBIND11_SRC_DIR:=${PWD}/ext/pybind11}
|
||||
@@ -20,7 +20,7 @@ PYBIND11_BUILD_DIR=${PYBIND11_BUILD_DIR:=${PYBIND11_SRC_DIR}/build}
|
||||
# Install area for pybind11 (default to ext/dist)
|
||||
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
|
||||
PYBIND11_INSTALL_DIR=${PYBIND11_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
|
||||
PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
|
||||
#PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
|
||||
|
||||
if [[ "${PYTHON_VERSION}" != "" ]] ; then
|
||||
PYBIND11_BUILD_OPTS+=" -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION}"
|
||||
@@ -38,16 +38,20 @@ if [[ ! -e ${PYBIND11_SRC_DIR} ]] ; then
|
||||
git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}
|
||||
fi
|
||||
cd ${PYBIND11_SRC_DIR}
|
||||
|
||||
echo "git checkout ${PYBIND11_VERSION} --force"
|
||||
git checkout ${PYBIND11_VERSION} --force
|
||||
|
||||
mkdir -p ${PYBIND11_BUILD_DIR}
|
||||
cd ${PYBIND11_BUILD_DIR}
|
||||
time cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
|
||||
-DPYBIND11_TEST=OFF \
|
||||
${PYBIND11_BUILD_OPTS} ..
|
||||
time cmake --build . --config Release --target install
|
||||
|
||||
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
|
||||
time cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
|
||||
-DPYBIND11_TEST=OFF \
|
||||
${PYBIND11_BUILD_OPTS} ..
|
||||
time cmake --build . --config Release --target install
|
||||
fi
|
||||
|
||||
# ls -R ${PYBIND11_INSTALL_DIR}
|
||||
popd
|
||||
|
||||
@@ -12,8 +12,12 @@ if [[ "$USE_SIMD" != "" ]] ; then
|
||||
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
|
||||
fi
|
||||
|
||||
pushd build/$PLATFORM
|
||||
cmake ../.. -G "$CMAKE_GENERATOR" \
|
||||
if [[ -n "$CODECOV" ]] ; then
|
||||
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DCODECOV=${CODECOV}"
|
||||
fi
|
||||
|
||||
pushd build
|
||||
cmake .. -G "$CMAKE_GENERATOR" \
|
||||
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
||||
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
|
||||
-DCMAKE_INSTALL_PREFIX="$OSL_ROOT" \
|
||||
@@ -23,7 +27,16 @@ cmake ../.. -G "$CMAKE_GENERATOR" \
|
||||
-DCMAKE_INSTALL_LIBDIR="$OSL_ROOT/lib" \
|
||||
-DCMAKE_CXX_STANDARD="$CMAKE_CXX_STANDARD" \
|
||||
$OSL_CMAKE_FLAGS -DVERBOSE=1
|
||||
time cmake --build . --target ${BUILDTARGET:=install} --config ${CMAKE_BUILD_TYPE}
|
||||
|
||||
# Save a copy of the generated files for debugging broken CI builds.
|
||||
mkdir cmake-save || /bin/true
|
||||
cp -r CMake* *.cmake cmake-save
|
||||
|
||||
: ${BUILDTARGET:=install}
|
||||
if [[ "$BUILDTARGET" != "none" ]] ; then
|
||||
echo "Parallel build ${CMAKE_BUILD_PARALLEL_LEVEL} of target ${BUILDTARGET}"
|
||||
time ${OSL_CMAKE_BUILD_WRAPPER} cmake --build . --target ${BUILDTARGET} --config ${CMAKE_BUILD_TYPE}
|
||||
fi
|
||||
popd
|
||||
|
||||
if [[ "${DEBUG_CI:=0}" != "0" ]] ; then
|
||||
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run code coverage analysis
|
||||
# This assumes that the build occurred with CODECOV=1 andtests have already
|
||||
# fully run.
|
||||
|
||||
set -ex
|
||||
|
||||
echo "Performing code coverage analysis"
|
||||
mkdir _coverage
|
||||
pushd _coverage
|
||||
|
||||
ls -R ../build/src/
|
||||
|
||||
# Remove files or directories we want to exclude from code coverage analysis,
|
||||
# generally because we don't expect to execute any of their code during our
|
||||
# CI. (Because it's only used interactively, or is fallback code only used
|
||||
# when certain dependencies are not found.) Including these when we know we
|
||||
# won't be calling them during coverage gathering will just make our coverage
|
||||
# percentage look artifically low.
|
||||
rm -f ../build/src/osltoy/CMakeFiles/osltoy.dir/*.cpp.{gcno,gcda}
|
||||
|
||||
|
||||
# The sed command below converts from:
|
||||
# ../build/src/liboslexec/CMakeFiles/oslexec.dir/foo.gcno
|
||||
# to:
|
||||
# ../src/liboslexec/foo.cpp
|
||||
|
||||
for g in $(find ../build -name "*.gcno" -type f); do
|
||||
echo "Processing $g"
|
||||
echo "dirname $g = $(dirname $g) to " `$(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\.cpp\.cpp/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')`
|
||||
gcov -l -p -o $(dirname "$g") $(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')
|
||||
done
|
||||
popd
|
||||
@@ -8,28 +8,6 @@
|
||||
# Since it sets many env variables needed by the caller, it should be run
|
||||
# with 'source', not in a separate shell.
|
||||
|
||||
# Figure out the platform
|
||||
if [[ $RUNNER_OS == macOS ]] ; then
|
||||
export ARCH=macosx
|
||||
elif [[ $RUNNER_OS == Linux ]] ; then
|
||||
export ARCH=linux64
|
||||
elif [[ $RUNNER_OS == Windows ]] ; then
|
||||
export ARCH=windows64
|
||||
elif [[ `uname -m` == aarch64 ]] ; then
|
||||
export ARCH=aarch64
|
||||
else
|
||||
export ARCH=unknown
|
||||
exit -1
|
||||
fi
|
||||
export PLATFORM=$ARCH
|
||||
|
||||
if [[ "${DEBUG:=0}" != "0" ]] ; then
|
||||
export PLATFORM=${PLATFORM}.debug
|
||||
fi
|
||||
|
||||
echo "Architecture is $ARCH"
|
||||
echo "Build platform name is $PLATFORM"
|
||||
|
||||
# Environment variables we always need
|
||||
export PATH=/usr/local/bin/_ccache:/usr/lib/ccache:$PATH
|
||||
export USE_CCACHE=${USE_CCACHE:=1}
|
||||
@@ -40,12 +18,12 @@ if [[ "${RUNNER_OS}" == "macOS" ]] ; then
|
||||
fi
|
||||
mkdir -p $CCACHE_DIR
|
||||
|
||||
export OSL_ROOT=$PWD/dist/$PLATFORM
|
||||
export OSL_ROOT=$PWD/dist
|
||||
export DYLD_LIBRARY_PATH=$OSL_ROOT/lib:$DYLD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=$OSL_ROOT/lib:$LD_LIBRARY_PATH
|
||||
export OIIO_LIBRARY_PATH=$OSL_ROOT/lib:${OIIO_LIBRARY_PATH}
|
||||
export LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt
|
||||
export ASAN_OPTIONS=print_suppressions=0
|
||||
export ASAN_OPTIONS=print_suppressions=0:detect_odr_violation=1
|
||||
|
||||
export USE_PYTHON=${USE_PYTHON:=1}
|
||||
export PYTHON_VERSION=${PYTHON_VERSION:="2.7"}
|
||||
@@ -55,7 +33,7 @@ export PYTHONPATH=$OSL_ROOT/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPAT
|
||||
export BUILD_MISSING_DEPS=${BUILD_MISSING_DEPS:=1}
|
||||
export COMPILER=${COMPILER:=gcc}
|
||||
export CXX=${CXX:=g++}
|
||||
export CI=true
|
||||
export OSL_CI=true
|
||||
export USE_NINJA=${USE_NINJA:=1}
|
||||
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
|
||||
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
|
||||
@@ -74,7 +52,7 @@ export DYLD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$DYLD_LIBRARY_PATH
|
||||
|
||||
export TESTSUITE_CLEANUP_ON_SUCCESS=${TESTSUITE_CLEANUP_ON_SUCCESS:=1}
|
||||
|
||||
mkdir -p build/$PLATFORM dist/$PLATFORM
|
||||
mkdir -p build dist
|
||||
|
||||
echo "HOME = $HOME"
|
||||
echo "PWD = $PWD"
|
||||
@@ -83,13 +61,14 @@ echo "uname -a: " `uname -a`
|
||||
echo "uname -m: " `uname -m`
|
||||
echo "uname -s: " `uname -s`
|
||||
echo "uname -n: " `uname -n`
|
||||
echo "nproc " `nproc`
|
||||
pwd
|
||||
ls
|
||||
env | sort
|
||||
|
||||
if [[ `uname -s` == "Linux" ]] ; then
|
||||
head -40 /proc/cpuinfo
|
||||
elif [[ $ARCH == macosx ]] ; then
|
||||
elif [[ ${RUNNER_OS} == "macOS" ]] ; then
|
||||
sysctl machdep.cpu.features
|
||||
fi
|
||||
|
||||
|
||||
@@ -8,12 +8,26 @@
|
||||
# any command in it fails. This is crucial for CI tests.
|
||||
set -ex
|
||||
|
||||
: ${CTEST_EXCLUSIONS:="broken"}
|
||||
: ${CTEST_TEST_TIMEOUT:=60}
|
||||
|
||||
$OSL_ROOT/bin/testshade --help
|
||||
|
||||
echo "Parallel test " ${CTEST_PARALLEL_LEVEL}
|
||||
pushd build/$PLATFORM
|
||||
time ctest -C ${CMAKE_BUILD_TYPE} -E broken --force-new-ctest-process \
|
||||
--output-on-failure --timeout ${CTEST_TEST_TIMEOUT:=240} ${CTEST_ARGS}
|
||||
echo "Parallel test ${CTEST_PARALLEL_LEVEL}"
|
||||
echo "Default timeout ${CTEST_TEST_TIMEOUT}"
|
||||
echo "Test exclusions '${CTEST_EXCLUSIONS}'"
|
||||
echo "CTEST_ARGS '${CTEST_ARGS}'"
|
||||
|
||||
pushd build
|
||||
|
||||
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process --output-on-failure \
|
||||
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS} \
|
||||
|| \
|
||||
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process \
|
||||
--rerun-failed --repeat until-pass:5 -R render --output-on-failure \
|
||||
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS}
|
||||
# The weird construct above allows the render-* tests to run multiple times
|
||||
|
||||
popd
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ from __future__ import print_function, absolute_import
|
||||
###
|
||||
### Only one main doc region will be output by the `docdeep` program,
|
||||
### specified with the `-d` command line argument. Any other doc-regions
|
||||
### will not be included in the documention output of that run.
|
||||
### will not be included in the documentation output of that run.
|
||||
###
|
||||
### However, one doc-region may *include* the text of another doc-region
|
||||
### as follows:
|
||||
@@ -114,7 +114,7 @@ from __future__ import print_function, absolute_import
|
||||
### For pre-code comments, the contiguous comment region associated with
|
||||
### a declaration immediately precedes the declaration. Such a comment
|
||||
### set has its first line start with `///>`. For post-code comments,
|
||||
### the documentaiton comments follows the code declaration, and this is
|
||||
### the documentation comments follows the code declaration, and this is
|
||||
### designated by having its first line start with `///<`. I like to
|
||||
### just remember that the `<` or `>` points in the direction of the code
|
||||
### declaration that the comment applies to.
|
||||
|
||||
Binary file not shown.
@@ -19,9 +19,44 @@ if [[ "$ASWF_ORG" != "" ]] ; then
|
||||
#ls /etc/yum.repos.d
|
||||
|
||||
sudo yum install -y giflib giflib-devel && true
|
||||
sudo yum install -y opencv opencv-devel && true
|
||||
sudo yum install -y Field3D Field3D-devel && true
|
||||
sudo yum install -y ffmpeg ffmpeg-devel && true
|
||||
# sudo yum install -y ffmpeg ffmpeg-devel && true
|
||||
|
||||
if [[ "${CONAN_LLVM_VERSION}" != "" ]] ; then
|
||||
mkdir conan
|
||||
pushd conan
|
||||
# Simple way to conan install just one package:
|
||||
# conan install clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1 -g deploy -g virtualenv
|
||||
# But the below method can accommodate multiple requirements:
|
||||
echo "[imports]" >> conanfile.txt
|
||||
echo "., * -> ." >> conanfile.txt
|
||||
echo "[requires]" >> conanfile.txt
|
||||
echo "clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1" >> conanfile.txt
|
||||
time conan install .
|
||||
echo "--ls--"
|
||||
ls -R .
|
||||
export PATH=$PWD/bin:$PATH
|
||||
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
|
||||
export LLVM_ROOT=$PWD
|
||||
popd
|
||||
fi
|
||||
|
||||
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
|
||||
sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d
|
||||
sudo yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2022.1.0-3768
|
||||
# Because multiple (possibly newer) versions of oneAPI may be installed,
|
||||
# use a config file to specify compiler and tbb versions
|
||||
# NOTE: oneAPI components have independent version numbering.
|
||||
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
|
||||
|
||||
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then
|
||||
echo "Verifying installation of Intel(r) C++ Compiler:"
|
||||
icpc --version
|
||||
fi
|
||||
if [[ "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
|
||||
echo "Verifying installation of Intel(r) oneAPI DPC++/C++ Compiler:"
|
||||
icpx --version
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
# Using native Ubuntu runner
|
||||
@@ -31,21 +66,30 @@ else
|
||||
|
||||
time sudo apt-get -q install -y \
|
||||
git cmake ninja-build ccache g++ \
|
||||
libboost-dev libboost-thread-dev \
|
||||
libboost-filesystem-dev libboost-regex-dev \
|
||||
libboost-dev libboost-thread-dev libboost-filesystem-dev \
|
||||
libilmbase-dev libopenexr-dev \
|
||||
python-dev python-numpy \
|
||||
libtiff-dev libgif-dev libpng-dev \
|
||||
flex bison libbison-dev \
|
||||
libpugixml-dev \
|
||||
libopencolorio-dev \
|
||||
qt5-default
|
||||
libopencolorio-dev
|
||||
|
||||
time sudo apt-get -q install -y \
|
||||
qt5-default || /bin/true
|
||||
|
||||
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH
|
||||
|
||||
if [[ "$CXX" == "g++-4.8" ]] ; then
|
||||
time sudo apt-get install -y g++-4.8
|
||||
elif [[ "$CXX" == "g++-6" ]] ; then
|
||||
# Nonstandard python versions
|
||||
if [[ "${PYTHON_VERSION}" == "3.9" ]] ; then
|
||||
time sudo apt-get -q install -y python3.9-dev python3-numpy
|
||||
pip3 --version
|
||||
pip3 install numpy
|
||||
elif [[ "$PYTHON_VERSION" == "2.7" ]] ; then
|
||||
time sudo apt-get -q install -y python-dev python-numpy
|
||||
else
|
||||
pip3 install numpy
|
||||
fi
|
||||
|
||||
if [[ "$CXX" == "g++-6" ]] ; then
|
||||
time sudo apt-get install -y g++-6
|
||||
elif [[ "$CXX" == "g++-7" ]] ; then
|
||||
time sudo apt-get install -y g++-7
|
||||
@@ -57,6 +101,20 @@ else
|
||||
time sudo apt-get install -y g++-10
|
||||
elif [[ "$CXX" == "g++-11" ]] ; then
|
||||
time sudo apt-get install -y g++-11
|
||||
elif [[ "$CXX" == "g++-12" ]] ; then
|
||||
time sudo apt-get install -y g++-12
|
||||
fi
|
||||
|
||||
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
|
||||
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
|
||||
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
|
||||
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
|
||||
time sudo apt-get update
|
||||
time sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic=2022.1.0-3768
|
||||
# Because multiple (possibly newer) versions of oneAPI may be installed,
|
||||
# use a config file to specify compiler and tbb versions
|
||||
# NOTE: oneAPI components have independent version numbering.
|
||||
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
|
||||
fi
|
||||
|
||||
source src/build-scripts/build_llvm.bash
|
||||
@@ -95,20 +153,30 @@ fi
|
||||
# fi
|
||||
|
||||
if [[ "$OPENCOLORIO_VERSION" != "" ]] ; then
|
||||
# Temporary (?) fix: GH ninja having problems, fall back to make
|
||||
CMAKE_GENERATOR="Unix Makefiles" \
|
||||
source src/build-scripts/build_opencolorio.bash
|
||||
fi
|
||||
|
||||
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then
|
||||
# There are many parts of OIIO we don't need to build
|
||||
# There are many parts of OIIO we don't need to build for OSL's tests
|
||||
export ENABLE_iinfo=0 ENABLE_iv=0 ENABLE_igrep=0
|
||||
export ENABLE_iconvert=0 ENABLE_testtex=0
|
||||
# For speed of compiling OIIO, disable the file formats that we don't
|
||||
# need for OSL's tests
|
||||
export ENABLE_BMP=0 ENABLE_cineon=0 ENABLE_DDS=0 ENABLE_DPX=0 ENABLE_FITS=0
|
||||
export ENABLE_ICO=0 ENABLE_iff=0 ENABLE_jpeg2000=0 ENABLE_PNM=0 ENABLE_PSD=0
|
||||
export ENABLE_RLA=0 ENABLE_SGI=0 ENABLE_SOCKET=0 ENABLE_SOFTIMAGE=0
|
||||
export ENABLE_TARGA=0 ENABLE_WEBP=0
|
||||
export OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0"
|
||||
# We don't need to run OIIO's tests
|
||||
export OPENIMAGEIO_CMAKE_FLAGS+=" -DOIIO_BUILD_TESTING=OFF -DOIIO_BUILD_TESTS=0"
|
||||
# Don't let warnings in OIIO break OSL's CI run
|
||||
export OPENIMAGEIO_CMAKE_FLAGS+=" -DSTOP_ON_WARNING=OFF"
|
||||
export OPENIMAGEIO_CMAKE_FLAGS+=" -DUSE_OPENGL=0"
|
||||
if [[ $OPENIMAGEIO_VERSION == master && "${OPENIMAGEIO_UNITY:-1}" != "0" ]] ; then
|
||||
# Speed up the OIIO build by doing a "unity" build. (Note: this is
|
||||
# only a savings in CI where there are only 1-2 cores available, and
|
||||
# is only supported for OIIO 2.3.14 and later)
|
||||
export OPENIMAGEIO_CMAKE_FLAGS+=" -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_MODE=BATCH"
|
||||
fi
|
||||
source src/build-scripts/build_openimageio.bash
|
||||
fi
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
# DEP_DIR="$PWD/ext/dist"
|
||||
DEP_DIR="$PWD/dist/$PLATFORM"
|
||||
DEP_DIR="$PWD/dist"
|
||||
mkdir -p "$DEP_DIR"
|
||||
INT_DIR="build/$PLATFORM"
|
||||
INT_DIR="build"
|
||||
VCPKG_INSTALLATION_ROOT=/c/vcpkg
|
||||
|
||||
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:=.}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
# This script, which assumes it is runnign on a Mac OSX with Homebrew
|
||||
# This script, which assumes it is running on a Mac OSX with Homebrew
|
||||
# installed, does a "brew install" in all packages reasonably needed by
|
||||
# OSL and its dependencies.
|
||||
|
||||
@@ -20,20 +20,24 @@ if [[ `which brew` == "" ]] ; then
|
||||
fi
|
||||
|
||||
|
||||
#brew update >/dev/null
|
||||
if [[ "$DO_BREW_UPDATE" != "" ]] ; then
|
||||
brew update >/dev/null
|
||||
fi
|
||||
echo ""
|
||||
echo "Before my brew installs:"
|
||||
brew list --versions
|
||||
|
||||
brew install --display-times -q gcc ccache cmake ninja boost || true
|
||||
brew link --overwrite gcc
|
||||
brew install --display-times -q python@${PYTHON_VERSION} || true
|
||||
brew unlink python@2.7 || true
|
||||
brew unlink python@3.9 || true
|
||||
brew unlink python@3.8 || true
|
||||
brew unlink python@3.9 || true
|
||||
brew unlink python@3.10 || true
|
||||
brew link --overwrite --force python@${PYTHON_VERSION} || true
|
||||
brew upgrade --display-times -q cmake || true
|
||||
brew install --display-times -q libtiff ilmbase openexr
|
||||
brew install --display-times -q libpng giflib webp jpeg-turbo freetype
|
||||
brew install --display-times -q ilmbase openexr
|
||||
#brew install --display-times -q freetype
|
||||
brew install --display-times -q opencolorio partio pugixml
|
||||
brew install --display-times -q pybind11 numpy || true
|
||||
brew install --display-times -q tbb || true
|
||||
@@ -57,7 +61,7 @@ fi
|
||||
export PATH=/usr/local/opt/qt5/bin:$PATH
|
||||
export PATH=/usr/local/opt/python/libexec/bin:$PATH
|
||||
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
|
||||
export PATH=/usr/local/opt/llvm${LLVMBREWVER}/bin:$PATH
|
||||
# export PATH=/usr/local/opt/llvm${LLVMBREWVER}/bin:$PATH
|
||||
export LLVM_DIRECTORY=/usr/local/opt/llvm${LLVMBREWVER}
|
||||
export LLVM_ROOT=/usr/local/opt/llvm${LLVMBREWVER}
|
||||
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
leak:Imf_2_2
|
||||
leak:Imf_2_3
|
||||
leak:Imf_2_4
|
||||
leak:libIlmImf
|
||||
leak:oslgram.y
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[oneAPI]
|
||||
name=Intel® oneAPI repository
|
||||
baseurl=https://yum.repos.intel.com/oneapi
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
repo_gpgcheck=1
|
||||
gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
|
||||
@@ -0,0 +1,3 @@
|
||||
default=exclude
|
||||
compiler=2022.1.0
|
||||
tbb=2021.6.0
|
||||
Regular → Executable
+1
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
@@ -8,7 +8,7 @@ include(CMakeFindDependencyMacro)
|
||||
|
||||
# add here all the find_dependency() whenever switching to config based dependencies
|
||||
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 3.0)
|
||||
find_dependency(Imath @OpenEXR_VERSION@)
|
||||
find_dependency(Imath @Imath_VERSION@)
|
||||
elseif (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.4 AND @FOUND_OPENEXR_WITH_CONFIG@)
|
||||
find_dependency(IlmBase @OpenEXR_VERSION@)
|
||||
find_dependency(OpenEXR @OpenEXR_VERSION@)
|
||||
@@ -19,9 +19,16 @@ endif ()
|
||||
|
||||
find_dependency(OpenImageIO @OpenImageIO_VERSION@ REQUIRED)
|
||||
|
||||
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
|
||||
set_and_check (@PROJECT_NAME@_INCLUDES "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
|
||||
set_and_check (@PROJECT_NAME@_LIB_DIR "@CMAKE_INSTALL_FULL_LIBDIR@")
|
||||
# Compute the installation prefix relative to this file
|
||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
|
||||
|
||||
# There's no guarantee that CMAKE_INSTALL_XXXDIR is a relative path so we extract the final component to handle absolute paths
|
||||
get_filename_component(_INCLUDE_DIR_NAME "@CMAKE_INSTALL_INCLUDEDIR@" NAME)
|
||||
get_filename_component(_LIB_DIR_NAME "@CMAKE_INSTALL_LIBDIR@" NAME)
|
||||
|
||||
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
|
||||
set_and_check (@PROJECT_NAME@_INCLUDES "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
|
||||
set_and_check (@PROJECT_NAME@_LIB_DIR "${_IMPORT_PREFIX}/${_LIB_DIR_NAME}")
|
||||
|
||||
#...logic to determine installedPrefix from the own location...
|
||||
#set (@PROJECT_NAME@_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Copyright 2008-present Contributors to the OpenImageIO project.
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
# Is the named package "enabled" via our disabling convention? If either
|
||||
# USE_pkgname (or the all-uppercase USE_PKGNAME, or ENABLE_pkgname, or
|
||||
|
||||
@@ -3,10 +3,27 @@
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
|
||||
set (REQUIED_DEPS "" CACHE STRING
|
||||
set (REQUIRED_DEPS "" CACHE STRING
|
||||
"Additional dependencies to consider required (semicolon-separated list, or ALL)")
|
||||
set (OPTIONAL_DEPS "" CACHE STRING
|
||||
"Additional dependencies to consider optional (semicolon-separated list, or ALL)")
|
||||
option (ALWAYS_PREFER_CONFIG "Prefer a dependency's exported config file if it's available" OFF)
|
||||
|
||||
|
||||
# Utility function to list the names and values of all variables matching
|
||||
# the pattern (case-insensitive)
|
||||
function (dump_matching_variables pattern)
|
||||
string (TOLOWER ${pattern} _pattern_lower)
|
||||
get_cmake_property(_allvars VARIABLES)
|
||||
list (SORT _allvars)
|
||||
foreach (_var IN LISTS _allvars)
|
||||
string (TOLOWER ${_var} _var_lower)
|
||||
if (_var_lower MATCHES ${_pattern_lower})
|
||||
message (STATUS " ${_var} = ${${_var}}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endfunction ()
|
||||
|
||||
|
||||
|
||||
# checked_find_package(Pkgname ...) is a wrapper for find_package, with the
|
||||
@@ -20,8 +37,11 @@ set (OPTIONAL_DEPS "" CACHE STRING
|
||||
# turned off explicitly from one of these sources.
|
||||
# * Print a message if the package is enabled but not found. This is based
|
||||
# on ${Pkgname}_FOUND or $PKGNAME_FOUND.
|
||||
# * Optional DEFINITIONS <string> are passed to add_definitions if the
|
||||
# * Optional DEFINITIONS <string>... are passed to add_definitions if the
|
||||
# package is found.
|
||||
# * Optional SETVARIABLES <id>... is a list of CMake variables to set to
|
||||
# TRUE if the package is found (they will not be set or changed if the
|
||||
# package is not found).
|
||||
# * Optional PRINT <list> is a list of variables that will be printed
|
||||
# if the package is found, if VERBOSE is on.
|
||||
# * Optional DEPS <list> is a list of hard dependencies; for each one, if
|
||||
@@ -42,6 +62,10 @@ set (OPTIONAL_DEPS "" CACHE STRING
|
||||
# version, accepting but warning if it is below this number (even
|
||||
# if above the true minimum version accepted). The warning message
|
||||
# can give an optional explanation, passed as RECOMMEND_MIN_REASON.
|
||||
# * Optional PREFER_CONFIG, if supplied, tries to use an exported config
|
||||
# file from the package before using a FindPackage.cmake module.
|
||||
# * Optional DEBUG turns on extra debugging information related to how
|
||||
# this package is found.
|
||||
#
|
||||
# N.B. This needs to be a macro, not a function, because the find modules
|
||||
# will set(blah val PARENT_SCOPE) and we need that to be the global scope,
|
||||
@@ -49,16 +73,20 @@ set (OPTIONAL_DEPS "" CACHE STRING
|
||||
macro (checked_find_package pkgname)
|
||||
cmake_parse_arguments(_pkg # prefix
|
||||
# noValueKeywords:
|
||||
"REQUIRED"
|
||||
"REQUIRED;PREFER_CONFIG;DEBUG"
|
||||
# singleValueKeywords:
|
||||
"ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON"
|
||||
# multiValueKeywords:
|
||||
"DEFINITIONS;PRINT;DEPS"
|
||||
"DEFINITIONS;PRINT;DEPS;SETVARIABLES"
|
||||
# argsToParse:
|
||||
${ARGN})
|
||||
string (TOLOWER ${pkgname} pkgname_lower)
|
||||
string (TOUPPER ${pkgname} pkgname_upper)
|
||||
if (NOT VERBOSE)
|
||||
set (_pkg_VERBOSE ${VERBOSE})
|
||||
if (_pkg_DEBUG)
|
||||
set (_pkg_VERBOSE ON)
|
||||
endif ()
|
||||
if (NOT _pkg_VERBOSE)
|
||||
set (${pkgname}_FIND_QUIETLY true)
|
||||
set (${pkgname_upper}_FIND_QUIETLY true)
|
||||
endif ()
|
||||
@@ -85,8 +113,19 @@ macro (checked_find_package pkgname)
|
||||
set (_quietskip true)
|
||||
endif ()
|
||||
endif ()
|
||||
set (_config_status "")
|
||||
if (_enable OR _pkg_REQUIRED)
|
||||
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
|
||||
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
|
||||
# was already found
|
||||
elseif (_pkg_PREFER_CONFIG OR ALWAYS_PREFER_CONFIG)
|
||||
find_package (${pkgname} CONFIG ${_pkg_UNPARSED_ARGUMENTS})
|
||||
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
|
||||
set (_config_status "from CONFIG")
|
||||
endif ()
|
||||
endif ()
|
||||
if (NOT (${pkgname}_FOUND OR ${pkgname_upper}_FOUND))
|
||||
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
|
||||
endif()
|
||||
if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
|
||||
AND ${pkgname}_VERSION
|
||||
AND (_pkg_VERSION_MIN OR _pkg_VERSION_MAX))
|
||||
@@ -106,21 +145,11 @@ macro (checked_find_package pkgname)
|
||||
set (${pkgname}_VERSION ${${_vervar}})
|
||||
endif ()
|
||||
endforeach ()
|
||||
message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${ColorReset}")
|
||||
if (VERBOSE)
|
||||
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
|
||||
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
|
||||
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
|
||||
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
|
||||
${_pkg_PRINT})
|
||||
list (REMOVE_DUPLICATES _vars_to_print)
|
||||
foreach (_v IN LISTS _vars_to_print)
|
||||
if (NOT "${${_v}}" STREQUAL "")
|
||||
message (STATUS " ${_v} = ${${_v}}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${_config_status}${ColorReset}")
|
||||
add_definitions (${_pkg_DEFINITIONS})
|
||||
foreach (_v IN LISTS _pkg_SETVARIABLES)
|
||||
set (${_v} TRUE)
|
||||
endforeach ()
|
||||
if (_pkg_RECOMMEND_MIN)
|
||||
if (${${pkgname}_VERSION} VERSION_LESS ${_pkg_RECOMMEND_MIN})
|
||||
message (STATUS "${ColorYellow}Recommend ${pkgname} >= ${_pkg_RECOMMEND_MIN} ${_pkg_RECOMMEND_MIN_REASON} ${ColorReset}")
|
||||
@@ -148,6 +177,22 @@ macro (checked_find_package pkgname)
|
||||
message (FATAL_ERROR "${ColorRed}${pkgname} is required, aborting.${ColorReset}")
|
||||
endif ()
|
||||
endif()
|
||||
if (_pkg_VERBOSE AND (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_DEBUG))
|
||||
if (_pkg_DEBUG)
|
||||
dump_matching_variables (${pkgname})
|
||||
endif ()
|
||||
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
|
||||
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
|
||||
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
|
||||
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
|
||||
${_pkg_PRINT})
|
||||
list (REMOVE_DUPLICATES _vars_to_print)
|
||||
foreach (_v IN LISTS _vars_to_print)
|
||||
if (NOT "${${_v}}" STREQUAL "")
|
||||
message (STATUS " ${_v} = ${${_v}}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
else ()
|
||||
if (NOT _quietskip)
|
||||
message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Copyright 2008-present Contributors to the OpenImageIO project.
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
|
||||
# Define color codes for pretty terminal output
|
||||
|
||||
+108
-91
@@ -28,10 +28,12 @@ message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
|
||||
# C++ language standard
|
||||
#
|
||||
set (CMAKE_CXX_STANDARD 14 CACHE STRING
|
||||
"C++ standard to prefer (14, 17, 20, etc.)")
|
||||
"C++ standard to build with (14, 17, 20, etc.)")
|
||||
set (DOWNSTREAM_CXX_STANDARD 14 CACHE STRING
|
||||
"C++ minimum standard to impose on downstream clients")
|
||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set (CMAKE_CXX_EXTENSIONS OFF)
|
||||
message (STATUS "Building for C++${CMAKE_CXX_STANDARD}")
|
||||
message (STATUS "Building with C++${CMAKE_CXX_STANDARD}, downstream minimum C++${DOWNSTREAM_CXX_STANDARD}")
|
||||
|
||||
|
||||
###########################################################################
|
||||
@@ -49,7 +51,8 @@ else ()
|
||||
set (GCC_VERSION 0)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang"
|
||||
OR CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
|
||||
# If using any flavor of clang, set CMAKE_COMPILER_IS_CLANG. If it's
|
||||
# Apple's variety, set CMAKE_COMPILER_IS_APPLECLANG and
|
||||
# APPLECLANG_VERSION_STRING, otherwise for generic clang set
|
||||
@@ -63,6 +66,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
|
||||
if (VERBOSE)
|
||||
message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
|
||||
endif ()
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
|
||||
set (CMAKE_COMPILER_IS_INTELCLANG 1)
|
||||
string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string})
|
||||
if (VERBOSE)
|
||||
message (STATUS "The compiler is Intel Clang: ${CMAKE_CXX_COMPILER_ID} version ${INTELCLANG_VERSION_STRING}")
|
||||
endif ()
|
||||
else ()
|
||||
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
|
||||
if (VERBOSE)
|
||||
@@ -80,17 +89,23 @@ endif ()
|
||||
###########################################################################
|
||||
# Turn on more detailed warnings and optionally consider warnings as errors
|
||||
#
|
||||
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
|
||||
if (NOT ${PROJECT_NAME}_SUPPORTED_RELEASE OR DEFINED ENV{${PROJECT_NAME}_CI})
|
||||
# For development branches (i.e., not a supported release), or when
|
||||
# running CI, default to treating all warnings as errors.
|
||||
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
|
||||
else ()
|
||||
# For release branches not doing a CI build default to just printing
|
||||
# warnings but not letting them stop the build.
|
||||
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" OFF)
|
||||
endif()
|
||||
option (EXTRA_WARNINGS "Enable lots of extra pedantic warnings" OFF)
|
||||
if (NOT MSVC)
|
||||
add_compile_options ("-Wall")
|
||||
if (EXTRA_WARNINGS)
|
||||
add_compile_options ("-Wextra")
|
||||
endif ()
|
||||
if (STOP_ON_WARNING OR DEFINED ENV{CI})
|
||||
if (STOP_ON_WARNING)
|
||||
add_compile_options ("-Werror")
|
||||
# N.B. Force CI builds to use -Werror, even if STOP_ON_WARNING has
|
||||
# been switched off by default, which we may do in release branches.
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
@@ -110,7 +125,7 @@ set (CXX_VISIBILITY_PRESET "hidden" CACHE STRING "Symbol visibility (hidden or d
|
||||
option (VISIBILITY_INLINES_HIDDEN "Hide symbol visibility of inline functions" ON)
|
||||
set (VISIBILITY_MAP_FILE "${PROJECT_SOURCE_DIR}/src/build-scripts/hidesymbols.map" CACHE FILEPATH "Visibility map file")
|
||||
set (C_VISIBILITY_PRESET ${CXX_VISIBILITY_PRESET})
|
||||
if (${CXX_VISIBILITY_PRESET} STREQUAL "hidden" AND
|
||||
if (${CXX_VISIBILITY_PRESET} STREQUAL "hidden" AND VISIBILITY_MAP_FILE AND
|
||||
(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND
|
||||
(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU"))
|
||||
# Linux/FreeBSD/Hurd: also hide all the symbols of dependent libraries
|
||||
@@ -144,9 +159,16 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
|
||||
add_compile_options ("-Wno-unused-local-typedefs")
|
||||
endif ()
|
||||
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.9)
|
||||
# Don't warn about using unknown preprocessor symbols in #if'set
|
||||
# Don't warn about using unknown preprocessor symbols in `#if`
|
||||
add_compile_options ("-Wno-expansion-to-defined")
|
||||
endif ()
|
||||
# Suppress warnings about our strategic use of bitwise operations in place
|
||||
# of logical operators to produce branchless code in some places.
|
||||
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0
|
||||
OR INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0)
|
||||
add_compile_options ("-Wno-bitwise-instead-of-logical")
|
||||
endif ()
|
||||
|
||||
# disable warning in flex-generated code
|
||||
add_compile_options ("-Wno-null-conversion")
|
||||
add_compile_options ("-Wno-error=strict-overflow")
|
||||
@@ -174,6 +196,11 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
add_compile_options ("-fno-math-errno")
|
||||
endif ()
|
||||
|
||||
if (INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 2022.1.0)
|
||||
# New versions of icx warn about changing certain floating point options
|
||||
add_compile_options ("-Wno-overriding-t-option")
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
# Microsoft specific options
|
||||
string (REGEX REPLACE "/W[1-4]" "/W1" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
@@ -191,6 +218,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
|
||||
endif ()
|
||||
|
||||
|
||||
# Remember the -std flags we need will be used later for custom Cuda builds
|
||||
set (CSTD_FLAGS "")
|
||||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_INTEL)
|
||||
set (CSTD_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
|
||||
@@ -198,6 +226,10 @@ endif ()
|
||||
|
||||
|
||||
|
||||
# We will use this for ccache and timing
|
||||
set (MY_RULE_LAUNCH "")
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Use ccache if found
|
||||
#
|
||||
@@ -211,12 +243,30 @@ if (CCACHE_FOUND AND USE_CCACHE)
|
||||
if (CMAKE_COMPILER_IS_CLANG AND USE_QT AND (NOT DEFINED ENV{CCACHE_CPP2}))
|
||||
message (STATUS "Ignoring ccache because clang + Qt + env CCACHE_CPP2 is not set")
|
||||
else ()
|
||||
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
set (MY_RULE_LAUNCH ccache)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Build time debugging aid: time all compile & link commands
|
||||
#
|
||||
# Note, though, that this is not especially helpful when doing a parallel
|
||||
# build. If you wish to time individual compile commands, it's best to also
|
||||
# set `-j 1` or CMAKE_BUILD_PARALLEL_LEVEL to 1.
|
||||
option (TIME_COMMANDS "Time each compile and link command" OFF)
|
||||
if (TIME_COMMANDS)
|
||||
set (MY_RULE_LAUNCH "${CMAKE_COMMAND} -E time ${MY_RULE_LAUNCH}")
|
||||
endif ()
|
||||
|
||||
|
||||
# Note: This must be after any option that alters MY_RULE_LAUNCH
|
||||
if (MY_RULE_LAUNCH)
|
||||
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${MY_RULE_LAUNCH})
|
||||
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ${MY_RULE_LAUNCH})
|
||||
endif ()
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Option to force use of libc++ (the LLVM project's alternate C++ standard
|
||||
# library). Currently this only has an effect if using clang as the
|
||||
@@ -289,6 +339,7 @@ endif ()
|
||||
# The USE_BATCHED option may be set to indicate that support for batched
|
||||
# SIMD shader execution be compiled along with targe specific libraries
|
||||
set (USE_BATCHED "" CACHE STRING "Build batched SIMD shader execution for (0, b8_AVX, b8_AVX2, b8_AVX2_noFMA, b8_AVX512, b8_AVX512_noFMA, b16_AVX512, b16_AVX512_noFMA)")
|
||||
option (VEC_REPORT "Enable compiler's reporting system for vectorization" OFF)
|
||||
set (BATCHED_SUPPORT_DEFINES "")
|
||||
set (BATCHED_TARGET_LIBS "")
|
||||
set (BUILD_BATCHED False)
|
||||
@@ -325,11 +376,9 @@ include (CheckCXXSourceRuns)
|
||||
option (CODECOV "Build code coverage tests" OFF)
|
||||
if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
|
||||
message (STATUS "Compiling for code coverage analysis")
|
||||
add_compile_options ("-ftest-coverage -fprofile-arcs -O0")
|
||||
add_compile_options (-ftest-coverage -fprofile-arcs)
|
||||
add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
|
||||
link_libraries(gcov)
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -343,22 +392,9 @@ if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
|
||||
foreach (feature ${SANITIZE_FEATURE_LIST})
|
||||
message (STATUS " sanitize feature: ${feature}")
|
||||
add_compile_options (-fsanitize=${feature})
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${feature}")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=${feature}")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${feature}")
|
||||
add_link_options (-fsanitize=${feature})
|
||||
endforeach()
|
||||
add_compile_options (-g -fno-omit-frame-pointer)
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set (SANITIZE_ON_LINUX 1)
|
||||
endif ()
|
||||
if (CMAKE_COMPILER_IS_GNUCC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
add_compile_options ("-fuse-ld=gold")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
|
||||
set (SANITIZE_LIBRARIES "asan;pthread")
|
||||
# set (SANITIZE_LIBRARIES "asan" "ubsan")
|
||||
endif()
|
||||
if (CMAKE_COMPILER_IS_GNUCC)
|
||||
# turn on glibcxx extra annotations to find vector writes past end
|
||||
add_definitions ("-D_GLIBCXX_SANITIZE_VECTOR=1")
|
||||
@@ -420,66 +456,46 @@ endif ()
|
||||
# correct any deviations. If clang-format is found on the system, a
|
||||
# "clang-format" build target will trigger a reformatting.
|
||||
#
|
||||
set (CLANG_FORMAT_EXE_HINT "" CACHE PATH "clang-format executable's directory (will search if not specified")
|
||||
set (CLANG_FORMAT_INCLUDES # "src/*.h" "src/*.cpp"
|
||||
"src/include/*.h"
|
||||
"src/liboslcomp/*.cpp"
|
||||
"src/liboslcomp/*.h"
|
||||
"src/liboslexec/batched_rendservices.cpp"
|
||||
"src/liboslquery/*.cpp"
|
||||
"src/liboslquery/*.h"
|
||||
"src/oslinfo/*.cpp"
|
||||
"src/oslc/*.cpp"
|
||||
"src/osl.imageio/*.cpp"
|
||||
"src/osltoy/*.cpp"
|
||||
"src/osltoy/*.h"
|
||||
"testsuite/*.cpp"
|
||||
CACHE STRING "Glob patterns to include for clang-format")
|
||||
set (CLANG_FORMAT_EXCLUDES
|
||||
# Files "imported and modified" that we don't want to reformat, so
|
||||
# they continue to match their upstream versions.
|
||||
"src/include/OSL/Imathx/*"
|
||||
"src/include/OSL/matrix22.h"
|
||||
# Files that are currently being modified with the SIMD batch
|
||||
# shading -- we'll reformat those only after that project work is
|
||||
# completed, to avoid nasty merge conflicts.
|
||||
"src/include/OSL/rendererservices.h"
|
||||
"src/include/OSL/*llvm*"
|
||||
"src/liboslexec/*llvm*"
|
||||
"src/liboslexec/oslexec_pvt.h"
|
||||
# Files that are currently being modified with the OptiX work --
|
||||
# we'll reformat those only after that project work is completed, to
|
||||
# avoid nasty merge conflicts.
|
||||
"src/include/OSL/device_string.h"
|
||||
"src/include/OSL/oslexec.h"
|
||||
"src/testrender/cuda/*"
|
||||
# Header files in testsuite are almost certainly osl headers, not C++
|
||||
"testsuite/*.h"
|
||||
""
|
||||
CACHE STRING "Glob patterns to exclude for clang-format")
|
||||
find_program (CLANG_FORMAT_EXE
|
||||
NAMES clang-format bin/clang-format
|
||||
HINTS ${CLANG_FORMAT_EXE_HINT} ENV CLANG_FORMAT_EXE_HINT
|
||||
ENV LLVM_DIRECTORY
|
||||
NO_DEFAULT_PATH
|
||||
DOC "Path to clang-format executable")
|
||||
find_program (CLANG_FORMAT_EXE NAMES clang-format bin/clang-format)
|
||||
if (CLANG_FORMAT_EXE)
|
||||
message (STATUS "clang-format found: ${CLANG_FORMAT_EXE}")
|
||||
# Start with the list of files to include when formatting...
|
||||
file (GLOB_RECURSE FILES_TO_FORMAT ${CLANG_FORMAT_INCLUDES})
|
||||
# ... then process any list of excludes we are given
|
||||
foreach (_pat ${CLANG_FORMAT_EXCLUDES})
|
||||
file (GLOB_RECURSE _excl ${_pat})
|
||||
list (REMOVE_ITEM FILES_TO_FORMAT ${_excl})
|
||||
endforeach ()
|
||||
# message (STATUS "clang-format file list: ${FILES_TO_FORMAT}")
|
||||
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_custom_target (clang-format
|
||||
COMMAND "${CLANG_FORMAT_EXE}" -i -style=file ${FILES_TO_FORMAT} )
|
||||
else ()
|
||||
message (STATUS "clang-format not found.")
|
||||
# Note: skip all of this checking, setup, and cmake-format target if this
|
||||
# is being built as a subproject.
|
||||
if (PROJECT_IS_TOP_LEVEL)
|
||||
set (CLANG_FORMAT_EXE_HINT "" CACHE PATH "clang-format executable's directory (will search if not specified")
|
||||
set (CLANG_FORMAT_INCLUDES "src/*.cpp" "src/*.h" "src/*.cu"
|
||||
CACHE STRING "Glob patterns to include for clang-format")
|
||||
set (CLANG_FORMAT_EXCLUDES
|
||||
# Files "imported and modified" that we don't want to reformat, so
|
||||
# they continue to match their upstream versions.
|
||||
"src/include/OSL/Imathx/*"
|
||||
"src/include/OSL/matrix22.h"
|
||||
# Header files in testsuite are almost certainly osl headers, not C++
|
||||
"testsuite/*.h"
|
||||
# Header files in shaders are OSL, not C++
|
||||
"src/shaders/*.h"
|
||||
CACHE STRING "Glob patterns to exclude for clang-format")
|
||||
find_program (CLANG_FORMAT_EXE
|
||||
NAMES clang-format bin/clang-format
|
||||
HINTS ${CLANG_FORMAT_EXE_HINT} ENV CLANG_FORMAT_EXE_HINT
|
||||
ENV LLVM_DIRECTORY
|
||||
NO_DEFAULT_PATH
|
||||
DOC "Path to clang-format executable")
|
||||
find_program (CLANG_FORMAT_EXE NAMES clang-format bin/clang-format)
|
||||
if (CLANG_FORMAT_EXE)
|
||||
message (STATUS "clang-format found: ${CLANG_FORMAT_EXE}")
|
||||
# Start with the list of files to include when formatting...
|
||||
file (GLOB_RECURSE FILES_TO_FORMAT ${CLANG_FORMAT_INCLUDES})
|
||||
# ... then process any list of excludes we are given
|
||||
foreach (_pat ${CLANG_FORMAT_EXCLUDES})
|
||||
file (GLOB_RECURSE _excl ${_pat})
|
||||
list (REMOVE_ITEM FILES_TO_FORMAT ${_excl})
|
||||
endforeach ()
|
||||
# message (STATUS "clang-format file list: ${FILES_TO_FORMAT}")
|
||||
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_custom_target (clang-format
|
||||
COMMAND "${CLANG_FORMAT_EXE}" -i -style=file ${FILES_TO_FORMAT} )
|
||||
else ()
|
||||
message (STATUS "clang-format not found.")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -541,9 +557,10 @@ endif ()
|
||||
|
||||
###########################################################################
|
||||
# Any extra logic to be run only for CI builds goes here.
|
||||
# We expect our own CI runs to define env variable ${PROJECT_NAME}_CI
|
||||
#
|
||||
if (DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS})
|
||||
add_definitions ("-D${PROJ_NAME}_CI=1" "-DBUILD_CI=1")
|
||||
if (DEFINED ENV{${PROJECT_NAME}_CI})
|
||||
add_definitions (-D${PROJ_NAME}_CI=1 -DBUILD_CI=1)
|
||||
if (APPLE)
|
||||
# Keep Mono framework from being incorrectly searched for include
|
||||
# files on GitHub Actions CI.
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
set ($OSL_EXTRA_NVCC_ARGS "" CACHE STRING "Custom args passed to nvcc when compiling CUDA code")
|
||||
|
||||
# Compile a CUDA file to PTX using NVCC
|
||||
function ( NVCC_COMPILE cuda_src ptx_generated extra_nvcc_args )
|
||||
function ( NVCC_COMPILE cuda_src extra_headers ptx_generated extra_nvcc_args )
|
||||
get_filename_component ( cuda_src_we ${cuda_src} NAME_WE )
|
||||
get_filename_component ( cuda_src_dir ${cuda_src} DIRECTORY )
|
||||
set (cuda_ptx "${CMAKE_CURRENT_BINARY_DIR}/${cuda_src_we}.ptx" )
|
||||
set (${ptxlist} ${${ptxlist}} ${cuda_ptx} )
|
||||
set (${ptx_generated} ${cuda_ptx} PARENT_SCOPE)
|
||||
file ( GLOB cuda_headers "${cuda_src_dir}/*.h" )
|
||||
list (APPEND cuda_headers ${extra_headers})
|
||||
|
||||
list (TRANSFORM IMATH_INCLUDES PREPEND -I
|
||||
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
|
||||
@@ -79,6 +80,20 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
|
||||
message (STATUS "Using LLVM_BC_GENERATOR ${LLVM_BC_GENERATOR} to generate bitcode.")
|
||||
endif()
|
||||
|
||||
if (NOT LLVM_AS_TOOL)
|
||||
find_program (LLVM_AS_TOOL NAMES "llvm-as"
|
||||
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
|
||||
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
endif ()
|
||||
|
||||
if (NOT LLVM_LINK_TOOL)
|
||||
find_program (LLVM_LINK_TOOL NAMES "llvm-link"
|
||||
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
|
||||
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
# fix compilation error when using MSVC
|
||||
set (CLANG_MSVC_FIX "-DBOOST_CONFIG_REQUIRES_THREADS_HPP")
|
||||
@@ -114,7 +129,7 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
|
||||
-Wno-deprecated-register -Wno-format-security
|
||||
-O3 -fno-math-errno -ffast-math -S -emit-llvm ${extra_clang_args}
|
||||
${src} -o ${asm_cuda}
|
||||
COMMAND "${LLVM_DIRECTORY}/bin/llvm-as" -f -o ${bc_cuda} ${asm_cuda}
|
||||
COMMAND ${LLVM_AS_TOOL} -f -o ${bc_cuda} ${asm_cuda}
|
||||
DEPENDS ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
endfunction ()
|
||||
@@ -129,8 +144,8 @@ function ( LLVM_COMPILE_CUDA llvm_src headers prefix llvm_bc_cpp_generated extra
|
||||
MAKE_CUDA_BITCODE (${llvm_src} "" llvm_bc "${extra_clang_args}")
|
||||
|
||||
add_custom_command (OUTPUT ${llvm_bc_cpp}
|
||||
COMMAND python "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
|
||||
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
|
||||
MAIN_DEPENDENCY ${llvm_src}
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
endfunction ()
|
||||
|
||||
@@ -80,22 +80,18 @@ checked_find_package (ZLIB REQUIRED) # Needed by several packages
|
||||
|
||||
# IlmBase & OpenEXR
|
||||
checked_find_package (OpenEXR REQUIRED
|
||||
VERSION_MIN 2.0
|
||||
RECOMMEND_MIN 2.2
|
||||
VERSION_MIN 2.3
|
||||
RECOMMEND_MIN 2.4
|
||||
RECOMMEND_MIN_REASON
|
||||
"OpenEXR 2.2 is the oldest version our CI tests against, and the minimum that supports DWA compression"
|
||||
"Even extremely critical patches are no longer supplied to < 2.4"
|
||||
PRINT IMATH_INCLUDES
|
||||
)
|
||||
# Force Imath includes to be before everything else to ensure that we have
|
||||
# the right Imath/OpenEXR version, not some older version in the system
|
||||
# library. This shoudn't be necessary, except for the common case of people
|
||||
# library. This shouldn't be necessary, except for the common case of people
|
||||
# building against Imath/OpenEXR 3.x when there is still a system-level
|
||||
# install version of 2.x.
|
||||
include_directories(BEFORE ${IMATH_INCLUDES})
|
||||
if (CMAKE_COMPILER_IS_CLANG AND OPENEXR_VERSION VERSION_LESS 2.3)
|
||||
# clang C++ >= 11 doesn't like 'register' keyword in old exr headers
|
||||
add_compile_options (-Wno-deprecated-register)
|
||||
endif ()
|
||||
if (MSVC AND NOT LINKSTATIC)
|
||||
add_definitions (-DOPENEXR_DLL) # Is this needed for new versions?
|
||||
endif ()
|
||||
@@ -109,8 +105,8 @@ endif ()
|
||||
|
||||
# OpenImageIO
|
||||
checked_find_package (OpenImageIO REQUIRED
|
||||
VERSION_MIN 2.1.9)
|
||||
|
||||
VERSION_MIN 2.3.17
|
||||
DEFINITIONS -DOIIO_HIDE_FORMAT=1)
|
||||
|
||||
checked_find_package (pugixml REQUIRED
|
||||
VERSION_MIN 1.8)
|
||||
@@ -118,7 +114,7 @@ checked_find_package (pugixml REQUIRED
|
||||
|
||||
# LLVM library setup
|
||||
checked_find_package (LLVM REQUIRED
|
||||
VERSION_MIN 7.0
|
||||
VERSION_MIN 9.0
|
||||
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES)
|
||||
# ensure include directory is added (in case of non-standard locations
|
||||
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
|
||||
@@ -131,27 +127,23 @@ add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}")
|
||||
if (LLVM_NAMESPACE)
|
||||
add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}")
|
||||
endif ()
|
||||
if (LLVM_VERSION VERSION_GREATER_EQUAL 10.0.0 AND
|
||||
CMAKE_CXX_STANDARD VERSION_LESS 14)
|
||||
message (FATAL_ERROR
|
||||
"LLVM 10+ requires C++14 or higher (was ${CMAKE_CXX_STANDARD}). "
|
||||
"To build against this LLVM ${LLVM_VERSION}, you need to set "
|
||||
"build option CMAKE_CXX_STANDARD=14. The minimum requirements "
|
||||
"for that are gcc >= 5.1, clang >= 3.5, Apple clang >= 7, "
|
||||
"icc >= 7, MSVS >= 2017. "
|
||||
"If you must use C++11, you need to build against LLVM 9 or earlier.")
|
||||
endif ()
|
||||
if (APPLE AND LLVM_VERSION VERSION_EQUAL 10.0.1 AND EXISTS "/usr/local/Cellar/llvm")
|
||||
message (WARNING
|
||||
"${ColorYellow}If you are using LLVM 10.0.1 installed by Homebrew, "
|
||||
"please note that a known bug in LLVM may produce a link error where "
|
||||
"it says it can't find libxml2.tbd. If you encounter this, please "
|
||||
"try downgrading to LLVM 9: \n"
|
||||
" brew uninstall llvm \n"
|
||||
" brew install llvm@9 \n"
|
||||
" export LLVM_DIRECTORY=/usr/local/opt/llvm@9 "
|
||||
"try upgrading to a newer LLVM: \n"
|
||||
" brew upgrade llvm \n"
|
||||
"${ColorReset}\n")
|
||||
endif ()
|
||||
if (LLVM_VERSION VERSION_GREATER_EQUAL 15.0
|
||||
AND ( (CMAKE_COMPILER_IS_APPLECLANG AND APPLECLANG_VERSION_STRING VERSION_LESS 15.0)
|
||||
OR (CMAKE_COMPILER_IS_CLANG AND CLANG_VERSION_STRING VERSION_LESS 15.0)))
|
||||
message (WARNING
|
||||
"${ColorYellow}"
|
||||
"If you are using LLVM 15 or higher, you should also use clang version "
|
||||
"15 or higher, or you may get build errors.${ColorReset}\n")
|
||||
endif ()
|
||||
|
||||
checked_find_package (partio)
|
||||
|
||||
@@ -214,7 +206,7 @@ if (USE_CUDA OR USE_OPTIX)
|
||||
# OptiX setup
|
||||
if (USE_OPTIX)
|
||||
checked_find_package (OptiX REQUIRED
|
||||
VERSION_MIN 5.1)
|
||||
VERSION_MIN 7.0)
|
||||
include_directories (BEFORE "${OPTIX_INCLUDES}")
|
||||
if (NOT USE_LLVM_BITCODE OR NOT USE_FAST_MATH)
|
||||
message (FATAL_ERROR "Enabling OptiX requires USE_LLVM_BITCODE=1 and USE_FAST_MATH=1")
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
# The executable may be disabled individually using any of the usual
|
||||
# check_is_enabled() conventions (e.g. -DENABLE_<executable>=OFF).
|
||||
#
|
||||
# If -DENABLE_INSTALL_<executable>=OFF was specified, the target will be built
|
||||
# (in the build area) but will not be installed.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# fancy_add_executable ([ NAME targetname ... ]
|
||||
@@ -42,13 +45,16 @@ macro (fancy_add_executable)
|
||||
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
|
||||
endif ()
|
||||
if (_target_DEFINITIONS)
|
||||
target_compile_definitions (${_target_name} PRIVATE ${_target_DEFINITIONS})
|
||||
target_compile_definitions (${_target_NAME} PRIVATE ${_target_DEFINITIONS})
|
||||
endif ()
|
||||
if (_target_LINK_LIBRARIES)
|
||||
target_link_libraries (${_target_NAME} PRIVATE ${_target_LINK_LIBRARIES})
|
||||
endif ()
|
||||
set_target_properties (${_target_NAME} PROPERTIES FOLDER "Tools")
|
||||
install_targets (${_target_NAME})
|
||||
check_is_enabled (INSTALL_${_target_NAME} _target_NAME_INSTALL_enabled)
|
||||
if (_target_NAME_INSTALL_enabled)
|
||||
install_targets (${_target_NAME})
|
||||
endif ()
|
||||
else ()
|
||||
message (STATUS "${ColorRed}Disabling ${_target_NAME} ${ColorReset}")
|
||||
endif ()
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
|
||||
function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_cpp extra_clang_args)
|
||||
|
||||
if (VERBOSE)
|
||||
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP src_list=${src_list}")
|
||||
endif ()
|
||||
|
||||
foreach ( src ${src_list} )
|
||||
get_filename_component ( src_we ${src} NAME_WE )
|
||||
set ( src_asm "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.s" )
|
||||
set ( src_bc "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.bc" )
|
||||
if (VERBOSE)
|
||||
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP in=${src}")
|
||||
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP asm=${src_asm}")
|
||||
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP bc=${src_bc}")
|
||||
endif ()
|
||||
list ( APPEND src_bc_list ${src_bc} )
|
||||
|
||||
get_property (CURRENT_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
||||
if (VERBOSE)
|
||||
message (STATUS "Current #defines are ${CURRENT_DEFINITIONS}")
|
||||
endif ()
|
||||
foreach (def ${CURRENT_DEFINITIONS})
|
||||
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-D${def}")
|
||||
endforeach()
|
||||
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} ${SIMD_COMPILE_FLAGS} ${CSTD_FLAGS} ${TOOLCHAIN_FLAGS})
|
||||
# Avoid generating __dso_handle external global
|
||||
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-fno-use-cxa-atexit")
|
||||
|
||||
# Figure out what program we will use to make the bitcode.
|
||||
if (NOT LLVM_BC_GENERATOR)
|
||||
find_program (LLVM_BC_GENERATOR NAMES "clang++"
|
||||
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
|
||||
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
endif ()
|
||||
|
||||
if (NOT LLVM_BC_GENERATOR)
|
||||
message (FATAL_ERROR "You must have a valid llvm bitcode generator (clang++) somewhere.")
|
||||
endif ()
|
||||
if (VERBOSE)
|
||||
message (STATUS "Using LLVM_BC_GENERATOR ${LLVM_BC_GENERATOR} to generate bitcode.")
|
||||
endif()
|
||||
|
||||
if (NOT LLVM_AS_TOOL)
|
||||
find_program (LLVM_AS_TOOL NAMES "llvm-as"
|
||||
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
|
||||
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
endif ()
|
||||
|
||||
if (NOT LLVM_LINK_TOOL)
|
||||
find_program (LLVM_LINK_TOOL NAMES "llvm-link"
|
||||
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
|
||||
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
endif ()
|
||||
|
||||
|
||||
# Fix specific problem I had on new Apple systems (e.g. Mavericks) with
|
||||
# LLVM/libc++ installed -- for some reason, LLVM 3.4 wasn't finding it,
|
||||
# so in that specific case, append another -I to point it in the right
|
||||
# direction.
|
||||
#if (APPLE AND ${LLVM_BC_GENERATOR} MATCHES ".*clang.*")
|
||||
# exec_program ( "${LLVM_BC_GENERATOR}" ARGS --version OUTPUT_VARIABLE MY_CLANG_VERSION )
|
||||
# string (REGEX REPLACE "clang version ([0-9][.][0-9]+).*" "\\1" MY_CLANG_VERSION "${MY_CLANG_VERSION}")
|
||||
# if ((${MY_CLANG_VERSION} VERSION_GREATER "3.3")
|
||||
# AND (EXISTS "/usr/lib/libc++.dylib")
|
||||
# AND (EXISTS "/Library/Developer/CommandLineTools/usr/lib/c++/v1"))
|
||||
# set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-I/Library/Developer/CommandLineTools/usr/lib/c++/v1")
|
||||
# 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)
|
||||
|
||||
if (${LLVM_VERSION} VERSION_GREATER_EQUAL 15.0)
|
||||
# Until we fully support opaque pointers, we need to disable
|
||||
# them when using LLVM 15.
|
||||
list (APPEND LLVM_COMPILE_FLAGS -Xclang -no-opaque-pointers)
|
||||
endif ()
|
||||
|
||||
# Command to turn the .cpp file into LLVM assembly language .s, into
|
||||
# LLVM bitcode .bc, then back into a C++ file with the bc embedded!
|
||||
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}"
|
||||
-DOSL_COMPILING_TO_BITCODE=1
|
||||
-Wno-deprecated-register
|
||||
# the following 2 warnings can be restored when all 3rd parties have fixed their export macros
|
||||
# (dllimport attribute is not supported when compiling for Cuda and triggers a ton of warnings)
|
||||
-Wno-ignored-attributes -Wno-unknown-attributes
|
||||
-O3 -fno-math-errno -S -emit-llvm ${extra_clang_args}
|
||||
-o ${src_asm} ${src}
|
||||
COMMAND ${LLVM_AS_TOOL} -f -o ${src_bc} ${src_asm}
|
||||
# Do NOT setup a MAIN_DEPENDENCY because only 1 may exist
|
||||
# and we may have the several outputs dependent on the same source
|
||||
DEPENDS ${src} ${exec_headers} ${PROJECT_PUBLIC_HEADERS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
endforeach ()
|
||||
|
||||
|
||||
if (VERBOSE)
|
||||
message ( STATUS "^^^^^^^^^^^^^^^^^^^^^^^^^^" )
|
||||
message ( STATUS "src_bc_list: ${src_bc_list} ")
|
||||
message ( STATUS "^^^^^^^^^^^^^^^^^^^^^^^^^^" )
|
||||
endif()
|
||||
|
||||
# Link all of the individual LLVM bitcode files
|
||||
set ( linked_src_bc "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.bc" )
|
||||
add_custom_command ( OUTPUT ${linked_src_bc}
|
||||
COMMAND ${LLVM_LINK_TOOL} -internalize ${src_bc_list} -o ${linked_src_bc}
|
||||
DEPENDS ${src_bc_list} ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src_list}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
|
||||
# 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"
|
||||
${linked_src_bc} ${src_bc_cpp} ${output_name}
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${linked_src_bc}
|
||||
${exec_headers} ${PROJECT_PUBLIC_HEADERS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
|
||||
# add generated .cpp with embedded bitcode to the list of sources
|
||||
set ( ${list_to_append_cpp} ${${list_to_append_cpp}} ${src_bc_cpp} PARENT_SCOPE )
|
||||
|
||||
endfunction ( )
|
||||
@@ -10,7 +10,7 @@
|
||||
# PARTIO_LIBRARIES - library to link against
|
||||
# PARTIO_FOUND - true if Partio was found.
|
||||
|
||||
# Hack! perfer a config if it can be found
|
||||
# Hack! prefer a config if it can be found
|
||||
find_package(partio CONFIG)
|
||||
if (PARTIO_FOUND OR partio_FOUND)
|
||||
if (VERBOSE)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright Contributors to the Open Shading Languge project.
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ macro (setup_python_module)
|
||||
|
||||
set (target_name ${lib_TARGET})
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_COMPILER_ID} STREQUAL "Intel")
|
||||
# Seems to be a problem on some systems, with pybind11 and python headers
|
||||
set_property (SOURCE ${lib_SOURCES} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-macro-redefined ")
|
||||
endif ()
|
||||
@@ -77,7 +77,7 @@ macro (setup_python_module)
|
||||
PRIVATE
|
||||
pybind11::pybind11
|
||||
Python::Python
|
||||
${lib_LIBS} ${SANITIZE_LIBRARIES})
|
||||
${lib_LIBS})
|
||||
if (APPLE)
|
||||
set_target_properties (${target_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
|
||||
endif ()
|
||||
|
||||
+137
-38
@@ -1,4 +1,4 @@
|
||||
# Copyright Contributors to the Open Shading Languge project.
|
||||
# Copyright Contributors to the Open Shading Language project.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
|
||||
|
||||
@@ -16,6 +16,10 @@ add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
|
||||
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/testsuite/runtest.py")
|
||||
add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest.py" )
|
||||
|
||||
|
||||
set (OSL_TEST_BIG_TIMEOUT 800 CACHE STRING "Timeout for tests that take a long time")
|
||||
|
||||
|
||||
# add_one_testsuite() - set up one testsuite entry
|
||||
#
|
||||
# Usage:
|
||||
@@ -26,10 +30,12 @@ add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest
|
||||
# [COMMAND cmd...] - optional override of launch command
|
||||
# )
|
||||
#
|
||||
|
||||
macro (add_one_testsuite testname testsrcdir)
|
||||
cmake_parse_arguments (_tst "" "" "ENV;COMMAND" ${ARGN})
|
||||
set (testsuite "${CMAKE_SOURCE_DIR}/testsuite")
|
||||
set (testdir "${CMAKE_BINARY_DIR}/testsuite/${testname}")
|
||||
file (MAKE_DIRECTORY "${testdir}")
|
||||
if (NOT _tst_COMMAND)
|
||||
set (_tst_COMMAND ${Python_EXECUTABLE} "${testsuite}/runtest.py" ${testdir})
|
||||
if (MSVC_IDE)
|
||||
@@ -45,7 +51,17 @@ macro (add_one_testsuite testname testsrcdir)
|
||||
OSL_TESTSUITE_SRC=${testsrcdir}
|
||||
OSL_TESTSUITE_CUR=${testdir}
|
||||
)
|
||||
file (MAKE_DIRECTORY "${testdir}")
|
||||
|
||||
# We need to suppress the leak sanitizer for "texture" tests, because of a
|
||||
# minor leak inside OIIO (140 bytes! -- inconsequential) but which we
|
||||
# can't use the suppressions list becuase the leaks come from calls made
|
||||
# inside JITed code for which there is not a good stack trace. Any real
|
||||
# leaks from OIIO or its dependencies we assume will be caught by lsan on
|
||||
# the OIIO side, where there is no JIT to complicate things.
|
||||
if (${testname} MATCHES "^texture" OR ${testname} MATCHES "gettextureinfo")
|
||||
list (APPEND _tst_ENV ASAN_OPTIONS=detect_leaks=0:$ENV{ASAN_OPTIONS})
|
||||
endif ()
|
||||
|
||||
add_test ( NAME ${testname} COMMAND ${_tst_COMMAND} )
|
||||
# message ("Test -- env ${_tst_ENV} cmd ${_tst_COMMAND}")
|
||||
set_tests_properties (${testname} PROPERTIES ENVIRONMENT "${_tst_ENV}" )
|
||||
@@ -53,10 +69,10 @@ macro (add_one_testsuite testname testsrcdir)
|
||||
# from piling up together, allocate a few cores each.
|
||||
if (${testname} MATCHES "^render-")
|
||||
set_tests_properties (${testname} PROPERTIES LABELS render
|
||||
PROCESSORS 4 COST 10)
|
||||
PROCESSORS 4 COST 10 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
|
||||
endif ()
|
||||
# Some labeling for fun
|
||||
if (${testname} MATCHES "^texture-")
|
||||
if (${testname} MATCHES "^texture")
|
||||
set_tests_properties (${testname} PROPERTIES LABELS texture
|
||||
PROCESSORS 2 COST 4)
|
||||
endif ()
|
||||
@@ -68,9 +84,15 @@ macro (add_one_testsuite testname testsrcdir)
|
||||
set_tests_properties (${testname} PROPERTIES LABELS optix)
|
||||
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "10.0")
|
||||
# Make sure libnvrtc-builtins.so is reachable
|
||||
set_property (TEST ${testname} APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CUDA_TOOLKIT_ROOT_DIR}/lib64)
|
||||
set_property (TEST ${testname} APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CUDA_TOOLKIT_ROOT_DIR}/lib64:$ENV{LD_LIBRARY_PATH})
|
||||
endif()
|
||||
endif ()
|
||||
if (${testname} MATCHES "-reg")
|
||||
# These are batched shading regression tests. Some are quite
|
||||
# long, so give them a higher cost and timeout.
|
||||
set_tests_properties (${testname} PROPERTIES LABELS batchregression
|
||||
COST 15 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
|
||||
@@ -83,6 +105,7 @@ macro ( TESTSUITE )
|
||||
endif ()
|
||||
set (test_all_optix $ENV{TESTSUITE_OPTIX})
|
||||
set (test_all_batched $ENV{TESTSUITE_BATCHED})
|
||||
set (test_all_rs_bitcode $ENV{TESTSUITE_RS_BITCODE})
|
||||
# Add the tests if all is well.
|
||||
set (ALL_TEST_LIST "")
|
||||
set (_testsuite "${CMAKE_SOURCE_DIR}/testsuite")
|
||||
@@ -99,9 +122,10 @@ macro ( TESTSUITE )
|
||||
|
||||
# Run the test unoptimized, unless it matches a few patterns that
|
||||
# we don't test unoptimized (or has an OPTIMIZEONLY marker file).
|
||||
if (NOT _testname MATCHES "optix" AND
|
||||
NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION" AND
|
||||
NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
|
||||
if (NOT _testname MATCHES "optix"
|
||||
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
|
||||
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
|
||||
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
|
||||
add_one_testsuite ("${_testname}" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=0 )
|
||||
endif ()
|
||||
@@ -109,11 +133,15 @@ macro ( TESTSUITE )
|
||||
# optimization, triggered by setting TESTSHADE_OPT env variable.
|
||||
# Skip OptiX-only tests and those with a NOOPTIMIZE marker file.
|
||||
if (NOT _testname MATCHES "optix"
|
||||
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
|
||||
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
|
||||
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
|
||||
add_one_testsuite ("${_testname}.opt" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=2 )
|
||||
endif ()
|
||||
if (_testname MATCHES "render-" AND ${CMAKE_BUILD_TYPE} STREQUAL Debug)
|
||||
set_tests_properties (${_testname} PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
|
||||
endif ()
|
||||
# When building for OptiX support, also run it in OptiX mode
|
||||
# if there is an OPTIX marker file in the directory.
|
||||
# If an environment variable $TESTSUITE_OPTIX is nonzero, then
|
||||
@@ -132,7 +160,7 @@ macro ( TESTSUITE )
|
||||
add_one_testsuite ("${_testname}.optix.opt" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=2 TESTSHADE_OPTIX=1 )
|
||||
endif ()
|
||||
|
||||
|
||||
if (BUILD_BATCHED)
|
||||
# When building for Batched support, also run it in Batched mode
|
||||
# if there is an BATCHED marker file in the directory.
|
||||
@@ -146,7 +174,7 @@ macro ( TESTSUITE )
|
||||
add_one_testsuite ("${_testname}.batched" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=0 TESTSHADE_BATCHED=1 )
|
||||
endif ()
|
||||
|
||||
|
||||
if ((EXISTS "${_testsrcdir}/BATCHED" OR test_all_batched OR _testname MATCHES "batched")
|
||||
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
|
||||
AND NOT EXISTS "${_testsrcdir}/NOBATCHED"
|
||||
@@ -155,15 +183,41 @@ macro ( TESTSUITE )
|
||||
add_one_testsuite ("${_testname}.batched.opt" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=2 TESTSHADE_BATCHED=1 )
|
||||
endif ()
|
||||
|
||||
|
||||
# When building for Batched support, optionally run a regression test
|
||||
# if there is an BATCHED_REGRESSION marker file in the directory.
|
||||
if (EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
|
||||
if ((EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
|
||||
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
|
||||
# optimized for right now
|
||||
add_one_testsuite ("${_testname}.regress.batched.opt" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=2 OSL_REGRESSION_TEST=BATCHED )
|
||||
endif ()
|
||||
if ((EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
|
||||
AND EXISTS "${_testsrcdir}/NOOPTIMIZE")
|
||||
# not optimized
|
||||
add_one_testsuite ("${_testname}.regress.batched" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=0 OSL_REGRESSION_TEST=BATCHED )
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# if there is an RS_BITCODE marker file in the directory.
|
||||
if ((EXISTS "${_testsrcdir}/RS_BITCODE" OR test_all_rs_bitcode)
|
||||
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
|
||||
AND NOT EXISTS "${_testsrcdir}/RS_BITCODE_REGRESSION"
|
||||
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
|
||||
add_one_testsuite ("${_testname}.rsbitcode.opt" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=2 TESTSHADE_RS_BITCODE=1 )
|
||||
endif ()
|
||||
|
||||
# if there is an RS_BITCODE_REGRESSION marker file in the directory.
|
||||
if (EXISTS "${_testsrcdir}/RS_BITCODE_REGRESSION" OR (
|
||||
test_all_rs_bitcode AND EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
|
||||
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
|
||||
# optimized for right now
|
||||
add_one_testsuite ("${_testname}.regress.rsbitcode.opt" "${_testsrcdir}"
|
||||
ENV TESTSHADE_OPT=2 OSL_REGRESSION_TEST=RS_BITCODE )
|
||||
endif ()
|
||||
|
||||
endforeach ()
|
||||
if (VERBOSE)
|
||||
message (STATUS "Added tests: ${ALL_TEST_LIST}")
|
||||
@@ -173,16 +227,17 @@ endmacro ()
|
||||
macro (osl_add_all_tests)
|
||||
# List all the individual testsuite tests here, except those that need
|
||||
# special installed tests.
|
||||
TESTSUITE ( aastep allowconnect-err and-or-not-synonyms arithmetic
|
||||
area-reg arithmetic-reg
|
||||
array array-reg array-copy-reg array-derivs array-range
|
||||
TESTSUITE ( aastep allowconnect-err andor-reg and-or-not-synonyms
|
||||
arithmetic area-reg arithmetic-reg
|
||||
array array-reg array-copy-reg array-derivs array-range
|
||||
array-aassign array-assign-reg array-length-reg
|
||||
blackbody blendmath breakcont breakcont-reg
|
||||
bitwise-and-reg bitwise-or-reg bitwise-shl-reg bitwise-shr-reg bitwise-xor-reg
|
||||
blackbody blackbody-reg blendmath breakcont breakcont-reg
|
||||
bug-array-heapoffsets bug-locallifetime bug-outputinit
|
||||
bug-param-duplicate bug-peep bug-return
|
||||
calculatenormal-reg
|
||||
cellnoise closure closure-array color comparison
|
||||
compile-buffer compassign-reg
|
||||
cellnoise closure closure-array color color-reg colorspace comparison
|
||||
complement-reg compile-buffer compassign-reg
|
||||
component-range
|
||||
control-flow-reg connect-components
|
||||
const-array-params const-array-fill
|
||||
@@ -191,31 +246,42 @@ macro (osl_add_all_tests)
|
||||
draw_string
|
||||
error-dupes error-serialized
|
||||
example-deformer
|
||||
example-batched-deformer
|
||||
exit exponential
|
||||
filterwidth-reg
|
||||
for-reg format-reg fprintf
|
||||
function-earlyreturn function-simple function-outputelem
|
||||
function-overloads function-redef
|
||||
geomath getattribute-camera getattribute-shader
|
||||
getsymbol-nonheap gettextureinfo
|
||||
getsymbol-nonheap gettextureinfo gettextureinfo-reg
|
||||
globals-needed
|
||||
group-outputs groupstring
|
||||
hash hashnoise hex hyperb
|
||||
ieee_fp if if-reg incdec initlist initops intbits isconnected
|
||||
ieee_fp ieee_fp-reg if if-reg incdec initlist
|
||||
initops initops-instance-clash
|
||||
intbits isconnected
|
||||
isconstant
|
||||
layers layers-Ciassign layers-entry layers-lazy layers-lazyerror
|
||||
layers-nonlazycopy layers-repeatedoutputs
|
||||
length-reg linearstep
|
||||
logic loop matrix matrix-reg matrix-arithmetic-reg
|
||||
matrix-compref-reg max-reg message
|
||||
logic loop luminance-reg
|
||||
matrix matrix-reg matrix-arithmetic-reg
|
||||
matrix-compref-reg max-reg message message-no-closure message-reg
|
||||
mergeinstances-duplicate-entrylayers
|
||||
mergeinstances-nouserdata mergeinstances-vararray
|
||||
metadata-braces min-reg miscmath missing-shader
|
||||
mix-reg
|
||||
named-components
|
||||
noise noise-cell
|
||||
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
|
||||
noise-gabor-reg
|
||||
noise-generic
|
||||
noise-perlin noise-simplex
|
||||
noise-reg
|
||||
normalize-reg
|
||||
pnoise pnoise-cell pnoise-gabor pnoise-perlin
|
||||
pnoise pnoise-cell pnoise-gabor
|
||||
pnoise-generic pnoise-perlin
|
||||
pnoise-reg
|
||||
operator-overloading
|
||||
opt-warnings
|
||||
oslc-comma oslc-D oslc-M
|
||||
@@ -229,6 +295,7 @@ macro (osl_add_all_tests)
|
||||
oslc-err-outputparamvararray oslc-err-paramdefault
|
||||
oslc-err-struct-array-init oslc-err-struct-ctr
|
||||
oslc-err-struct-dup oslc-err-struct-print
|
||||
oslc-err-type-as-variable
|
||||
oslc-err-unknown-ctr
|
||||
oslc-pragma-warnerr
|
||||
oslc-warn-commainit
|
||||
@@ -244,10 +311,21 @@ macro (osl_add_all_tests)
|
||||
raytype raytype-reg raytype-specialized regex-reg reparam
|
||||
render-background render-bumptest
|
||||
render-cornell render-furnace-diffuse
|
||||
render-microfacet render-oren-nayar render-veachmis render-ward
|
||||
select shaderglobals shortcircuit
|
||||
smoothstep-reg
|
||||
spline splineinverse splineinverse-ident
|
||||
render-mx-furnace-burley-diffuse
|
||||
render-mx-furnace-oren-nayar
|
||||
render-mx-furnace-sheen
|
||||
render-mx-burley-diffuse
|
||||
render-mx-dielectric render-mx-dielectric-glass
|
||||
render-mx-conductor
|
||||
render-mx-generalized-schlick render-mx-generalized-schlick-glass
|
||||
render-mx-layer
|
||||
render-mx-sheen
|
||||
render-microfacet render-oren-nayar
|
||||
render-uv render-veachmis render-ward
|
||||
select select-reg shaderglobals shortcircuit
|
||||
smoothstep-reg
|
||||
spline spline-reg splineinverse splineinverse-ident
|
||||
splineinverse-knots-ascend-reg splineinverse-knots-descend-reg
|
||||
spline-boundarybug spline-derivbug
|
||||
split-reg
|
||||
string string-reg
|
||||
@@ -260,36 +338,48 @@ macro (osl_add_all_tests)
|
||||
testshade-expr
|
||||
texture-alpha texture-alpha-derivs
|
||||
texture-blur texture-connected-options
|
||||
texture-derivs texture-errormsg
|
||||
texture-derivs texture-environment texture-errormsg
|
||||
texture-environment-opts-reg
|
||||
texture-firstchannel texture-interp
|
||||
texture-missingalpha texture-missingcolor texture-simple
|
||||
texture-missingalpha texture-missingcolor texture-opts-reg texture-simple
|
||||
texture-smallderivs texture-swirl texture-udim
|
||||
texture-width texture-withderivs texture-wrap
|
||||
trace-reg
|
||||
trailing-commas
|
||||
transcendental-reg
|
||||
transitive-assign
|
||||
transform transform-reg transformc trig trig-reg
|
||||
transform transform-reg transformc transformc-reg trig trig-reg
|
||||
typecast
|
||||
unknown-instruction
|
||||
userdata userdata-passthrough
|
||||
vararray-connect vararray-default
|
||||
vararray-deserialize vararray-param
|
||||
vecctr vector vector-reg
|
||||
wavelength_color Werror xml )
|
||||
wavelength_color wavelength_color-reg Werror xml xml-reg )
|
||||
|
||||
# Coordinate-aware gettextureinfo only works for TextureSystem >= 2.3.7
|
||||
if (OpenImageIO_VERSION VERSION_GREATER_EQUAL 2.3.7)
|
||||
TESTSUITE ( gettextureinfo-udim gettextureinfo-udim-reg )
|
||||
endif ()
|
||||
|
||||
# Only run the ocio test if the OIIO we are using has OCIO support
|
||||
if (OpenImageIO_HAS_OpenColorIO)
|
||||
TESTSUITE ( ocio )
|
||||
endif ()
|
||||
|
||||
# Add tests that require the Python bindings if we built them.
|
||||
# We also exclude these tests if this is a sanitizer build on Linux,
|
||||
# because the Python interpreter itself won't be linked with the right asan
|
||||
# We also exclude these tests if this is a sanitizer build, because the
|
||||
# Python interpreter itself won't be linked with the right asan
|
||||
# libraries to run correctly.
|
||||
if (USE_PYTHON AND NOT SANITIZE_ON_LINUX)
|
||||
if (USE_PYTHON AND NOT SANITIZE)
|
||||
TESTSUITE ( python-oslquery )
|
||||
endif ()
|
||||
|
||||
# Only run field3d-related tests if the local OIIO was built with f3d support.
|
||||
execute_process ( COMMAND ${OPENIMAGEIO_BIN} --help
|
||||
# Only run openvdb-related tests if the local OIIO has openvdb support.
|
||||
execute_process ( COMMAND ${OpenImageIO_LIB_DIR}/../bin/oiiotool --help
|
||||
OUTPUT_VARIABLE oiiotool_help )
|
||||
if (oiiotool_help MATCHES "field3d")
|
||||
TESTSUITE ( texture-field3d )
|
||||
if (oiiotool_help MATCHES "openvdb")
|
||||
TESTSUITE ( texture3d texture3d-opts-reg )
|
||||
endif()
|
||||
|
||||
# Only run pointcloud tests if Partio is found
|
||||
@@ -302,4 +392,13 @@ macro (osl_add_all_tests)
|
||||
TESTSUITE ( testoptix testoptix-noise example-cuda)
|
||||
endif ()
|
||||
|
||||
# Some regression tests have a lot of combinations and may need more time to finish
|
||||
if (BUILD_BATCHED)
|
||||
set_tests_properties (arithmetic-reg.regress.batched.opt
|
||||
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
|
||||
set_tests_properties (transform-reg.regress.batched.opt
|
||||
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
|
||||
endif ()
|
||||
set_tests_properties (matrix-reg.regress.rsbitcode.opt
|
||||
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
|
||||
endmacro()
|
||||
|
||||
+753
-88
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -11,7 +11,7 @@
|
||||
_testshade_ basics
|
||||
==================================================
|
||||
|
||||
The OSL software distribution inculdes `testshade`, a command-line utility
|
||||
The OSL software distribution includes `testshade`, a command-line utility
|
||||
that was written for OSL unit tests, and for a "test harness" in which we
|
||||
can execute shaders for debugging (the shaders or OSL itself) in isolation
|
||||
from any particular rendering system.
|
||||
@@ -28,7 +28,7 @@ itself, it has a number of potential uses in a production studio, including:
|
||||
* Baking procedural patterns into textures.
|
||||
|
||||
* Benchmarking shaders and evaluating their performance, including
|
||||
comparitive tests such as "is it faster to code it this way or that way?"
|
||||
comparative tests such as "is it faster to code it this way or that way?"
|
||||
|
||||
* Exploring the inner workings of OSL's runtime optimizer, to answer
|
||||
questions like: "will this idiom optimize away at runtime when I use
|
||||
@@ -176,7 +176,7 @@ Helpful command line arguments:
|
||||
|
||||
For the sake of simplicity, this document presents almost all examples as if
|
||||
they consisted of just a single shader node. But `testshade` is able to
|
||||
specify and execut entire shader groups (networks of shader nodes). The
|
||||
specify and execute entire shader groups (networks of shader nodes). The
|
||||
remainder of this section will explain how this can be done.
|
||||
|
||||
Let's make a simple shader network as an example.
|
||||
@@ -582,7 +582,7 @@ single texture lookup.
|
||||
|
||||
|
||||
|
||||
## Controling optimization
|
||||
## Controlling optimization
|
||||
|
||||
You can control the optimization level overall:
|
||||
|
||||
@@ -638,7 +638,7 @@ that they are not optimized away so as to lead you to an inaccurate
|
||||
reflection of what optimizations would really happen at render time. At the
|
||||
same time, be careful not to inadvertently set `lockgeom=0` for parameters
|
||||
that will typically be set to default values, instance values, or
|
||||
connections from layers that are likely to be analized and found to emit
|
||||
connections from layers that are likely to be analyzed and found to emit
|
||||
constants for theor outputs -- you also don't want your benchmarks to
|
||||
incorrectly disable optimizations what would typically happen at render
|
||||
time.
|
||||
|
||||
@@ -135,7 +135,7 @@ template <class T> class Matrix33
|
||||
//------------
|
||||
|
||||
~Matrix33 () = default;
|
||||
|
||||
|
||||
//----------------------
|
||||
// Compatibility with Sb
|
||||
//----------------------
|
||||
@@ -378,8 +378,8 @@ template <class T> class Matrix33
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Set matrix to shear x for each y coord. by given factor h[0]
|
||||
// and to shear y for each x coord. by given factor h[1]
|
||||
// Set matrix to shear x for each y coord. by given factor h.x
|
||||
// and to shear y for each x coord. by given factor h.y
|
||||
//-------------------------------------------------------------
|
||||
|
||||
template <class S>
|
||||
@@ -867,16 +867,16 @@ template <class S, class T>
|
||||
IMATH_HOSTDEVICE Vec3<S> operator * (const Vec3<S> &v, const Matrix33<T> &m);
|
||||
|
||||
template <class S, class T>
|
||||
const Vec3<S> & operator *= (Vec3<S> &v, const Matrix44<T> &m);
|
||||
IMATH_HOSTDEVICE const Vec3<S> & operator *= (Vec3<S> &v, const Matrix44<T> &m);
|
||||
|
||||
template <class S, class T>
|
||||
Vec3<S> operator * (const Vec3<S> &v, const Matrix44<T> &m);
|
||||
IMATH_HOSTDEVICE Vec3<S> operator * (const Vec3<S> &v, const Matrix44<T> &m);
|
||||
|
||||
template <class S, class T>
|
||||
const Vec4<S> & operator *= (Vec4<S> &v, const Matrix44<T> &m);
|
||||
IMATH_HOSTDEVICE const Vec4<S> & operator *= (Vec4<S> &v, const Matrix44<T> &m);
|
||||
|
||||
template <class S, class T>
|
||||
Vec4<S> operator * (const Vec4<S> &v, const Matrix44<T> &m);
|
||||
IMATH_HOSTDEVICE Vec4<S> operator * (const Vec4<S> &v, const Matrix44<T> &m);
|
||||
|
||||
//-------------------------
|
||||
// Typedefs for convenience
|
||||
@@ -1133,7 +1133,7 @@ Matrix33<T>::equalWithAbsError (const Matrix33<T> &m, T e) const
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this)[i][j], m[i][j], e))
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this).x[i][j], m.x[i][j], e))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1145,7 +1145,7 @@ Matrix33<T>::equalWithRelError (const Matrix33<T> &m, T e) const
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this)[i][j], m[i][j], e))
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this).x[i][j], m.x[i][j], e))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1356,9 +1356,9 @@ Matrix33<T>::multVecMatrix(const Vec2<S> &src, Vec2<S> &dst) const
|
||||
{
|
||||
S a, b, w;
|
||||
|
||||
a = src[0] * x[0][0] + src[1] * x[1][0] + x[2][0];
|
||||
b = src[0] * x[0][1] + src[1] * x[1][1] + x[2][1];
|
||||
w = src[0] * x[0][2] + src[1] * x[1][2] + x[2][2];
|
||||
a = src.x * x[0][0] + src.y * x[1][0] + x[2][0];
|
||||
b = src.x * x[0][1] + src.y * x[1][1] + x[2][1];
|
||||
w = src.x * x[0][2] + src.y * x[1][2] + x[2][2];
|
||||
|
||||
dst.x = a / w;
|
||||
dst.y = b / w;
|
||||
@@ -1371,8 +1371,8 @@ Matrix33<T>::multDirMatrix(const Vec2<S> &src, Vec2<S> &dst) const
|
||||
{
|
||||
S a, b;
|
||||
|
||||
a = src[0] * x[0][0] + src[1] * x[1][0];
|
||||
b = src[0] * x[0][1] + src[1] * x[1][1];
|
||||
a = src.x * x[0][0] + src.y * x[1][0];
|
||||
b = src.x * x[0][1] + src.y * x[1][1];
|
||||
|
||||
dst.x = a;
|
||||
dst.y = b;
|
||||
@@ -1464,14 +1464,14 @@ Matrix33<T>::gjInverse (bool singExc) const
|
||||
{
|
||||
int pivot = i;
|
||||
|
||||
T pivotsize = t[i][i];
|
||||
T pivotsize = t.x[i][i];
|
||||
|
||||
if (pivotsize < 0)
|
||||
pivotsize = -pivotsize;
|
||||
|
||||
for (j = i + 1; j < 3; j++)
|
||||
{
|
||||
T tmp = t[j][i];
|
||||
T tmp = t.x[j][i];
|
||||
|
||||
if (tmp < 0)
|
||||
tmp = -tmp;
|
||||
@@ -1497,24 +1497,24 @@ Matrix33<T>::gjInverse (bool singExc) const
|
||||
{
|
||||
T tmp;
|
||||
|
||||
tmp = t[i][j];
|
||||
t[i][j] = t[pivot][j];
|
||||
t[pivot][j] = tmp;
|
||||
tmp = t.x[i][j];
|
||||
t.x[i][j] = t.x[pivot][j];
|
||||
t.x[pivot][j] = tmp;
|
||||
|
||||
tmp = s[i][j];
|
||||
s[i][j] = s[pivot][j];
|
||||
s[pivot][j] = tmp;
|
||||
tmp = s.x[i][j];
|
||||
s.x[i][j] = s.x[pivot][j];
|
||||
s.x[pivot][j] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = i + 1; j < 3; j++)
|
||||
{
|
||||
T f = t[j][i] / t[i][i];
|
||||
T f = t.x[j][i] / t.x[i][i];
|
||||
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
t[j][k] -= f * t[i][k];
|
||||
s[j][k] -= f * s[i][k];
|
||||
t.x[j][k] -= f * t.x[i][k];
|
||||
s.x[j][k] -= f * s.x[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1525,7 +1525,7 @@ Matrix33<T>::gjInverse (bool singExc) const
|
||||
{
|
||||
T f;
|
||||
|
||||
if ((f = t[i][i]) == 0)
|
||||
if ((f = t.x[i][i]) == 0)
|
||||
{
|
||||
if (singExc)
|
||||
throw ::IMATH_INTERNAL_NAMESPACE::SingMatrixExc ("Cannot invert singular matrix.");
|
||||
@@ -1535,18 +1535,18 @@ Matrix33<T>::gjInverse (bool singExc) const
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
t[i][j] /= f;
|
||||
s[i][j] /= f;
|
||||
t.x[i][j] /= f;
|
||||
s.x[i][j] /= f;
|
||||
}
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
f = t[j][i];
|
||||
f = t.x[j][i];
|
||||
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
t[j][k] -= f * t[i][k];
|
||||
s[j][k] -= f * s[i][k];
|
||||
t.x[j][k] -= f * t.x[i][k];
|
||||
s.x[j][k] -= f * s.x[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1580,7 +1580,7 @@ Matrix33<T>::inverse (bool singExc) const
|
||||
x[2][0] * x[0][1] - x[0][0] * x[2][1],
|
||||
x[0][0] * x[1][1] - x[1][0] * x[0][1]);
|
||||
|
||||
T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
|
||||
T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
|
||||
|
||||
if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
|
||||
{
|
||||
@@ -1588,7 +1588,7 @@ Matrix33<T>::inverse (bool singExc) const
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
s[i][j] /= r;
|
||||
s.x[i][j] /= r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1600,9 +1600,9 @@ Matrix33<T>::inverse (bool singExc) const
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
|
||||
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
|
||||
{
|
||||
s[i][j] /= r;
|
||||
s.x[i][j] /= r;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1641,7 +1641,7 @@ Matrix33<T>::inverse (bool singExc) const
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
{
|
||||
s[i][j] /= r;
|
||||
s.x[i][j] /= r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1653,9 +1653,9 @@ Matrix33<T>::inverse (bool singExc) const
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
{
|
||||
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
|
||||
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
|
||||
{
|
||||
s[i][j] /= r;
|
||||
s.x[i][j] /= r;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1670,8 +1670,8 @@ Matrix33<T>::inverse (bool singExc) const
|
||||
}
|
||||
}
|
||||
|
||||
s[2][0] = -x[2][0] * s[0][0] - x[2][1] * s[1][0];
|
||||
s[2][1] = -x[2][0] * s[0][1] - x[2][1] * s[1][1];
|
||||
s.x[2][0] = -x[2][0] * s.x[0][0] - x[2][1] * s.x[1][0];
|
||||
s.x[2][1] = -x[2][0] * s.x[0][1] - x[2][1] * s.x[1][1];
|
||||
|
||||
return s;
|
||||
}
|
||||
@@ -1758,8 +1758,8 @@ IMATH_HOSTDEVICE const Matrix33<T> &
|
||||
Matrix33<T>::setScale (const Vec2<S> &s)
|
||||
{
|
||||
memset (x, 0, sizeof (x));
|
||||
x[0][0] = s[0];
|
||||
x[1][1] = s[1];
|
||||
x[0][0] = s.x;
|
||||
x[1][1] = s.y;
|
||||
x[2][2] = 1;
|
||||
|
||||
return *this;
|
||||
@@ -1770,13 +1770,13 @@ template <class S>
|
||||
IMATH_HOSTDEVICE const Matrix33<T> &
|
||||
Matrix33<T>::scale (const Vec2<S> &s)
|
||||
{
|
||||
x[0][0] *= s[0];
|
||||
x[0][1] *= s[0];
|
||||
x[0][2] *= s[0];
|
||||
x[0][0] *= s.x;
|
||||
x[0][1] *= s.x;
|
||||
x[0][2] *= s.x;
|
||||
|
||||
x[1][0] *= s[1];
|
||||
x[1][1] *= s[1];
|
||||
x[1][2] *= s[1];
|
||||
x[1][0] *= s.y;
|
||||
x[1][1] *= s.y;
|
||||
x[1][2] *= s.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1794,8 +1794,8 @@ Matrix33<T>::setTranslation (const Vec2<S> &t)
|
||||
x[1][1] = 1;
|
||||
x[1][2] = 0;
|
||||
|
||||
x[2][0] = t[0];
|
||||
x[2][1] = t[1];
|
||||
x[2][0] = t.x;
|
||||
x[2][1] = t.y;
|
||||
x[2][2] = 1;
|
||||
|
||||
return *this;
|
||||
@@ -1813,9 +1813,9 @@ template <class S>
|
||||
IMATH_HOSTDEVICE const Matrix33<T> &
|
||||
Matrix33<T>::translate (const Vec2<S> &t)
|
||||
{
|
||||
x[2][0] += t[0] * x[0][0] + t[1] * x[1][0];
|
||||
x[2][1] += t[0] * x[0][1] + t[1] * x[1][1];
|
||||
x[2][2] += t[0] * x[0][2] + t[1] * x[1][2];
|
||||
x[2][0] += t.x * x[0][0] + t.y * x[1][0];
|
||||
x[2][1] += t.x * x[0][1] + t.y * x[1][1];
|
||||
x[2][2] += t.x * x[0][2] + t.y * x[1][2];
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1846,10 +1846,10 @@ IMATH_HOSTDEVICE const Matrix33<T> &
|
||||
Matrix33<T>::setShear (const Vec2<S> &h)
|
||||
{
|
||||
x[0][0] = 1;
|
||||
x[0][1] = h[1];
|
||||
x[0][1] = h.y;
|
||||
x[0][2] = 0;
|
||||
|
||||
x[1][0] = h[0];
|
||||
x[1][0] = h.x;
|
||||
x[1][1] = 1;
|
||||
x[1][2] = 0;
|
||||
|
||||
@@ -1885,13 +1885,13 @@ Matrix33<T>::shear (const Vec2<S> &h)
|
||||
{
|
||||
Matrix33<T> P (*this);
|
||||
|
||||
x[0][0] = P[0][0] + h[1] * P[1][0];
|
||||
x[0][1] = P[0][1] + h[1] * P[1][1];
|
||||
x[0][2] = P[0][2] + h[1] * P[1][2];
|
||||
x[0][0] = P.x[0][0] + h.y * P.x[1][0];
|
||||
x[0][1] = P.x[0][1] + h.y * P.x[1][1];
|
||||
x[0][2] = P.x[0][2] + h.y * P.x[1][2];
|
||||
|
||||
x[1][0] = P[1][0] + h[0] * P[0][0];
|
||||
x[1][1] = P[1][1] + h[0] * P[0][1];
|
||||
x[1][2] = P[1][2] + h[0] * P[0][2];
|
||||
x[1][0] = P.x[1][0] + h.x * P.x[0][0];
|
||||
x[1][1] = P.x[1][1] + h.x * P.x[0][1];
|
||||
x[1][2] = P.x[1][2] + h.x * P.x[0][2];
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -1983,21 +1983,21 @@ template <class T>
|
||||
IMATH_HOSTDEVICE inline
|
||||
Matrix44<T>::Matrix44 (Matrix33<T> r, Vec3<T> t)
|
||||
{
|
||||
x[0][0] = r[0][0];
|
||||
x[0][1] = r[0][1];
|
||||
x[0][2] = r[0][2];
|
||||
x[0][0] = r.x[0][0];
|
||||
x[0][1] = r.x[0][1];
|
||||
x[0][2] = r.x[0][2];
|
||||
x[0][3] = 0;
|
||||
x[1][0] = r[1][0];
|
||||
x[1][1] = r[1][1];
|
||||
x[1][2] = r[1][2];
|
||||
x[1][0] = r.x[1][0];
|
||||
x[1][1] = r.x[1][1];
|
||||
x[1][2] = r.x[1][2];
|
||||
x[1][3] = 0;
|
||||
x[2][0] = r[2][0];
|
||||
x[2][1] = r[2][1];
|
||||
x[2][2] = r[2][2];
|
||||
x[2][0] = r.x[2][0];
|
||||
x[2][1] = r.x[2][1];
|
||||
x[2][2] = r.x[2][2];
|
||||
x[2][3] = 0;
|
||||
x[3][0] = t[0];
|
||||
x[3][1] = t[1];
|
||||
x[3][2] = t[2];
|
||||
x[3][0] = t.x;
|
||||
x[3][1] = t.y;
|
||||
x[3][2] = t.z;
|
||||
x[3][3] = 1;
|
||||
}
|
||||
|
||||
@@ -2261,7 +2261,7 @@ Matrix44<T>::equalWithAbsError (const Matrix44<T> &m, T e) const
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this)[i][j], m[i][j], e))
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this).x[i][j], m.x[i][j], e))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -2273,7 +2273,7 @@ Matrix44<T>::equalWithRelError (const Matrix44<T> &m, T e) const
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this)[i][j], m[i][j], e))
|
||||
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this).x[i][j], m.x[i][j], e))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -2598,10 +2598,10 @@ Matrix44<T>::multVecMatrix(const Vec3<S> &src, Vec3<S> &dst) const
|
||||
{
|
||||
S a, b, c, w;
|
||||
|
||||
a = src[0] * x[0][0] + src[1] * x[1][0] + src[2] * x[2][0] + x[3][0];
|
||||
b = src[0] * x[0][1] + src[1] * x[1][1] + src[2] * x[2][1] + x[3][1];
|
||||
c = src[0] * x[0][2] + src[1] * x[1][2] + src[2] * x[2][2] + x[3][2];
|
||||
w = src[0] * x[0][3] + src[1] * x[1][3] + src[2] * x[2][3] + x[3][3];
|
||||
a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0] + x[3][0];
|
||||
b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1] + x[3][1];
|
||||
c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2] + x[3][2];
|
||||
w = src.x * x[0][3] + src.y * x[1][3] + src.z * x[2][3] + x[3][3];
|
||||
|
||||
dst.x = a / w;
|
||||
dst.y = b / w;
|
||||
@@ -2614,9 +2614,9 @@ Matrix44<T>::multDirMatrix(const Vec3<S> &src, Vec3<S> &dst) const
|
||||
{
|
||||
S a, b, c;
|
||||
|
||||
a = src[0] * x[0][0] + src[1] * x[1][0] + src[2] * x[2][0];
|
||||
b = src[0] * x[0][1] + src[1] * x[1][1] + src[2] * x[2][1];
|
||||
c = src[0] * x[0][2] + src[1] * x[1][2] + src[2] * x[2][2];
|
||||
a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0];
|
||||
b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1];
|
||||
c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2];
|
||||
|
||||
dst.x = a;
|
||||
dst.y = b;
|
||||
@@ -2737,14 +2737,14 @@ Matrix44<T>::gjInverse (bool singExc) const
|
||||
{
|
||||
int pivot = i;
|
||||
|
||||
T pivotsize = t[i][i];
|
||||
T pivotsize = t.x[i][i];
|
||||
|
||||
if (pivotsize < 0)
|
||||
pivotsize = -pivotsize;
|
||||
|
||||
for (j = i + 1; j < 4; j++)
|
||||
{
|
||||
T tmp = t[j][i];
|
||||
T tmp = t.x[j][i];
|
||||
|
||||
if (tmp < 0)
|
||||
tmp = -tmp;
|
||||
@@ -2772,24 +2772,24 @@ Matrix44<T>::gjInverse (bool singExc) const
|
||||
{
|
||||
T tmp;
|
||||
|
||||
tmp = t[i][j];
|
||||
t[i][j] = t[pivot][j];
|
||||
t[pivot][j] = tmp;
|
||||
tmp = t.x[i][j];
|
||||
t.x[i][j] = t.x[pivot][j];
|
||||
t.x[pivot][j] = tmp;
|
||||
|
||||
tmp = s[i][j];
|
||||
s[i][j] = s[pivot][j];
|
||||
s[pivot][j] = tmp;
|
||||
tmp = s.x[i][j];
|
||||
s.x[i][j] = s.x[pivot][j];
|
||||
s.x[pivot][j] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = i + 1; j < 4; j++)
|
||||
{
|
||||
T f = t[j][i] / t[i][i];
|
||||
T f = t.x[j][i] / t.x[i][i];
|
||||
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
t[j][k] -= f * t[i][k];
|
||||
s[j][k] -= f * s[i][k];
|
||||
t.x[j][k] -= f * t.x[i][k];
|
||||
s.x[j][k] -= f * s.x[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2812,18 +2812,18 @@ Matrix44<T>::gjInverse (bool singExc) const
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
t[i][j] /= f;
|
||||
s[i][j] /= f;
|
||||
t.x[i][j] /= f;
|
||||
s.x[i][j] /= f;
|
||||
}
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
f = t[j][i];
|
||||
f = t.x[j][i];
|
||||
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
t[j][k] -= f * t[i][k];
|
||||
s[j][k] -= f * s[i][k];
|
||||
t.x[j][k] -= f * t.x[i][k];
|
||||
s.x[j][k] -= f * s.x[i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2866,7 +2866,7 @@ Matrix44<T>::inverse (bool singExc) const
|
||||
0,
|
||||
1);
|
||||
|
||||
T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
|
||||
T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
|
||||
|
||||
if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
|
||||
{
|
||||
@@ -2874,7 +2874,7 @@ Matrix44<T>::inverse (bool singExc) const
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
s[i][j] /= r;
|
||||
s.x[i][j] /= r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2886,9 +2886,9 @@ Matrix44<T>::inverse (bool singExc) const
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
|
||||
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
|
||||
{
|
||||
s[i][j] /= r;
|
||||
s.x[i][j] /= r;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2903,9 +2903,9 @@ Matrix44<T>::inverse (bool singExc) const
|
||||
}
|
||||
}
|
||||
|
||||
s[3][0] = -x[3][0] * s[0][0] - x[3][1] * s[1][0] - x[3][2] * s[2][0];
|
||||
s[3][1] = -x[3][0] * s[0][1] - x[3][1] * s[1][1] - x[3][2] * s[2][1];
|
||||
s[3][2] = -x[3][0] * s[0][2] - x[3][1] * s[1][2] - x[3][2] * s[2][2];
|
||||
s.x[3][0] = -x[3][0] * s.x[0][0] - x[3][1] * s.x[1][0] - x[3][2] * s.x[2][0];
|
||||
s.x[3][1] = -x[3][0] * s.x[0][1] - x[3][1] * s.x[1][1] - x[3][2] * s.x[2][1];
|
||||
s.x[3][2] = -x[3][0] * s.x[0][2] - x[3][1] * s.x[1][2] - x[3][2] * s.x[2][2];
|
||||
|
||||
return s;
|
||||
}
|
||||
@@ -2959,13 +2959,13 @@ Matrix44<T>::setEulerAngles (const Vec3<S>& r)
|
||||
{
|
||||
S cos_rz, sin_rz, cos_ry, sin_ry, cos_rx, sin_rx;
|
||||
|
||||
cos_rz = Math<T>::cos (r[2]);
|
||||
cos_ry = Math<T>::cos (r[1]);
|
||||
cos_rx = Math<T>::cos (r[0]);
|
||||
cos_rz = Math<T>::cos (r.z);
|
||||
cos_ry = Math<T>::cos (r.y);
|
||||
cos_rx = Math<T>::cos (r.x);
|
||||
|
||||
sin_rz = Math<T>::sin (r[2]);
|
||||
sin_ry = Math<T>::sin (r[1]);
|
||||
sin_rx = Math<T>::sin (r[0]);
|
||||
sin_rz = Math<T>::sin (r.z);
|
||||
sin_ry = Math<T>::sin (r.y);
|
||||
sin_rx = Math<T>::sin (r.x);
|
||||
|
||||
x[0][0] = cos_rz * cos_ry;
|
||||
x[0][1] = sin_rz * cos_ry;
|
||||
@@ -2999,19 +2999,19 @@ Matrix44<T>::setAxisAngle (const Vec3<S>& axis, S angle)
|
||||
S sine = Math<T>::sin (angle);
|
||||
S cosine = Math<T>::cos (angle);
|
||||
|
||||
x[0][0] = unit[0] * unit[0] * (1 - cosine) + cosine;
|
||||
x[0][1] = unit[0] * unit[1] * (1 - cosine) + unit[2] * sine;
|
||||
x[0][2] = unit[0] * unit[2] * (1 - cosine) - unit[1] * sine;
|
||||
x[0][0] = unit.x * unit.x * (1 - cosine) + cosine;
|
||||
x[0][1] = unit.x * unit.y * (1 - cosine) + unit.z * sine;
|
||||
x[0][2] = unit.x * unit.z * (1 - cosine) - unit.y * sine;
|
||||
x[0][3] = 0;
|
||||
|
||||
x[1][0] = unit[0] * unit[1] * (1 - cosine) - unit[2] * sine;
|
||||
x[1][1] = unit[1] * unit[1] * (1 - cosine) + cosine;
|
||||
x[1][2] = unit[1] * unit[2] * (1 - cosine) + unit[0] * sine;
|
||||
x[1][0] = unit.x * unit.y * (1 - cosine) - unit.z * sine;
|
||||
x[1][1] = unit.y * unit.y * (1 - cosine) + cosine;
|
||||
x[1][2] = unit.y * unit.z * (1 - cosine) + unit.x * sine;
|
||||
x[1][3] = 0;
|
||||
|
||||
x[2][0] = unit[0] * unit[2] * (1 - cosine) + unit[1] * sine;
|
||||
x[2][1] = unit[1] * unit[2] * (1 - cosine) - unit[0] * sine;
|
||||
x[2][2] = unit[2] * unit[2] * (1 - cosine) + cosine;
|
||||
x[2][0] = unit.x * unit.z * (1 - cosine) + unit.y * sine;
|
||||
x[2][1] = unit.y * unit.z * (1 - cosine) - unit.x * sine;
|
||||
x[2][2] = unit.z * unit.z * (1 - cosine) + cosine;
|
||||
x[2][3] = 0;
|
||||
|
||||
x[3][0] = 0;
|
||||
@@ -3032,13 +3032,13 @@ Matrix44<T>::rotate (const Vec3<S> &r)
|
||||
S m10, m11, m12;
|
||||
S m20, m21, m22;
|
||||
|
||||
cos_rz = Math<S>::cos (r[2]);
|
||||
cos_ry = Math<S>::cos (r[1]);
|
||||
cos_rx = Math<S>::cos (r[0]);
|
||||
cos_rz = Math<S>::cos (r.z);
|
||||
cos_ry = Math<S>::cos (r.y);
|
||||
cos_rx = Math<S>::cos (r.x);
|
||||
|
||||
sin_rz = Math<S>::sin (r[2]);
|
||||
sin_ry = Math<S>::sin (r[1]);
|
||||
sin_rx = Math<S>::sin (r[0]);
|
||||
sin_rz = Math<S>::sin (r.z);
|
||||
sin_ry = Math<S>::sin (r.y);
|
||||
sin_rx = Math<S>::sin (r.x);
|
||||
|
||||
m00 = cos_rz * cos_ry;
|
||||
m01 = sin_rz * cos_ry;
|
||||
@@ -3052,20 +3052,20 @@ Matrix44<T>::rotate (const Vec3<S> &r)
|
||||
|
||||
Matrix44<T> P (*this);
|
||||
|
||||
x[0][0] = P[0][0] * m00 + P[1][0] * m01 + P[2][0] * m02;
|
||||
x[0][1] = P[0][1] * m00 + P[1][1] * m01 + P[2][1] * m02;
|
||||
x[0][2] = P[0][2] * m00 + P[1][2] * m01 + P[2][2] * m02;
|
||||
x[0][3] = P[0][3] * m00 + P[1][3] * m01 + P[2][3] * m02;
|
||||
x[0][0] = P.x[0][0] * m00 + P.x[1][0] * m01 + P.x[2][0] * m02;
|
||||
x[0][1] = P.x[0][1] * m00 + P.x[1][1] * m01 + P.x[2][1] * m02;
|
||||
x[0][2] = P.x[0][2] * m00 + P.x[1][2] * m01 + P.x[2][2] * m02;
|
||||
x[0][3] = P.x[0][3] * m00 + P.x[1][3] * m01 + P.x[2][3] * m02;
|
||||
|
||||
x[1][0] = P[0][0] * m10 + P[1][0] * m11 + P[2][0] * m12;
|
||||
x[1][1] = P[0][1] * m10 + P[1][1] * m11 + P[2][1] * m12;
|
||||
x[1][2] = P[0][2] * m10 + P[1][2] * m11 + P[2][2] * m12;
|
||||
x[1][3] = P[0][3] * m10 + P[1][3] * m11 + P[2][3] * m12;
|
||||
x[1][0] = P.x[0][0] * m10 + P.x[1][0] * m11 + P.x[2][0] * m12;
|
||||
x[1][1] = P.x[0][1] * m10 + P.x[1][1] * m11 + P.x[2][1] * m12;
|
||||
x[1][2] = P.x[0][2] * m10 + P.x[1][2] * m11 + P.x[2][2] * m12;
|
||||
x[1][3] = P.x[0][3] * m10 + P.x[1][3] * m11 + P.x[2][3] * m12;
|
||||
|
||||
x[2][0] = P[0][0] * m20 + P[1][0] * m21 + P[2][0] * m22;
|
||||
x[2][1] = P[0][1] * m20 + P[1][1] * m21 + P[2][1] * m22;
|
||||
x[2][2] = P[0][2] * m20 + P[1][2] * m21 + P[2][2] * m22;
|
||||
x[2][3] = P[0][3] * m20 + P[1][3] * m21 + P[2][3] * m22;
|
||||
x[2][0] = P.x[0][0] * m20 + P.x[1][0] * m21 + P.x[2][0] * m22;
|
||||
x[2][1] = P.x[0][1] * m20 + P.x[1][1] * m21 + P.x[2][1] * m22;
|
||||
x[2][2] = P.x[0][2] * m20 + P.x[1][2] * m21 + P.x[2][2] * m22;
|
||||
x[2][3] = P.x[0][3] * m20 + P.x[1][3] * m21 + P.x[2][3] * m22;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -3089,9 +3089,9 @@ IMATH_HOSTDEVICE const Matrix44<T> &
|
||||
Matrix44<T>::setScale (const Vec3<S> &s)
|
||||
{
|
||||
memset (x, 0, sizeof (x));
|
||||
x[0][0] = s[0];
|
||||
x[1][1] = s[1];
|
||||
x[2][2] = s[2];
|
||||
x[0][0] = s.x;
|
||||
x[1][1] = s.y;
|
||||
x[2][2] = s.z;
|
||||
x[3][3] = 1;
|
||||
|
||||
return *this;
|
||||
@@ -3102,20 +3102,20 @@ template <class S>
|
||||
IMATH_HOSTDEVICE const Matrix44<T> &
|
||||
Matrix44<T>::scale (const Vec3<S> &s)
|
||||
{
|
||||
x[0][0] *= s[0];
|
||||
x[0][1] *= s[0];
|
||||
x[0][2] *= s[0];
|
||||
x[0][3] *= s[0];
|
||||
x[0][0] *= s.x;
|
||||
x[0][1] *= s.x;
|
||||
x[0][2] *= s.x;
|
||||
x[0][3] *= s.x;
|
||||
|
||||
x[1][0] *= s[1];
|
||||
x[1][1] *= s[1];
|
||||
x[1][2] *= s[1];
|
||||
x[1][3] *= s[1];
|
||||
x[1][0] *= s.y;
|
||||
x[1][1] *= s.y;
|
||||
x[1][2] *= s.y;
|
||||
x[1][3] *= s.y;
|
||||
|
||||
x[2][0] *= s[2];
|
||||
x[2][1] *= s[2];
|
||||
x[2][2] *= s[2];
|
||||
x[2][3] *= s[2];
|
||||
x[2][0] *= s.z;
|
||||
x[2][1] *= s.z;
|
||||
x[2][2] *= s.z;
|
||||
x[2][3] *= s.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -3140,9 +3140,9 @@ Matrix44<T>::setTranslation (const Vec3<S> &t)
|
||||
x[2][2] = 1;
|
||||
x[2][3] = 0;
|
||||
|
||||
x[3][0] = t[0];
|
||||
x[3][1] = t[1];
|
||||
x[3][2] = t[2];
|
||||
x[3][0] = t.x;
|
||||
x[3][1] = t.y;
|
||||
x[3][2] = t.z;
|
||||
x[3][3] = 1;
|
||||
|
||||
return *this;
|
||||
@@ -3160,10 +3160,10 @@ template <class S>
|
||||
IMATH_HOSTDEVICE const Matrix44<T> &
|
||||
Matrix44<T>::translate (const Vec3<S> &t)
|
||||
{
|
||||
x[3][0] += t[0] * x[0][0] + t[1] * x[1][0] + t[2] * x[2][0];
|
||||
x[3][1] += t[0] * x[0][1] + t[1] * x[1][1] + t[2] * x[2][1];
|
||||
x[3][2] += t[0] * x[0][2] + t[1] * x[1][2] + t[2] * x[2][2];
|
||||
x[3][3] += t[0] * x[0][3] + t[1] * x[1][3] + t[2] * x[2][3];
|
||||
x[3][0] += t.x * x[0][0] + t.y * x[1][0] + t.z * x[2][0];
|
||||
x[3][1] += t.x * x[0][1] + t.y * x[1][1] + t.z * x[2][1];
|
||||
x[3][2] += t.x * x[0][2] + t.y * x[1][2] + t.z * x[2][2];
|
||||
x[3][3] += t.x * x[0][3] + t.y * x[1][3] + t.z * x[2][3];
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -3178,13 +3178,13 @@ Matrix44<T>::setShear (const Vec3<S> &h)
|
||||
x[0][2] = 0;
|
||||
x[0][3] = 0;
|
||||
|
||||
x[1][0] = h[0];
|
||||
x[1][0] = h.x;
|
||||
x[1][1] = 1;
|
||||
x[1][2] = 0;
|
||||
x[1][3] = 0;
|
||||
|
||||
x[2][0] = h[1];
|
||||
x[2][1] = h[2];
|
||||
x[2][0] = h.y;
|
||||
x[2][1] = h.z;
|
||||
x[2][2] = 1;
|
||||
x[2][3] = 0;
|
||||
|
||||
@@ -3237,8 +3237,8 @@ Matrix44<T>::shear (const Vec3<S> &h)
|
||||
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
x[2][i] += h[1] * x[0][i] + h[2] * x[1][i];
|
||||
x[1][i] += h[0] * x[0][i];
|
||||
x[2][i] += h.y * x[0][i] + h.z * x[1][i];
|
||||
x[1][i] += h.x * x[0][i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -3253,9 +3253,9 @@ Matrix44<T>::shear (const Shear6<S> &h)
|
||||
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
x[0][i] = P[0][i] + h.yx * P[1][i] + h.zx * P[2][i];
|
||||
x[1][i] = h.xy * P[0][i] + P[1][i] + h.zy * P[2][i];
|
||||
x[2][i] = h.xz * P[0][i] + h.yz * P[1][i] + P[2][i];
|
||||
x[0][i] = P.x[0][i] + h.yx * P.x[1][i] + h.zx * P.x[2][i];
|
||||
x[1][i] = h.xy * P.x[0][i] + P.x[1][i] + h.zy * P.x[2][i];
|
||||
x[2][i] = h.xz * P.x[0][i] + h.yz * P.x[1][i] + P.x[2][i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -3285,17 +3285,17 @@ operator << (std::ostream &s, const Matrix33<T> &m)
|
||||
width = static_cast<int>(s.precision()) + 8;
|
||||
}
|
||||
|
||||
s << "(" << std::setw (width) << m[0][0] <<
|
||||
" " << std::setw (width) << m[0][1] <<
|
||||
" " << std::setw (width) << m[0][2] << "\n" <<
|
||||
s << "(" << std::setw (width) << m.x[0][0] <<
|
||||
" " << std::setw (width) << m.x[0][1] <<
|
||||
" " << std::setw (width) << m.x[0][2] << "\n" <<
|
||||
|
||||
" " << std::setw (width) << m[1][0] <<
|
||||
" " << std::setw (width) << m[1][1] <<
|
||||
" " << std::setw (width) << m[1][2] << "\n" <<
|
||||
" " << std::setw (width) << m.x[1][0] <<
|
||||
" " << std::setw (width) << m.x[1][1] <<
|
||||
" " << std::setw (width) << m.x[1][2] << "\n" <<
|
||||
|
||||
" " << std::setw (width) << m[2][0] <<
|
||||
" " << std::setw (width) << m[2][1] <<
|
||||
" " << std::setw (width) << m[2][2] << ")\n";
|
||||
" " << std::setw (width) << m.x[2][0] <<
|
||||
" " << std::setw (width) << m.x[2][1] <<
|
||||
" " << std::setw (width) << m.x[2][2] << ")\n";
|
||||
|
||||
s.flags (oldFlags);
|
||||
return s;
|
||||
@@ -3320,25 +3320,25 @@ operator << (std::ostream &s, const Matrix44<T> &m)
|
||||
width = static_cast<int>(s.precision()) + 8;
|
||||
}
|
||||
|
||||
s << "(" << std::setw (width) << m[0][0] <<
|
||||
" " << std::setw (width) << m[0][1] <<
|
||||
" " << std::setw (width) << m[0][2] <<
|
||||
" " << std::setw (width) << m[0][3] << "\n" <<
|
||||
s << "(" << std::setw (width) << m.x[0][0] <<
|
||||
" " << std::setw (width) << m.x[0][1] <<
|
||||
" " << std::setw (width) << m.x[0][2] <<
|
||||
" " << std::setw (width) << m.x[0][3] << "\n" <<
|
||||
|
||||
" " << std::setw (width) << m[1][0] <<
|
||||
" " << std::setw (width) << m[1][1] <<
|
||||
" " << std::setw (width) << m[1][2] <<
|
||||
" " << std::setw (width) << m[1][3] << "\n" <<
|
||||
" " << std::setw (width) << m.x[1][0] <<
|
||||
" " << std::setw (width) << m.x[1][1] <<
|
||||
" " << std::setw (width) << m.x[1][2] <<
|
||||
" " << std::setw (width) << m.x[1][3] << "\n" <<
|
||||
|
||||
" " << std::setw (width) << m[2][0] <<
|
||||
" " << std::setw (width) << m[2][1] <<
|
||||
" " << std::setw (width) << m[2][2] <<
|
||||
" " << std::setw (width) << m[2][3] << "\n" <<
|
||||
" " << std::setw (width) << m.x[2][0] <<
|
||||
" " << std::setw (width) << m.x[2][1] <<
|
||||
" " << std::setw (width) << m.x[2][2] <<
|
||||
" " << std::setw (width) << m.x[2][3] << "\n" <<
|
||||
|
||||
" " << std::setw (width) << m[3][0] <<
|
||||
" " << std::setw (width) << m[3][1] <<
|
||||
" " << std::setw (width) << m[3][2] <<
|
||||
" " << std::setw (width) << m[3][3] << ")\n";
|
||||
" " << std::setw (width) << m.x[3][0] <<
|
||||
" " << std::setw (width) << m.x[3][1] <<
|
||||
" " << std::setw (width) << m.x[3][2] <<
|
||||
" " << std::setw (width) << m.x[3][3] << ")\n";
|
||||
|
||||
s.flags (oldFlags);
|
||||
return s;
|
||||
@@ -3353,9 +3353,9 @@ template <class S, class T>
|
||||
IMATH_HOSTDEVICE inline const Vec2<S> &
|
||||
operator *= (Vec2<S> &v, const Matrix33<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + m[2][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + m[2][1]);
|
||||
S w = S(v.x * m[0][2] + v.y * m[1][2] + m[2][2]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + m.x[2][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + m.x[2][1]);
|
||||
S w = S(v.x * m.x[0][2] + v.y * m.x[1][2] + m.x[2][2]);
|
||||
|
||||
v.x = x / w;
|
||||
v.y = y / w;
|
||||
@@ -3367,9 +3367,9 @@ template <class S, class T>
|
||||
IMATH_HOSTDEVICE inline Vec2<S>
|
||||
operator * (const Vec2<S> &v, const Matrix33<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + m[2][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + m[2][1]);
|
||||
S w = S(v.x * m[0][2] + v.y * m[1][2] + m[2][2]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + m.x[2][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + m.x[2][1]);
|
||||
S w = S(v.x * m.x[0][2] + v.y * m.x[1][2] + m.x[2][2]);
|
||||
|
||||
return Vec2<S> (x / w, y / w);
|
||||
}
|
||||
@@ -3379,9 +3379,9 @@ template <class S, class T>
|
||||
IMATH_HOSTDEVICE inline const Vec3<S> &
|
||||
operator *= (Vec3<S> &v, const Matrix33<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1]);
|
||||
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1]);
|
||||
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2]);
|
||||
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
@@ -3394,22 +3394,22 @@ template <class S, class T>
|
||||
IMATH_HOSTDEVICE inline Vec3<S>
|
||||
operator * (const Vec3<S> &v, const Matrix33<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1]);
|
||||
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1]);
|
||||
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2]);
|
||||
|
||||
return Vec3<S> (x, y, z);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline const Vec3<S> &
|
||||
IMATH_HOSTDEVICE inline const Vec3<S> &
|
||||
operator *= (Vec3<S> &v, const Matrix44<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]);
|
||||
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
|
||||
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + m[3][3]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + m.x[3][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + m.x[3][1]);
|
||||
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + m.x[3][2]);
|
||||
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + m.x[3][3]);
|
||||
|
||||
v.x = x / w;
|
||||
v.y = y / w;
|
||||
@@ -3419,26 +3419,26 @@ operator *= (Vec3<S> &v, const Matrix44<T> &m)
|
||||
}
|
||||
|
||||
template <class S, class T>
|
||||
inline Vec3<S>
|
||||
IMATH_HOSTDEVICE inline Vec3<S>
|
||||
operator * (const Vec3<S> &v, const Matrix44<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]);
|
||||
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
|
||||
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + m[3][3]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + m.x[3][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + m.x[3][1]);
|
||||
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + m.x[3][2]);
|
||||
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + m.x[3][3]);
|
||||
|
||||
return Vec3<S> (x / w, y / w, z / w);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline const Vec4<S> &
|
||||
IMATH_HOSTDEVICE inline const Vec4<S> &
|
||||
operator *= (Vec4<S> &v, const Matrix44<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1]);
|
||||
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2]);
|
||||
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + v.w * m.x[3][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + v.w * m.x[3][1]);
|
||||
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + v.w * m.x[3][2]);
|
||||
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + v.w * m.x[3][3]);
|
||||
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
@@ -3449,13 +3449,13 @@ operator *= (Vec4<S> &v, const Matrix44<T> &m)
|
||||
}
|
||||
|
||||
template <class S, class T>
|
||||
inline Vec4<S>
|
||||
IMATH_HOSTDEVICE inline Vec4<S>
|
||||
operator * (const Vec4<S> &v, const Matrix44<T> &m)
|
||||
{
|
||||
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0]);
|
||||
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1]);
|
||||
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2]);
|
||||
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3]);
|
||||
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + v.w * m.x[3][0]);
|
||||
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + v.w * m.x[3][1]);
|
||||
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + v.w * m.x[3][2]);
|
||||
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + v.w * m.x[3][3]);
|
||||
|
||||
return Vec4<S> (x, y, z, w);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,21 @@
|
||||
|
||||
#include <OSL/oslconfig.h>
|
||||
|
||||
#if OSL_USING_IMATH < 3
|
||||
# include <OSL/matrix22.h>
|
||||
#endif
|
||||
|
||||
|
||||
OSL_NAMESPACE_ENTER
|
||||
|
||||
|
||||
#if OSL_USING_IMATH >= 3
|
||||
using Matrix22 = Imath::Matrix22<Float>;
|
||||
#else
|
||||
using Matrix22 = Imathx::Matrix22<Float>;
|
||||
#endif
|
||||
|
||||
|
||||
// Choose to treat helper functions as static
|
||||
// so their symbols don't escape and possibly collide
|
||||
// with other compilation units who might be compiled with
|
||||
@@ -244,16 +256,17 @@ affineInverse(const Matrix44 &m)
|
||||
// match results between LLVM IR based implementation and
|
||||
// compiler optimized versions which may have optimized
|
||||
// differently than the LLVM IR version.
|
||||
// Clang doesn't currently have a way to control fast-math/fp:strict
|
||||
// at a per function level, so we will resort to disabling optimization
|
||||
// for this function. Not ideal, but this is already a slow path
|
||||
// for exceptional situations.
|
||||
// GCC could use __attribute__((optimize("-fno-fast-math")))
|
||||
// NOTE: only using "inline" to get ODR (One Definition Rule) behavior
|
||||
static inline OSL_HOSTDEVICE Matrix44
|
||||
nonAffineInverse(const Matrix44 &source) OSL_CLANG_ATTRIBUTE(optnone)
|
||||
#if !OSL_INTEL_CLASSIC_COMPILER_VERSION
|
||||
OSL_GNUC_ATTRIBUTE(optimize("fp-contract=off"))
|
||||
#endif
|
||||
nonAffineInverse(const Matrix44 &source);
|
||||
|
||||
Matrix44 OSL_HOSTDEVICE nonAffineInverse(const Matrix44 &source)
|
||||
{
|
||||
OSL_INTEL_PRAGMA(float_control(strict,on,push))
|
||||
OSL_CLANG_PRAGMA(clang fp contract(off))
|
||||
|
||||
using ScalarT = typename Matrix44::BaseType;
|
||||
Matrix44 t(source);
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
AccumRule(int outidx, bool toalpha)
|
||||
: m_outidx(outidx), m_save_to_alpha(toalpha) {};
|
||||
|
||||
/// Called to accumulate from AccumAutomata. It will select the right ouput from
|
||||
/// Called to accumulate from AccumAutomata. It will select the right output from
|
||||
/// the given vector based in the AOV index number (they are guaranteed to match)
|
||||
void accum(const Color3& color, std::vector<AovOutput>& outputs) const;
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ public:
|
||||
virtual Mask get_matrix(BatchedShaderGlobals* bsg, Masked<Matrix44> wresult,
|
||||
Wide<const TransformationPtr> wxform,
|
||||
Wide<const float> wtime)
|
||||
= 0;
|
||||
{
|
||||
return Mask(false);
|
||||
}
|
||||
|
||||
/// Get the 4x4 matrix that transforms by the specified
|
||||
/// transformation at the given time. Return a Mask with lanes set to true
|
||||
@@ -81,7 +83,9 @@ public:
|
||||
/// is not known.
|
||||
virtual Mask get_matrix(BatchedShaderGlobals* bsg, Masked<Matrix44> wresult,
|
||||
ustring from, Wide<const float> wtime)
|
||||
= 0;
|
||||
{
|
||||
return Mask(false);
|
||||
}
|
||||
virtual Mask get_matrix(BatchedShaderGlobals* bsg, Masked<Matrix44> result,
|
||||
Wide<const ustring> wfrom, Wide<const float> wtime);
|
||||
virtual bool is_overridden_get_matrix_WmWsWf() const = 0;
|
||||
@@ -108,8 +112,12 @@ public:
|
||||
/// Identify if the the named attribute from the renderer can be treated as uniform
|
||||
/// across all batches to the shader. We assume all attributes are varying unless
|
||||
/// identified as uniform by the renderer. NOTE: To enable constant folding of
|
||||
// an attribute value, it must be uniform and retrievable with a NULL BatchedShaderGlobals
|
||||
virtual bool is_attribute_uniform(ustring object, ustring name) = 0;
|
||||
/// an attribute value, it must be uniform and retrievable with
|
||||
/// a NULL BatchedShaderGlobals
|
||||
virtual bool is_attribute_uniform(ustring object, ustring name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Get the named attribute from the renderer and if found then
|
||||
/// write it into 'val'. Otherwise, return false. If no object is
|
||||
@@ -118,25 +126,33 @@ public:
|
||||
/// unsuccessful, on the currently shaded "scene".
|
||||
virtual Mask get_attribute(BatchedShaderGlobals* bsg, ustring object,
|
||||
ustring name, MaskedData wval)
|
||||
= 0;
|
||||
{
|
||||
return Mask(false);
|
||||
}
|
||||
|
||||
/// Similar to get_attribute(); this method will fetch the 'index'
|
||||
/// element of an attribute array.
|
||||
virtual Mask get_array_attribute(BatchedShaderGlobals* bsg, ustring object,
|
||||
ustring name, int index, MaskedData wval)
|
||||
= 0;
|
||||
{
|
||||
return Mask(false);
|
||||
}
|
||||
|
||||
virtual bool get_attribute_uniform(BatchedShaderGlobals* bsg,
|
||||
ustring object, ustring name,
|
||||
RefData val)
|
||||
= 0;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Similar to get_attribute(); this method will fetch the 'index'
|
||||
/// element of an attribute array.
|
||||
virtual bool get_array_attribute_uniform(BatchedShaderGlobals* bsg,
|
||||
ustring object, ustring name,
|
||||
int index, RefData val)
|
||||
= 0;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Get multiple named user-data from the current object and write them into
|
||||
/// 'val'. If derivatives is true, the derivatives should be written into val
|
||||
@@ -145,7 +161,9 @@ public:
|
||||
/// found.
|
||||
virtual Mask get_userdata(ustring name, BatchedShaderGlobals* bsg,
|
||||
MaskedData wval)
|
||||
= 0;
|
||||
{
|
||||
return Mask(false);
|
||||
}
|
||||
|
||||
// Currently texture handles are serviced by the non-batched
|
||||
// RendererServices interface. If necessary, customized ones could
|
||||
@@ -233,7 +251,38 @@ public:
|
||||
virtual bool is_overridden_texture3d() const = 0;
|
||||
|
||||
|
||||
// Filtered environment lookup for a single point is T.B.D.
|
||||
/// Filtered environment lookup for a single point.
|
||||
///
|
||||
/// R is the directional texture coordinate; dRd[xy] are the
|
||||
/// differentials of R in canonical directions x, y.
|
||||
///
|
||||
/// The filename will always be passed, and it's ok for the renderer
|
||||
/// implementation to use only that (and in fact should be prepared to
|
||||
/// deal with texture_handle and texture_thread_info being NULL). But
|
||||
/// sometimes OSL can figure out the texture handle or thread info also
|
||||
/// and may pass them as non-NULL, in which case the renderer may (if it
|
||||
/// can) use that extra information to perform a less expensive texture
|
||||
/// lookup.
|
||||
///
|
||||
/// Return a Mask with lanes set to true if the file is found and could
|
||||
/// be opened, otherwise return false.
|
||||
///
|
||||
/// If the errormessage parameter is NULL, this method is expected to
|
||||
/// handle the errors fully, including forwarding them to the renderer
|
||||
/// or shading system. If errormessage is non-NULL, any resulting error
|
||||
/// messages (in case of failure, when the function returns false) will
|
||||
/// be stored there, leaving it up to the caller/shader to handle the
|
||||
/// error.
|
||||
virtual Mask environment(ustring filename,
|
||||
TextureSystem::TextureHandle* texture_handle,
|
||||
TextureSystem::Perthread* texture_thread_info,
|
||||
const BatchedTextureOptions& options,
|
||||
BatchedShaderGlobals* bsg, Wide<const Vec3> wR,
|
||||
Wide<const Vec3> wdRdx, Wide<const Vec3> wdRdy,
|
||||
BatchedTextureOutputs& outputs);
|
||||
virtual bool is_overridden_environment() const = 0;
|
||||
|
||||
|
||||
|
||||
/// Get information about the given texture. Return a Mask with lanes
|
||||
/// set to true if found and the data has been put in *data. Mask lanes
|
||||
@@ -249,20 +298,137 @@ public:
|
||||
/// can) use that extra information to perform a less expensive texture
|
||||
/// lookup.
|
||||
|
||||
// Should shader's fully avoid non-constant strings we could remove this
|
||||
// method which supports Wide<const ustring> wfilename. Or replace
|
||||
// this virtual method with a library side loop that calls the uniform version
|
||||
virtual Mask get_texture_info(
|
||||
virtual TextureSystem::TextureHandle* resolve_udim_uniform(
|
||||
BatchedShaderGlobals* bsg, TexturePerthread* texture_thread_info,
|
||||
Wide<const ustring> wfilename,
|
||||
// We do not need to support texture handle for varying data.
|
||||
int subimage, ustring dataname, MaskedData val);
|
||||
ustring filename, TextureSystem::TextureHandle* texture_handle, float S,
|
||||
float T);
|
||||
|
||||
virtual void resolve_udim(BatchedShaderGlobals* bsg,
|
||||
TexturePerthread* texture_thread_info,
|
||||
ustring filename,
|
||||
TextureSystem::TextureHandle* texture_handle,
|
||||
Wide<const float> wS, Wide<const float> wT,
|
||||
Masked<TextureSystem::TextureHandle*> wresult);
|
||||
|
||||
// Assumes any UDIM has been resolved already
|
||||
virtual bool get_texture_info_uniform(
|
||||
BatchedShaderGlobals* bsg, TexturePerthread* texture_thread_info,
|
||||
ustring filename, TextureSystem::TextureHandle* texture_handle,
|
||||
int subimage, ustring dataname, RefData val);
|
||||
|
||||
|
||||
/// Lookup nearest points in a point cloud. It will search for
|
||||
/// points around the given center within the specified radius. A
|
||||
/// list of indices is returned so the programmer can later retrieve
|
||||
/// attributes with pointcloud_get. The indices array is mandatory,
|
||||
/// but distances MaskedData can be invalid (empty), may or may not
|
||||
/// have derivs, will always be float[], and contains the mask to use
|
||||
/// for the operations.
|
||||
///
|
||||
/// out_num_points will contain the number of points found, always < max_points
|
||||
|
||||
// To enable sharing of single mask with multiple outputs we use
|
||||
// a class to encapsulate multiple wide pointers with a single mask.
|
||||
// Because the Masked accessors will be constructed by the helper methods
|
||||
// once inlined compilers will see the same mask_value is used for both.
|
||||
class PointCloudSearchResults {
|
||||
void* m_wnum_points;
|
||||
void* m_windices;
|
||||
int m_indices_array_length;
|
||||
void* m_wdistances;
|
||||
int m_distances_array_length;
|
||||
bool m_distances_have_derivs;
|
||||
Mask m_mask;
|
||||
|
||||
public:
|
||||
PointCloudSearchResults(void* wnum_points, void* windices,
|
||||
int indices_array_length, void* wdistances,
|
||||
int distances_array_length,
|
||||
int distances_have_derivs, int mask_value)
|
||||
: m_wnum_points(wnum_points)
|
||||
, m_windices(windices)
|
||||
, m_indices_array_length(indices_array_length)
|
||||
, m_wdistances(wdistances)
|
||||
, m_distances_array_length(distances_array_length)
|
||||
, m_distances_have_derivs(distances_have_derivs)
|
||||
, m_mask(mask_value)
|
||||
{
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE Mask mask() const { return m_mask; }
|
||||
|
||||
// NOTE: Always assign to a local object before calling an
|
||||
// array subscript operator []. Bugs can occur if the []
|
||||
// is called on a temporary object as a reference to a
|
||||
// temporary object would be created.
|
||||
// DO NOT DO THIS:
|
||||
// auto out_num_points = results.wnum_points()[lane];
|
||||
// instead
|
||||
// auto wnum_points = results.wnum_points();
|
||||
// auto out_num_points = wnum_points[lane];
|
||||
|
||||
OSL_FORCEINLINE Masked<int> wnum_points() const
|
||||
{
|
||||
return Masked<int>(m_wnum_points, m_mask);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE Masked<int[]> windices() const
|
||||
{
|
||||
return Masked<int[]>(m_windices, m_indices_array_length, m_mask);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE bool has_distances() const
|
||||
{
|
||||
return m_wdistances != nullptr;
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE Masked<float[]> wdistances() const
|
||||
{
|
||||
return Masked<float[]>(m_wdistances, m_distances_array_length,
|
||||
m_mask);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE bool distances_have_derivs() const
|
||||
{
|
||||
return m_distances_have_derivs;
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE MaskedDx<float[]> wdistancesDx() const
|
||||
{
|
||||
return MaskedDx<float[]>(m_wdistances, m_distances_array_length,
|
||||
m_mask);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE MaskedDy<float[]> wdistancesDy() const
|
||||
{
|
||||
return MaskedDy<float[]>(m_wdistances, m_distances_array_length,
|
||||
m_mask);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
virtual void pointcloud_search(BatchedShaderGlobals* bsg, ustring filename,
|
||||
const void* wcenter,
|
||||
Wide<const float> wradius, int max_points,
|
||||
bool sort, PointCloudSearchResults& results);
|
||||
virtual bool is_overridden_pointcloud_search() const = 0;
|
||||
|
||||
|
||||
virtual Mask pointcloud_get(BatchedShaderGlobals* bsg, ustring filename,
|
||||
Wide<const int[]> windices,
|
||||
Wide<const int> wnum_points, ustring attr_name,
|
||||
MaskedData wout_data);
|
||||
virtual bool is_overridden_pointcloud_get() const = 0;
|
||||
|
||||
|
||||
virtual Mask pointcloud_write(BatchedShaderGlobals* bsg, ustring filename,
|
||||
Wide<const OSL::Vec3> wpos, int nattribs,
|
||||
const ustring* attr_names,
|
||||
const TypeDesc* attr_types,
|
||||
const void** pointers_to_wide_attr_value,
|
||||
Mask mask);
|
||||
virtual bool is_overridden_pointcloud_write() const = 0;
|
||||
|
||||
/// Options for the trace call.
|
||||
using TraceOpt = RendererServices::TraceOpt;
|
||||
|
||||
|
||||
@@ -43,13 +43,6 @@ struct UniformShaderGlobals {
|
||||
/// way back to the renderer for callbacks.
|
||||
RendererServices* renderer;
|
||||
|
||||
/// The output closure will be placed here. The rendererer should
|
||||
/// initialize this to NULL before shading execution, and this is where
|
||||
/// it can retrieve the output closure from after shader execution has
|
||||
/// completed.
|
||||
/// DESIGN DECISION: NOT CURRENTLY SUPPORTING CLOSURES IN BATCH MODE
|
||||
ClosureColor* Ci;
|
||||
|
||||
/// Bit field of ray type flags.
|
||||
int raytype;
|
||||
|
||||
@@ -59,6 +52,8 @@ struct UniformShaderGlobals {
|
||||
int pad0;
|
||||
int pad1;
|
||||
int pad2;
|
||||
int pad3;
|
||||
int pad4;
|
||||
|
||||
void dump()
|
||||
{
|
||||
@@ -70,7 +65,6 @@ struct UniformShaderGlobals {
|
||||
__OSL_DUMP(objdata);
|
||||
__OSL_DUMP(context);
|
||||
__OSL_DUMP(renderer);
|
||||
__OSL_DUMP(Ci);
|
||||
__OSL_DUMP(raytype);
|
||||
|
||||
std::cout << "};" << std::endl;
|
||||
@@ -129,6 +123,12 @@ template<int WidthT> struct alignas(64) VaryingShaderGlobals {
|
||||
Block<TransformationPtr> object2common;
|
||||
Block<TransformationPtr> shader2common;
|
||||
|
||||
/// The output closure will be placed here. The rendererer should
|
||||
/// initialize this to NULL before shading execution, and this is where
|
||||
/// it can retrieve the output closure from after shader execution has
|
||||
/// completed.
|
||||
Block<ClosureColor*> Ci;
|
||||
|
||||
/// Surface area of the emissive object (used by light shaders for
|
||||
/// energy normalization).
|
||||
Block<float> surfacearea;
|
||||
@@ -168,6 +168,7 @@ template<int WidthT> struct alignas(64) VaryingShaderGlobals {
|
||||
__OSL_DUMP(dPsdy);
|
||||
__OSL_DUMP(object2common);
|
||||
__OSL_DUMP(shader2common);
|
||||
__OSL_DUMP(Ci);
|
||||
__OSL_DUMP(surfacearea);
|
||||
__OSL_DUMP(flipHandedness);
|
||||
__OSL_DUMP(backfacing);
|
||||
|
||||
@@ -41,6 +41,9 @@ template<int WidthT> struct VaryingTextureOptions {
|
||||
Block<float, WidthT> swidth; ///< Multiplier for derivatives
|
||||
Block<float, WidthT> twidth;
|
||||
Block<float, WidthT> rwidth; // For 3D volume texture lookups only:
|
||||
#if OIIO_VERSION_GREATER_EQUAL(2, 4, 0)
|
||||
Block<float, WidthT> rnd; // For stochastic sampling
|
||||
#endif
|
||||
};
|
||||
static_assert(std::alignment_of<VaryingTextureOptions<16>>::value
|
||||
== VecReg<16>::alignment,
|
||||
@@ -66,6 +69,9 @@ template<int WidthT> struct BatchedTextureOptions {
|
||||
swidth,
|
||||
twidth,
|
||||
rwidth,
|
||||
#if OIIO_VERSION_GREATER_EQUAL(2, 4, 0)
|
||||
rnd,
|
||||
#endif
|
||||
firstchannel,
|
||||
subimage,
|
||||
subimagename,
|
||||
@@ -117,6 +123,10 @@ static_assert(offsetof(OIIO::TextureOptBatch, twidth) % 64 == 0,
|
||||
"oops unaligned wide variable");
|
||||
static_assert(offsetof(OIIO::TextureOptBatch, rwidth) % 64 == 0,
|
||||
"oops unaligned wide variable");
|
||||
# if OIIO_VERSION_GREATER_EQUAL(2, 4, 0)
|
||||
static_assert(offsetof(OIIO::TextureOptBatch, rnd) % 64 == 0,
|
||||
"oops unaligned wide variable");
|
||||
# endif
|
||||
|
||||
static_assert(sizeof(OIIO::TextureOptBatch)
|
||||
== sizeof(BatchedTextureOptions<16>),
|
||||
@@ -125,77 +135,77 @@ static_assert(sizeof(OIIO::TextureOptBatch)
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, sblur)
|
||||
== varying_offset + offsetof(VTO, sblur),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, tblur)
|
||||
== varying_offset + offsetof(VTO, tblur),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, rblur)
|
||||
== varying_offset + offsetof(VTO, rblur),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, swidth)
|
||||
== varying_offset + offsetof(VTO, swidth),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, twidth)
|
||||
== varying_offset + offsetof(VTO, twidth),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, rwidth)
|
||||
== varying_offset + offsetof(VTO, rwidth),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, firstchannel)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, firstchannel),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, subimage)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, subimage),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, subimagename)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, subimagename),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, swrap)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, swrap),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, twrap)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, twrap),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, rwrap)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, rwrap),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, mipmode)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, mipmode),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, interpmode)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, interpmode),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, anisotropic)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, anisotropic),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, conservative_filter)
|
||||
== uniform_offset
|
||||
+ offsetof(UniformTextureOptions, conservative_filter),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, fill)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, fill),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
static_assert(
|
||||
offsetof(OIIO::TextureOptBatch, missingcolor)
|
||||
== uniform_offset + offsetof(UniformTextureOptions, missingcolor),
|
||||
"BatchedTextureOptions members offset different that OIIO::TextureOptBatch");
|
||||
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
|
||||
|
||||
OSL_PRAGMA_WARNING_POP
|
||||
} // namespace validate_offsets
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <OSL/oslconfig.h>
|
||||
|
||||
#ifdef __CUDA_ARCH__
|
||||
#include <optix.h>
|
||||
# include <optix.h>
|
||||
#endif
|
||||
|
||||
// USAGE NOTES:
|
||||
@@ -36,20 +36,20 @@ OSL_NAMESPACE_ENTER
|
||||
// stored in the table, in the 16 bytes preceding the characters.
|
||||
|
||||
struct DeviceString {
|
||||
#if defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000
|
||||
size_t m_chars;
|
||||
#ifdef __CUDA_ARCH__
|
||||
size_t m_chars;
|
||||
#else
|
||||
const char* m_chars;
|
||||
#endif
|
||||
|
||||
#if defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000
|
||||
#ifdef __CUDA_ARCH__
|
||||
OSL_HOSTDEVICE DeviceString() {}
|
||||
OSL_HOSTDEVICE DeviceString(uint64_t i) : m_chars(i) {}
|
||||
#endif
|
||||
|
||||
OSL_HOSTDEVICE uint64_t hash() const
|
||||
{
|
||||
#if defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000
|
||||
#ifdef __CUDA_ARCH__
|
||||
return m_chars;
|
||||
#else
|
||||
return *(uint64_t*)(m_chars - sizeof(uint64_t) - sizeof(uint64_t));
|
||||
@@ -58,7 +58,7 @@ struct DeviceString {
|
||||
|
||||
// In OptiX 7 we don't store the string's length. Make this a compile
|
||||
// time error.
|
||||
#if ! (defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000)
|
||||
#ifndef __CUDA_ARCH__
|
||||
OSL_HOSTDEVICE uint64_t length() const
|
||||
{
|
||||
return *(uint64_t*)(m_chars - sizeof(uint64_t));
|
||||
@@ -67,36 +67,39 @@ struct DeviceString {
|
||||
|
||||
// In OptiX 7 we can't return the string's contents. Make this a compile
|
||||
// time error.
|
||||
#if ! (defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000)
|
||||
#ifndef __CUDA_ARCH__
|
||||
OSL_HOSTDEVICE const char* c_str() const
|
||||
{
|
||||
return m_chars;
|
||||
}
|
||||
#endif
|
||||
|
||||
OSL_HOSTDEVICE bool operator== (const DeviceString& other) const
|
||||
OSL_HOSTDEVICE bool operator==(const DeviceString& other) const
|
||||
{
|
||||
return m_chars == other.m_chars;
|
||||
}
|
||||
|
||||
OSL_HOSTDEVICE bool operator!= (const DeviceString& other) const
|
||||
OSL_HOSTDEVICE bool operator!=(const DeviceString& other) const
|
||||
{
|
||||
return m_chars != other.m_chars;
|
||||
}
|
||||
|
||||
#if defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000
|
||||
#ifdef __CUDA_ARCH__
|
||||
|
||||
OSL_HOSTDEVICE bool operator== (const size_t other) const
|
||||
OSL_HOSTDEVICE bool operator==(const size_t other) const
|
||||
{
|
||||
return hash() == other;
|
||||
}
|
||||
|
||||
OSL_HOSTDEVICE bool operator!= (const size_t other) const
|
||||
OSL_HOSTDEVICE bool operator!=(const size_t other) const
|
||||
{
|
||||
return hash() != other;
|
||||
}
|
||||
|
||||
OSL_HOSTDEVICE operator size_t() const { return hash(); }
|
||||
OSL_HOSTDEVICE operator size_t() const
|
||||
{
|
||||
return hash();
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
@@ -106,9 +109,9 @@ struct DeviceString {
|
||||
// macro is the same as the USTR macro defined in oslexec_pvt.h when compiling
|
||||
// for the host.
|
||||
#ifndef __CUDA_ARCH__
|
||||
# define HDSTR(cstr) (*((ustring *)&cstr))
|
||||
# define HDSTR(cstr) (*((ustring*)&cstr))
|
||||
#else
|
||||
#define HDSTR(cstr) (*((OSL::DeviceString*)&cstr))
|
||||
# define HDSTR(cstr) (*((OSL::DeviceString*)&cstr))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -124,25 +127,22 @@ typedef DeviceString StringParam;
|
||||
|
||||
#ifdef __CUDA_ARCH__
|
||||
namespace DeviceStrings {
|
||||
#define STRDECL(str,var_name) \
|
||||
extern __device__ OSL_NAMESPACE::DeviceString var_name;
|
||||
#if OPTIX_VERSION < 70000
|
||||
# include <OSL/strdecls.h>
|
||||
#endif
|
||||
#undef STRDECL
|
||||
}
|
||||
# define STRDECL(str, var_name) \
|
||||
extern __device__ OSL_NAMESPACE::DeviceString var_name;
|
||||
# undef STRDECL
|
||||
} // namespace DeviceStrings
|
||||
#else
|
||||
# define STRING_PARAMS(x) StringParams::x
|
||||
# ifdef OSL_HOST_RS_BITCODE
|
||||
# define STRING_PARAMS(x) RS_##x
|
||||
# else
|
||||
# define STRING_PARAMS(x) StringParams::x
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
OSL_NAMESPACE_EXIT
|
||||
|
||||
|
||||
#ifdef __CUDA_ARCH__
|
||||
#if OPTIX_VERSION < 70000
|
||||
namespace StringParams = OSL_NAMESPACE::DeviceStrings;
|
||||
#endif
|
||||
#else
|
||||
#ifndef __CUDA_ARCH__
|
||||
namespace StringParams = OSL_NAMESPACE::Strings;
|
||||
#endif
|
||||
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
// delegating access to element storage to the DualStorage base class
|
||||
template<
|
||||
class T, // Base data type
|
||||
int PARTIALS=1 // Number of dimentions of partial derivs
|
||||
int PARTIALS=1 // Number of dimensions of partial derivs
|
||||
>
|
||||
class Dual : public DualStorage<T, PARTIALS> {
|
||||
static const int elements = PARTIALS+1; // main value + partials
|
||||
|
||||
+509
-406
File diff suppressed because it is too large
Load Diff
+40
-12
@@ -4,7 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <immintrin.h>
|
||||
#include <type_traits>
|
||||
|
||||
#include <OSL/oslconfig.h>
|
||||
@@ -21,7 +20,9 @@ OSL_NAMESPACE_ENTER
|
||||
using std::popcount;
|
||||
using std::countr_zero;
|
||||
|
||||
#elif OSL_INTEL_COMPILER
|
||||
#elif OSL_INTEL_CLASSIC_COMPILER_VERSION
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
OSL_FORCEINLINE int popcount(uint32_t x) noexcept { return _mm_popcnt_u32(x);}
|
||||
OSL_FORCEINLINE int popcount(uint64_t x) noexcept { return _mm_popcnt_u64(x); }
|
||||
@@ -170,13 +171,22 @@ public:
|
||||
}
|
||||
|
||||
|
||||
OSL_FORCEINLINE ValueType value() const { return m_value; }
|
||||
OSL_FORCEINLINE ValueType value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
// count number of active bits
|
||||
OSL_FORCEINLINE int count() const { return OSL::popcount(m_value); }
|
||||
OSL_FORCEINLINE int count() const
|
||||
{
|
||||
return OSL::popcount(m_value);
|
||||
}
|
||||
|
||||
// NOTE: undefined result if no bits are on
|
||||
OSL_FORCEINLINE int first_on() const { return OSL::countr_zero(m_value); }
|
||||
OSL_FORCEINLINE int first_on() const
|
||||
{
|
||||
return OSL::countr_zero(m_value);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE Mask invert() const
|
||||
{
|
||||
@@ -229,7 +239,10 @@ public:
|
||||
return (m_value != static_cast<ValueType>(0));
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE bool any_off() const { return (m_value < valid_bits); }
|
||||
OSL_FORCEINLINE bool any_off() const
|
||||
{
|
||||
return (m_value < valid_bits);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE bool any_off(const Mask& mask) const
|
||||
{
|
||||
@@ -244,27 +257,39 @@ public:
|
||||
// So really only set_on or set_off is required
|
||||
// Choose to not provide a generic set(int lane, bool flag)
|
||||
|
||||
OSL_FORCEINLINE void set_on(int lane) { m_value |= (1 << lane); }
|
||||
OSL_FORCEINLINE void set_on(int lane)
|
||||
{
|
||||
m_value |= (1 << lane);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE void set_on_if(int lane, bool cond)
|
||||
{
|
||||
m_value |= (cond << lane);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE void set_all_on() { m_value = valid_bits; }
|
||||
OSL_FORCEINLINE void set_all_on()
|
||||
{
|
||||
m_value = valid_bits;
|
||||
}
|
||||
OSL_FORCEINLINE void set_count_on(int count)
|
||||
{
|
||||
m_value = valid_bits >> (width - count);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE void set_off(int lane) { m_value &= (~(1 << lane)); }
|
||||
OSL_FORCEINLINE void set_off(int lane)
|
||||
{
|
||||
m_value &= (~(1 << lane));
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE void set_off_if(int lane, bool cond)
|
||||
{
|
||||
m_value &= (~(cond << lane));
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE void set_all_off() { m_value = static_cast<ValueType>(0); }
|
||||
OSL_FORCEINLINE void set_all_off()
|
||||
{
|
||||
m_value = static_cast<ValueType>(0);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE bool operator==(const Mask& other) const
|
||||
{
|
||||
@@ -298,7 +323,10 @@ public:
|
||||
return Mask(m_value | other.m_value);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE Mask operator~() const { return invert(); }
|
||||
OSL_FORCEINLINE Mask operator~() const
|
||||
{
|
||||
return invert();
|
||||
}
|
||||
|
||||
|
||||
template<int MinOccupancyT, int MaxOccupancyT = width, typename FunctorT>
|
||||
@@ -342,7 +370,7 @@ public:
|
||||
// mixing serial code gen with call site which could inhibit
|
||||
// ability to generate SIMD code.
|
||||
template<int MinOccupancyT, int MaxOccupancyT = width, typename FunctorT>
|
||||
OSL_FORCEINLINE void invoke_foreach(FunctorT f) const;
|
||||
OSL_NOINLINE void invoke_foreach(FunctorT f) const;
|
||||
|
||||
template<typename FunctorT>
|
||||
OSL_NOINLINE void invoke_foreach(FunctorT f) const;
|
||||
|
||||
@@ -959,7 +959,7 @@ Matrix22<T>::inverse (bool singExc) const
|
||||
{
|
||||
#ifndef __CUDA_ARCH__
|
||||
if (singExc)
|
||||
throw Imath::SingMatrixExc ("Cannot invert "
|
||||
throw std::invalid_argument ("Cannot invert "
|
||||
"singular matrix.");
|
||||
#endif
|
||||
return Matrix22();
|
||||
|
||||
@@ -109,8 +109,14 @@ OSL_ALIGNAS(16) ClosureComponent : public ClosureColor
|
||||
Vec3 w; ///< Weight of this component
|
||||
|
||||
/// Handy method for getting the parameter memory as a void*.
|
||||
OSL_HOSTDEVICE void* data() { return (char*)(this + 1); }
|
||||
OSL_HOSTDEVICE const void* data() const { return (const char*)(this + 1); }
|
||||
OSL_HOSTDEVICE void* data()
|
||||
{
|
||||
return (char*)(this + 1);
|
||||
}
|
||||
OSL_HOSTDEVICE const void* data() const
|
||||
{
|
||||
return (const char*)(this + 1);
|
||||
}
|
||||
|
||||
/// Handy methods for extracting the underlying parameters as a struct
|
||||
template<typename T> OSL_HOSTDEVICE const T* as() const
|
||||
@@ -120,7 +126,7 @@ OSL_ALIGNAS(16) ClosureComponent : public ClosureColor
|
||||
|
||||
template<typename T> OSL_HOSTDEVICE T* as()
|
||||
{
|
||||
return reinterpret_cast<const T*>(data());
|
||||
return reinterpret_cast<T*>(data());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -140,4 +146,10 @@ struct OSLEXECPUBLIC ClosureAdd : public ClosureColor {
|
||||
const ClosureColor* closureB;
|
||||
};
|
||||
|
||||
/// Type for pointers to closures
|
||||
typedef ClosureColor* ClosureColorPtr;
|
||||
typedef ClosureComponent* ClosureComponentPtr;
|
||||
typedef ClosureAdd* ClosureAddPtr;
|
||||
typedef ClosureMul* ClosureMulPtr;
|
||||
|
||||
OSL_NAMESPACE_EXIT
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OSL/platform.h>
|
||||
#include <OSL/export.h>
|
||||
#include <OSL/oslversion.h>
|
||||
#include <OSL/platform.h>
|
||||
|
||||
|
||||
// All the things we need from Imath.
|
||||
@@ -23,19 +23,33 @@
|
||||
# include <OSL/Imathx/ImathVec.h>
|
||||
# include <OSL/Imathx/ImathMatrix.h>
|
||||
# include <OSL/Imathx/ImathColor.h>
|
||||
# include <OSL/matrix22.h>
|
||||
#endif
|
||||
|
||||
// The fmt library causes trouble for Cuda. Work around by disabling it from
|
||||
// oiio headers (OIIO <= 2.1) or telling fmt not to use the troublesome
|
||||
// int128 that Cuda doesn't understand (OIIO >= 2.2).
|
||||
// We included the Imath files we needed, so set the OIIO_IMATH_H_INCLUDED
|
||||
// symbol to prevent OpenImageIO/Imath.h from including them again (or
|
||||
// before), which is critical if they turn out to be different versions.
|
||||
#define OIIO_IMATH_H_INCLUDED 1
|
||||
|
||||
|
||||
// The fmt library causes trouble for Cuda. Work around by telling fmt not to
|
||||
// use the troublesome int128 that Cuda doesn't understand.
|
||||
#ifdef __CUDA_ARCH__
|
||||
# define OIIO_USE_FMT 0
|
||||
# ifndef FMT_USE_INT128
|
||||
# define FMT_USE_INT128 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// For OSL internal compilation only, get deprecation warnings if we call OIIO
|
||||
// methods that use the old printf style interface.
|
||||
#ifdef OSL_INTERNAL
|
||||
# ifdef OIIO_ERRORHANDLER_HIDE_PRINTF
|
||||
# define OIIO_ERRORHANDLER_HIDE_PRINTF 1
|
||||
# endif
|
||||
# ifdef OIIO_HIDE_FORMAT
|
||||
# define OIIO_HIDE_FORMAT 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// All the things we need from OpenImageIO
|
||||
#include <OpenImageIO/oiioversion.h>
|
||||
#include <OpenImageIO/errorhandler.h>
|
||||
@@ -76,11 +90,6 @@ using Color3 = Imath::Color3<Float>;
|
||||
using Matrix33 = Imath::Matrix33<Float>;
|
||||
using Matrix44 = Imath::Matrix44<Float>;
|
||||
|
||||
#if OSL_USING_IMATH >= 3
|
||||
using Matrix22 = Imath::Matrix22<Float>;
|
||||
#else
|
||||
using Matrix22 = Imathx::Matrix22<Float>;
|
||||
#endif
|
||||
|
||||
|
||||
/// Assume that we are dealing with OpenImageIO's texture system. It
|
||||
@@ -92,13 +101,37 @@ using OIIO::TextureOpt;
|
||||
|
||||
// And some other things we borrow from OIIO...
|
||||
using OIIO::ErrorHandler;
|
||||
using OIIO::TypeDesc;
|
||||
using OIIO::ustring;
|
||||
using OIIO::ustringHash;
|
||||
using OIIO::ustringhash;
|
||||
using OIIO::string_view;
|
||||
using OIIO::span;
|
||||
using OIIO::cspan;
|
||||
|
||||
using OIIO::TypeDesc;
|
||||
using OIIO::TypeUnknown;
|
||||
using OIIO::TypeFloat;
|
||||
using OIIO::TypeColor;
|
||||
using OIIO::TypePoint;
|
||||
using OIIO::TypeVector;
|
||||
using OIIO::TypeNormal;
|
||||
using OIIO::TypeMatrix;
|
||||
using OIIO::TypeFloat4;
|
||||
using OIIO::TypeString;
|
||||
using OIIO::TypeInt;
|
||||
using OIIO::TypeFloat2;
|
||||
using OIIO::TypeVector2;
|
||||
using OIIO::TypeVector4;
|
||||
|
||||
using OIIO::Strutil::print;
|
||||
|
||||
template<typename Str, typename... Args>
|
||||
OSL_NODISCARD inline std::string
|
||||
fmtformat(const Str& fmt, Args&&... args)
|
||||
{
|
||||
return OIIO::Strutil::fmt::format(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// N.B. SymArena is not really "configuration", but we cram it here for
|
||||
// lack of a better home.
|
||||
@@ -108,9 +141,9 @@ enum class SymArena {
|
||||
Unknown = 0, // Unknown/uninitialized value
|
||||
Absolute, // Absolute address
|
||||
Heap, // Belongs to context heap
|
||||
Outputs // Belongs to output arena
|
||||
Outputs, // Belongs to output arena
|
||||
UserData, // UserData arena
|
||||
// ShaderGlobals, // RESERVED
|
||||
// UserData, // RESERVED
|
||||
};
|
||||
|
||||
|
||||
@@ -192,3 +225,30 @@ using ConstIndex = std::integral_constant<int, N>;
|
||||
|
||||
|
||||
OSL_NAMESPACE_EXIT
|
||||
|
||||
|
||||
namespace std { // not necessary in C++17, then we can just say std::hash
|
||||
#ifndef OIIO_USTRING_HAS_STDHASH
|
||||
// Not a new enough OIIO to define std::hash<ustring>, so we'll do it
|
||||
template<> struct hash<OSL::ustring> {
|
||||
std::size_t operator()(OSL::ustring u) const noexcept { return u.hash(); }
|
||||
};
|
||||
|
||||
template<> struct hash<OSL::ustringhash> {
|
||||
OSL_HOSTDEVICE constexpr std::size_t
|
||||
operator()(OSL::ustringhash u) const noexcept
|
||||
{
|
||||
return u.hash();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// Not necessary once minimum OIIO defines operator< for ustringhash
|
||||
template<> struct less<OSL::ustringhash> {
|
||||
OSL_HOSTDEVICE constexpr bool operator()(OSL::ustringhash u,
|
||||
OSL::ustringhash v) const noexcept
|
||||
{
|
||||
return u.hash() < v.hash();
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
+299
-228
@@ -25,9 +25,16 @@ class ShaderSymbol;
|
||||
class OSLQuery;
|
||||
#if OSL_USE_BATCHED
|
||||
template<int WidthT> struct alignas(64) BatchedShaderGlobals;
|
||||
template<typename DataT, int WidthT> struct Wide;
|
||||
#endif
|
||||
|
||||
|
||||
/// RendererServices free function bitcode may reference global variables that
|
||||
/// only exist in the renderer's program space and won't automatically be
|
||||
/// found when referenced in JIT'd code inside OSL. A renderer may register
|
||||
/// the addresses of these global variables to allow valid JIT to occur.
|
||||
void OSLEXECPUBLIC
|
||||
register_JIT_Global(const char* global_var_name, void* global_var_addr);
|
||||
|
||||
/// Opaque pointer to whatever the renderer uses to represent a
|
||||
/// (potentially motion-blurred) coordinate transformation.
|
||||
@@ -43,73 +50,73 @@ namespace pvt {
|
||||
class ShadingSystemImpl;
|
||||
}
|
||||
|
||||
#if defined(__CUDA_ARCH__) && OPTIX_VERSION >= 70000
|
||||
# define STRINGIFY(x) XSTR(x)
|
||||
# define XSTR(x) #x
|
||||
# define STRING_PARAMS(x) UStringHash::Hash(STRINGIFY(x))
|
||||
#ifdef __CUDA_ARCH__
|
||||
# define STRING_PARAMS(x) UStringHash::Hash(__OSL_STRINGIFY(x))
|
||||
#else
|
||||
# define STRING_PARAMS(x) StringParams::x
|
||||
# define STRING_PARAMS(x) StringParams::x
|
||||
#endif
|
||||
|
||||
namespace Strings {
|
||||
#ifdef __CUDA_ARCH__
|
||||
# if OPTIX_VERSION >= 70000
|
||||
# define STRDECL(str,var_name)
|
||||
# define STRDECL(str, var_name)
|
||||
#else
|
||||
# define STRDECL(str,var_name) extern __device__ ustring var_name;
|
||||
#endif
|
||||
#else
|
||||
// Any strings referenced inside of a libsoslexec/wide/*.cpp
|
||||
// or liboslnoise/wide/*.cpp will need OSLEXECPUBLIC
|
||||
#define STRDECL(str,var_name) OSLEXECPUBLIC extern const ustring var_name;
|
||||
// Any strings referenced inside of a libsoslexec/wide/*.cpp
|
||||
// or liboslnoise/wide/*.cpp will need OSLEXECPUBLIC
|
||||
# define STRDECL(str, var_name) OSLEXECPUBLIC extern const ustring var_name;
|
||||
#endif
|
||||
#include <OSL/strdecls.h>
|
||||
#undef STRDECL
|
||||
}; // namespace Strings
|
||||
}; // namespace Strings
|
||||
|
||||
|
||||
|
||||
/// Description of where a symbol is located on the app side.
|
||||
struct SymLocationDesc {
|
||||
public:
|
||||
using offset_t = int64_t;
|
||||
using stride_t = int64_t;
|
||||
using offset_t = int64_t;
|
||||
using stride_t = int64_t;
|
||||
static const int64_t AutoStride = std::numeric_limits<stride_t>::min();
|
||||
|
||||
SymLocationDesc() {}
|
||||
SymLocationDesc(string_view name, TypeDesc type, bool derivs = false,
|
||||
SymArena arena = SymArena::Heap, offset_t offset = -1,
|
||||
stride_t stride = AutoStride)
|
||||
: name(name), type(type), offset(offset),
|
||||
stride(stride == AutoStride ? type.size() : stride),
|
||||
arena(arena), derivs(derivs)
|
||||
{}
|
||||
: name(name)
|
||||
, type(type)
|
||||
, offset(offset)
|
||||
, stride(stride == AutoStride ? type.size() : stride)
|
||||
, arena(arena)
|
||||
, derivs(derivs)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(ustring n) const { return name == n; }
|
||||
friend bool operator<(ustring n, const SymLocationDesc& sld) {
|
||||
friend bool operator<(ustring n, const SymLocationDesc& sld)
|
||||
{
|
||||
return n < sld.name;
|
||||
}
|
||||
friend bool operator<(const SymLocationDesc& sld, ustring n) {
|
||||
friend bool operator<(const SymLocationDesc& sld, ustring n)
|
||||
{
|
||||
return sld.name < n;
|
||||
}
|
||||
|
||||
ustring name; ///< Name of the symbol
|
||||
TypeDesc type; ///< Data type of the symbol
|
||||
offset_t offset = -1; ///< Offset from arena base for point 0
|
||||
stride_t stride = AutoStride; ///< Stride in bytes between shade points
|
||||
SymArena arena = SymArena::Heap; ///< Memory arena type for the symbol
|
||||
bool derivs = false; ///< Space allocated for derivs also
|
||||
ustring name; ///< Name of the symbol
|
||||
TypeDesc type; ///< Data type of the symbol
|
||||
offset_t offset
|
||||
= -1; ///< Offset from arena base for point 0 (batched mode assumes userdata at point 0 is readable)
|
||||
stride_t stride = AutoStride; ///< Stride in bytes between shade points
|
||||
SymArena arena = SymArena::Heap; ///< Memory arena type for the symbol
|
||||
bool derivs = false; ///< Space allocated for derivs also
|
||||
};
|
||||
|
||||
|
||||
|
||||
class OSLEXECPUBLIC ShadingSystem
|
||||
{
|
||||
class OSLEXECPUBLIC ShadingSystem {
|
||||
public:
|
||||
ShadingSystem (RendererServices *renderer=NULL,
|
||||
TextureSystem *texturesystem=NULL,
|
||||
ErrorHandler *err=NULL);
|
||||
~ShadingSystem ();
|
||||
ShadingSystem(RendererServices* renderer = NULL,
|
||||
TextureSystem* texturesystem = NULL,
|
||||
ErrorHandler* err = NULL);
|
||||
~ShadingSystem();
|
||||
|
||||
/// Set an attribute controlling the shading system. Return true
|
||||
/// if the name and type were recognized and the attrib was set.
|
||||
@@ -136,10 +143,11 @@ public:
|
||||
/// int no_noise Replace noise with constant value. (0)
|
||||
/// int no_pointcloud Skip pointcloud lookups. (0)
|
||||
/// int exec_repeat How many times to run each group (1).
|
||||
/// int opt_warnings Warn on certain failure to runtime-optimize
|
||||
/// certain shader constructs. (0)
|
||||
/// int gpu_opt_error Consider a hard error if certain shader
|
||||
/// constructs cannot be optimized away. (0)
|
||||
/// int opt_warnings Warn on failure to runtime-optimize certain
|
||||
/// shader constructs. (0)
|
||||
/// int gpu_opt_error Issue a hard error if certain shader
|
||||
/// constructs cannot be optimized away, which
|
||||
/// have no way to run on GPU. (0)
|
||||
/// 2. Attributes that should be set by applications/renderers that
|
||||
/// incorporate OSL:
|
||||
/// string commonspace Name of "common" coord system ("world")
|
||||
@@ -223,8 +231,7 @@ public:
|
||||
/// for debugging. (0)
|
||||
/// int llvm_dumpasm Print the CPU assembly code from the JIT (0)
|
||||
/// string llvm_prune_ir_strategy Strategy for pruning unnecessary
|
||||
/// IR (choices: "prune" [default],
|
||||
/// "internalize", or "none").
|
||||
/// IR (choices: "prune" [default], or "none").
|
||||
/// int max_local_mem_KB Error if shader group needs more than this
|
||||
/// much local storage to execute (1024K)
|
||||
/// string debug_groupname Name of shader group -- debug only this one
|
||||
@@ -239,22 +246,27 @@ public:
|
||||
/// Note: the attributes referred to as "string" are actually on the app
|
||||
/// side as ustring or const char* (they have the same data layout), NOT
|
||||
/// std::string!
|
||||
bool attribute (string_view name, TypeDesc type, const void *val);
|
||||
bool attribute(string_view name, TypeDesc type, const void* val);
|
||||
|
||||
// Shortcuts for common types
|
||||
bool attribute (string_view name, int val) {
|
||||
return attribute (name, TypeDesc::INT, &val);
|
||||
bool attribute(string_view name, int val)
|
||||
{
|
||||
return attribute(name, TypeDesc::INT, &val);
|
||||
}
|
||||
bool attribute (string_view name, float val) {
|
||||
return attribute (name, TypeDesc::FLOAT, &val);
|
||||
bool attribute(string_view name, float val)
|
||||
{
|
||||
return attribute(name, TypeDesc::FLOAT, &val);
|
||||
}
|
||||
bool attribute (string_view name, double val) {
|
||||
float f = (float) val;
|
||||
return attribute (name, TypeDesc::FLOAT, &f);
|
||||
bool attribute(string_view name, double val)
|
||||
{
|
||||
float f = (float)val;
|
||||
return attribute(name, TypeDesc::FLOAT, &f);
|
||||
}
|
||||
bool attribute (string_view name, string_view val) {
|
||||
const char *s = val.c_str();
|
||||
return attribute (name, TypeDesc::STRING, &s);
|
||||
bool attribute(string_view name, string_view val)
|
||||
{
|
||||
std::string valstr(val);
|
||||
const char* s = valstr.c_str();
|
||||
return attribute(name, TypeDesc::STRING, &s);
|
||||
}
|
||||
|
||||
|
||||
@@ -270,21 +282,26 @@ public:
|
||||
/// called unconditionally.
|
||||
/// int exec_repeat How many times to run the group (1).
|
||||
///
|
||||
bool attribute (ShaderGroup *group, string_view name,
|
||||
TypeDesc type, const void *val);
|
||||
bool attribute (ShaderGroup *group, string_view name, int val) {
|
||||
return attribute (group, name, TypeDesc::INT, &val);
|
||||
bool attribute(ShaderGroup* group, string_view name, TypeDesc type,
|
||||
const void* val);
|
||||
bool attribute(ShaderGroup* group, string_view name, int val)
|
||||
{
|
||||
return attribute(group, name, TypeDesc::INT, &val);
|
||||
}
|
||||
bool attribute (ShaderGroup *group, string_view name, float val) {
|
||||
return attribute (group, name, TypeDesc::FLOAT, &val);
|
||||
bool attribute(ShaderGroup* group, string_view name, float val)
|
||||
{
|
||||
return attribute(group, name, TypeDesc::FLOAT, &val);
|
||||
}
|
||||
bool attribute (ShaderGroup *group, string_view name, double val) {
|
||||
float f = (float) val;
|
||||
return attribute (group, name, TypeDesc::FLOAT, &f);
|
||||
bool attribute(ShaderGroup* group, string_view name, double val)
|
||||
{
|
||||
float f = (float)val;
|
||||
return attribute(group, name, TypeDesc::FLOAT, &f);
|
||||
}
|
||||
bool attribute (ShaderGroup *group, string_view name, string_view val) {
|
||||
const char *s = val.c_str();
|
||||
return attribute (group, name, TypeDesc::STRING, &s);
|
||||
bool attribute(ShaderGroup* group, string_view name, string_view val)
|
||||
{
|
||||
std::string valstr(val);
|
||||
const char* s = valstr.c_str();
|
||||
return attribute(group, name, TypeDesc::STRING, &s);
|
||||
}
|
||||
|
||||
/// Get the named attribute of the ShadingSystem, store it in `*val`.
|
||||
@@ -314,23 +331,26 @@ public:
|
||||
/// library build dependencies and their versions (for example,
|
||||
/// "OIIO-2.3.0,LLVM-10.0.0,OpenEXR-2.5.0").
|
||||
///
|
||||
bool getattribute (string_view name, TypeDesc type, void *val);
|
||||
bool getattribute(string_view name, TypeDesc type, void* val);
|
||||
|
||||
/// Shortcut getattribute() for retrieving a single integer.
|
||||
/// The value is placed in `val`, and the function returns `true` if the
|
||||
/// attribute was found and was legally convertible to an int.
|
||||
bool getattribute (string_view name, int &val) {
|
||||
return getattribute (name, TypeDesc::INT, &val);
|
||||
bool getattribute(string_view name, int& val)
|
||||
{
|
||||
return getattribute(name, TypeDesc::INT, &val);
|
||||
}
|
||||
/// Shortcut getattribute() for retrieving a single float.
|
||||
/// The value is placed in `val`, and the function returns `true` if the
|
||||
/// attribute was found and was legally convertible to a float.
|
||||
bool getattribute (string_view name, float &val) {
|
||||
return getattribute (name, TypeDesc::FLOAT, &val);
|
||||
bool getattribute(string_view name, float& val)
|
||||
{
|
||||
return getattribute(name, TypeDesc::FLOAT, &val);
|
||||
}
|
||||
bool getattribute (string_view name, double &val) {
|
||||
bool getattribute(string_view name, double& val)
|
||||
{
|
||||
float f;
|
||||
bool ok = getattribute (name, TypeDesc::FLOAT, &f);
|
||||
bool ok = getattribute(name, TypeDesc::FLOAT, &f);
|
||||
if (ok)
|
||||
val = f;
|
||||
return ok;
|
||||
@@ -338,21 +358,24 @@ public:
|
||||
/// Shortcut getattribute() for retrieving a single string as a
|
||||
/// `const char*`. The value is placed in `val`, and the function
|
||||
/// returns `true` if the attribute was found.
|
||||
bool getattribute (string_view name, char **val) {
|
||||
return getattribute (name, TypeDesc::STRING, val);
|
||||
bool getattribute(string_view name, char** val)
|
||||
{
|
||||
return getattribute(name, TypeDesc::STRING, val);
|
||||
}
|
||||
/// Shortcut getattribute() for retrieving a single string as a
|
||||
/// `ustring`. The value is placed in `val`, and the function returns
|
||||
/// `true` if the attribute was found.
|
||||
bool getattribute (string_view name, ustring &val) {
|
||||
return getattribute (name, TypeDesc::STRING, (char **)&val);
|
||||
bool getattribute(string_view name, ustring& val)
|
||||
{
|
||||
return getattribute(name, TypeDesc::STRING, (char**)&val);
|
||||
}
|
||||
/// Shortcut getattribute() for retrieving a single string as a
|
||||
/// `std::string`. The value is placed in `val`, and the function
|
||||
/// returns `true` if the attribute was found.
|
||||
bool getattribute (string_view name, std::string &val) {
|
||||
const char *s = NULL;
|
||||
bool ok = getattribute (name, TypeDesc::STRING, &s);
|
||||
bool getattribute(string_view name, std::string& val)
|
||||
{
|
||||
const char* s = NULL;
|
||||
bool ok = getattribute(name, TypeDesc::STRING, &s);
|
||||
if (ok)
|
||||
val = s;
|
||||
return ok;
|
||||
@@ -423,31 +446,37 @@ public:
|
||||
/// Note: the attributes referred to as "string" are actually on the app
|
||||
/// side as ustring or const char* (they have the same data layout), NOT
|
||||
/// std::string!
|
||||
bool getattribute (ShaderGroup *group, string_view name,
|
||||
TypeDesc type, void *val);
|
||||
bool getattribute(ShaderGroup* group, string_view name, TypeDesc type,
|
||||
void* val);
|
||||
// Shortcuts for common types
|
||||
bool getattribute (ShaderGroup *group, string_view name, int &val) {
|
||||
return getattribute (group, name, TypeDesc::INT, &val);
|
||||
bool getattribute(ShaderGroup* group, string_view name, int& val)
|
||||
{
|
||||
return getattribute(group, name, TypeDesc::INT, &val);
|
||||
}
|
||||
bool getattribute (ShaderGroup *group, string_view name, float &val) {
|
||||
return getattribute (group, name, TypeDesc::FLOAT, &val);
|
||||
bool getattribute(ShaderGroup* group, string_view name, float& val)
|
||||
{
|
||||
return getattribute(group, name, TypeDesc::FLOAT, &val);
|
||||
}
|
||||
bool getattribute (ShaderGroup *group, string_view name, double &val) {
|
||||
bool getattribute(ShaderGroup* group, string_view name, double& val)
|
||||
{
|
||||
float f;
|
||||
bool ok = getattribute (group, name, TypeDesc::FLOAT, &f);
|
||||
bool ok = getattribute(group, name, TypeDesc::FLOAT, &f);
|
||||
if (ok)
|
||||
val = f;
|
||||
return ok;
|
||||
}
|
||||
bool getattribute (ShaderGroup *group, string_view name, char **val) {
|
||||
return getattribute (group, name, TypeDesc::STRING, val);
|
||||
bool getattribute(ShaderGroup* group, string_view name, char** val)
|
||||
{
|
||||
return getattribute(group, name, TypeDesc::STRING, val);
|
||||
}
|
||||
bool getattribute (ShaderGroup *group, string_view name, ustring &val) {
|
||||
return getattribute (group, name, TypeDesc::STRING, (char **)&val);
|
||||
bool getattribute(ShaderGroup* group, string_view name, ustring& val)
|
||||
{
|
||||
return getattribute(group, name, TypeDesc::STRING, (char**)&val);
|
||||
}
|
||||
bool getattribute (ShaderGroup *group, string_view name, std::string &val) {
|
||||
const char *s = NULL;
|
||||
bool ok = getattribute (group, name, TypeDesc::STRING, &s);
|
||||
bool getattribute(ShaderGroup* group, string_view name, std::string& val)
|
||||
{
|
||||
const char* s = NULL;
|
||||
bool ok = getattribute(group, name, TypeDesc::STRING, &s);
|
||||
if (ok)
|
||||
val = s;
|
||||
return ok;
|
||||
@@ -456,8 +485,7 @@ public:
|
||||
|
||||
/// Load compiled shader (oso) from a memory buffer, overriding
|
||||
/// shader lookups in the shader search path
|
||||
bool LoadMemoryCompiledShader (string_view shadername,
|
||||
string_view buffer);
|
||||
bool LoadMemoryCompiledShader(string_view shadername, string_view buffer);
|
||||
|
||||
// The basic sequence for declaring a shader group looks like this:
|
||||
// ShadingSystem *ss = ...;
|
||||
@@ -483,7 +511,7 @@ public:
|
||||
|
||||
/// Signal the start of a new shader group. The return value is a
|
||||
/// reference-counted opaque handle to the ShaderGroup.
|
||||
ShaderGroupRef ShaderGroupBegin (string_view groupname = string_view());
|
||||
ShaderGroupRef ShaderGroupBegin(string_view groupname = string_view());
|
||||
|
||||
/// Alternate way to specify a shader group. The group specification
|
||||
/// syntax looks like this: (as a string, all whitespace is equivalent):
|
||||
@@ -493,13 +521,13 @@ public:
|
||||
/// For the sake of easy assembling on command lines, a comma ',' may
|
||||
/// substitute for the semicolon as a separator, and the last separator
|
||||
/// before the end of the string is optional.
|
||||
ShaderGroupRef ShaderGroupBegin (string_view groupname,
|
||||
string_view shaderusage,
|
||||
string_view groupspec = string_view());
|
||||
ShaderGroupRef ShaderGroupBegin(string_view groupname,
|
||||
string_view shaderusage,
|
||||
string_view groupspec = string_view());
|
||||
|
||||
/// Signal the end of a new shader group.
|
||||
///
|
||||
bool ShaderGroupEnd (ShaderGroup& group);
|
||||
bool ShaderGroupEnd(ShaderGroup& group);
|
||||
|
||||
/// Set a parameter of the next shader that will be added to the group,
|
||||
/// optionally setting the 'lockgeom' metadata for that parameter
|
||||
@@ -508,32 +536,37 @@ public:
|
||||
/// against changes by the geometry, and therefore the shader should not
|
||||
/// optimize assuming that the instance value (the 'val' specified by
|
||||
/// this call) is a constant.
|
||||
bool Parameter (ShaderGroup& group, string_view name, TypeDesc t,
|
||||
const void *val, bool lockgeom=true);
|
||||
bool Parameter(ShaderGroup& group, string_view name, TypeDesc t,
|
||||
const void* val, bool lockgeom = true);
|
||||
// Shortcuts for param passing a single int, float, or string.
|
||||
bool Parameter (ShaderGroup& group, string_view name,
|
||||
int val, bool lockgeom=true) {
|
||||
return Parameter (group, name, TypeDesc::INT, &val, lockgeom);
|
||||
bool Parameter(ShaderGroup& group, string_view name, int val,
|
||||
bool lockgeom = true)
|
||||
{
|
||||
return Parameter(group, name, TypeDesc::INT, &val, lockgeom);
|
||||
}
|
||||
bool Parameter (ShaderGroup& group, string_view name,
|
||||
float val, bool lockgeom=true) {
|
||||
return Parameter (group, name, TypeDesc::FLOAT, &val, lockgeom);
|
||||
bool Parameter(ShaderGroup& group, string_view name, float val,
|
||||
bool lockgeom = true)
|
||||
{
|
||||
return Parameter(group, name, TypeDesc::FLOAT, &val, lockgeom);
|
||||
}
|
||||
bool Parameter (ShaderGroup& group, string_view name,
|
||||
const std::string& val, bool lockgeom=true) {
|
||||
const char *s = val.c_str();
|
||||
return Parameter (group, name, TypeDesc::STRING, &s, lockgeom);
|
||||
bool Parameter(ShaderGroup& group, string_view name, const std::string& val,
|
||||
bool lockgeom = true)
|
||||
{
|
||||
const char* s = val.c_str();
|
||||
return Parameter(group, name, TypeDesc::STRING, &s, lockgeom);
|
||||
}
|
||||
bool Parameter (ShaderGroup& group, string_view name,
|
||||
ustring val, bool lockgeom=true) {
|
||||
return Parameter (group, name, TypeDesc::STRING, (const char**)&val, lockgeom);
|
||||
bool Parameter(ShaderGroup& group, string_view name, ustring val,
|
||||
bool lockgeom = true)
|
||||
{
|
||||
return Parameter(group, name, TypeDesc::STRING, (const char**)&val,
|
||||
lockgeom);
|
||||
}
|
||||
|
||||
/// Append a new shader instance onto the specified group. The shader
|
||||
/// instance will get any pending parameters that were set by
|
||||
/// Parameter() calls since the last Shader() call for the group.
|
||||
bool Shader (ShaderGroup& group, string_view shaderusage,
|
||||
string_view shadername, string_view layername);
|
||||
bool Shader(ShaderGroup& group, string_view shaderusage,
|
||||
string_view shadername, string_view layername);
|
||||
|
||||
/// Connect two shaders within the specified group. The source layer
|
||||
/// must be *upstream* of down destination layer (i.e. source must be
|
||||
@@ -549,9 +582,9 @@ public:
|
||||
/// `ConnectShaders (group, "lay1", "mycolorout[2]",
|
||||
/// "lay2", "myfloatinput")`
|
||||
///
|
||||
bool ConnectShaders (ShaderGroup &group,
|
||||
string_view srclayer, string_view srcparam,
|
||||
string_view dstlayer, string_view dstparam);
|
||||
bool ConnectShaders(ShaderGroup& group, string_view srclayer,
|
||||
string_view srcparam, string_view dstlayer,
|
||||
string_view dstparam);
|
||||
|
||||
/// Replace a parameter value in a previously-declared shader group.
|
||||
/// This is meant to called after the ShaderGroupBegin/End, but will
|
||||
@@ -560,27 +593,30 @@ public:
|
||||
/// indicates that it's a parameter that may be overridden by the
|
||||
/// geometric primitive). This call gives you a way of changing the
|
||||
/// instance value, even if it's not a geometric override.
|
||||
bool ReParameter (ShaderGroup &group,
|
||||
string_view layername, string_view paramname,
|
||||
TypeDesc type, const void *val);
|
||||
bool ReParameter(ShaderGroup& group, string_view layername,
|
||||
string_view paramname, TypeDesc type, const void* val);
|
||||
// Shortcuts for param passing a single int, float, or string.
|
||||
bool ReParameter (ShaderGroup &group, string_view layername,
|
||||
string_view paramname, int val) {
|
||||
return ReParameter (group, layername, paramname, TypeDesc::INT, &val);
|
||||
bool ReParameter(ShaderGroup& group, string_view layername,
|
||||
string_view paramname, int val)
|
||||
{
|
||||
return ReParameter(group, layername, paramname, TypeDesc::INT, &val);
|
||||
}
|
||||
bool ReParameter (ShaderGroup &group, string_view layername,
|
||||
string_view paramname, float val) {
|
||||
return ReParameter (group, layername, paramname, TypeDesc::FLOAT, &val);
|
||||
bool ReParameter(ShaderGroup& group, string_view layername,
|
||||
string_view paramname, float val)
|
||||
{
|
||||
return ReParameter(group, layername, paramname, TypeDesc::FLOAT, &val);
|
||||
}
|
||||
bool ReParameter (ShaderGroup &group, string_view layername,
|
||||
string_view paramname, const std::string& val) {
|
||||
const char *s = val.c_str();
|
||||
return ReParameter (group, layername, paramname, TypeDesc::STRING, &s);
|
||||
bool ReParameter(ShaderGroup& group, string_view layername,
|
||||
string_view paramname, const std::string& val)
|
||||
{
|
||||
const char* s = val.c_str();
|
||||
return ReParameter(group, layername, paramname, TypeDesc::STRING, &s);
|
||||
}
|
||||
bool ReParameter (ShaderGroup &group, string_view layername,
|
||||
string_view paramname, ustring val) {
|
||||
return ReParameter (group, layername, paramname, TypeDesc::STRING,
|
||||
(const char**)&val);
|
||||
bool ReParameter(ShaderGroup& group, string_view layername,
|
||||
string_view paramname, ustring val)
|
||||
{
|
||||
return ReParameter(group, layername, paramname, TypeDesc::STRING,
|
||||
(const char**)&val);
|
||||
}
|
||||
|
||||
// Non-threadsafe versions of Parameter, Shader, ConnectShaders, and
|
||||
@@ -591,13 +627,13 @@ public:
|
||||
// concurrently). If there is any doubt about that, use the versions
|
||||
// above that take an explicit `ShaderGroup&`, which are thread-safe
|
||||
// and re-entrant.
|
||||
bool Parameter (string_view name, TypeDesc t, const void *val,
|
||||
bool lockgeom=true);
|
||||
bool Shader (string_view shaderusage, string_view shadername,
|
||||
string_view layername);
|
||||
bool ConnectShaders (string_view srclayer, string_view srcparam,
|
||||
string_view dstlayer, string_view dstparam);
|
||||
bool ShaderGroupEnd (void);
|
||||
bool Parameter(string_view name, TypeDesc t, const void* val,
|
||||
bool lockgeom = true);
|
||||
bool Shader(string_view shaderusage, string_view shadername,
|
||||
string_view layername);
|
||||
bool ConnectShaders(string_view srclayer, string_view srcparam,
|
||||
string_view dstlayer, string_view dstparam);
|
||||
bool ShaderGroupEnd(void);
|
||||
|
||||
/// Create a per-thread data needed for shader execution. It's very
|
||||
/// important for the app to never use a PerThreadInfo from more than
|
||||
@@ -605,11 +641,11 @@ public:
|
||||
/// for each renderer thread), and destroy it with destroy_thread_info
|
||||
/// when the thread terminates (and before the ShadingSystem is
|
||||
/// destroyed).
|
||||
PerThreadInfo * create_thread_info();
|
||||
PerThreadInfo* create_thread_info();
|
||||
|
||||
/// Destroy a PerThreadInfo that was allocated by
|
||||
/// create_thread_info().
|
||||
void destroy_thread_info (PerThreadInfo *threadinfo);
|
||||
void destroy_thread_info(PerThreadInfo* threadinfo);
|
||||
|
||||
/// Get a ShadingContext that we can use. The context is specific to a
|
||||
/// renderer thread, and should never be passed between or shared by
|
||||
@@ -617,12 +653,13 @@ public:
|
||||
/// thread-specific pointer created by create_thread_info. The context
|
||||
/// can be used to shade many points; a typical usage is to allocate
|
||||
/// just one context per thread and use it for the whole run.
|
||||
ShadingContext *get_context (PerThreadInfo *threadinfo,
|
||||
TextureSystem::Perthread *texture_threadinfo=NULL);
|
||||
ShadingContext*
|
||||
get_context(PerThreadInfo* threadinfo,
|
||||
TextureSystem::Perthread* texture_threadinfo = NULL);
|
||||
|
||||
/// Return a ShadingContext to the pool.
|
||||
///
|
||||
void release_context (ShadingContext *ctx);
|
||||
void release_context(ShadingContext* ctx);
|
||||
|
||||
/// Execute the shader group in this context on shading point
|
||||
/// `shadeindex`. If ctx is nullptr, then execute will request one
|
||||
@@ -631,19 +668,30 @@ public:
|
||||
/// execute_layer of the last (presumably group entry) layer, and
|
||||
/// execute_cleanup. If run==false, just do the binding and setup, don't
|
||||
/// actually run the shader.
|
||||
bool execute(ShadingContext &ctx, ShaderGroup &group, int shadeindex,
|
||||
ShaderGlobals& globals, void* output_base_ptr,
|
||||
bool run = true);
|
||||
bool execute(ShadingContext& ctx, ShaderGroup& group, int shadeindex,
|
||||
ShaderGlobals& globals, void* userdata_base_ptr,
|
||||
void* output_base_ptr, bool run = true);
|
||||
|
||||
/// Future execute signature that will be range based. Shader globals will be
|
||||
/// obtained from renderer services.
|
||||
#if 0 // TODO in future PR
|
||||
bool execute(ShadingContext& ctx, ShaderGroup& group, OpaqueShadingStateUniformPtr ssu,
|
||||
int shadeindex_begin_at, int shadeindex_end_before
|
||||
void* userdata_base_ptr,
|
||||
void* output_base_ptr, bool run = true);
|
||||
#endif
|
||||
|
||||
// DEPRECATED(2.0): no shadeindex or base pointers
|
||||
bool execute (ShadingContext &ctx, ShaderGroup &group,
|
||||
ShaderGlobals &globals, bool run=true) {
|
||||
return execute(ctx, group, 0, globals, nullptr, run);
|
||||
bool execute(ShadingContext& ctx, ShaderGroup& group,
|
||||
ShaderGlobals& globals, bool run = true)
|
||||
{
|
||||
return execute(ctx, group, 0, globals, nullptr, nullptr, run);
|
||||
}
|
||||
|
||||
// DEPRECATED(2.0): ctx pointer
|
||||
bool execute (ShadingContext *ctx, ShaderGroup &group,
|
||||
ShaderGlobals &globals, bool run=true) {
|
||||
bool execute(ShadingContext* ctx, ShaderGroup& group,
|
||||
ShaderGlobals& globals, bool run = true)
|
||||
{
|
||||
return execute(*ctx, group, globals, run);
|
||||
}
|
||||
|
||||
@@ -655,13 +703,14 @@ public:
|
||||
/// preparation, but don't actually run the shader. Return true if the
|
||||
/// shader executed, false if it did not (including if the shader itself
|
||||
/// was empty).
|
||||
bool execute_init(ShadingContext &ctx, ShaderGroup &group, int shadeindex,
|
||||
ShaderGlobals &globals, void* output_base_ptr,
|
||||
bool run=true);
|
||||
bool execute_init(ShadingContext& ctx, ShaderGroup& group, int shadeindex,
|
||||
ShaderGlobals& globals, void* userdata_base_ptr,
|
||||
void* output_base_ptr, bool run = true);
|
||||
// DEPRECATED(2.0): no shadeindex or base pointers
|
||||
bool execute_init (ShadingContext &ctx, ShaderGroup &group,
|
||||
ShaderGlobals &globals, bool run=true) {
|
||||
return execute_init(ctx, group, 0, globals, nullptr, run);
|
||||
bool execute_init(ShadingContext& ctx, ShaderGroup& group,
|
||||
ShaderGlobals& globals, bool run = true)
|
||||
{
|
||||
return execute_init(ctx, group, 0, globals, nullptr, nullptr, run);
|
||||
}
|
||||
|
||||
/// Execute the layer whose layernumber is specified, in this context.
|
||||
@@ -669,38 +718,44 @@ public:
|
||||
/// run==true, and that the call to execute_init() returned true. (One
|
||||
/// reason why it might have returned false is if the shader group
|
||||
/// turned out, after optimization, to do nothing.)
|
||||
bool execute_layer(ShadingContext &ctx, int shadeindex, ShaderGlobals &globals,
|
||||
bool execute_layer(ShadingContext& ctx, int shadeindex,
|
||||
ShaderGlobals& globals, void* userdata_base_ptr,
|
||||
void* output_base_ptr, int layernumber);
|
||||
/// Execute the layer by name.
|
||||
bool execute_layer(ShadingContext &ctx, int shadeindex, ShaderGlobals &globals,
|
||||
bool execute_layer(ShadingContext& ctx, int shadeindex,
|
||||
ShaderGlobals& globals, void* userdata_base_ptr,
|
||||
void* output_base_ptr, ustring layername);
|
||||
/// Execute the layer that has the given ShaderSymbol as an output.
|
||||
/// (The symbol is one returned by find_symbol()).
|
||||
bool execute_layer(ShadingContext &ctx, int shadeindex, ShaderGlobals &globals,
|
||||
void* output_base_ptr, const ShaderSymbol *symbol);
|
||||
bool execute_layer(ShadingContext& ctx, int shadeindex,
|
||||
ShaderGlobals& globals, void* userdata_base_ptr,
|
||||
void* output_base_ptr, const ShaderSymbol* symbol);
|
||||
|
||||
// DEPRECATED(2.0): no shadeindex or base pointers
|
||||
bool execute_layer (ShadingContext &ctx, ShaderGlobals &globals,
|
||||
int layernumber) {
|
||||
return execute_layer(ctx, 0, globals, nullptr, layernumber);
|
||||
bool execute_layer(ShadingContext& ctx, ShaderGlobals& globals,
|
||||
int layernumber)
|
||||
{
|
||||
return execute_layer(ctx, 0, globals, nullptr, nullptr, layernumber);
|
||||
}
|
||||
bool execute_layer (ShadingContext &ctx, ShaderGlobals &globals,
|
||||
ustring layername) {
|
||||
return execute_layer(ctx, 0, globals, nullptr, layername);
|
||||
bool execute_layer(ShadingContext& ctx, ShaderGlobals& globals,
|
||||
ustring layername)
|
||||
{
|
||||
return execute_layer(ctx, 0, globals, nullptr, nullptr, layername);
|
||||
}
|
||||
bool execute_layer (ShadingContext &ctx, ShaderGlobals &globals,
|
||||
const ShaderSymbol *symbol) {
|
||||
return execute_layer(ctx, 0, globals, nullptr, symbol);
|
||||
bool execute_layer(ShadingContext& ctx, ShaderGlobals& globals,
|
||||
const ShaderSymbol* symbol)
|
||||
{
|
||||
return execute_layer(ctx, 0, globals, nullptr, nullptr, symbol);
|
||||
}
|
||||
|
||||
/// Signify that the context is done with the current execution of the
|
||||
/// group that was kicked off by execute_init and one or more calls to
|
||||
/// execute_layer.
|
||||
bool execute_cleanup (ShadingContext &ctx);
|
||||
bool execute_cleanup(ShadingContext& ctx);
|
||||
|
||||
/// Find the named layer within a group and return its index, or -1
|
||||
/// if no such named layer exists.
|
||||
int find_layer (const ShaderGroup &group, ustring layername) const;
|
||||
int find_layer(const ShaderGroup& group, ustring layername) const;
|
||||
|
||||
/// Get a raw pointer to a named symbol (such as you'd need to pull
|
||||
/// out the value of an output parameter). ctx is the shading
|
||||
@@ -717,10 +772,10 @@ public:
|
||||
///
|
||||
/// These are considered somewhat deprecated, in favor of using
|
||||
/// find_symbol(), symbol_typedesc(), and symbol_address().
|
||||
const void* get_symbol (const ShadingContext &ctx, ustring layername,
|
||||
ustring symbolname, TypeDesc &type) const;
|
||||
const void* get_symbol (const ShadingContext &ctx, ustring symbolname,
|
||||
TypeDesc &type) const;
|
||||
const void* get_symbol(const ShadingContext& ctx, ustring layername,
|
||||
ustring symbolname, TypeDesc& type) const;
|
||||
const void* get_symbol(const ShadingContext& ctx, ustring symbolname,
|
||||
TypeDesc& type) const;
|
||||
|
||||
/// Search for an output symbol by name (and optionally, layer) within
|
||||
/// the optimized shader group. If the symbol is found, return an opaque
|
||||
@@ -734,22 +789,22 @@ public:
|
||||
/// separately, or by concatenating "layername.symbolname", but note
|
||||
/// that the latter will involve string manipulation inside find_symbol
|
||||
/// and is much more expensive than specifying them separately.
|
||||
const ShaderSymbol* find_symbol (const ShaderGroup &group,
|
||||
ustring layername, ustring symbolname) const;
|
||||
const ShaderSymbol* find_symbol (const ShaderGroup &group,
|
||||
ustring symbolname) const;
|
||||
const ShaderSymbol* find_symbol(const ShaderGroup& group, ustring layername,
|
||||
ustring symbolname) const;
|
||||
const ShaderSymbol* find_symbol(const ShaderGroup& group,
|
||||
ustring symbolname) const;
|
||||
|
||||
/// Given an opaque ShaderSymbol*, return the TypeDesc describing it.
|
||||
/// Note that a closure will end up with a TypeDesc::UNKNOWN value.
|
||||
TypeDesc symbol_typedesc (const ShaderSymbol *sym) const;
|
||||
TypeDesc symbol_typedesc(const ShaderSymbol* sym) const;
|
||||
|
||||
/// Given a context (that has executed a shader) and an opaque
|
||||
/// ShaderSymbol*, return the actual memory address where the value of
|
||||
/// the symbol resides within the heap memory of the context. This
|
||||
/// is only valid for the shader execution that had happened immediately
|
||||
/// prior for this context, but it is a very inexpensive operation.
|
||||
const void* symbol_address (const ShadingContext &ctx,
|
||||
const ShaderSymbol *sym) const;
|
||||
const void* symbol_address(const ShadingContext& ctx,
|
||||
const ShaderSymbol* sym) const;
|
||||
|
||||
#if OSL_USE_BATCHED
|
||||
/// Based on currently set attributes for llvm_jit_target and
|
||||
@@ -760,39 +815,56 @@ public:
|
||||
/// Returns true if supported, false otherwise
|
||||
bool configure_batch_execution_at(int width);
|
||||
|
||||
template<int WidthT>
|
||||
class OSLEXECPUBLIC BatchedExecutor {
|
||||
ShadingSystem & m_shading_system;
|
||||
template<int WidthT> class OSLEXECPUBLIC BatchedExecutor {
|
||||
ShadingSystem& m_shading_system;
|
||||
|
||||
public:
|
||||
explicit OSL_FORCEINLINE BatchedExecutor(ShadingSystem & ss)
|
||||
:m_shading_system(ss)
|
||||
{}
|
||||
explicit OSL_FORCEINLINE BatchedExecutor(ShadingSystem& ss)
|
||||
: m_shading_system(ss)
|
||||
{
|
||||
}
|
||||
OSL_FORCEINLINE BatchedExecutor(const BatchedExecutor&) = default;
|
||||
|
||||
/// Ensure that the group has been JITed.
|
||||
void jit_group (ShaderGroup *group, ShadingContext *ctx);
|
||||
void jit_group(ShaderGroup* group, ShadingContext* ctx);
|
||||
|
||||
/// If option "greedyjit" was set, this call will trigger all
|
||||
/// shader groups that have not yet been compiled to do so with the
|
||||
/// specified number of threads (0 means use all available HW cores).
|
||||
void jit_all_groups (int nthreads=0);
|
||||
void jit_all_groups(int nthreads = 0);
|
||||
|
||||
bool execute(ShadingContext &ctx, ShaderGroup &group, int batch_size,
|
||||
BatchedShaderGlobals<WidthT> &globals_batch, bool run=true);
|
||||
bool execute(ShadingContext& ctx, ShaderGroup& group, int batch_size,
|
||||
Wide<const int, WidthT> wide_shadeindex,
|
||||
BatchedShaderGlobals<WidthT>& globals_batch,
|
||||
void* userdata_base_ptr, void* output_base_ptr,
|
||||
bool run = true);
|
||||
|
||||
bool execute_init (ShadingContext &ctx, ShaderGroup &group, int batch_size,
|
||||
BatchedShaderGlobals<WidthT> &globals_batch, bool run=true);
|
||||
bool execute_init(ShadingContext& ctx, ShaderGroup& group,
|
||||
int batch_size,
|
||||
Wide<const int, WidthT> wide_shadeindex,
|
||||
BatchedShaderGlobals<WidthT>& globals_batch,
|
||||
void* userdata_base_ptr, void* output_base_ptr,
|
||||
bool run = true);
|
||||
|
||||
bool execute_layer (ShadingContext &ctx, int batch_size, BatchedShaderGlobals<WidthT> &globals_batch,
|
||||
int layernumber);
|
||||
bool execute_layer (ShadingContext &ctx, int batch_size, BatchedShaderGlobals<WidthT> &globals_batch,
|
||||
ustring layername);
|
||||
bool execute_layer (ShadingContext &ctx, int batch_size, BatchedShaderGlobals<WidthT> &globals_batch,
|
||||
const ShaderSymbol *symbol);
|
||||
bool execute_layer(ShadingContext& ctx, int batch_size,
|
||||
Wide<const int, WidthT> wide_shadeindex,
|
||||
BatchedShaderGlobals<WidthT>& globals_batch,
|
||||
void* userdata_base_ptr, void* output_base_ptr,
|
||||
int layernumber);
|
||||
bool execute_layer(ShadingContext& ctx, int batch_size,
|
||||
Wide<const int, WidthT> wide_shadeindex,
|
||||
BatchedShaderGlobals<WidthT>& globals_batch,
|
||||
void* userdata_base_ptr, void* output_base_ptr,
|
||||
ustring layername);
|
||||
bool execute_layer(ShadingContext& ctx, int batch_size,
|
||||
Wide<const int, WidthT> wide_shadeindex,
|
||||
BatchedShaderGlobals<WidthT>& globals_batch,
|
||||
void* userdata_base_ptr, void* output_base_ptr,
|
||||
const ShaderSymbol* symbol);
|
||||
};
|
||||
|
||||
template<int WidthT>
|
||||
OSL_FORCEINLINE BatchedExecutor<WidthT> batched() {
|
||||
template<int WidthT> OSL_FORCEINLINE BatchedExecutor<WidthT> batched()
|
||||
{
|
||||
return BatchedExecutor<WidthT>(*this);
|
||||
}
|
||||
#endif
|
||||
@@ -800,37 +872,36 @@ public:
|
||||
|
||||
/// Return the statistics output as a huge string.
|
||||
///
|
||||
std::string getstats (int level=1) const;
|
||||
std::string getstats(int level = 1) const;
|
||||
|
||||
void register_closure (string_view name, int id, const ClosureParam *params,
|
||||
PrepareClosureFunc prepare, SetupClosureFunc setup);
|
||||
void register_closure(string_view name, int id, const ClosureParam* params,
|
||||
PrepareClosureFunc prepare, SetupClosureFunc setup);
|
||||
|
||||
/// Query either by name or id an existing closure. If name is non
|
||||
/// NULL it will use it for the search, otherwise id would be used
|
||||
/// and the name will be placed in name if successful. Also return
|
||||
/// pointer to the params array in the last argument. All args are
|
||||
/// optional but at least one of name or id must non NULL.
|
||||
bool query_closure (const char **name, int *id,
|
||||
const ClosureParam **params);
|
||||
bool query_closure(const char** name, int* id, const ClosureParam** params);
|
||||
|
||||
/// For the proposed shader "global" name, return the corresponding
|
||||
/// SGBits enum.
|
||||
static SGBits globals_bit (ustring name);
|
||||
static SGBits globals_bit(ustring name);
|
||||
|
||||
/// For the SGBits value, return the shader "globals" name.
|
||||
static ustring globals_name (SGBits bit);
|
||||
static ustring globals_name(SGBits bit);
|
||||
|
||||
/// For the proposed raytype name, return the bit pattern that
|
||||
/// describes it, or 0 for an unrecognized name. (This retrieves
|
||||
/// data passed in via attribute("raytypes")).
|
||||
int raytype_bit (ustring name);
|
||||
int raytype_bit(ustring name);
|
||||
|
||||
/// Configure the default raytypes to assume to be on (or off) at optimization
|
||||
/// time for the given group. The raytypes_on gives a bitfield describing which
|
||||
/// ray flags are known to be 1, and raytypes_off describes which ray flags are
|
||||
/// known to be 0. Bits that are not set in either set of flags are not known
|
||||
/// to the optimizer, and will be determined strictly at execution time.
|
||||
void set_raytypes(ShaderGroup *group, int raytypes_on, int raytypes_off);
|
||||
void set_raytypes(ShaderGroup* group, int raytypes_on, int raytypes_off);
|
||||
|
||||
/// Clear any known mappings of symbol locations.
|
||||
void clear_symlocs();
|
||||
@@ -842,31 +913,32 @@ public:
|
||||
|
||||
/// 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, bool do_jit = true);
|
||||
void optimize_group(ShaderGroup* group, ShadingContext* ctx,
|
||||
bool do_jit = true);
|
||||
|
||||
/// Ensure that the group has been optimized and optionally JITed. This is a
|
||||
/// convenience function that simply calls set_raytypes followed by
|
||||
/// optimize_group. The ctx supplies a ShadingContext to use.
|
||||
void optimize_group (ShaderGroup *group, int raytypes_on,
|
||||
int raytypes_off, ShadingContext *ctx, bool do_jit = true);
|
||||
void optimize_group(ShaderGroup* group, int raytypes_on, int raytypes_off,
|
||||
ShadingContext* ctx, bool do_jit = true);
|
||||
|
||||
/// If option "greedyjit" was set, this call will trigger all
|
||||
/// shader groups that have not yet been compiled to do so with the
|
||||
/// specified number of threads (0 means use all available HW cores).
|
||||
void optimize_all_groups (int nthreads=0, bool do_jit = true);
|
||||
void optimize_all_groups(int nthreads = 0, bool do_jit = true);
|
||||
|
||||
/// Return a pointer to the TextureSystem being used.
|
||||
TextureSystem * texturesys () const;
|
||||
TextureSystem* texturesys() const;
|
||||
|
||||
/// Return a pointer to the RendererServices being used.
|
||||
RendererServices * renderer () const;
|
||||
RendererServices* renderer() const;
|
||||
|
||||
/// Archive the entire shader group so that it can be reconstituted
|
||||
/// later.
|
||||
bool archive_shadergroup (ShaderGroup &group, string_view filename);
|
||||
bool archive_shadergroup(ShaderGroup& group, string_view filename);
|
||||
|
||||
// DEPRECATED(2.0)
|
||||
bool archive_shadergroup (ShaderGroup *group, string_view filename);
|
||||
bool archive_shadergroup(ShaderGroup* group, string_view filename);
|
||||
|
||||
/// Construct and return an OSLQuery initialized with an existing
|
||||
/// ShaderGroup. For a shader group already loaded by the ShadingSystem,
|
||||
@@ -945,9 +1017,8 @@ bool
|
||||
shade_image(ShadingSystem& shadingsys, ShaderGroup& group,
|
||||
const ShaderGlobals* defaultsg, OIIO::ImageBuf& buf,
|
||||
cspan<ustring> outputs,
|
||||
ShadeImageLocations shadelocations = ShadePixelCenters,
|
||||
OIIO::ROI roi = OIIO::ROI(),
|
||||
OIIO::parallel_options popt = 0);
|
||||
ShadeImageLocations shadelocations = ShadePixelCenters,
|
||||
OIIO::ROI roi = OIIO::ROI(), OIIO::parallel_options popt = 0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+75
-22
@@ -9,6 +9,8 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include <OSL/oslconfig.h>
|
||||
|
||||
#include <OpenImageIO/fmath.h>
|
||||
#include <OpenImageIO/hash.h>
|
||||
#include <OpenImageIO/simd.h>
|
||||
@@ -100,7 +102,9 @@ struct NoiseParams;
|
||||
namespace pvt {
|
||||
using namespace OIIO::simd;
|
||||
using namespace OIIO::bjhash;
|
||||
|
||||
#ifdef __OSL_WIDE_PVT
|
||||
namespace sfm = OSL::__OSL_WIDE_PVT::sfm;
|
||||
#endif
|
||||
typedef void (*NoiseGenericFunc)(int outdim, float *out, bool derivs,
|
||||
int indim, const float *in,
|
||||
const float *period, NoiseParams *params);
|
||||
@@ -137,6 +141,19 @@ inline OSL_HOSTDEVICE float bits_to_01 (unsigned int bits) {
|
||||
}
|
||||
|
||||
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE int
|
||||
bitcast_to_uint (float x)
|
||||
{
|
||||
#if OPENIMAGEIO_VERSION >= 20500
|
||||
return OIIO::bitcast<unsigned int, float>(x);
|
||||
#else
|
||||
// obsolete call
|
||||
return OIIO::bit_cast<float, unsigned int>(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef __CUDA_ARCH__
|
||||
// Perform a bjmix (see OpenImageIO/hash.h) on 4 sets of values at once.
|
||||
OSL_FORCEINLINE void
|
||||
@@ -227,7 +244,7 @@ reference_inthash (const unsigned int k[N]) {
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE unsigned int
|
||||
inthash (const unsigned int k0, const unsigned int k1) {
|
||||
// now hash the data!
|
||||
unsigned int start_val = 0xdeadbeef + (2 << 2) + 13;
|
||||
unsigned int start_val = 0xdeadbeef + (2 << 2) + 13; //NOSONAR
|
||||
|
||||
unsigned int a = start_val + k0;
|
||||
unsigned int b = start_val + k1;
|
||||
@@ -463,7 +480,7 @@ struct HashNoise: public IntHashNoiseBase<HashNoise> {
|
||||
static OSL_FORCEINLINE OSL_HOSTDEVICE unsigned int
|
||||
transformToUint(float val)
|
||||
{
|
||||
return OIIO::bit_cast<float,unsigned int>(val);
|
||||
return bitcast_to_uint(val);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -540,7 +557,6 @@ using PeriodicHashNoise = PeriodicAdaptionOf<HashNoise>;
|
||||
|
||||
|
||||
|
||||
|
||||
inline OSL_HOSTDEVICE int
|
||||
inthashi (int x)
|
||||
{
|
||||
@@ -553,7 +569,7 @@ inline OSL_HOSTDEVICE int
|
||||
inthashf (float x)
|
||||
{
|
||||
return static_cast<int>(
|
||||
inthash(OIIO::bit_cast<float,unsigned int>(x))
|
||||
inthash(bitcast_to_uint(x))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -562,8 +578,8 @@ inthashf (float x, float y)
|
||||
{
|
||||
return static_cast<int>(
|
||||
inthash(
|
||||
OIIO::bit_cast<float,unsigned int>(x),
|
||||
OIIO::bit_cast<float,unsigned int>(y)
|
||||
bitcast_to_uint(x),
|
||||
bitcast_to_uint(y)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -574,9 +590,9 @@ inthashf (const float *x)
|
||||
{
|
||||
return static_cast<int>(
|
||||
inthash(
|
||||
OIIO::bit_cast<float,unsigned int>(x[0]),
|
||||
OIIO::bit_cast<float,unsigned int>(x[1]),
|
||||
OIIO::bit_cast<float,unsigned int>(x[2])
|
||||
bitcast_to_uint(x[0]),
|
||||
bitcast_to_uint(x[1]),
|
||||
bitcast_to_uint(x[2])
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -587,10 +603,10 @@ inthashf (const float *x, float y)
|
||||
{
|
||||
return static_cast<int>(
|
||||
inthash(
|
||||
OIIO::bit_cast<float,unsigned int>(x[0]),
|
||||
OIIO::bit_cast<float,unsigned int>(x[1]),
|
||||
OIIO::bit_cast<float,unsigned int>(x[2]),
|
||||
OIIO::bit_cast<float,unsigned int>(y)
|
||||
bitcast_to_uint(x[0]),
|
||||
bitcast_to_uint(x[1]),
|
||||
bitcast_to_uint(x[2]),
|
||||
bitcast_to_uint(y)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -636,7 +652,7 @@ OSL_FORCEINLINE OSL_HOSTDEVICE Dual2<float> select(const bool b, const Dual2<flo
|
||||
// versus requiring a stack location.
|
||||
// Without this work per component, gathers & scatters were being emitted
|
||||
// when used inside SIMD loops.
|
||||
#if OSL_NON_INTEL_CLANG
|
||||
#if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION && !OSL_INTEL_LLVM_COMPILER_VERSION
|
||||
// Clang's vectorizor was really insistent that a select operation could not be replaced
|
||||
// with control flow, so had to re-introduce the ? operator to make it happy
|
||||
return Dual2<float> (
|
||||
@@ -1150,16 +1166,16 @@ private:
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic () {}
|
||||
public:
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1; //NOSONAR
|
||||
}
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px, float py) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
|
||||
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1; //NOSONAR
|
||||
}
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px, float py, float pz) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
|
||||
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1;
|
||||
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1; //NOSONAR
|
||||
}
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px, float py, float pz, float pw) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
@@ -1221,16 +1237,16 @@ public:
|
||||
|
||||
struct HashVectorPeriodic {
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1; //NOSONAR
|
||||
}
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px, float py) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
|
||||
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1; //NOSONAR
|
||||
}
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px, float py, float pz) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
|
||||
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1;
|
||||
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1; //NOSONAR
|
||||
}
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px, float py, float pz, float pw) {
|
||||
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
|
||||
@@ -1877,7 +1893,7 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Vec3 &result, const H &hash,
|
||||
u, v, w);
|
||||
result = scale3 (result);
|
||||
#else
|
||||
static_assert(std::is_same<Vec3i, decltype(hash(X, Y, Z))>::value, "This re-implementation was developed for Hashs returning a vector type only");
|
||||
static_assert(std::is_same<Vec3i, decltype(hash(X, Y, Z))>::value, "This re-implementation was developed for hashes returning a vector type only");
|
||||
// Want to avoid repeating the same hash work 3 times in a row
|
||||
// so rather than executing the vector version, we will use HashScalar
|
||||
// and directly mask its results on a per component basis
|
||||
@@ -2241,6 +2257,9 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Dual2<Vec3> &result, const H &hash,
|
||||
Dual2<float> t = fade(fz);
|
||||
Dual2<float> s = fade(fw);
|
||||
|
||||
// With Dual2<Vec3> data types, a lot of code is generated below
|
||||
// which caused some runaway compiler memory consumption when vectorizing
|
||||
#if !OSL_INTEL_CLASSIC_COMPILER_VERSION
|
||||
auto l_result = OIIO::lerp (
|
||||
OIIO::trilerp (grad (hash (X , Y , Z , W ), fx , fy , fz , fw ),
|
||||
grad (hash (X+1, Y , Z , W ), fx-1.0f, fy , fz , fw ),
|
||||
@@ -2261,6 +2280,40 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Dual2<Vec3> &result, const H &hash,
|
||||
grad (hash (X+1, Y+1, Z+1, W+1), fx-1.0f, fy-1.0f, fz-1.0f, fw-1.0f),
|
||||
u, v, t),
|
||||
s);
|
||||
#else
|
||||
// Use a loop to avoid repeating code gen twice
|
||||
Dual2<Vec3> v0, v1;
|
||||
// GCC emits -Wmaybe-uninitialized errors for v0,v1.
|
||||
// To avoid, GCC uses reference version above
|
||||
|
||||
// Clang doesn't want to vectorize with the vIndex loop
|
||||
// To enable vectorization, Clang uses reference version above
|
||||
OSL_INTEL_PRAGMA(nounroll_and_jam)
|
||||
for(int vIndex=0; vIndex < 2;++vIndex) {
|
||||
int vW = W + vIndex;
|
||||
Dual2<float> vfw = fw - float(vIndex);
|
||||
|
||||
Dual2<Vec3> vResult = OIIO::trilerp (
|
||||
grad (hash (X , Y , Z , vW ), fx , fy , fz , vfw ),
|
||||
grad (hash (X+1, Y , Z , vW ), fx-1.0f, fy , fz , vfw ),
|
||||
grad (hash (X , Y+1, Z , vW ), fx , fy-1.0f, fz , vfw ),
|
||||
grad (hash (X+1, Y+1, Z , vW ), fx-1.0f, fy-1.0f, fz , vfw ),
|
||||
grad (hash (X , Y , Z+1, vW ), fx , fy , fz-1.0f, vfw ),
|
||||
grad (hash (X+1, Y , Z+1, vW ), fx-1.0f, fy , fz-1.0f, vfw ),
|
||||
grad (hash (X , Y+1, Z+1, vW ), fx , fy-1.0f, fz-1.0f, vfw ),
|
||||
grad (hash (X+1, Y+1, Z+1, vW ), fx-1.0f, fy-1.0f, fz-1.0f, vfw ),
|
||||
u, v, t);
|
||||
// Rather than dynamic indexing array,
|
||||
// use masking to store outputs,
|
||||
// to better enable SROA (Scalar Replacement of Aggregates) optimizations
|
||||
if (vIndex == 0) {
|
||||
v0 = vResult;
|
||||
} else {
|
||||
v1 = vResult;
|
||||
}
|
||||
}
|
||||
auto l_result = OIIO::lerp (v0, v1, s);
|
||||
#endif
|
||||
|
||||
result = scale4 (l_result);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class OSOReaderQuery; // Just so OSLQuery can friend OSLReaderQuery
|
||||
/// ~~~
|
||||
///
|
||||
/// And the `Parameter` structure will hold all the information you need
|
||||
/// about that paramter. For example:
|
||||
/// about that parameter. For example:
|
||||
///
|
||||
/// ~~~
|
||||
/// std::cout << "Parameter " << p->name
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
}
|
||||
///< Construct an OSLQuery and open a compiled shader from a disk file.
|
||||
/// The `shadername` may be either the name of the `.oso` file, or the
|
||||
/// name of the shader. The optional `searchpath` paramter gives a
|
||||
/// name of the shader. The optional `searchpath` parameter gives a
|
||||
/// colon-separated list of directories to search for compiled shaders.
|
||||
|
||||
OSL_DEPRECATED("Use ShadingSystem::oslquery(group,layernum)")
|
||||
@@ -214,8 +214,16 @@ private:
|
||||
std::vector<Parameter> m_meta; //< Meta-data about the shader
|
||||
friend class pvt::OSOReaderQuery;
|
||||
|
||||
// Internal error reporting routine, with printf-like arguments.
|
||||
// Internal error reporting routine, with std::format-like arguments.
|
||||
template<typename Str, typename... Args>
|
||||
inline void errorfmt(const Str& fmt, Args&&... args) const
|
||||
{
|
||||
append_error(
|
||||
OIIO::Strutil::fmt::format(fmt, std::forward<Args>(args)...));
|
||||
}
|
||||
// DEPRECATED(1.12): old style printf-like arguments.
|
||||
template<typename... Args>
|
||||
OSL_DEPRECATED("Use errfmt instead, with std::format args")
|
||||
inline void errorf(const char* fmt, const Args&... args) const
|
||||
{
|
||||
append_error(OIIO::Strutil::sprintf(fmt, args...));
|
||||
|
||||
@@ -36,13 +36,14 @@
|
||||
100 * OSL_VERSION_MINOR + \
|
||||
OSL_VERSION_PATCH)
|
||||
|
||||
// Magic macros to make OSL_LIBRARY_VERSION_STRING that looks like "1.2.3"
|
||||
#define OSL_MAKE_VERSION_STRING2(a,b,c,d) #a "." #b "." #c #d
|
||||
#define OSL_MAKE_VERSION_STRING(a,b,c,d) OSL_MAKE_VERSION_STRING2(a,b,c,d)
|
||||
// Magic macros to make OSL_LIBRARY_VERSION_STRING that looks like "1.2.3.0"
|
||||
#define OSL_MAKE_VERSION_STRING2(a,b,c,d,e) #a "." #b "." #c "." #d #e
|
||||
#define OSL_MAKE_VERSION_STRING(a,b,c,d,e) OSL_MAKE_VERSION_STRING2(a,b,c,d,e)
|
||||
#define OSL_LIBRARY_VERSION_STRING \
|
||||
OSL_MAKE_VERSION_STRING(OSL_LIBRARY_VERSION_MAJOR, \
|
||||
OSL_LIBRARY_VERSION_MINOR, \
|
||||
OSL_LIBRARY_VERSION_PATCH, \
|
||||
OSL_LIBRARY_VERSION_TWEAK, \
|
||||
OSL_LIBRARY_VERSION_RELEASE_TYPE)
|
||||
#define OSL_INTRO_STRING "Open Shading Language " OSL_LIBRARY_VERSION_STRING
|
||||
#define OSL_COPYRIGHT_STRING "Copyright Contributors to the Open Shading Language project."
|
||||
@@ -102,4 +103,7 @@ namespace @PROJ_NAME@ = @PROJ_NAMESPACE_V@;
|
||||
#define __OSL_WIDE_PVT __OSL_CONCAT5(b,__OSL_WIDTH,_,__OSL_TARGET_ISA,_pvt)
|
||||
#endif
|
||||
|
||||
#define __OSL_INDIRECT_STRINGIFY(x) #x
|
||||
#define __OSL_STRINGIFY(x) __OSL_INDIRECT_STRINGIFY(x)
|
||||
|
||||
#endif /* OSLVERSION_H */
|
||||
|
||||
+70
-22
@@ -26,6 +26,19 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Detect which compiler and version we're using
|
||||
|
||||
// Notes:
|
||||
// __GNUC__ is defined for gcc and all clang varieties
|
||||
// __clang__ is defined for all clang varieties (generic, Apple, and Intel)
|
||||
// __apple_build_version__ is only defined for Apple clang
|
||||
// __INTEL_COMPILER is defined only for icc
|
||||
// __INTEL_LLVM_COMPILER is defined only for icx
|
||||
// _MSC_VER is defined for MSVS compiler (not gcc/clang/icc even on Windows)
|
||||
// _WIN32 is defined on Windows regardless of compiler
|
||||
// __CUDACC__ is defined any time we are compiling a module for Cuda
|
||||
// (both for the host pass and the device pass). "Do this
|
||||
// when using nvcc or clang with ptx target."
|
||||
// __CUDA_ARCH__ is only defined when doing the device pass. "Do this only
|
||||
// for code that will actually run on the GPU."
|
||||
|
||||
// Define OSL_GNUC_VERSION to hold an encoded gcc version (e.g. 40802 for
|
||||
// 4.8.2), or 0 if not a GCC release. N.B.: This will be 0 for clang.
|
||||
@@ -39,7 +52,7 @@
|
||||
// 30402 for clang 3.4.2), or 0 if not a generic Clang release.
|
||||
// N.B. This will be 0 for the clang Apple distributes (which has different
|
||||
// version numbers entirely).
|
||||
#if defined(__clang__) && !defined(__apple_build_version__)
|
||||
#if defined(__clang__) && !defined(__apple_build_version__) && !defined(__INTEL_LLVM_COMPILER)
|
||||
# define OSL_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__)
|
||||
#else
|
||||
# define OSL_CLANG_VERSION 0
|
||||
@@ -48,29 +61,48 @@
|
||||
// Define OSL_APPLE_CLANG_VERSION to hold an encoded Apple Clang version
|
||||
// (e.g. 70002 for clang 7.0.2), or 0 if not an Apple Clang release.
|
||||
#if defined(__clang__) && defined(__apple_build_version__)
|
||||
# if defined(__INTEL_LLVM_COMPILER)
|
||||
# error Not expected for __INTEL_LLVM_COMPILER to be defined with an __apple_build_version__
|
||||
# endif
|
||||
# define OSL_APPLE_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__)
|
||||
#else
|
||||
# define OSL_APPLE_CLANG_VERSION 0
|
||||
#endif
|
||||
// The classic Intel(r) C++ Compiler on OSX may still define __clang__
|
||||
// combine with testing OSL_INTEL_CLASSIC_COMPILER_VERSION to further differentiate if needed.
|
||||
|
||||
// Define OSL_INTEL_COMPILER to hold an encoded Intel compiler version
|
||||
// (e.g. 1900), or 0 if not an Intel compiler.
|
||||
// Define OSL_INTEL_CLASSIC_COMPILER_VERSION to hold an encoded Intel(r) C++ Compiler version
|
||||
// (e.g. 1900), or 0 if not an Intel(r) C++ Compiler.
|
||||
#if defined(__INTEL_COMPILER)
|
||||
# define OSL_INTEL_COMPILER __INTEL_COMPILER
|
||||
# define OSL_INTEL_CLASSIC_COMPILER_VERSION __INTEL_COMPILER
|
||||
#else
|
||||
# define OSL_INTEL_COMPILER 0
|
||||
# define OSL_INTEL_CLASSIC_COMPILER_VERSION 0
|
||||
#endif
|
||||
|
||||
// Intel's compiler on OSX may still define __clang__
|
||||
// and we have need to know when using a true clang compiler
|
||||
#if !defined(__INTEL_COMPILER) && defined(__clang__)
|
||||
#define OSL_NON_INTEL_CLANG __clang__
|
||||
// Define OSL_INTEL_LLVM_COMPILER_VERSION to hold an encoded Intel(r) LLVM Compiler version
|
||||
// (e.g. 20220000), or 0 if not an Intel(r) LLVM Compiler.
|
||||
// Define OSL_INTEL_CLANG_VERSION to hold the encoded Clang version the
|
||||
// Intel(r) LLVM Compiler is based on (e.g. 140000),
|
||||
// or 0 if not an Intel(r) LLVM compiler.
|
||||
#if defined(__INTEL_LLVM_COMPILER)
|
||||
# define OSL_INTEL_LLVM_COMPILER_VERSION __INTEL_LLVM_COMPILER
|
||||
# define OSL_INTEL_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__)
|
||||
#else
|
||||
#define OSL_NON_INTEL_CLANG 0
|
||||
# define OSL_INTEL_LLVM_COMPILER_VERSION 0
|
||||
# define OSL_INTEL_CLANG_VERSION 0
|
||||
#endif
|
||||
|
||||
// Define OSL_ANY_CLANG to 0 or 1 to indicate if any Clang based compiler is in use
|
||||
#if defined(__clang__)
|
||||
# define OSL_ANY_CLANG 1
|
||||
#else
|
||||
# define OSL_ANY_CLANG 0
|
||||
#endif
|
||||
|
||||
|
||||
// Tests for MSVS versions, always 0 if not MSVS at all.
|
||||
#if defined(_MSC_VER)
|
||||
# define OSL_MSVS_VERSION _MSC_VER
|
||||
# define OSL_MSVS_AT_LEAST_2013 (_MSC_VER >= 1800)
|
||||
# define OSL_MSVS_BEFORE_2013 (_MSC_VER < 1800)
|
||||
# define OSL_MSVS_AT_LEAST_2015 (_MSC_VER >= 1900)
|
||||
@@ -81,6 +113,7 @@
|
||||
# error "This version of OSL is meant to work only with Visual Studio 2017 or later"
|
||||
# endif
|
||||
#else
|
||||
# define OSL_MSVS_VERSION 0
|
||||
# define OSL_MSVS_AT_LEAST_2013 0
|
||||
# define OSL_MSVS_BEFORE_2013 0
|
||||
# define OSL_MSVS_AT_LEAST_2015 0
|
||||
@@ -90,14 +123,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
// Note about __CUDACC__ versus __CUDA_ARCH__:
|
||||
//
|
||||
// __CUDACC__ defined any time we are compiling a module for Cuda
|
||||
// (both for the host pass and the device pass). "Do this
|
||||
// when using nvcc or clang with ptx target."
|
||||
// __CUDA_ARCH__ is only defined when doing the device pass. "Do this only
|
||||
// for code that will actually run on the GPU."
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Detect which C++ standard we're using, and handy macros.
|
||||
@@ -208,6 +233,11 @@
|
||||
#define OSL_CLANG_ATTRIBUTE(value)
|
||||
#endif
|
||||
|
||||
#if OSL_GNUC_VERSION
|
||||
#define OSL_GNUC_ATTRIBUTE(value) __attribute__((value))
|
||||
#else
|
||||
#define OSL_GNUC_ATTRIBUTE(value)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef OSL_DEBUG
|
||||
@@ -234,6 +264,16 @@
|
||||
#define OSL_OMP_PRAGMA(aUnQuotedPragma)
|
||||
#endif
|
||||
|
||||
#define OSL_OMP_SIMD_LOOP(...) OSL_OMP_PRAGMA(omp simd __VA_ARGS__)
|
||||
|
||||
#if (OSL_GCCVERSION || OSL_INTEL_CLASSIC_COMPILER_VERSION || OSL_INTEL_LLVM_COMPILER_VERSION)
|
||||
# define OSL_OMP_COMPLEX_SIMD_LOOP(...) OSL_OMP_SIMD_LOOP(__VA_ARGS__)
|
||||
#else
|
||||
// Ignore requests to vectorize complex/nested SIMD loops for certain
|
||||
// compilers/versions that are not currently vectorizing complex loops.
|
||||
# define OSL_OMP_COMPLEX_SIMD_LOOP(...)
|
||||
#endif
|
||||
|
||||
// OSL_FORCEINLINE is a function attribute that attempts to make the
|
||||
// function always inline. On many compilers regular 'inline' is only
|
||||
// advisory. Put this attribute before the function return type, just like
|
||||
@@ -442,11 +482,19 @@
|
||||
# define OSL_DASSERT_MSG(x, ...) ((void)sizeof(x)) /*NOLINT*/
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
|
||||
#define OSL_STACK_ARRAY(TYPE, NAME, DYNAMIC_COUNT) TYPE * NAME = reinterpret_cast<TYPE *>(alloca(sizeof(TYPE)*(DYNAMIC_COUNT)))
|
||||
|
||||
/// OSL_ALLOCA is used to allocate smallish amount of memory on the stack,
|
||||
/// equivalent of C99 type var_name[size].
|
||||
///
|
||||
/// NOTE: in a debug build, this will assert for allocations >= 1MB, which is
|
||||
/// much too big. Hopefully this will keep us from abusing alloca and having
|
||||
/// stack overflows. The rule of thumb is that it's ok to use alloca for small
|
||||
/// things of bounded size, but not for anything that could be arbitrarily
|
||||
/// big, which should instead use heap allocation.
|
||||
#if defined(__GNUC__)
|
||||
# define OSL_ALLOCA(type, size) (assert(size < (1<<20)), (size) != 0 ? (reinterpret_cast<type*>(__builtin_alloca((size) * sizeof(type)))) : nullptr)
|
||||
#else
|
||||
// Utilize variable length array compiler extension when available
|
||||
#define OSL_STACK_ARRAY(TYPE, NAME, DYNAMIC_COUNT) TYPE NAME[DYNAMIC_COUNT]
|
||||
# define OSL_ALLOCA(type, size) (assert(size < (1<<20)), (size) != 0 ? (reinterpret_cast<type*>(alloca((size) * sizeof(type)))) : nullptr)
|
||||
#endif
|
||||
|
||||
OSL_NAMESPACE_ENTER
|
||||
|
||||
@@ -42,6 +42,7 @@ OSL_GCC_PRAGMA(GCC diagnostic ignored "-Wunused-parameter")
|
||||
/// RendererServices defines an abstract interface through which a
|
||||
/// renderer may provide callback to the ShadingSystem.
|
||||
class OSLEXECPUBLIC RendererServices {
|
||||
// Keep interface in sync with rs_free_function.h
|
||||
public:
|
||||
typedef TextureSystem::TextureHandle TextureHandle;
|
||||
typedef TextureSystem::Perthread TexturePerthread;
|
||||
@@ -193,6 +194,10 @@ public:
|
||||
/// read or sampled.
|
||||
virtual bool good (TextureHandle *texture_handle);
|
||||
|
||||
/// Return true if the texture handle (previously returned by
|
||||
/// get_texture_handle()) is udim
|
||||
virtual bool is_udim (TextureHandle *texture_handle);
|
||||
|
||||
/// Filtered 2D texture lookup for a single point.
|
||||
///
|
||||
/// s,t are the texture coordinates; dsdx, dtdx, dsdy, and dtdy are
|
||||
@@ -319,6 +324,16 @@ public:
|
||||
void *data,
|
||||
ustring *errormessage);
|
||||
|
||||
virtual bool get_texture_info (ustring filename,
|
||||
TextureHandle *texture_handle,
|
||||
float s, float t,
|
||||
TexturePerthread *texture_thread_info,
|
||||
ShadingContext *shading_context,
|
||||
int subimage,
|
||||
ustring dataname, TypeDesc datatype,
|
||||
void *data,
|
||||
ustring *errormessage);
|
||||
|
||||
|
||||
/// Lookup nearest points in a point cloud. It will search for
|
||||
/// points around the given center within the specified radius. A
|
||||
@@ -359,6 +374,15 @@ public:
|
||||
bool shade; ///< whether to shade what is hit
|
||||
ustring traceset; ///< named trace set
|
||||
TraceOpt () : mindist(0.0f), maxdist(1.0e30), shade(false) { }
|
||||
|
||||
enum class LLVMMemberIndex
|
||||
{
|
||||
mindist = 0,
|
||||
maxdist,
|
||||
shade,
|
||||
traceset,
|
||||
count
|
||||
};
|
||||
};
|
||||
|
||||
/// Immediately trace a ray from P in the direction R. Return true
|
||||
@@ -381,15 +405,6 @@ public:
|
||||
/// Return a pointer to the texture system (if available).
|
||||
virtual TextureSystem *texturesys () const;
|
||||
|
||||
/// Register a string with the renderer, so that the renderer can arrange
|
||||
/// to make the string available in GPU memory as needed. Optionally specify
|
||||
/// a variable name to associate with the string value.
|
||||
virtual uint64_t register_string (const std::string& str,
|
||||
const std::string& var_name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint64_t register_global (const std::string& var_name,
|
||||
uint64_t value)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
// Copyright Contributors to the Open Shading Language project.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
#include <OSL/oslconfig.h>
|
||||
|
||||
// Make all the strings defined in OSL
|
||||
// available to the renderer services free functions
|
||||
OSL_NAMESPACE_ENTER
|
||||
namespace Strings {
|
||||
#define STRDECL(str, var_name) OSLEXECPUBLIC extern const ustring var_name;
|
||||
#include <OSL/strdecls.h>
|
||||
#undef STRDECL
|
||||
}; // namespace Strings
|
||||
OSL_NAMESPACE_EXIT
|
||||
|
||||
#ifdef OSL_HOST_RS_BITCODE
|
||||
extern "C" {
|
||||
# define STRDECL(str, var_name) \
|
||||
const OSL::ustring& RS_##var_name = OSL::Strings::var_name;
|
||||
# include <OSL/strdecls.h>
|
||||
# undef STRDECL
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <OSL/device_string.h>
|
||||
#include <OSL/shaderglobals.h>
|
||||
|
||||
// Prefix for OSL shade op declarations.
|
||||
// "C" linkage (no C++ name mangling) and local visibility
|
||||
#define OSL_RSOP extern "C"
|
||||
|
||||
// We are choosing to use unique names encoding parameters directly
|
||||
// as opposed to using overloaded functions.
|
||||
|
||||
// Keep free functions in sync with virtual function based RendererServices.
|
||||
|
||||
/// Get the 4x4 matrix that transforms by the specified
|
||||
/// transformation at the given time. Return true if ok, false
|
||||
/// on error.
|
||||
OSL_RSOP bool
|
||||
rs_get_matrix_xform_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::TransformationPtr from, float time);
|
||||
|
||||
/// Get the 4x4 matrix that transforms by the specified
|
||||
/// transformation at the given time. Return true if ok, false on
|
||||
/// error. Suggested implementation is to use rs_get_matrix_xform_time and
|
||||
/// invert it, but a particular renderer may have a better technique.
|
||||
OSL_RSOP bool
|
||||
rs_get_inverse_matrix_xform_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::TransformationPtr xform, float time);
|
||||
|
||||
/// Get the 4x4 matrix that transforms points from the named
|
||||
/// 'from' coordinate system to "common" space at the given time.
|
||||
/// Returns true if ok, false if the named matrix is not known.
|
||||
OSL_RSOP bool
|
||||
rs_get_matrix_space_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::StringParam from, float time);
|
||||
|
||||
/// Get the 4x4 matrix that transforms points from "common" space to
|
||||
/// the named 'to' coordinate system to at the given time. Suggested
|
||||
/// implementation is to use rs_get_matrix_space_time and invert it, but a
|
||||
/// particular renderer may have a better technique.
|
||||
OSL_RSOP bool
|
||||
rs_get_inverse_matrix_space_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::StringParam to, float time);
|
||||
|
||||
/// Get the 4x4 matrix that transforms by the specified
|
||||
/// transformation. Return true if ok, false on error. Since no
|
||||
/// time value is given, also return false if the transformation may
|
||||
/// be time-varying.
|
||||
OSL_RSOP bool
|
||||
rs_get_matrix_xform(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::TransformationPtr xform);
|
||||
|
||||
/// Get the 4x4 matrix that transforms by the specified
|
||||
/// transformation. Return true if ok, false on error. Since no
|
||||
/// time value is given, also return false if the transformation may
|
||||
/// be time-varying. Suggested implementation is to use
|
||||
/// rs_get_matrix_xform and invert it, but a particular renderer may have a
|
||||
/// better technique.
|
||||
OSL_RSOP bool
|
||||
rs_get_inverse_matrix_xform(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::TransformationPtr xform);
|
||||
|
||||
/// Get the 4x4 matrix that transforms 'from' to "common" space.
|
||||
/// Since there is no time value passed, return false if the
|
||||
/// transformation may be time-varying (as well as if it's not found
|
||||
/// at all).
|
||||
OSL_RSOP bool
|
||||
rs_get_matrix_space(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::StringParam from);
|
||||
|
||||
/// Get the 4x4 matrix that transforms points from "common" space to
|
||||
/// the named 'to' coordinate system. Since there is no time value
|
||||
/// passed, return false if the transformation may be time-varying
|
||||
/// (as well as if it's not found at all). Suggested
|
||||
/// implementation is to use rs_get_matrix_space and invert it, but a
|
||||
/// particular renderer may have a better technique.
|
||||
OSL_RSOP bool
|
||||
rs_get_inverse_matrix_space(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
|
||||
OSL::StringParam to);
|
||||
|
||||
/// Transform points Pin[0..npoints-1] in named coordinate system
|
||||
/// 'from' into 'to' coordinates, storing the result in Pout[] using
|
||||
/// the specified vector semantic (POINT, VECTOR, NORMAL). The
|
||||
/// function returns true if the renderer correctly transformed the
|
||||
/// points, false if it failed (for example, because it did not know
|
||||
/// the name of one of the coordinate systems). Suggested implementation
|
||||
/// is simply to make appropriate calls to rs_get_matrix_space and
|
||||
/// get_inverse_matrix_space. The existence of this function is to allow
|
||||
/// some renderers to provide transformations that cannot be
|
||||
/// expressed by a 4x4 matrix.
|
||||
///
|
||||
/// Note, the virtual function based RendererServices::transform_points
|
||||
/// provides additional functionality/modes that are only used during
|
||||
/// code generation to detect if it required to even call rs_transform_points
|
||||
/// during evaluation of the shader. There is no need for the free
|
||||
/// function version to handle these additional modes.
|
||||
///
|
||||
/// Note to implementations: just return 'false'
|
||||
/// if there isn't a special nonlinear transformation between the
|
||||
/// two spaces.
|
||||
OSL_RSOP bool
|
||||
rs_transform_points(OSL::ShaderGlobals* sg, OSL::StringParam from,
|
||||
OSL::StringParam to, float time, const OSL::Vec3* Pin,
|
||||
OSL::Vec3* Pout, int npoints,
|
||||
OSL::TypeDesc::VECSEMANTICS vectype);
|
||||
+159
-131
@@ -86,14 +86,14 @@ namespace fast_grad2 {
|
||||
Vec2( -1.0f, -1.0f ), Vec2( 1.0f, 0.0f ), Vec2( -1.0f, 0.0f ), Vec2( 1.0f, 1.0f ),
|
||||
Vec2( -1.0f, 1.0f ), Vec2( 0.0f, -1.0f ), Vec2( 0.0f, 1.0f ), Vec2( 1.0f, -1.0f ));
|
||||
|
||||
//static constexpr uint8_t x_one_mask = 0b10001010;
|
||||
static constexpr uint8_t x_one_mask = 0x8A;
|
||||
//static constexpr uint8_t x_one_mask = 0b10001010;
|
||||
static constexpr uint8_t x_one_mask = 0x8A;
|
||||
//static constexpr uint8_t x_neg_one_mask = 0b00010101;
|
||||
static constexpr uint8_t x_neg_one_mask = 0x15;
|
||||
//static constexpr uint8_t y_one_mask = 0b01011000;
|
||||
static constexpr uint8_t y_one_mask = 0x58;
|
||||
static constexpr uint8_t x_neg_one_mask = 0x15;
|
||||
//static constexpr uint8_t y_one_mask = 0b01011000;
|
||||
static constexpr uint8_t y_one_mask = 0x58;
|
||||
//static constexpr uint8_t y_neg_one_mask = 0b10100001;
|
||||
static constexpr uint8_t y_neg_one_mask = 0xA1;
|
||||
static constexpr uint8_t y_neg_one_mask = 0xA1;
|
||||
|
||||
#ifdef __OSL_EMIT_GRAD_MASKS
|
||||
class OSLEXECPUBLIC mask_emitter {
|
||||
@@ -193,22 +193,23 @@ namespace fast_grad4 {
|
||||
Vec4( -1.0f, 1.0f, 1.0f, 0.0f ), Vec4( -1.0f, 1.0f, -1.0f, 0.0f ), Vec4( -1.0f, -1.0f, 1.0f, 0.0f ), Vec4( -1.0f, -1.0f, -1.0f, 0.0f ));
|
||||
|
||||
|
||||
//static constexpr uint32_t x_one_mask = 0b00001111000011110000111100000000;
|
||||
static constexpr uint32_t x_one_mask = 0x0F0F0F00;
|
||||
//static constexpr uint32_t x_one_mask = 0b00001111000011110000111100000000;
|
||||
static constexpr uint32_t x_one_mask = 0x0F0F0F00;
|
||||
//static constexpr uint32_t x_neg_one_mask = 0b11110000111100001111000000000000;
|
||||
static constexpr uint32_t x_neg_one_mask = 0xF0F0F000;
|
||||
//static constexpr uint32_t y_one_mask = 0b00110011001100110000000000001111;
|
||||
static constexpr uint32_t y_one_mask = 0x3333000F;
|
||||
static constexpr uint32_t x_neg_one_mask = 0xF0F0F000;
|
||||
//static constexpr uint32_t y_one_mask = 0b00110011001100110000000000001111;
|
||||
static constexpr uint32_t y_one_mask = 0x3333000F;
|
||||
//static constexpr uint32_t y_neg_one_mask = 0b11001100110011000000000011110000;
|
||||
static constexpr uint32_t y_neg_one_mask = 0xCCCC00F0;
|
||||
//static constexpr uint32_t z_one_mask = 0b01010101000000000011001100110011;
|
||||
static constexpr uint32_t z_one_mask = 0x55003333;
|
||||
static constexpr uint32_t y_neg_one_mask = 0xCCCC00F0;
|
||||
//static constexpr uint32_t z_one_mask = 0b01010101000000000011001100110011;
|
||||
static constexpr uint32_t z_one_mask = 0x55003333;
|
||||
//static constexpr uint32_t z_neg_one_mask = 0b10101010000000001100110011001100;
|
||||
static constexpr uint32_t z_neg_one_mask = 0xAA00CCCC;
|
||||
//static constexpr uint32_t w_one_mask = 0b00000000010101010101010101010101;
|
||||
static constexpr uint32_t w_one_mask = 0x00555555;
|
||||
static constexpr uint32_t z_neg_one_mask = 0xAA00CCCC;
|
||||
//static constexpr uint32_t w_one_mask = 0b00000000010101010101010101010101;
|
||||
static constexpr uint32_t w_one_mask = 0x00555555;
|
||||
//static constexpr uint32_t w_neg_one_mask = 0b00000000101010101010101010101010;
|
||||
static constexpr uint32_t w_neg_one_mask = 0x00AAAAAA;
|
||||
static constexpr uint32_t w_neg_one_mask = 0x00AAAAAA;
|
||||
|
||||
|
||||
#ifdef __OSL_EMIT_GRAD_MASKS
|
||||
class OSLEXECPUBLIC mask_emitter {
|
||||
@@ -254,29 +255,29 @@ namespace fast_simplex {
|
||||
|
||||
|
||||
//static constexpr uint64_t corner2_i_offset_mask = 0b1101000010110000000000000000000000000000000000000000000000000000;
|
||||
static constexpr uint64_t corner2_i_offset_mask = 0xD0B0000000000000;
|
||||
static constexpr uint64_t corner2_i_offset_mask = 0xD0B0000000000000;
|
||||
//static constexpr uint64_t corner2_j_offset_mask = 0b0000000000000000000000000000000011000100000000001000110000000000;
|
||||
static constexpr uint64_t corner2_j_offset_mask = 0x00000000C4008C00;
|
||||
static constexpr uint64_t corner2_j_offset_mask = 0x00000000C4008C00;
|
||||
//static constexpr uint64_t corner2_k_offset_mask = 0b0000000000000000000000001010001000000000000000000000000010001010;
|
||||
static constexpr uint64_t corner2_k_offset_mask = 0x000000A20000008A;
|
||||
static constexpr uint64_t corner2_k_offset_mask = 0x000000A20000008A;
|
||||
//static constexpr uint64_t corner2_l_offset_mask = 0b0000000100000001000000000000000100000001000000000000000100000001;
|
||||
static constexpr uint64_t corner2_l_offset_mask = 0x0101000101000101;
|
||||
static constexpr uint64_t corner2_l_offset_mask = 0x0101000101000101;
|
||||
//static constexpr uint64_t corner3_i_offset_mask = 0b1101000110110001000000001010000011000000000000000000000000000000;
|
||||
static constexpr uint64_t corner3_i_offset_mask = 0xD1B100A0C0000000;
|
||||
static constexpr uint64_t corner3_i_offset_mask = 0xD1B100A0C0000000;
|
||||
//static constexpr uint64_t corner3_j_offset_mask = 0b1100000000000000000000000000000011000101000000001000110110001000;
|
||||
static constexpr uint64_t corner3_j_offset_mask = 0xC0000000C5008D88;
|
||||
static constexpr uint64_t corner3_j_offset_mask = 0xC0000000C5008D88;
|
||||
//static constexpr uint64_t corner3_k_offset_mask = 0b0000000010100000000000001010001100000000000000001000100010001011;
|
||||
static constexpr uint64_t corner3_k_offset_mask = 0x00A000A30000888B;
|
||||
static constexpr uint64_t corner3_k_offset_mask = 0x00A000A30000888B;
|
||||
//static constexpr uint64_t corner3_l_offset_mask = 0b0001000100010001000000000000001100000101000000000000010100000011;
|
||||
static constexpr uint64_t corner3_l_offset_mask = 0x1111000305000503;
|
||||
static constexpr uint64_t corner3_l_offset_mask = 0x1111000305000503;
|
||||
//static constexpr uint64_t corner4_i_offset_mask = 0b1101000110110001000000001010001111000101000000001000000010000000;
|
||||
static constexpr uint64_t corner4_i_offset_mask = 0xD1B100A3C5008080;
|
||||
static constexpr uint64_t corner4_i_offset_mask = 0xD1B100A3C5008080;
|
||||
//static constexpr uint64_t corner4_j_offset_mask = 0b1101000110000000000000001000000011000101000000001000110110001011;
|
||||
static constexpr uint64_t corner4_j_offset_mask = 0xD1800080C5008D8B;
|
||||
static constexpr uint64_t corner4_j_offset_mask = 0xD1800080C5008D8B;
|
||||
//static constexpr uint64_t corner4_k_offset_mask = 0b1000000010110001000000001010001110000000000000001000110110001011;
|
||||
static constexpr uint64_t corner4_k_offset_mask = 0x80B100A380008D8B;
|
||||
static constexpr uint64_t corner4_k_offset_mask = 0x80B100A380008D8B;
|
||||
//static constexpr uint64_t corner4_l_offset_mask = 0b0101000100110001000000000010001101000101000000000000110100001011;
|
||||
static constexpr uint64_t corner4_l_offset_mask = 0x5131002345000D0B;
|
||||
static constexpr uint64_t corner4_l_offset_mask = 0x5131002345000D0B;
|
||||
|
||||
|
||||
#ifdef __OSL_EMIT_GRAD_MASKS
|
||||
@@ -389,7 +390,7 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
return fast_grad2::lut_wide.get(h & 7);
|
||||
#else
|
||||
int clamped_index = h&7;
|
||||
uint8_t bit_index = 0x01 << clamped_index;
|
||||
uint8_t bit_index = uint8_t(1) << clamped_index;
|
||||
float x = 0.0f;
|
||||
if (bit_index & fast_grad2::x_one_mask)
|
||||
x = 1.0f;
|
||||
@@ -419,7 +420,7 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
// and use a mask to blend 1.0f and -1.0f on the appropriate indices
|
||||
//return fast_grad3::lut_wide.get(h & 15);
|
||||
int clamped_index = h&15;
|
||||
uint16_t bit_index = 0x0001 << clamped_index;
|
||||
uint16_t bit_index = uint16_t(1) << clamped_index;
|
||||
float x = 0.0f;
|
||||
if (bit_index & fast_grad3::x_one_mask)
|
||||
x = 1.0f;
|
||||
@@ -439,8 +440,8 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
z = -1.0f;
|
||||
|
||||
return Vec3(x,y,z);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<int seedT>
|
||||
static OSL_FORCEINLINE const Vec4
|
||||
@@ -455,7 +456,7 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
// table lookup, so turn index into a linear bit index
|
||||
// and use a mask to blend 1.0f and -1.0f on the appropriate indices
|
||||
int clamped_index = h&31;
|
||||
uint32_t bit_index = 0x00000001 << clamped_index;
|
||||
uint32_t bit_index = uint32_t(1) << clamped_index;
|
||||
float x = 0.0f;
|
||||
if (bit_index & fast_grad4::x_one_mask)
|
||||
x = 1.0f;
|
||||
@@ -656,27 +657,36 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
|
||||
// Noise contributions from the simplex corners
|
||||
// Calculate the contribution from the three corners
|
||||
Vec2 g0 = grad2<seedT> (i, j);
|
||||
Vec2 g1 = grad2<seedT> (i+i1, j+j1);
|
||||
Vec2 g2 = grad2<seedT> (i+1, j+1);
|
||||
|
||||
// As we do not expect any coherency between data lanes
|
||||
// Hoisted work out of conditionals to encourage masking blending
|
||||
// versus a check for coherency
|
||||
// In other words we will do all the work, all the time versus
|
||||
// trying to manage it on a per lane basis.
|
||||
// NOTE: this may be slower if used for serial vs. simd
|
||||
float t0 = 0.5f - x0 * x0 - y0 * y0;
|
||||
float t20 = t0 * t0;
|
||||
float t40 = t20 * t20;
|
||||
float tn0 = t40 * (g0.x * x0 + g0.y * y0);
|
||||
float n0 = (t0 >= 0.0f) ? tn0 : 0.0f;
|
||||
Vec2 g0 = grad2<seedT> (i, j);
|
||||
float n0 = t40 * (g0.x * x0 + g0.y * y0);
|
||||
if (t0 < 0.0f)
|
||||
n0 = 0.0f;
|
||||
|
||||
float t1 = 0.5f - x1 * x1 - y1 * y1;
|
||||
float t21 = t1 * t1;
|
||||
float t41 = t21 * t21;
|
||||
float tn1 = t41 * (g1.x * x1 + g1.y * y1);
|
||||
float n1 = (t1 >= 0.0f) ? tn1 : 0.0f;
|
||||
Vec2 g1 = grad2<seedT> (i+i1, j+j1);
|
||||
float n1 = t41 * (g1.x * x1 + g1.y * y1);
|
||||
if (t1 < 0.0f)
|
||||
n1 = 0.0f;
|
||||
|
||||
float t2 = 0.5f - x2 * x2 - y2 * y2;
|
||||
float t22 = t2 * t2;
|
||||
float t42 = t22 * t22;
|
||||
float tn2 = t42 * (g2.x * x2 + g2.y * y2);
|
||||
float n2 = (t2 >= 0.0f) ? tn2 : 0.0f;
|
||||
Vec2 g2 = grad2<seedT> (i+1, j+1);
|
||||
float n2 = t42 * (g2.x * x2 + g2.y * y2);
|
||||
if (t2 < 0.0f)
|
||||
n2 = 0.0f;
|
||||
|
||||
// Sum up and scale the result. The scale is empirical, to make it
|
||||
// cover [-1,1], and to make it approximately match the range of our
|
||||
@@ -687,26 +697,29 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
// Compute derivative, if requested by supplying non-null pointers
|
||||
// for the last two arguments
|
||||
if (derivPolicy.has_derivs()) {
|
||||
/* A straight, unoptimised calculation would be like:
|
||||
* *dnoise_dx = -8.0f * t20 * t0 * x0 * ( g0.x * x0 + g0.y * y0 ) + t40 * g0.x;
|
||||
* *dnoise_dy = -8.0f * t20 * t0 * y0 * ( g0.x * x0 + g0.y * y0 ) + t40 * g0.y;
|
||||
* *dnoise_dx += -8.0f * t21 * t1 * x1 * ( g1.x * x1 + g1.y * y1 ) + t41 * g1.x;
|
||||
* *dnoise_dy += -8.0f * t21 * t1 * y1 * ( g1.x * x1 + g1.y * y1 ) + t41 * g1.y;
|
||||
* *dnoise_dx += -8.0f * t22 * t2 * x2 * ( g2.x * x2 + g2.y * y2 ) + t42 * g2.x;
|
||||
* *dnoise_dy += -8.0f * t22 * t2 * y2 * ( g2.x * x2 + g2.y * y2 ) + t42 * g2.y;
|
||||
*/
|
||||
// As we always calculated g# above,
|
||||
// we need to zero out those who were invalid
|
||||
// before they are used in more calculations
|
||||
g0 = (t0 >= 0.0f) ? g0 : Vec2(0.0f);
|
||||
g1 = (t1 >= 0.0f) ? g1 : Vec2(0.0f);
|
||||
g2 = (t2 >= 0.0f) ? g2 : Vec2(0.0f);
|
||||
/* A straight, unoptimised calculation would be like:
|
||||
* *dnoise_dx = -8.0f * t20 * t0 * x0 * ( g0[0] * x0 + g0[1] * y0 ) + t40 * g0[0];
|
||||
* *dnoise_dy = -8.0f * t20 * t0 * y0 * ( g0[0] * x0 + g0[1] * y0 ) + t40 * g0[1];
|
||||
* *dnoise_dx += -8.0f * t21 * t1 * x1 * ( g1[0] * x1 + g1[1] * y1 ) + t41 * g1[0];
|
||||
* *dnoise_dy += -8.0f * t21 * t1 * y1 * ( g1[0] * x1 + g1[1] * y1 ) + t41 * g1[1];
|
||||
* *dnoise_dx += -8.0f * t22 * t2 * x2 * ( g2[0] * x2 + g2[1] * y2 ) + t42 * g2[0];
|
||||
* *dnoise_dy += -8.0f * t22 * t2 * y2 * ( g2[0] * x2 + g2[1] * y2 ) + t42 * g2[1];
|
||||
*/
|
||||
if (t0 < 0.0f)
|
||||
g0 = Vec2(0.0f);
|
||||
float temp0 = t20 * t0 * (g0.x * x0 + g0.y * y0);
|
||||
float dnoise_dx = temp0 * x0;
|
||||
float dnoise_dy = temp0 * y0;
|
||||
if (t1 < 0.0f)
|
||||
g1 = Vec2(0.0f);
|
||||
float temp1 = t21 * t1 * (g1.x * x1 + g1.y * y1);
|
||||
dnoise_dx += temp1 * x1;
|
||||
dnoise_dy += temp1 * y1;
|
||||
if (t2 < 0.0f)
|
||||
g2 = Vec2(0.0f);
|
||||
float temp2 = t22 * t2 * (g2.x* x2 + g2.y * y2);
|
||||
dnoise_dx += temp2 * x2;
|
||||
dnoise_dy += temp2 * y2;
|
||||
@@ -844,38 +857,42 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
// In other words we will do all the work, all the time versus
|
||||
// trying to manage it on a per lane basis.
|
||||
// NOTE: this may be slower if used for serial vs. simd
|
||||
Vec3 g0 = grad3<seedT>(i, j, k);
|
||||
Vec3 g1 = grad3<seedT>(i+i1, j+j1, k+k1);
|
||||
Vec3 g2 = grad3<seedT>(i+i2, j+j2, k+k2);
|
||||
Vec3 g3 = grad3<seedT>(i+1, j+1, k+1);
|
||||
|
||||
// Calculate the contribution from the four corners
|
||||
float t0 = 0.5f - x0*x0 - y0*y0 - z0*z0;
|
||||
float t20 = t0 * t0;
|
||||
float t40 = t20 * t20;
|
||||
Vec3 g0 = grad3<seedT>(i, j, k);
|
||||
// NOTE: avoid array access of points, always use
|
||||
// the real data members to avoid aliasing issues
|
||||
//n0 = t40 * (g0[0] * x0 + g0[1] * y0 + g0[2] * z0);
|
||||
float tn0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
|
||||
float n0 = (t0 >= 0.0f) ? tn0 : 0.0f;
|
||||
//n0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
|
||||
float n0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
|
||||
if (t0 < 0.0f)
|
||||
n0 = 0.0f;
|
||||
|
||||
float t1 = 0.5f - x1*x1 - y1*y1 - z1*z1;
|
||||
float t21 = t1 * t1;
|
||||
float t41 = t21 * t21;
|
||||
float tn1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1);
|
||||
float n1 = (t1 >= 0.0f) ? tn1 : 0.0f;
|
||||
Vec3 g1 = grad3<seedT>(i+i1, j+j1, k+k1);
|
||||
float n1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1);
|
||||
if (t1 < 0.0f)
|
||||
n1 = 0.0f;
|
||||
|
||||
float t2 = 0.5f - x2*x2 - y2*y2 - z2*z2;
|
||||
float t22 = t2 * t2;
|
||||
float t42 = t22 * t22;
|
||||
float tn2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2);
|
||||
float n2 = (t2 >= 0.0f) ? tn2 : 0.0f;
|
||||
Vec3 g2 = grad3<seedT>(i+i2, j+j2, k+k2);
|
||||
float n2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2);
|
||||
if (t2 < 0.0f)
|
||||
n2 = 0.0f;
|
||||
|
||||
float t3 = 0.5f - x3*x3 - y3*y3 - z3*z3;
|
||||
float t23 = t3 * t3;
|
||||
float t43 = t23 * t23;
|
||||
float tn3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3);
|
||||
float n3 = (t3 >= 0.0f) ? tn3 : 0.0f;
|
||||
Vec3 g3 = grad3<seedT>(i+1, j+1, k+1);
|
||||
float n3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3);
|
||||
if (t3 < 0.0f)
|
||||
n3 = 0.0f;
|
||||
|
||||
// Sum up and scale the result. The scale is empirical, to make it
|
||||
// cover [-1,1], and to make it approximately match the range of our
|
||||
@@ -885,40 +902,43 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
|
||||
|
||||
if (derivPolicy.has_derivs()) {
|
||||
/* A straight, unoptimized calculation would be like:
|
||||
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0.x, g0.y, g0.z, x0, y0, z0) + t40 * g0.x;
|
||||
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0.x, g0.y, g0.z, x0, y0, z0) + t40 * g0.y;
|
||||
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0.x, g0.y, g0.z, x0, y0, z0) + t40 * g0.z;
|
||||
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1.x, g1.y, g1.z, x1, y1, z1) + t41 * g1.x;
|
||||
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1.x, g1.y, g1.z, x1, y1, z1) + t41 * g1.y;
|
||||
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1.x, g1.y, g1.z, x1, y1, z1) + t41 * g1.z;
|
||||
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2.x, g2.y, g2.z, x2, y2, z2) + t42 * g2.x;
|
||||
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2.x, g2.y, g2.z, x2, y2, z2) + t42 * g2.y;
|
||||
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2.x, g2.y, g2.z, x2, y2, z2) + t42 * g2.z;
|
||||
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3.x, g3.y, g3.z, x3, y3, z3) + t43 * g3.x;
|
||||
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3.x, g3.y, g3.z, x3, y3, z3) + t43 * g3.y;
|
||||
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3.x, g3.y, g3.z, x3, y3, z3) + t43 * g3.z;
|
||||
*/
|
||||
// As we always calculated g# above,
|
||||
// we need to zero out those who were invalid
|
||||
// before they are used in more calculations
|
||||
g0 = (t0 >= 0.0f) ? g0 : Vec3(0.0f);
|
||||
g1 = (t1 >= 0.0f) ? g1 : Vec3(0.0f);
|
||||
g2 = (t2 >= 0.0f) ? g2 : Vec3(0.0f);
|
||||
g3 = (t3 >= 0.0f) ? g3 : Vec3(0.0f);
|
||||
|
||||
/* A straight, unoptimized calculation would be like:
|
||||
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0[0], g0[1], g0[2], x0, y0, z0) + t40 * g0[0];
|
||||
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0[0], g0[1], g0[2], x0, y0, z0) + t40 * g0[1];
|
||||
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0[0], g0[1], g0[2], x0, y0, z0) + t40 * g0[2];
|
||||
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1[0], g1[1], g1[2], x1, y1, z1) + t41 * g1[0];
|
||||
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1[0], g1[1], g1[2], x1, y1, z1) + t41 * g1[1];
|
||||
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1[0], g1[1], g1[2], x1, y1, z1) + t41 * g1[2];
|
||||
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2[0], g2[1], g2[2], x2, y2, z2) + t42 * g2[0];
|
||||
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2[0], g2[1], g2[2], x2, y2, z2) + t42 * g2[1];
|
||||
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2[0], g2[1], g2[2], x2, y2, z2) + t42 * g2[2];
|
||||
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3[0], g3[1], g3[2], x3, y3, z3) + t43 * g3[0];
|
||||
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3[0], g3[1], g3[2], x3, y3, z3) + t43 * g3[1];
|
||||
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3[0], g3[1], g3[2], x3, y3, z3) + t43 * g3[2];
|
||||
*/
|
||||
if (t0 < 0.0f)
|
||||
g0 = Vec3(0.0f);
|
||||
float temp0 = t20 * t0 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
|
||||
float dnoise_dx = temp0 * x0;
|
||||
float dnoise_dy = temp0 * y0;
|
||||
float dnoise_dz = temp0 * z0;
|
||||
if (t1 < 0.0f)
|
||||
g1 = Vec3(0.0f);
|
||||
float temp1 = t21 * t1 * (g1.x * x1 + g1.y * y1 + g1.z * z1);
|
||||
dnoise_dx += temp1 * x1;
|
||||
dnoise_dy += temp1 * y1;
|
||||
dnoise_dz += temp1 * z1;
|
||||
if (t2 < 0.0f)
|
||||
g2 = Vec3(0.0f);
|
||||
float temp2 = t22 * t2 * (g2.x * x2 + g2.y * y2 + g2.z * z2);
|
||||
dnoise_dx += temp2 * x2;
|
||||
dnoise_dy += temp2 * y2;
|
||||
dnoise_dz += temp2 * z2;
|
||||
if (t3 < 0.0f)
|
||||
g3 = Vec3(0.0f);
|
||||
float temp3 = t23 * t3 * (g3.x * x3 + g3.y * y3 + g3.z * z3);
|
||||
dnoise_dx += temp3 * x3;
|
||||
dnoise_dy += temp3 * y3;
|
||||
@@ -1074,45 +1094,49 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
// In other words we will do all the work, all the time versus
|
||||
// trying to manage it on a per lane basis.
|
||||
// NOTE: this may be slower if used for serial vs. simd
|
||||
Vec4 g0 = grad4<seedT>(i, j, k, l);
|
||||
Vec4 g1 = grad4<seedT>(i+i1, j+j1, k+k1, l+l1);
|
||||
Vec4 g2 = grad4<seedT>(i+i2, j+j2, k+k2, l+l2);
|
||||
Vec4 g3 = grad4<seedT>(i+i3, j+j3, k+k3, l+l3);
|
||||
Vec4 g4 = grad4<seedT>(i+1, j+1, k+1, l+1);
|
||||
|
||||
// Calculate the contribution from the five corners
|
||||
float t0 = 0.5f - x0*x0 - y0*y0 - z0*z0 - w0*w0;
|
||||
// NOTE: avoid array access of points, always use
|
||||
// the real data members to avoid aliasing issues
|
||||
|
||||
float t0 = 0.5f - x0*x0 - y0*y0 - z0*z0 - w0*w0;
|
||||
float t20 = t0 * t0;
|
||||
float t40 = t20 * t20;
|
||||
float tn0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0 + g0.w * w0);
|
||||
float n0 = (t0 >= 0.0f) ? tn0 : 0.0f;
|
||||
Vec4 g0 = grad4<seedT>(i, j, k, l);
|
||||
float n0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0 + g0.w * w0);
|
||||
if (t0 < 0.0f)
|
||||
n0 = 0.0f;
|
||||
|
||||
float t1 = 0.5f - x1*x1 - y1*y1 - z1*z1 - w1*w1;
|
||||
float t21 = t1 * t1;
|
||||
float t41 = t21 * t21;
|
||||
float tn1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1 + g1.w * w1);
|
||||
float n1 = (t1 >= 0.0f) ? tn1 : 0.0f;
|
||||
Vec4 g1 = grad4<seedT>(i+i1, j+j1, k+k1, l+l1);
|
||||
float n1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1 + g1.w * w1);
|
||||
if (t1 < 0.0f)
|
||||
n1 = 0.0f;
|
||||
|
||||
float t2 = 0.5f - x2*x2 - y2*y2 - z2*z2 - w2*w2;
|
||||
float t22 = t2 * t2;
|
||||
float t42 = t22 * t22;
|
||||
float tn2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2 + g2.w * w2);
|
||||
float n2 = (t2 >= 0.0f) ? tn2 : 0.0f;
|
||||
Vec4 g2 = grad4<seedT>(i+i2, j+j2, k+k2, l+l2);
|
||||
float n2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2 + g2.w * w2);
|
||||
if (t2 < 0.0f)
|
||||
n2 = 0.0f;
|
||||
|
||||
float t3 = 0.5f - x3*x3 - y3*y3 - z3*z3 - w3*w3;
|
||||
float t23 = t3 * t3;
|
||||
float t43 = t23 * t23;
|
||||
float tn3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3 + g3.w * w3);
|
||||
float n3 = (t3 >= 0.0f) ? tn3 : 0.0f;
|
||||
Vec4 g3 = grad4<seedT>(i+i3, j+j3, k+k3, l+l3);
|
||||
float n3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3 + g3.w * w3);
|
||||
if (t3 < 0.0f)
|
||||
n3 = 0.0f;
|
||||
|
||||
float t4 = 0.5f - x4*x4 - y4*y4 - z4*z4 - w4*w4;
|
||||
float t24 = t4 * t4;
|
||||
float t44 = t24 * t24;
|
||||
float tn4 = t44 * (g4.x * x4 + g4.y * y4 + g4.z * z4 + g4.w * w4);
|
||||
float n4 = (t4 >= 0.0f) ? tn4 : 0.0f;
|
||||
Vec4 g4 = grad4<seedT>(i+1, j+1, k+1, l+1);
|
||||
float n4 = t44 * (g4.x * x4 + g4.y * y4 + g4.z * z4 + g4.w * w4);
|
||||
if (t4 < 0.0f)
|
||||
n4 = 0.0f;
|
||||
|
||||
// Sum up and scale the result. The scale is empirical, to make it
|
||||
// cover [-1,1], and to make it approximately match the range of our
|
||||
@@ -1121,57 +1145,61 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
|
||||
float noise = scale * (n0 + n1 + n2 + n3 + n4);
|
||||
|
||||
if (derivPolicy.has_derivs()) {
|
||||
/* A straight, unoptimised calculation would be like:
|
||||
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.x;
|
||||
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.y;
|
||||
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.z;
|
||||
* *dnoise_dw = -8.0f * t20 * t0 * w0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.w;
|
||||
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.x;
|
||||
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.y;
|
||||
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.z;
|
||||
* *dnoise_dw = -8.0f * t21 * t1 * w1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.w;
|
||||
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.x;
|
||||
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.y;
|
||||
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.z;
|
||||
* *dnoise_dw += -8.0f * t22 * t2 * w2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.w;
|
||||
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.x;
|
||||
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.y;
|
||||
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.z;
|
||||
* *dnoise_dw += -8.0f * t23 * t3 * w3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.w;
|
||||
* *dnoise_dx += -8.0f * t24 * t4 * x4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.x;
|
||||
* *dnoise_dy += -8.0f * t24 * t4 * y4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.y;
|
||||
* *dnoise_dz += -8.0f * t24 * t4 * z4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.z;
|
||||
* *dnoise_dw += -8.0f * t24 * t4 * w4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.w;
|
||||
*/
|
||||
// As we always calculated g# above,
|
||||
// we need to zero out those who were invalid
|
||||
// before they are used in more calculations
|
||||
g0 = (t0 >= 0.0f) ? g0 : Vec4(0.0f);
|
||||
g1 = (t1 >= 0.0f) ? g1 : Vec4(0.0f);
|
||||
g2 = (t2 >= 0.0f) ? g2 : Vec4(0.0f);
|
||||
g3 = (t3 >= 0.0f) ? g3 : Vec4(0.0f);
|
||||
g4 = (t4 >= 0.0f) ? g4 : Vec4(0.0f);
|
||||
|
||||
/* A straight, unoptimised calculation would be like:
|
||||
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[0];
|
||||
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[1];
|
||||
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[2];
|
||||
* *dnoise_dw = -8.0f * t20 * t0 * w0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[3];
|
||||
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[0];
|
||||
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[1];
|
||||
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[2];
|
||||
* *dnoise_dw = -8.0f * t21 * t1 * w1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[3];
|
||||
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[0];
|
||||
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[1];
|
||||
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[2];
|
||||
* *dnoise_dw += -8.0f * t22 * t2 * w2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[3];
|
||||
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[0];
|
||||
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[1];
|
||||
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[2];
|
||||
* *dnoise_dw += -8.0f * t23 * t3 * w3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[3];
|
||||
* *dnoise_dx += -8.0f * t24 * t4 * x4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[0];
|
||||
* *dnoise_dy += -8.0f * t24 * t4 * y4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[1];
|
||||
* *dnoise_dz += -8.0f * t24 * t4 * z4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[2];
|
||||
* *dnoise_dw += -8.0f * t24 * t4 * w4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[3];
|
||||
*/
|
||||
if (t0 < 0.0f)
|
||||
g0 = Vec4(0.0f);
|
||||
float temp0 = t20 * t0 * (g0.x * x0 + g0.y * y0 + g0.z * z0 + g0.w * w0);
|
||||
float dnoise_dx = temp0 * x0;
|
||||
float dnoise_dy = temp0 * y0;
|
||||
float dnoise_dz = temp0 * z0;
|
||||
float dnoise_dw = temp0 * w0;
|
||||
if (t1 < 0.0f)
|
||||
g1 = Vec4(0.0f);
|
||||
float temp1 = t21 * t1 * (g1.x * x1 + g1.y * y1 + g1.z * z1 + g1.w * w1);
|
||||
dnoise_dx += temp1 * x1;
|
||||
dnoise_dy += temp1 * y1;
|
||||
dnoise_dz += temp1 * z1;
|
||||
dnoise_dw += temp1 * w1;
|
||||
if (t2 < 0.0f)
|
||||
g2 = Vec4(0.0f);
|
||||
float temp2 = t22 * t2 * (g2.x * x2 + g2.y * y2 + g2.z * z2 + g2.w * w2);
|
||||
dnoise_dx += temp2 * x2;
|
||||
dnoise_dy += temp2 * y2;
|
||||
dnoise_dz += temp2 * z2;
|
||||
dnoise_dw += temp2 * w2;
|
||||
if (t3 < 0.0f)
|
||||
g3 = Vec4(0.0f);
|
||||
float temp3 = t23 * t3 * (g3.x * x3 + g3.y * y3 + g3.z * z3 + g3.w * w3);
|
||||
dnoise_dx += temp3 * x3;
|
||||
dnoise_dy += temp3 * y3;
|
||||
dnoise_dz += temp3 * z3;
|
||||
dnoise_dw += temp3 * w3;
|
||||
if (t4 < 0.0f)
|
||||
g4 = Vec4(0.0f);
|
||||
float temp4 = t24 * t4 * (g4.x * x4 + g4.y * y4 + g4.z * z4 + g4.w * w4);
|
||||
dnoise_dx += temp4 * x4;
|
||||
dnoise_dy += temp4 * y4;
|
||||
|
||||
@@ -0,0 +1,479 @@
|
||||
// Copyright Contributors to the Open Shading Language project.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
//#include <iostream>
|
||||
|
||||
#include <OSL/dual.h>
|
||||
#include <OSL/dual_vec.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
OSL_NAMESPACE_ENTER
|
||||
|
||||
namespace __OSL_WIDE_PVT {
|
||||
|
||||
// SIMD FRIENDLY MATH
|
||||
// Scalar code meant to be used from inside
|
||||
// compiler vectorized SIMD loops.
|
||||
// No intrinsics or assembly, just vanilla C++
|
||||
namespace sfm {
|
||||
template<int MT, int DivisorT> struct Multiplier {
|
||||
static OSL_FORCEINLINE float multiply(float value)
|
||||
{
|
||||
return value * (static_cast<float>(MT) / static_cast<float>(DivisorT));
|
||||
}
|
||||
};
|
||||
|
||||
template<int DivisorT> struct Multiplier<0, DivisorT> {
|
||||
static OSL_FORCEINLINE float multiply(float value) { return 0.0f; }
|
||||
};
|
||||
|
||||
template<int DivisorT> struct Multiplier<DivisorT, DivisorT> {
|
||||
static OSL_FORCEINLINE float multiply(float value) { return value; }
|
||||
};
|
||||
|
||||
template<int ValueT> struct Negative {
|
||||
static constexpr int value = -ValueT;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<int MT, int DivisorT> struct ProxyElement {
|
||||
OSL_FORCEINLINE float operator*(float value) const
|
||||
{
|
||||
return value * (static_cast<float>(MT) / static_cast<float>(DivisorT));
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const
|
||||
{
|
||||
return static_cast<float>(MT) / static_cast<float>(DivisorT);
|
||||
}
|
||||
};
|
||||
|
||||
template<int DivisorT> struct ProxyElement<0, DivisorT> {
|
||||
OSL_FORCEINLINE ProxyElement<0, DivisorT> operator*(float) const
|
||||
{
|
||||
return ProxyElement<0, DivisorT>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float operator+(float value) const { return value; }
|
||||
|
||||
template<int OtherMt, int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<OtherMt, OtherDivisorT>
|
||||
operator+(ProxyElement<OtherMt, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<OtherMt, OtherDivisorT>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const { return 0.0f; }
|
||||
};
|
||||
|
||||
template<int MT> struct ProxyElement<MT, 1> {
|
||||
OSL_FORCEINLINE float operator*(float value) const
|
||||
{
|
||||
return static_cast<float>(MT) * value;
|
||||
}
|
||||
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE float
|
||||
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
|
||||
{
|
||||
return static_cast<float>(MT + 1);
|
||||
}
|
||||
|
||||
template<int OtherMT>
|
||||
OSL_FORCEINLINE ProxyElement<OtherMT + MT, 1>
|
||||
operator+(ProxyElement<OtherMT, 1>) const
|
||||
{
|
||||
return ProxyElement<OtherMT + MT, 1>();
|
||||
}
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<MT, 1>
|
||||
operator+(ProxyElement<0, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<MT, 1>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const { return static_cast<float>(MT); }
|
||||
};
|
||||
|
||||
|
||||
template<> struct ProxyElement<0, 1> {
|
||||
OSL_FORCEINLINE ProxyElement<0, 1> operator*(float) const
|
||||
{
|
||||
return ProxyElement<0, 1>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float operator+(float value) const { return value; }
|
||||
|
||||
template<int OtherMt, int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<OtherMt, OtherDivisorT>
|
||||
operator+(ProxyElement<OtherMt, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<OtherMt, OtherDivisorT>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const { return 0.0f; }
|
||||
};
|
||||
|
||||
template<int DivisorT> struct ProxyElement<DivisorT, DivisorT> {
|
||||
OSL_FORCEINLINE float operator*(float value) const { return value; }
|
||||
|
||||
OSL_FORCEINLINE float operator+(float value) const
|
||||
{
|
||||
return 1.0f + value; //
|
||||
}
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<2, 1>
|
||||
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<2, 1>();
|
||||
}
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<0, DivisorT>
|
||||
operator+(ProxyElement<0, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<0, DivisorT>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const { return 1.0f; }
|
||||
};
|
||||
//
|
||||
template<> struct ProxyElement<1, 1> {
|
||||
OSL_FORCEINLINE float operator*(float value) const { return value; }
|
||||
|
||||
OSL_FORCEINLINE float operator+(float value) const { return 1.0f + value; }
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<2, 1>
|
||||
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<2, 1>();
|
||||
}
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<0, 1>
|
||||
operator+(ProxyElement<0, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<0, 1>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const { return 1.0f; }
|
||||
};
|
||||
|
||||
|
||||
template<> struct ProxyElement<-1, 1> {
|
||||
OSL_FORCEINLINE float operator*(float value) const { return -value; }
|
||||
|
||||
OSL_FORCEINLINE float operator+(float value) const
|
||||
{
|
||||
return -1.0f + value;
|
||||
} //
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<0, 1>
|
||||
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<0, 1>();
|
||||
}
|
||||
|
||||
template<int OtherDivisorT>
|
||||
OSL_FORCEINLINE ProxyElement<-1, 1>
|
||||
operator+(ProxyElement<0, OtherDivisorT>) const
|
||||
{
|
||||
return ProxyElement<-1, 1>();
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE float to_float() const { return -1.0f; }
|
||||
};
|
||||
|
||||
template<typename ProxyElementX_T, typename ProxyElementY_T,
|
||||
typename ProxyElementZ_T>
|
||||
struct ProxyVec3 {
|
||||
ProxyVec3() = delete;
|
||||
OSL_FORCEINLINE ProxyVec3(const ProxyVec3& other)
|
||||
: x(other.x), y(other.y), z(other.z)
|
||||
{
|
||||
}
|
||||
OSL_FORCEINLINE ProxyVec3(const ProxyElementX_T& x_,
|
||||
const ProxyElementY_T& y_,
|
||||
const ProxyElementZ_T& z_)
|
||||
: x(x_), y(y_), z(z_)
|
||||
{
|
||||
}
|
||||
|
||||
ProxyElementX_T x;
|
||||
ProxyElementY_T y;
|
||||
ProxyElementZ_T z;
|
||||
};
|
||||
|
||||
template<typename ProxyElementX_T, typename ProxyElementY_T,
|
||||
typename ProxyElementZ_T>
|
||||
OSL_FORCEINLINE ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>
|
||||
makeProxyVec3(ProxyElementX_T x, ProxyElementY_T y, ProxyElementZ_T z)
|
||||
{
|
||||
return ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>(x, y,
|
||||
z);
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE
|
||||
Vec3
|
||||
makeProxyVec3(float x, float y, float z)
|
||||
{
|
||||
return Vec3(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator+(float a, ProxyElement<MT, DivisorT> b) -> decltype(b + a)
|
||||
{
|
||||
return b + a;
|
||||
}
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator*(float a, ProxyElement<MT, DivisorT> b) -> decltype(b * a)
|
||||
{
|
||||
return b * a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
OSL_FORCEINLINE
|
||||
float
|
||||
unproxy_element(float value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
OSL_FORCEINLINE
|
||||
Vec3
|
||||
unproxy_element(const Vec3& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename ProxyElementX_T, typename ProxyElementY_T,
|
||||
typename ProxyElementZ_T>
|
||||
OSL_FORCEINLINE Vec3
|
||||
unproxy_element(
|
||||
const ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>& value)
|
||||
{
|
||||
return Vec3(unproxy_element(value.x), unproxy_element(value.y),
|
||||
unproxy_element(value.z));
|
||||
}
|
||||
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE float
|
||||
unproxy_element(ProxyElement<MT, DivisorT> value)
|
||||
{
|
||||
return value.to_float();
|
||||
}
|
||||
|
||||
template<typename ProxyElementX_T, typename ProxyElementY_T,
|
||||
typename ProxyElementZ_T>
|
||||
OSL_FORCEINLINE Vec3
|
||||
unproxy_vec3(
|
||||
const ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>& a)
|
||||
{
|
||||
return Vec3(unproxy_element(a.x), unproxy_element(a.y),
|
||||
unproxy_element(a.z));
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE Vec3
|
||||
unproxy_vec3(const Vec3& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Specialize operators for Vec3 to interact with ProxyElements:
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator*(ProxyElement<MT, DivisorT> a, const Vec3& b)
|
||||
-> decltype(makeProxyVec3(a * b.x, a* b.y, a* b.z))
|
||||
{
|
||||
return makeProxyVec3(a * b.x, a * b.y, a * b.z);
|
||||
}
|
||||
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator+(ProxyElement<MT, DivisorT> a, const Vec3& b)
|
||||
-> decltype(makeProxyVec3(a + b.x, a + b.y, a + b.z))
|
||||
{
|
||||
return makeProxyVec3(a + b.x, a + b.y, a + b.z);
|
||||
}
|
||||
|
||||
template<typename XT, typename YT, typename ZT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator+(ProxyVec3<XT, YT, ZT> a, const Vec3& b)
|
||||
-> decltype(makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z))
|
||||
{
|
||||
return makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z);
|
||||
}
|
||||
|
||||
|
||||
template<typename XT, typename YT, typename ZT, typename X2T, typename Y2T,
|
||||
typename Z2T>
|
||||
OSL_FORCEINLINE auto
|
||||
operator+(ProxyVec3<XT, YT, ZT> a, ProxyVec3<X2T, Y2T, Z2T> b)
|
||||
-> decltype(makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z))
|
||||
{
|
||||
return makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z);
|
||||
}
|
||||
|
||||
template<typename XT, typename YT, typename ZT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator*(ProxyVec3<XT, YT, ZT> a, float b)
|
||||
-> decltype(makeProxyVec3(a.x * b, a.y* b, a.z* b))
|
||||
{
|
||||
return makeProxyVec3(a.x * b, a.y * b, a.z * b);
|
||||
}
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator+(const Vec3& a, ProxyElement<MT, DivisorT> b) -> decltype(b + a)
|
||||
{
|
||||
return b + a;
|
||||
}
|
||||
|
||||
|
||||
template<typename XT, typename YT, typename ZT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator+(const Vec3& a, ProxyVec3<XT, YT, ZT> b) -> decltype(b + a)
|
||||
{
|
||||
return b + a;
|
||||
}
|
||||
|
||||
template<int MT, int DivisorT>
|
||||
OSL_FORCEINLINE auto
|
||||
operator*(const Vec3& a, const ProxyElement<MT, DivisorT>& b) -> decltype(b * a)
|
||||
{
|
||||
return b * a;
|
||||
}
|
||||
|
||||
|
||||
//Dual2
|
||||
|
||||
// Specialize operators for Dual2 to interact with ProxyElements
|
||||
template<class T, int MT, int DivisorT>
|
||||
OSL_FORCEINLINE Dual2<T>
|
||||
operator*(ProxyElement<MT, DivisorT> b, const Dual2<T>& a)
|
||||
{
|
||||
return Dual2<T>(unproxy_element(a.val() * b), unproxy_element(a.dx() * b),
|
||||
unproxy_element(a.dy() * b));
|
||||
}
|
||||
|
||||
|
||||
template<class T, int MT, int DivisorT>
|
||||
OSL_FORCEINLINE Dual2<T>
|
||||
operator+(const Dual2<T>& a, ProxyElement<MT, DivisorT> b)
|
||||
{
|
||||
return Dual2<T>(a.val() + b, a.dx(), a.dy());
|
||||
}
|
||||
|
||||
|
||||
template<typename XT, typename YT, typename ZT>
|
||||
OSL_FORCEINLINE Dual2<Vec3>
|
||||
operator*(ProxyVec3<XT, YT, ZT> a, const Dual2<float>& b)
|
||||
{
|
||||
return Dual2<Vec3>(unproxy_vec3(a * b.val()), unproxy_vec3(a * b.dx()),
|
||||
unproxy_vec3(a * b.dy()));
|
||||
}
|
||||
|
||||
template<typename XT, typename YT, typename ZT>
|
||||
OSL_FORCEINLINE Dual2<Vec3>
|
||||
operator*(const Dual2<float>& b, ProxyVec3<XT, YT, ZT> a)
|
||||
{
|
||||
return Dual2<Vec3>(unproxy_vec3(a * b.val()), unproxy_vec3(a * b.dx()),
|
||||
unproxy_vec3(a * b.dy()));
|
||||
}
|
||||
|
||||
|
||||
template<typename XT, typename YT, typename ZT>
|
||||
OSL_FORCEINLINE Dual2<Vec3>
|
||||
operator+(const Dual2<Vec3>& b, ProxyVec3<XT, YT, ZT> a)
|
||||
{
|
||||
return Dual2<Vec3>(unproxy_vec3(b.val() + a), b.dx(), b.dy());
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE
|
||||
Dual2<float>
|
||||
unproxy_element(const Dual2<float>& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
OSL_FORCEINLINE
|
||||
Dual2<Vec3>
|
||||
unproxy_element(const Dual2<Vec3>& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
template<int M00, int M01, int M02, int M03, int M10, int M11, int M12, int M13,
|
||||
int M20, int M21, int M22, int M23, int M30, int M31, int M32, int M33,
|
||||
int DivisorT>
|
||||
struct StaticMatrix44 {
|
||||
ProxyElement<M00, DivisorT> m00;
|
||||
ProxyElement<M01, DivisorT> m01;
|
||||
ProxyElement<M02, DivisorT> m02;
|
||||
ProxyElement<M03, DivisorT> m03;
|
||||
|
||||
ProxyElement<M10, DivisorT> m10;
|
||||
ProxyElement<M11, DivisorT> m11;
|
||||
ProxyElement<M12, DivisorT> m12;
|
||||
ProxyElement<M13, DivisorT> m13;
|
||||
|
||||
ProxyElement<M20, DivisorT> m20;
|
||||
ProxyElement<M21, DivisorT> m21;
|
||||
ProxyElement<M22, DivisorT> m22;
|
||||
ProxyElement<M23, DivisorT> m23;
|
||||
|
||||
ProxyElement<M30, DivisorT> m30;
|
||||
ProxyElement<M31, DivisorT> m31;
|
||||
ProxyElement<M32, DivisorT> m32;
|
||||
ProxyElement<M33, DivisorT> m33;
|
||||
};
|
||||
|
||||
// For debugging purposes, you can swap in a DynamicMatrix44 for a StaticMatrix44
|
||||
#if __OSL_DEBUG_STATIC_MATRIX44
|
||||
struct DynamicMatrix44 {
|
||||
float m00;
|
||||
float m01;
|
||||
float m02;
|
||||
float m03;
|
||||
|
||||
float m10;
|
||||
float m11;
|
||||
float m12;
|
||||
float m13;
|
||||
|
||||
float m20;
|
||||
float m21;
|
||||
float m22;
|
||||
float m23;
|
||||
|
||||
float m30;
|
||||
float m31;
|
||||
float m32;
|
||||
float m33;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace sfm
|
||||
} // namespace __OSL_WIDE_PVT
|
||||
OSL_NAMESPACE_EXIT
|
||||
@@ -68,7 +68,7 @@ namespace sfm
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if OSL_INTEL_COMPILER
|
||||
#if OSL_INTEL_CLASSIC_COMPILER_VERSION
|
||||
// std::isinf wasn't vectorizing and was branchy. This slightly
|
||||
// perturbed version fairs better and is branch free when vectorized
|
||||
// with the Intel compiler.
|
||||
@@ -112,11 +112,7 @@ namespace sfm
|
||||
// return x.val() >= 0.0f ? x : -x;
|
||||
|
||||
// NOTE: negation happens outside of conditional, then is blended based on the condition
|
||||
#if OPENIMAGEIO_VERSION >= 20112
|
||||
Dual2<float> neg_x = OIIO::fast_neg(x);
|
||||
#else
|
||||
Dual2<float> neg_x = -x;
|
||||
#endif
|
||||
|
||||
bool cond = x.val() < 0.0f;
|
||||
// Blend per builtin component to allow
|
||||
@@ -149,7 +145,7 @@ namespace sfm
|
||||
//return static_cast<int>(rintf(x));
|
||||
return rintf(x);
|
||||
#else
|
||||
// emulate rounding by adding/substracting 0.5
|
||||
// emulate rounding by adding/subtracting 0.5
|
||||
return static_cast<int>(x + copysignf(0.5f, x));
|
||||
|
||||
// Other possible factorings
|
||||
@@ -267,14 +263,71 @@ namespace sfm
|
||||
}
|
||||
}
|
||||
|
||||
#if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION && !OSL_INTEL_LLVM_COMPILER_VERSION
|
||||
|
||||
// To make clang's loop vectorizor happy
|
||||
// we need to make sure result of min and max
|
||||
// is truly by value, not address or reference
|
||||
// to the original.
|
||||
// This required creating temporary result
|
||||
// versus just returning by value (which could have been elided)
|
||||
template<typename T>
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE
|
||||
T min_val(const T &left, const T &right)
|
||||
{
|
||||
T result(right);
|
||||
if (right > left)
|
||||
result = left;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE
|
||||
T max_val(const T &left, const T &right)
|
||||
{
|
||||
T result(left);
|
||||
if (right > left)
|
||||
result = right;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE
|
||||
T select_val(bool cond, const T &left, const T &right)
|
||||
{
|
||||
T result(right);
|
||||
if (cond)
|
||||
result = left;
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
|
||||
template<typename T>
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE
|
||||
T min_val(T left, T right)
|
||||
{
|
||||
return (right > left)? left : right;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE
|
||||
T max_val(T left, T right)
|
||||
{
|
||||
return (right > left)? right: left;
|
||||
return (right > left)? right : left;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
OSL_FORCEINLINE OSL_HOSTDEVICE
|
||||
T select_val(bool cond, const T left, const T right)
|
||||
{
|
||||
if (cond)
|
||||
return left;
|
||||
else
|
||||
return right;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if OSL_USING_IMATH >= 3
|
||||
using Matrix33 = OSL::Matrix33;
|
||||
#else
|
||||
@@ -388,7 +441,7 @@ namespace sfm
|
||||
|
||||
// Considering having functionally equivalent versions of Vec3, Color3, Matrix44
|
||||
// with slight modifications to inlining and implementation to avoid aliasing and
|
||||
// improve likelyhood of proper privation of local variables within a SIMD loop
|
||||
// improve likelihood of proper privation of local variables within a SIMD loop
|
||||
|
||||
} // namespace sfm
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ class RendererServices;
|
||||
/// coordinate transformation.
|
||||
typedef const void* TransformationPtr;
|
||||
|
||||
/// Type for an opaque pointer to whatever the Shading System uses to represent
|
||||
/// Uniform State.
|
||||
typedef const void* OpaqueShadingStateUniformPtr;
|
||||
|
||||
|
||||
/// The ShaderGlobals structure represents the state describing a particular
|
||||
@@ -83,6 +86,7 @@ struct ShaderGlobals {
|
||||
/// Back-pointer to the ShadingContext (set and used by OSL itself --
|
||||
/// renderers shouldn't mess with this at all).
|
||||
ShadingContext* context;
|
||||
OpaqueShadingStateUniformPtr shadingStateUniform;
|
||||
|
||||
/// Pointer to the RendererServices object. This is how OSL finds its
|
||||
/// way back to the renderer for callbacks.
|
||||
|
||||
@@ -139,6 +139,8 @@ STRDECL("SMPTE", SMPTE)
|
||||
STRDECL("HDTV", HDTV)
|
||||
STRDECL("CIE", CIE)
|
||||
STRDECL("AdobeRGB", AdobeRGB)
|
||||
STRDECL("ACES2065-1", ACES2065_1)
|
||||
STRDECL("ACEScg", ACEScg)
|
||||
STRDECL("colorsystem", colorsystem)
|
||||
STRDECL("arraylength", arraylength)
|
||||
STRDECL("unknown", unknown)
|
||||
|
||||
+800
-515
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,124 @@
|
||||
// Copyright Contributors to the Open Shading Language project.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
#ifndef __OSL_WIDTH
|
||||
# error must define __OSL_WIDTH to number of SIMD lanes before including this header
|
||||
#endif
|
||||
|
||||
#include <OSL/oslconfig.h>
|
||||
|
||||
#include <OSL/dual_vec.h>
|
||||
#include <OSL/wide.h>
|
||||
|
||||
OSL_NAMESPACE_ENTER
|
||||
|
||||
struct NoiseParams;
|
||||
|
||||
namespace __OSL_WIDE_PVT {
|
||||
|
||||
OSL_USING_DATA_WIDTH(__OSL_WIDTH)
|
||||
|
||||
// Forward declaration, implementation is in liboslnoise/wide_gabornoise.h
|
||||
struct DisabledFilterPolicy {
|
||||
static constexpr bool active = false;
|
||||
};
|
||||
|
||||
struct EnabledFilterPolicy {
|
||||
static constexpr bool active = true;
|
||||
};
|
||||
|
||||
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_gabor(Masked<Dual2<float>> wResult, Wide<const Dual2<float>> wX,
|
||||
NoiseParams const* opt, Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_gabor(Masked<Dual2<float>> wResult, Wide<const Dual2<float>> wX,
|
||||
Wide<const Dual2<float>> wY, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_gabor(Masked<Dual2<float>> wResult, Wide<const Dual2<Vec3>> wP,
|
||||
NoiseParams const* opt, Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_gabor3(Masked<Dual2<Vec3>> wResult, Wide<const Dual2<float>> wX,
|
||||
NoiseParams const* opt, Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_gabor3(Masked<Dual2<Vec3>> wResult, Wide<const Dual2<float>> wX,
|
||||
Wide<const Dual2<float>> wY, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_gabor3(Masked<Dual2<Vec3>> wResult, Wide<const Dual2<Vec3>> wP,
|
||||
NoiseParams const* opt, Block<Vec3>* opt_varying_direction);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Periodic gabor(s)
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_pgabor(Masked<Dual2<float>> wResult, Wide<const Dual2<float>> wX,
|
||||
Wide<const float> wXp, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_pgabor(Masked<Dual2<float>> wResult, Wide<const Dual2<float>> wX,
|
||||
Wide<const Dual2<float>> wY, Wide<const float> wXp,
|
||||
Wide<const float> wYp, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_pgabor(Masked<Dual2<float>> wResult, Wide<const Dual2<Vec3>> wP,
|
||||
Wide<const Vec3> wPp, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_pgabor3(Masked<Dual2<Vec3>> wResult, Wide<const Dual2<float>> wX,
|
||||
Wide<const float> wXp, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_pgabor3(Masked<Dual2<Vec3>> wResult, Wide<const Dual2<float>> wX,
|
||||
Wide<const Dual2<float>> wY, Wide<const float> wXp,
|
||||
Wide<const float> wYp, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
// Forward declaration, implementation is in wide_gabor.h
|
||||
template<int AnisotropicT, typename FilterPolicyT>
|
||||
OSL_NOINLINE void
|
||||
wide_pgabor3(Masked<Dual2<Vec3>> wResult, Wide<const Dual2<Vec3>> wP,
|
||||
Wide<const Vec3> wPp, NoiseParams const* opt,
|
||||
Block<Vec3>* opt_varying_direction);
|
||||
|
||||
|
||||
|
||||
} // namespace __OSL_WIDE_PVT
|
||||
|
||||
OSL_NAMESPACE_EXIT
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OSL/oslconfig.h>
|
||||
#include <OSL/oslversion.h>
|
||||
|
||||
#ifdef OSL_USE_OPTIX
|
||||
@@ -13,14 +14,18 @@
|
||||
# ifdef _WIN32
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# if (OPTIX_VERSION < 70000)
|
||||
# include <optix_world.h>
|
||||
# endif
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(OSL_USE_OPTIX) && !defined(__CUDA_ARCH__)
|
||||
using CUdeviceptr = void*;
|
||||
using float3 = OSL::Vec3;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
OSL_NAMESPACE_ENTER
|
||||
|
||||
#ifdef OSL_USE_OPTIX
|
||||
@@ -31,14 +36,12 @@ OSL_NAMESPACE_ENTER
|
||||
|
||||
|
||||
// TODO clean this up once OptiX6 support is dropped
|
||||
# if (OPTIX_VERSION < 70000)
|
||||
namespace optix = ::optix;
|
||||
# else
|
||||
namespace optix {
|
||||
typedef OptixDeviceContext Context;
|
||||
typedef cudaTextureObject_t TextureSampler;
|
||||
using ::CUdeviceptr;
|
||||
using ::float3;
|
||||
} // namespace optix
|
||||
# endif
|
||||
|
||||
using ::cudaFree;
|
||||
using ::cudaMalloc;
|
||||
@@ -49,13 +52,19 @@ using ::cudaMalloc;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// If OptiX is not available, make reasonable proxies just so that we
|
||||
// don't have to litter the code with quite as many #ifdef's.
|
||||
// OSL::optix::
|
||||
// Mostly under OSL::optix::
|
||||
|
||||
|
||||
|
||||
namespace optix {
|
||||
|
||||
typedef void* Context;
|
||||
typedef void* Program;
|
||||
typedef void* TextureSampler;
|
||||
typedef void* CUdeviceptr;
|
||||
using float3 = OSL::Vec3;
|
||||
|
||||
|
||||
struct Exception {
|
||||
static const char* what() { return "OSL compiled without Optix."; }
|
||||
};
|
||||
|
||||
+217
-57
@@ -51,7 +51,8 @@ enum SymType {
|
||||
SymTypeGlobal,
|
||||
SymTypeConst,
|
||||
SymTypeFunction,
|
||||
SymTypeType
|
||||
SymTypeType,
|
||||
SymTypeLast
|
||||
};
|
||||
|
||||
|
||||
@@ -502,7 +503,7 @@ public:
|
||||
{
|
||||
}
|
||||
Symbol() : m_free_data(false) {}
|
||||
~Symbol()
|
||||
virtual ~Symbol()
|
||||
{
|
||||
if (m_free_data) {
|
||||
OSL_ASSERT(arena() == SymArena::Absolute);
|
||||
@@ -557,7 +558,7 @@ public:
|
||||
///
|
||||
void scope(int s) { m_scope = s; }
|
||||
|
||||
/// Return teh AST node containing the declaration of this symbol.
|
||||
/// Return the AST node containing the declaration of this symbol.
|
||||
/// Use with care!
|
||||
ASTNode* node() const { return m_node; }
|
||||
|
||||
@@ -632,55 +633,133 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void dataoffset(int d) { m_dataoffset = d; }
|
||||
int dataoffset() const { return m_dataoffset; }
|
||||
void dataoffset(int d)
|
||||
{
|
||||
m_dataoffset = d;
|
||||
}
|
||||
int dataoffset() const
|
||||
{
|
||||
return m_dataoffset;
|
||||
}
|
||||
|
||||
void wide_dataoffset(int d) { m_wide_dataoffset = d; }
|
||||
int wide_dataoffset() const { return m_wide_dataoffset; }
|
||||
void wide_dataoffset(int d)
|
||||
{
|
||||
m_wide_dataoffset = d;
|
||||
}
|
||||
int wide_dataoffset() const
|
||||
{
|
||||
return m_wide_dataoffset;
|
||||
}
|
||||
|
||||
SymArena arena() const { return static_cast<SymArena>(m_arena); }
|
||||
SymArena arena() const
|
||||
{
|
||||
return static_cast<SymArena>(m_arena);
|
||||
}
|
||||
|
||||
void initializers(int d) { m_initializers = d; }
|
||||
int initializers() const { return m_initializers; }
|
||||
void initializers(int d)
|
||||
{
|
||||
m_initializers = d;
|
||||
}
|
||||
int initializers() const
|
||||
{
|
||||
return m_initializers;
|
||||
}
|
||||
|
||||
bool has_derivs() const { return m_has_derivs; }
|
||||
void has_derivs(bool new_derivs) { m_has_derivs = new_derivs; }
|
||||
int size() const { return m_size; }
|
||||
void size(size_t newsize) { m_size = (int)newsize; }
|
||||
bool has_derivs() const
|
||||
{
|
||||
return m_has_derivs;
|
||||
}
|
||||
void has_derivs(bool new_derivs)
|
||||
{
|
||||
m_has_derivs = new_derivs;
|
||||
}
|
||||
int size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
void size(size_t newsize)
|
||||
{
|
||||
m_size = (int)newsize;
|
||||
}
|
||||
|
||||
/// Return the size for each point, including derivs.
|
||||
///
|
||||
int derivsize() const { return m_has_derivs ? 3 * m_size : m_size; }
|
||||
int derivsize() const
|
||||
{
|
||||
return m_has_derivs ? 3 * m_size : m_size;
|
||||
}
|
||||
|
||||
bool connected() const { return valuesource() == ConnectedVal; }
|
||||
bool connected_down() const { return m_connected_down; }
|
||||
void connected_down(bool c) { m_connected_down = c; }
|
||||
bool connected() const
|
||||
{
|
||||
return valuesource() == ConnectedVal;
|
||||
}
|
||||
bool connected_down() const
|
||||
{
|
||||
return m_connected_down;
|
||||
}
|
||||
void connected_down(bool c)
|
||||
{
|
||||
m_connected_down = c;
|
||||
}
|
||||
|
||||
/// Where did the symbol's value come from?
|
||||
///
|
||||
enum ValueSource { DefaultVal, InstanceVal, GeomVal, ConnectedVal };
|
||||
|
||||
ValueSource valuesource() const { return (ValueSource)m_valuesource; }
|
||||
void valuesource(ValueSource v) { m_valuesource = v; }
|
||||
ValueSource valuesource() const
|
||||
{
|
||||
return (ValueSource)m_valuesource;
|
||||
}
|
||||
void valuesource(ValueSource v)
|
||||
{
|
||||
m_valuesource = v;
|
||||
}
|
||||
const char* valuesourcename() const;
|
||||
static const char* valuesourcename(ValueSource v);
|
||||
|
||||
int fieldid() const { return m_fieldid; }
|
||||
void fieldid(int id) { m_fieldid = id; }
|
||||
int fieldid() const
|
||||
{
|
||||
return m_fieldid;
|
||||
}
|
||||
void fieldid(int id)
|
||||
{
|
||||
m_fieldid = id;
|
||||
}
|
||||
|
||||
int layer() const { return m_layer; }
|
||||
void layer(int id) { m_layer = id; }
|
||||
int layer() const
|
||||
{
|
||||
return m_layer;
|
||||
}
|
||||
void layer(int id)
|
||||
{
|
||||
m_layer = id;
|
||||
}
|
||||
|
||||
int initbegin() const { return m_initbegin; }
|
||||
void initbegin(int i) { m_initbegin = i; }
|
||||
int initend() const { return m_initend; }
|
||||
void initend(int i) { m_initend = i; }
|
||||
int initbegin() const
|
||||
{
|
||||
return m_initbegin;
|
||||
}
|
||||
void initbegin(int i)
|
||||
{
|
||||
m_initbegin = i;
|
||||
}
|
||||
int initend() const
|
||||
{
|
||||
return m_initend;
|
||||
}
|
||||
void initend(int i)
|
||||
{
|
||||
m_initend = i;
|
||||
}
|
||||
void set_initrange(int b = 0, int e = 0)
|
||||
{
|
||||
m_initbegin = b;
|
||||
m_initend = e;
|
||||
}
|
||||
bool has_init_ops() const { return m_initbegin != m_initend; }
|
||||
bool has_init_ops() const
|
||||
{
|
||||
return m_initbegin != m_initend;
|
||||
}
|
||||
|
||||
/// Clear read/write usage info.
|
||||
///
|
||||
@@ -724,15 +803,42 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int firstread() const { return m_firstread; }
|
||||
int lastread() const { return m_lastread; }
|
||||
int firstwrite() const { return m_firstwrite; }
|
||||
int lastwrite() const { return m_lastwrite; }
|
||||
int firstuse() const { return std::min(firstread(), firstwrite()); }
|
||||
int lastuse() const { return std::max(lastread(), lastwrite()); }
|
||||
bool everread() const { return lastread() >= 0; }
|
||||
bool everwritten() const { return lastwrite() >= 0; }
|
||||
bool everused() const { return everread() || everwritten(); }
|
||||
int firstread() const
|
||||
{
|
||||
return m_firstread;
|
||||
}
|
||||
int lastread() const
|
||||
{
|
||||
return m_lastread;
|
||||
}
|
||||
int firstwrite() const
|
||||
{
|
||||
return m_firstwrite;
|
||||
}
|
||||
int lastwrite() const
|
||||
{
|
||||
return m_lastwrite;
|
||||
}
|
||||
int firstuse() const
|
||||
{
|
||||
return std::min(firstread(), firstwrite());
|
||||
}
|
||||
int lastuse() const
|
||||
{
|
||||
return std::max(lastread(), lastwrite());
|
||||
}
|
||||
bool everread() const
|
||||
{
|
||||
return lastread() >= 0;
|
||||
}
|
||||
bool everwritten() const
|
||||
{
|
||||
return lastwrite() >= 0;
|
||||
}
|
||||
bool everused() const
|
||||
{
|
||||
return everread() || everwritten();
|
||||
}
|
||||
// everused_in_group is an even more stringent test -- not only must
|
||||
// the symbol not be used within the shader but it also must not be
|
||||
// used elsewhere in the group, by being connected to something downstream
|
||||
@@ -753,31 +859,67 @@ public:
|
||||
m_lastwrite = last;
|
||||
}
|
||||
|
||||
bool initialized() const { return m_initialized; }
|
||||
void initialized(bool init) { m_initialized = init; }
|
||||
bool initialized() const
|
||||
{
|
||||
return m_initialized;
|
||||
}
|
||||
void initialized(bool init)
|
||||
{
|
||||
m_initialized = init;
|
||||
}
|
||||
|
||||
bool lockgeom() const { return m_lockgeom; }
|
||||
void lockgeom(bool lock) { m_lockgeom = lock; }
|
||||
bool lockgeom() const
|
||||
{
|
||||
return m_lockgeom;
|
||||
}
|
||||
void lockgeom(bool lock)
|
||||
{
|
||||
m_lockgeom = lock;
|
||||
}
|
||||
|
||||
bool allowconnect() const { return m_allowconnect; }
|
||||
void allowconnect(bool val) { m_allowconnect = val; }
|
||||
bool allowconnect() const
|
||||
{
|
||||
return m_allowconnect;
|
||||
}
|
||||
void allowconnect(bool val)
|
||||
{
|
||||
m_allowconnect = val;
|
||||
}
|
||||
|
||||
int arraylen() const { return m_typespec.arraylength(); }
|
||||
int arraylen() const
|
||||
{
|
||||
return m_typespec.arraylength();
|
||||
}
|
||||
void arraylen(int len)
|
||||
{
|
||||
m_typespec.make_array(len);
|
||||
m_size = m_typespec.simpletype().size();
|
||||
}
|
||||
|
||||
bool renderer_output() const { return m_renderer_output; }
|
||||
void renderer_output(bool v) { m_renderer_output = v; }
|
||||
bool renderer_output() const
|
||||
{
|
||||
return m_renderer_output;
|
||||
}
|
||||
void renderer_output(bool v)
|
||||
{
|
||||
m_renderer_output = v;
|
||||
}
|
||||
|
||||
// When not uniform a symbol will have a varying value under batched
|
||||
// execution and must use a Wide data type to hold different values
|
||||
// for each data lane executing
|
||||
bool is_uniform() const { return m_is_uniform; }
|
||||
bool is_varying() const { return (m_is_uniform == 0); }
|
||||
void make_varying() { m_is_uniform = false; }
|
||||
bool is_uniform() const
|
||||
{
|
||||
return m_is_uniform;
|
||||
}
|
||||
bool is_varying() const
|
||||
{
|
||||
return (m_is_uniform == 0);
|
||||
}
|
||||
void make_varying()
|
||||
{
|
||||
m_is_uniform = false;
|
||||
}
|
||||
|
||||
// Results of a compare_op and other ops with logically boolean
|
||||
// results under certain conditions could be forced to be represented
|
||||
@@ -791,14 +933,32 @@ public:
|
||||
// The value of forced_llvm_bool() is currently only respected during
|
||||
// batched execution. Forced bools should not be coalesced with regular
|
||||
// ints, only other forced bools.
|
||||
bool forced_llvm_bool() const { return m_forced_llvm_bool; }
|
||||
void forced_llvm_bool(bool v) { m_forced_llvm_bool = v; }
|
||||
bool forced_llvm_bool() const
|
||||
{
|
||||
return m_forced_llvm_bool;
|
||||
}
|
||||
void forced_llvm_bool(bool v)
|
||||
{
|
||||
m_forced_llvm_bool = v;
|
||||
}
|
||||
|
||||
bool readonly() const { return m_readonly; }
|
||||
void readonly(bool v) { m_readonly = v; }
|
||||
bool readonly() const
|
||||
{
|
||||
return m_readonly;
|
||||
}
|
||||
void readonly(bool v)
|
||||
{
|
||||
m_readonly = v;
|
||||
}
|
||||
|
||||
bool is_constant() const { return symtype() == SymTypeConst; }
|
||||
bool is_temp() const { return symtype() == SymTypeTemp; }
|
||||
bool is_constant() const
|
||||
{
|
||||
return symtype() == SymTypeConst;
|
||||
}
|
||||
bool is_temp() const
|
||||
{
|
||||
return symtype() == SymTypeTemp;
|
||||
}
|
||||
|
||||
// Retrieve the const float value (must be a const float!)
|
||||
float get_float(int index = 0) const
|
||||
@@ -854,7 +1014,7 @@ public:
|
||||
|
||||
// Stream output. Note that print/print_vals assume that any string
|
||||
// values are "raw" and they will be converted to C source code "escaped
|
||||
// string" notation for printing. For example, a newline characer will
|
||||
// string" notation for printing. For example, a newline character will
|
||||
// be rendered into the stream as the two character sequence '\n'.
|
||||
std::ostream& print(std::ostream& out, int maxvals = 100000000) const;
|
||||
std::ostream& print_vals(std::ostream& out, int maxvals = 100000000) const;
|
||||
|
||||
@@ -26,13 +26,13 @@ target_link_libraries (${local_lib}
|
||||
PUBLIC
|
||||
OpenImageIO::OpenImageIO
|
||||
# For OpenEXR/Imath 3.x:
|
||||
$<$<TARGET_EXISTS:Imath::Imath>:Imath::Imath>
|
||||
$<$<TARGET_EXISTS:Imath::Half>:Imath::Half>
|
||||
$<TARGET_NAME_IF_EXISTS:Imath::Imath>
|
||||
$<TARGET_NAME_IF_EXISTS:Imath::Half>
|
||||
# For OpenEXR >= 2.4/2.5 with reliable exported targets
|
||||
$<$<TARGET_EXISTS:IlmBase::Imath>:IlmBase::Imath>
|
||||
$<$<TARGET_EXISTS:IlmBase::Half>:IlmBase::Half>
|
||||
$<$<TARGET_EXISTS:IlmBase::IlmThread>:IlmBase::IlmThread>
|
||||
$<$<TARGET_EXISTS:IlmBase::Iex>:IlmBase::Iex>
|
||||
$<TARGET_NAME_IF_EXISTS:IlmBase::Imath>
|
||||
$<TARGET_NAME_IF_EXISTS:IlmBase::Half>
|
||||
$<TARGET_NAME_IF_EXISTS:IlmBase::IlmThread>
|
||||
$<TARGET_NAME_IF_EXISTS:IlmBase::Iex>
|
||||
# For OpenEXR <= 2.3:
|
||||
${ILMBASE_LIBRARIES}
|
||||
PRIVATE
|
||||
@@ -45,22 +45,23 @@ if (MSVC)
|
||||
target_link_libraries (${local_lib} PRIVATE "Version.lib")
|
||||
endif()
|
||||
|
||||
set (link_flags "${VISIBILITY_MAP_COMMAND} ${EXTRA_DSO_LINK_ARGS}")
|
||||
if (UNIX AND NOT APPLE)
|
||||
# Hide symbols from any static dependent libraries embedded here.
|
||||
set (link_flags "${link_flags} -Wl,--exclude-libs,ALL")
|
||||
endif ()
|
||||
|
||||
target_compile_features (${local_lib}
|
||||
PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
|
||||
INTERFACE cxx_std_${DOWNSTREAM_CXX_STANDARD})
|
||||
|
||||
set_target_properties (${local_lib}
|
||||
PROPERTIES
|
||||
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION}
|
||||
OUTPUT_NAME ${local_lib}${OSL_LIBNAME_SUFFIX}
|
||||
LINK_FLAGS ${link_flags}
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
|
||||
if (VISIBILITY_MAP_COMMAND)
|
||||
set_property (TARGET ${local_lib}
|
||||
APPEND PROPERTY LINK_FLAGS ${VISIBILITY_MAP_COMMAND})
|
||||
endif ()
|
||||
|
||||
install_targets (${local_lib})
|
||||
|
||||
|
||||
+104
-91
@@ -35,7 +35,7 @@ std::atomic<int> node_counts_peak[ASTNode::_last_node];
|
||||
class ScopeExit {
|
||||
public:
|
||||
typedef std::function<void()> Task;
|
||||
explicit ScopeExit(Task&& task) : m_task(std::forward<Task>(task)) {}
|
||||
explicit ScopeExit(Task&& task) : m_task(std::move(task)) {}
|
||||
~ScopeExit() { m_task(); }
|
||||
|
||||
private:
|
||||
@@ -45,8 +45,8 @@ private:
|
||||
ScopeExit print_node_counts([]() {
|
||||
for (int i = 0; i < ASTNode::_last_node; ++i)
|
||||
if (node_counts[i] > 0)
|
||||
Strutil::printf("ASTNode type %2d: %5d (peak %5d)\n", i,
|
||||
node_counts[i], node_counts_peak[i]);
|
||||
Strutil::print("ASTNode type {:2}: {:5} (peak {:5})\n", i,
|
||||
node_counts[i], node_counts_peak[i]);
|
||||
});
|
||||
} // namespace
|
||||
#endif
|
||||
@@ -213,7 +213,7 @@ ASTNode::~ASTNode()
|
||||
void
|
||||
ASTNode::error_impl(string_view msg) const
|
||||
{
|
||||
m_compiler->errorf(sourcefile(), sourceline(), "%s", msg);
|
||||
m_compiler->errorfmt(sourcefile(), sourceline(), "{}", msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ ASTNode::error_impl(string_view msg) const
|
||||
void
|
||||
ASTNode::warning_impl(string_view msg) const
|
||||
{
|
||||
m_compiler->warningf(sourcefile(), sourceline(), "%s", msg);
|
||||
m_compiler->warningfmt(sourcefile(), sourceline(), "{}", msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ ASTNode::warning_impl(string_view msg) const
|
||||
void
|
||||
ASTNode::info_impl(string_view msg) const
|
||||
{
|
||||
m_compiler->infof(sourcefile(), sourceline(), "%s", msg);
|
||||
m_compiler->infofmt(sourcefile(), sourceline(), "{}", msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ ASTNode::info_impl(string_view msg) const
|
||||
void
|
||||
ASTNode::message_impl(string_view msg) const
|
||||
{
|
||||
m_compiler->messagef(sourcefile(), sourceline(), "%s", msg);
|
||||
m_compiler->messagefmt(sourcefile(), sourceline(), "{}", msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -246,12 +246,11 @@ void
|
||||
ASTNode::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
indent(out, indentlevel);
|
||||
out << "(" << nodetypename() << " : "
|
||||
<< " (type: " << typespec().string() << ") "
|
||||
<< (opname() ? opname() : "") << "\n";
|
||||
OSL::print(out, "({} : (type: {}) {}\n", nodetypename(), typespec(),
|
||||
(opname() ? opname() : ""));
|
||||
printchildren(out, indentlevel);
|
||||
indent(out, indentlevel);
|
||||
out << ")\n";
|
||||
OSL::print(out, ")\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -264,13 +263,13 @@ ASTNode::printchildren(std::ostream& out, int indentlevel) const
|
||||
continue;
|
||||
indent(out, indentlevel);
|
||||
if (childname(i))
|
||||
out << " " << childname(i);
|
||||
OSL::print(out, " {}", childname(i));
|
||||
else
|
||||
out << " child" << i;
|
||||
out << ": ";
|
||||
OSL::print(out, " child{}", i);
|
||||
OSL::print(out, ": ");
|
||||
if (typespec() != TypeSpec() && !child(i)->next())
|
||||
out << " (type: " << typespec().string() << ")";
|
||||
out << "\n";
|
||||
OSL::print(out, " (type: {})", typespec());
|
||||
OSL::print(out, "\n");
|
||||
printlist(out, child(i), indentlevel + 1);
|
||||
}
|
||||
}
|
||||
@@ -314,11 +313,8 @@ std::string
|
||||
ASTNode::list_to_types_string(const ASTNode* node)
|
||||
{
|
||||
std::ostringstream result;
|
||||
for (int i = 0; node; node = node->nextptr(), ++i) {
|
||||
if (i)
|
||||
result << ", ";
|
||||
result << node->typespec();
|
||||
}
|
||||
for (int i = 0; node; node = node->nextptr(), ++i)
|
||||
OSL::print(result, "{}{}", i ? ", " : "", node->typespec());
|
||||
return result.str();
|
||||
}
|
||||
|
||||
@@ -335,11 +331,11 @@ ASTshader_declaration::ASTshader_declaration(OSLCompilerImpl* comp, int stype,
|
||||
OSL_ASSERT(arg->nodetype() == variable_declaration_node);
|
||||
ASTvariable_declaration* v = (ASTvariable_declaration*)arg;
|
||||
if (!v->init())
|
||||
v->errorf("shader parameter '%s' requires a default initializer",
|
||||
v->name());
|
||||
v->errorfmt("shader parameter '{}' requires a default initializer",
|
||||
v->name());
|
||||
if (v->is_output() && v->typespec().is_unsized_array())
|
||||
v->errorf("shader output parameter '%s' can't be unsized array",
|
||||
v->name());
|
||||
v->errorfmt("shader output parameter '{}' can't be unsized array",
|
||||
v->name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,11 +354,11 @@ void
|
||||
ASTshader_declaration::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
indent(out, indentlevel);
|
||||
out << "(" << nodetypename() << " " << shadertypename() << " \""
|
||||
<< m_shadername << "\"\n";
|
||||
OSL::print(out, "({} {} \"{}\"\n", nodetypename(), shadertypename(),
|
||||
m_shadername);
|
||||
printchildren(out, indentlevel);
|
||||
indent(out, indentlevel);
|
||||
out << ")\n";
|
||||
OSL::print(out, ")\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -392,13 +388,13 @@ ASTfunction_declaration::ASTfunction_declaration(OSLCompilerImpl* comp,
|
||||
m_sourceline = sourceline_start;
|
||||
|
||||
if (Strutil::starts_with(name, "___"))
|
||||
errorf("\"%s\" : sorry, can't start with three underscores", name);
|
||||
errorfmt("\"{}\" : sorry, can't start with three underscores", name);
|
||||
|
||||
// Get a pointer to the first of the existing symbols of that name.
|
||||
Symbol* existing_syms = comp->symtab().clash(name);
|
||||
if (existing_syms && existing_syms->symtype() != SymTypeFunction) {
|
||||
errorf("\"%s\" already declared in this scope as a %s", name,
|
||||
existing_syms->typespec());
|
||||
errorfmt("\"{}\" already declared in this scope as a {}", name,
|
||||
existing_syms->typespec());
|
||||
// FIXME -- print the file and line of the other definition
|
||||
existing_syms = NULL;
|
||||
}
|
||||
@@ -416,8 +412,8 @@ ASTfunction_declaration::ASTfunction_declaration(OSLCompilerImpl* comp,
|
||||
OSL_ASSERT(arg->nodetype() == variable_declaration_node);
|
||||
ASTvariable_declaration* v = (ASTvariable_declaration*)arg;
|
||||
if (v->init())
|
||||
v->errorf(
|
||||
"function parameter '%s' may not have a default initializer.",
|
||||
v->errorfmt(
|
||||
"function parameter '{}' may not have a default initializer.",
|
||||
v->name());
|
||||
}
|
||||
|
||||
@@ -435,16 +431,15 @@ ASTfunction_declaration::ASTfunction_declaration(OSLCompilerImpl* comp,
|
||||
auto other = static_cast<ASTfunction_declaration*>(f->node());
|
||||
if (!other || (other->statements() || other->is_builtin())) {
|
||||
if (err.empty()) {
|
||||
err = Strutil::sprintf("Function '%s %s (%s)' redefined "
|
||||
"in the same scope\n"
|
||||
" Previous definitions:",
|
||||
type, name,
|
||||
list_to_types_string(form));
|
||||
err = Strutil::fmt::format(
|
||||
"Function '{} {} ({})' redefined in the same scope\n"
|
||||
" Previous definitions:",
|
||||
type, name, list_to_types_string(form));
|
||||
}
|
||||
err += "\n ";
|
||||
if (other) {
|
||||
err += Strutil::sprintf(
|
||||
"%s:%d",
|
||||
err += Strutil::fmt::format(
|
||||
"{}:{}",
|
||||
OIIO::Filesystem::filename(
|
||||
other->sourcefile().string()),
|
||||
other->sourceline());
|
||||
@@ -454,7 +449,7 @@ ASTfunction_declaration::ASTfunction_declaration(OSLCompilerImpl* comp,
|
||||
}
|
||||
}
|
||||
if (!err.empty())
|
||||
warningf("%s", err);
|
||||
warningfmt("{}", err);
|
||||
}
|
||||
|
||||
|
||||
@@ -519,10 +514,10 @@ void
|
||||
ASTfunction_declaration::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
indent(out, indentlevel);
|
||||
out << nodetypename() << " " << m_sym->mangled();
|
||||
OSL::print(out, "{} {}", nodetypename(), m_sym->mangled());
|
||||
if (m_sym->scope())
|
||||
out << " (" << m_sym->name() << " in scope " << m_sym->scope() << ")";
|
||||
out << "\n";
|
||||
OSL::print(out, " ({} in scope {})", m_sym->name(), m_sym->scope());
|
||||
OSL::print(out, "\n");
|
||||
printchildren(out, indentlevel);
|
||||
}
|
||||
|
||||
@@ -557,23 +552,24 @@ ASTvariable_declaration::ASTvariable_declaration(OSLCompilerImpl* comp,
|
||||
m_typespec = type;
|
||||
Symbol* f = comp->symtab().clash(name);
|
||||
if (f && !m_ismetadata) {
|
||||
std::string e = Strutil::sprintf("\"%s\" already declared in this scope",
|
||||
name.c_str());
|
||||
std::string e
|
||||
= Strutil::fmt::format("\"{}\" already declared in this scope",
|
||||
name);
|
||||
if (f->node()) {
|
||||
std::string filename = OIIO::Filesystem::filename(
|
||||
f->node()->sourcefile().string());
|
||||
e += Strutil::sprintf("\n\t\tprevious declaration was at %s:%d",
|
||||
filename, f->node()->sourceline());
|
||||
e += Strutil::fmt::format("\n\t\tprevious declaration was at {}:{}",
|
||||
filename, f->node()->sourceline());
|
||||
}
|
||||
if (f->scope() == 0 && f->symtype() == SymTypeFunction && isparam) {
|
||||
// special case: only a warning for param to mask global function
|
||||
warningf("%s", e);
|
||||
warningfmt("{}", e);
|
||||
} else {
|
||||
errorf("%s", e);
|
||||
errorfmt("{}", e);
|
||||
}
|
||||
}
|
||||
if (OIIO::Strutil::starts_with(name, "___")) {
|
||||
errorf("\"%s\" : sorry, can't start with three underscores", name);
|
||||
errorfmt("\"{}\" : sorry, can't start with three underscores", name);
|
||||
}
|
||||
SymType symtype = isparam ? (isoutput ? SymTypeOutputParam : SymTypeParam)
|
||||
: SymTypeLocal;
|
||||
@@ -582,8 +578,14 @@ ASTvariable_declaration::ASTvariable_declaration(OSLCompilerImpl* comp,
|
||||
if (symtype == SymTypeLocal && Strutil::starts_with(name, "__debug_tmp__"))
|
||||
symtype = SymTypeTemp;
|
||||
m_sym = new Symbol(name, type, symtype, this);
|
||||
if (!m_ismetadata)
|
||||
if (m_ismetadata) {
|
||||
// Metadata doesn't go in the symbol table, so we need to retain
|
||||
// an owning pointer so it doesn't leak.
|
||||
m_sym_owned.reset(m_sym);
|
||||
} else {
|
||||
// Put in the symbol table, after which symtab is the owner
|
||||
m_compiler->symtab().insert(m_sym);
|
||||
}
|
||||
|
||||
// A struct really makes several subvariables
|
||||
if (type.is_structure() || type.is_structure_array()) {
|
||||
@@ -620,17 +622,15 @@ void
|
||||
ASTvariable_declaration::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
indent(out, indentlevel);
|
||||
out << "(" << nodetypename() << " " << m_sym->typespec().string() << " "
|
||||
<< m_sym->mangled();
|
||||
OSL::print(out, "({} {}", nodetypename(), m_sym->mangled());
|
||||
#if 0
|
||||
if (m_sym->scope())
|
||||
out << " (" << m_sym->name()
|
||||
<< " in scope " << m_sym->scope() << ")";
|
||||
OSL::print(out, " ({} in scope {})", m_sym->name(), m_sym->scope());
|
||||
#endif
|
||||
out << "\n";
|
||||
OSL::print(out, "\n");
|
||||
printchildren(out, indentlevel);
|
||||
indent(out, indentlevel);
|
||||
out << ")\n";
|
||||
OSL::print(out, ")\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -640,13 +640,17 @@ ASTvariable_ref::ASTvariable_ref(OSLCompilerImpl* comp, ustring name)
|
||||
{
|
||||
m_sym = comp->symtab().find(name);
|
||||
if (!m_sym) {
|
||||
errorf("'%s' was not declared in this scope", name);
|
||||
errorfmt("'{}' was not declared in this scope", name);
|
||||
// FIXME -- would be fun to troll through the symtab and try to
|
||||
// find the things that almost matched and offer suggestions.
|
||||
return;
|
||||
}
|
||||
if (m_sym->symtype() == SymTypeFunction) {
|
||||
errorf("function '%s' can't be used as a variable", name);
|
||||
errorfmt("function '{}' can't be used as a variable", name);
|
||||
return;
|
||||
}
|
||||
if (m_sym->symtype() == SymTypeType) {
|
||||
errorfmt("type name '{}' can't be used as a variable", name);
|
||||
return;
|
||||
}
|
||||
m_typespec = m_sym->typespec();
|
||||
@@ -658,9 +662,9 @@ void
|
||||
ASTvariable_ref::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
indent(out, indentlevel);
|
||||
out << "(" << nodetypename()
|
||||
<< " (type: " << (m_sym ? m_sym->typespec().string() : "unknown")
|
||||
<< ") " << (m_sym ? m_sym->mangled() : m_name.string()) << ")\n";
|
||||
OSL::print(out, "({} (type: {}) {})\n", nodetypename(),
|
||||
m_sym ? m_sym->typespec().string() : "unknown",
|
||||
m_sym ? m_sym->mangled() : m_name.string());
|
||||
OSL_DASSERT(nchildren() == 0);
|
||||
}
|
||||
|
||||
@@ -758,7 +762,7 @@ ASTindex::ASTindex(OSLCompilerImpl* comp, ASTNode* expr, ASTNode* index,
|
||||
}
|
||||
|
||||
if (m_typespec.is_unknown()) {
|
||||
errorf("indexing into non-array or non-component type");
|
||||
errorfmt("indexing into non-array or non-component type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,7 +827,7 @@ ASTstructselect::find_fieldsym(int& structid, int& fieldid)
|
||||
}
|
||||
|
||||
if (!lvtype.is_structure() && !lvtype.is_structure_array()) {
|
||||
errorf("type '%s' does not have a member '%s'", lvtype, m_field);
|
||||
errorfmt("type '{}' does not have a member '{}'", lvtype, m_field);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -842,14 +846,14 @@ ASTstructselect::find_fieldsym(int& structid, int& fieldid)
|
||||
}
|
||||
|
||||
if (fieldid < 0) {
|
||||
errorf("struct type '%s' does not have a member '%s'",
|
||||
structspec->name(), m_field);
|
||||
errorfmt("struct type '{}' does not have a member '{}'",
|
||||
structspec->name(), m_field);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const StructSpec::FieldSpec& fieldrec(structspec->field(fieldid));
|
||||
ustring fieldsymname = ustring::sprintf("%s.%s", structsymname,
|
||||
fieldrec.name);
|
||||
ustring fieldsymname = ustring::fmtformat("{}.{}", structsymname,
|
||||
fieldrec.name);
|
||||
Symbol* sym = m_compiler->symtab().find(fieldsymname);
|
||||
return sym;
|
||||
}
|
||||
@@ -910,7 +914,7 @@ ASTstructselect::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
ASTNode::print(out, indentlevel);
|
||||
indent(out, indentlevel + 1);
|
||||
out << "select " << field() << "\n";
|
||||
OSL::print(out, "select {}\n", field());
|
||||
}
|
||||
|
||||
|
||||
@@ -960,7 +964,8 @@ ASTloop_statement::opname() const
|
||||
|
||||
|
||||
|
||||
const char* ASTloopmod_statement::childname(size_t /*i*/) const
|
||||
const char*
|
||||
ASTloopmod_statement::childname(size_t /*i*/) const
|
||||
{
|
||||
return NULL; // no children
|
||||
}
|
||||
@@ -979,7 +984,8 @@ ASTloopmod_statement::opname() const
|
||||
|
||||
|
||||
|
||||
const char* ASTreturn_statement::childname(size_t /*i*/) const
|
||||
const char*
|
||||
ASTreturn_statement::childname(size_t /*i*/) const
|
||||
{
|
||||
return "expression"; // only child
|
||||
}
|
||||
@@ -995,7 +1001,8 @@ ASTcompound_initializer::ASTcompound_initializer(OSLCompilerImpl* comp,
|
||||
|
||||
|
||||
|
||||
const char* ASTcompound_initializer::childname(size_t /*i*/) const
|
||||
const char*
|
||||
ASTcompound_initializer::childname(size_t /*i*/) const
|
||||
{
|
||||
return canconstruct() ? "args" : "expression_list";
|
||||
}
|
||||
@@ -1003,8 +1010,10 @@ const char* ASTcompound_initializer::childname(size_t /*i*/) const
|
||||
|
||||
|
||||
bool
|
||||
ASTNode::check_symbol_writeability(ASTNode* var)
|
||||
ASTNode::check_symbol_writeability(ASTNode* var, bool quiet, Symbol** dest_sym)
|
||||
{
|
||||
if (dest_sym)
|
||||
*dest_sym = nullptr;
|
||||
if (var->nodetype() == index_node)
|
||||
return check_symbol_writeability(
|
||||
static_cast<ASTindex*>(var)->lvalue().get());
|
||||
@@ -1019,9 +1028,12 @@ ASTNode::check_symbol_writeability(ASTNode* var)
|
||||
dest = static_cast<ASTvariable_declaration*>(var)->sym();
|
||||
|
||||
if (dest) {
|
||||
if (dest_sym)
|
||||
*dest_sym = dest;
|
||||
if (dest->readonly()) {
|
||||
warningf("cannot write to non-output parameter \"%s\"",
|
||||
dest->name());
|
||||
if (!quiet)
|
||||
warningfmt("cannot write to non-output parameter \"{}\"",
|
||||
dest->name());
|
||||
// Note: Consider it only a warning to write to a non-output
|
||||
// parameter. Users who want it to be a hard error can use
|
||||
// -Werror. Writing to any other readonly symbols is a full
|
||||
@@ -1029,8 +1041,8 @@ ASTNode::check_symbol_writeability(ASTNode* var)
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// std::cout << "Don't know how to check_symbol_writeability "
|
||||
// << var->nodetypename() << "\n";
|
||||
// OSL::print("Don't know how to check_symbol_writeability {}\n",
|
||||
// var->nodetypename());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1113,7 +1125,7 @@ ASTunary_expression::ASTunary_expression (OSLCompilerImpl *comp, int op,
|
||||
: ASTNode (unary_expression_node, comp, op, expr)
|
||||
{
|
||||
// Check for a user-overloaded function for this operator
|
||||
Symbol *sym = comp->symtab().find (ustring::sprintf ("__operator__%s__", opword()));
|
||||
Symbol *sym = comp->symtab().find(ustring::fmtformat("__operator__{}__", opword()));
|
||||
if (sym && sym->symtype() == SymTypeFunction)
|
||||
m_function_overload = (FunctionSymbol *)sym;
|
||||
}
|
||||
@@ -1168,7 +1180,7 @@ ASTbinary_expression::ASTbinary_expression (OSLCompilerImpl *comp, Operator op,
|
||||
// Check for a user-overloaded function for this operator.
|
||||
// Disallow a few ops from overloading.
|
||||
if (op != And && op != Or) {
|
||||
ustring funcname = ustring::sprintf ("__operator__%s__", opword());
|
||||
ustring funcname = ustring::fmtformat("__operator__{}__", opword());
|
||||
Symbol *sym = comp->symtab().find (funcname);
|
||||
if (sym && sym->symtype() == SymTypeFunction)
|
||||
m_function_overload = (FunctionSymbol *)sym;
|
||||
@@ -1289,7 +1301,7 @@ ASTfunction_call::ASTfunction_call(OSLCompilerImpl* comp, ustring name,
|
||||
, m_argtakesderivs(0) // Default - doesn't take derivs
|
||||
{
|
||||
if (!m_sym) {
|
||||
errorf("function '%s' was not declared in this scope", name);
|
||||
errorfmt("function '{}' was not declared in this scope", name);
|
||||
// FIXME -- would be fun to troll through the symtab and try to
|
||||
// find the things that almost matched and offer suggestions.
|
||||
return;
|
||||
@@ -1298,7 +1310,7 @@ ASTfunction_call::ASTfunction_call(OSLCompilerImpl* comp, ustring name,
|
||||
return; // It's a struct constructor
|
||||
}
|
||||
if (m_sym->symtype() != SymTypeFunction) {
|
||||
errorf("'%s' is not a function", name);
|
||||
errorfmt("'{}' is not a function", name);
|
||||
m_sym = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -1309,7 +1321,7 @@ ASTfunction_call::ASTfunction_call(OSLCompilerImpl* comp, ustring name,
|
||||
const char*
|
||||
ASTfunction_call::childname(size_t i) const
|
||||
{
|
||||
return ustring::sprintf("param%d", (int)i).c_str();
|
||||
return ustring::fmtformat("param{}", (int)i).c_str();
|
||||
}
|
||||
|
||||
|
||||
@@ -1328,16 +1340,17 @@ ASTfunction_call::print(std::ostream& out, int indentlevel) const
|
||||
ASTNode::print(out, indentlevel);
|
||||
#if 0
|
||||
if (is_user_function()) {
|
||||
out << "\n";
|
||||
OSL::print(out, "\n");
|
||||
user_function()->print (out, indentlevel+1);
|
||||
out << "\n";
|
||||
OSL::print(out, "\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char* ASTliteral::childname(size_t /*i*/) const
|
||||
const char*
|
||||
ASTliteral::childname(size_t /*i*/) const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -1348,14 +1361,14 @@ void
|
||||
ASTliteral::print(std::ostream& out, int indentlevel) const
|
||||
{
|
||||
indent(out, indentlevel);
|
||||
out << "(" << nodetypename() << " (type: " << m_typespec.string() << ") ";
|
||||
OSL::print(out, "({} (type: {}) ", nodetypename(), m_typespec);
|
||||
if (m_typespec.is_int())
|
||||
out << m_i;
|
||||
OSL::print(out, "{}", m_i);
|
||||
else if (m_typespec.is_float())
|
||||
out << m_f;
|
||||
OSL::print(out, "{}", m_f);
|
||||
else if (m_typespec.is_string())
|
||||
out << "\"" << m_s << "\"";
|
||||
out << ")\n";
|
||||
OSL::print(out, "\"{}\"", m_s);
|
||||
OSL::print(out, ")\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+20
-15
@@ -202,34 +202,34 @@ public:
|
||||
void sourceline(int line) { m_sourceline = line; }
|
||||
|
||||
template<typename... Args>
|
||||
void errorf(const char* format, const Args&... args) const
|
||||
void errorfmt(const char* format, const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
error_impl(OIIO::Strutil::sprintf(format, args...));
|
||||
error_impl(OIIO::Strutil::fmt::format(format, args...));
|
||||
}
|
||||
|
||||
/// Warning reporting
|
||||
template<typename... Args>
|
||||
void warningf(const char* format, const Args&... args) const
|
||||
void warningfmt(const char* format, const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
warning_impl(OIIO::Strutil::sprintf(format, args...));
|
||||
warning_impl(OIIO::Strutil::fmt::format(format, args...));
|
||||
}
|
||||
|
||||
/// info reporting
|
||||
template<typename... Args>
|
||||
void infof(const char* format, const Args&... args) const
|
||||
void infofmt(const char* format, const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
info_impl(OIIO::Strutil::sprintf(format, args...));
|
||||
info_impl(OIIO::Strutil::fmt::format(format, args...));
|
||||
}
|
||||
|
||||
/// message reporting
|
||||
template<typename... Args>
|
||||
void messagef(const char* format, const Args&... args) const
|
||||
void messagefmt(const char* format, const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
message_impl(OIIO::Strutil::sprintf(format, args...));
|
||||
message_impl(OIIO::Strutil::fmt::format(format, args...));
|
||||
}
|
||||
|
||||
bool is_lvalue() const { return m_is_lvalue; }
|
||||
@@ -375,7 +375,7 @@ protected:
|
||||
void codegen_initlist(ref init, TypeSpec type, Symbol* sym);
|
||||
|
||||
// Special code generation for structure initializers.
|
||||
// It's in the ASTNode base class because it's used from mutiple
|
||||
// It's in the ASTNode base class because it's used from multiple
|
||||
// subclasses.
|
||||
Symbol* codegen_struct_initializers(ref init, Symbol* sym,
|
||||
bool is_constructor = false,
|
||||
@@ -387,10 +387,14 @@ protected:
|
||||
Symbol* codegen_aassign(TypeSpec elemtype, Symbol* src, Symbol* lval,
|
||||
Symbol* index, int i = 0);
|
||||
|
||||
// Check whether the node's symbol destination is ok to write. Return
|
||||
// true if ok, return false and issue error or warning if not. (Used to
|
||||
// check for writing to read-only variables like non-output parameters.)
|
||||
bool check_symbol_writeability(ASTNode* var);
|
||||
// Check whether the node's symbol destination is ok to write. Return true
|
||||
// if ok, return false and issue error or warning if not. If `quiet` is
|
||||
// true, do not actually issue the error/warning, leave it to the caller.
|
||||
// If `dest_sym` is non-null, store in it the `Symbol*` of the destination
|
||||
// symbol designated. This method is used to check for writing to
|
||||
// read-only variables like non-output parameters.
|
||||
bool check_symbol_writeability(ASTNode* var, bool quiet = false,
|
||||
Symbol** dest_sym = nullptr);
|
||||
|
||||
// Helper for param_default_literals: generate the string that gives
|
||||
// the initialization of the literal value (and/or the default, if
|
||||
@@ -516,7 +520,7 @@ public:
|
||||
|
||||
private:
|
||||
ustring m_name; ///< Name of the symbol (unmangled)
|
||||
Symbol* m_sym; ///< Ptr to the symbol this declares
|
||||
Symbol* m_sym; ///< Ptr to the symbol this declares (non-owning)
|
||||
bool m_isparam; ///< Is this a parameter?
|
||||
bool m_isoutput; ///< Is this an output parameter?
|
||||
bool m_ismetadata; ///< Is this declaration a piece of metadata?
|
||||
@@ -525,6 +529,7 @@ private:
|
||||
// specific initializers.
|
||||
typedef std::pair<ustring, ASTNode*> NamedInit;
|
||||
std::vector<NamedInit> m_struct_field_inits;
|
||||
std::unique_ptr<Symbol> m_sym_owned; // if we own the symbol
|
||||
};
|
||||
|
||||
|
||||
@@ -945,7 +950,7 @@ private:
|
||||
/// return false and call an appropriate error().
|
||||
bool typecheck_printf_args(const char* format, ASTNode* arg);
|
||||
|
||||
/// Handle "funcion calls" that are really struct ctrs.
|
||||
/// Handle "function calls" that are really struct ctrs.
|
||||
TypeSpec typecheck_struct_constructor();
|
||||
|
||||
/// Is the argument number 'arg' read by the op?
|
||||
|
||||
+58
-59
@@ -101,7 +101,7 @@ OSLCompilerImpl::insert_code(int opnum, const char* opname, size_t nargs,
|
||||
Symbol*
|
||||
OSLCompilerImpl::make_temporary(const TypeSpec& type)
|
||||
{
|
||||
ustring name = ustring::sprintf("$tmp%d", ++m_next_temp);
|
||||
ustring name = ustring::fmtformat("$tmp{}", ++m_next_temp);
|
||||
Symbol* s = new Symbol(name, type, SymTypeTemp);
|
||||
symtab().insert(s);
|
||||
|
||||
@@ -131,14 +131,15 @@ OSLCompilerImpl::add_struct_fields(StructSpec* structspec, ustring basename,
|
||||
// arraylen is the length of the array of the surrounding data type
|
||||
for (int i = 0; i < (int)structspec->numfields(); ++i) {
|
||||
const StructSpec::FieldSpec& field(structspec->field(i));
|
||||
ustring fieldname = ustring::sprintf("%s.%s", basename, field.name);
|
||||
ustring fieldname = ustring::fmtformat("{}.{}", basename, field.name);
|
||||
TypeSpec type = field.type;
|
||||
int arr = type.arraylength();
|
||||
if (arr && arraylen) {
|
||||
errorf(node ? node->sourcefile() : ustring(),
|
||||
node ? node->sourceline() : 1,
|
||||
"Nested structs with >1 levels of arrays are not allowed: %s",
|
||||
structspec->name());
|
||||
errorfmt(
|
||||
node ? node->sourcefile() : ustring(),
|
||||
node ? node->sourceline() : 1,
|
||||
"Nested structs with >1 levels of arrays are not allowed: {}",
|
||||
structspec->name());
|
||||
}
|
||||
if (arraylen || arr) {
|
||||
// Translate an outer array into an inner array
|
||||
@@ -174,7 +175,7 @@ OSLCompilerImpl::make_constant(ustring val)
|
||||
return sym;
|
||||
}
|
||||
// It's not a constant we've added before
|
||||
ustring name = ustring::sprintf("$const%d", ++m_next_const);
|
||||
ustring name = ustring::fmtformat("$const{}", ++m_next_const);
|
||||
ConstantSymbol* s = new ConstantSymbol(name, val);
|
||||
symtab().insert(s);
|
||||
m_const_syms.push_back(s);
|
||||
@@ -193,7 +194,7 @@ OSLCompilerImpl::make_constant(TypeDesc type, const void* val)
|
||||
return sym;
|
||||
}
|
||||
// It's not a constant we've added before
|
||||
ustring name = ustring::sprintf("$const%d", ++m_next_const);
|
||||
ustring name = ustring::fmtformat("$const{}", ++m_next_const);
|
||||
ConstantSymbol* s = new ConstantSymbol(name, type);
|
||||
memcpy(s->dataptr(), val, typesize);
|
||||
symtab().insert(s);
|
||||
@@ -211,7 +212,7 @@ OSLCompilerImpl::make_constant(int val)
|
||||
return sym;
|
||||
}
|
||||
// It's not a constant we've added before
|
||||
ustring name = ustring::sprintf("$const%d", ++m_next_const);
|
||||
ustring name = ustring::fmtformat("$const{}", ++m_next_const);
|
||||
ConstantSymbol* s = new ConstantSymbol(name, val);
|
||||
symtab().insert(s);
|
||||
m_const_syms.push_back(s);
|
||||
@@ -228,7 +229,7 @@ OSLCompilerImpl::make_constant(float val)
|
||||
return sym;
|
||||
}
|
||||
// It's not a constant we've added before
|
||||
ustring name = ustring::sprintf("$const%d", ++m_next_const);
|
||||
ustring name = ustring::fmtformat("$const{}", ++m_next_const);
|
||||
ConstantSymbol* s = new ConstantSymbol(name, val);
|
||||
symtab().insert(s);
|
||||
m_const_syms.push_back(s);
|
||||
@@ -246,7 +247,7 @@ OSLCompilerImpl::make_constant(TypeDesc type, float x, float y, float z)
|
||||
return sym;
|
||||
}
|
||||
// It's not a constant we've added before
|
||||
ustring name = ustring::sprintf("$const%d", ++m_next_const);
|
||||
ustring name = ustring::fmtformat("$const{}", ++m_next_const);
|
||||
ConstantSymbol* s = new ConstantSymbol(name, type, x, y, z);
|
||||
symtab().insert(s);
|
||||
m_const_syms.push_back(s);
|
||||
@@ -453,9 +454,9 @@ ASTcompound_initializer::codegen(Symbol* sym)
|
||||
return sym;
|
||||
}
|
||||
|
||||
errorf("Possible compiler bug: compound_initializer codegen does not "
|
||||
"know how to handle type %s",
|
||||
typespec());
|
||||
errorfmt("Possible compiler bug: compound_initializer codegen does not "
|
||||
"know how to handle type {}",
|
||||
typespec());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -549,8 +550,8 @@ ASTNode::codegen_assign_struct(StructSpec* structspec, ustring dstsym,
|
||||
// struct within struct -- recurse
|
||||
ustring fieldname(structspec->field(i).name);
|
||||
codegen_assign_struct(fieldtype.structspec(),
|
||||
ustring::sprintf("%s.%s", dstsym, fieldname),
|
||||
ustring::sprintf("%s.%s", srcsym, fieldname),
|
||||
ustring::fmtformat("{}.{}", dstsym, fieldname),
|
||||
ustring::fmtformat("{}.{}", srcsym, fieldname),
|
||||
arrayindex, copywholearrays, 0, paraminit);
|
||||
continue;
|
||||
}
|
||||
@@ -559,8 +560,8 @@ ASTNode::codegen_assign_struct(StructSpec* structspec, ustring dstsym,
|
||||
// struct array within struct -- loop over indices and recurse
|
||||
OSL_ASSERT(!arrayindex && "two levels of arrays not allowed");
|
||||
ustring fieldname(structspec->field(i).name);
|
||||
ustring dstfield = ustring::sprintf("%s.%s", dstsym, fieldname);
|
||||
ustring srcfield = ustring::sprintf("%s.%s", srcsym, fieldname);
|
||||
ustring dstfield = ustring::fmtformat("{}.{}", dstsym, fieldname);
|
||||
ustring srcfield = ustring::fmtformat("{}.{}", srcsym, fieldname);
|
||||
for (int i = 0; i < fieldtype.arraylength(); ++i) {
|
||||
codegen_assign_struct(fieldtype.structspec(), dstfield,
|
||||
srcfield, m_compiler->make_constant(i),
|
||||
@@ -631,16 +632,16 @@ ASTNode::one_default_literal(const Symbol* sym, ASTNode* init, std::string& out,
|
||||
completed = false;
|
||||
} else if (type.is_int()) {
|
||||
if (islit && lit->typespec().is_int())
|
||||
out += Strutil::sprintf("%d", lit->intval());
|
||||
out += fmtformat("{}", lit->intval());
|
||||
else {
|
||||
out += "0"; // FIXME?
|
||||
completed = false;
|
||||
}
|
||||
} else if (type.is_float()) {
|
||||
if (islit && lit->typespec().is_int())
|
||||
out += Strutil::sprintf("%d", lit->intval());
|
||||
out += fmtformat("{}", lit->intval());
|
||||
else if (islit && lit->typespec().is_float())
|
||||
out += Strutil::sprintf("%.9g", lit->floatval());
|
||||
out += fmtformat("{:.9g}", lit->floatval());
|
||||
else {
|
||||
out += "0"; // FIXME?
|
||||
completed = false;
|
||||
@@ -648,10 +649,10 @@ ASTNode::one_default_literal(const Symbol* sym, ASTNode* init, std::string& out,
|
||||
} else if (type.is_triple()) {
|
||||
if (islit && lit->typespec().is_int()) {
|
||||
float f = lit->intval();
|
||||
out += Strutil::sprintf("%.9g%s%.9g%s%.9g", f, sep, f, sep, f);
|
||||
out += fmtformat("{:.9g}{}{:.9g}{}{:.9g}", f, sep, f, sep, f);
|
||||
} else if (islit && lit->typespec().is_float()) {
|
||||
float f = lit->floatval();
|
||||
out += Strutil::sprintf("%.9g%s%.9g%s%.9g", f, sep, f, sep, f);
|
||||
out += fmtformat("{:.9g}{}{:.9g}{}{:.9g}", f, sep, f, sep, f);
|
||||
} else if (init && init->typespec() == type
|
||||
&& (init->nodetype() == ASTNode::type_constructor_node
|
||||
|| (init->nodetype() == ASTNode::compound_initializer_node
|
||||
@@ -681,26 +682,26 @@ ASTNode::one_default_literal(const Symbol* sym, ASTNode* init, std::string& out,
|
||||
}
|
||||
}
|
||||
if (nargs == 1)
|
||||
out += Strutil::sprintf("%.9g%s%.9g%s%.9g", f[0], sep, f[0],
|
||||
sep, f[0]);
|
||||
out += fmtformat("{:.9g}{}{:.9g}{}{:.9g}", f[0], sep, f[0], sep,
|
||||
f[0]);
|
||||
else
|
||||
out += Strutil::sprintf("%.9g%s%.9g%s%.9g", f[0], sep, f[1],
|
||||
sep, f[2]);
|
||||
out += fmtformat("{:.9g}{}{:.9g}{}{:.9g}", f[0], sep, f[1], sep,
|
||||
f[2]);
|
||||
} else {
|
||||
out += Strutil::sprintf("0%s0%s0", sep, sep);
|
||||
out += fmtformat("0{}0{}0", sep, sep);
|
||||
completed = false;
|
||||
}
|
||||
} else if (type.is_matrix()) {
|
||||
if (islit && lit->typespec().is_int()) {
|
||||
float f = lit->intval();
|
||||
for (int c = 0; c < 16; ++c)
|
||||
out += Strutil::sprintf("%.9g%s", (c / 4) == (c % 4) ? f : 0.0f,
|
||||
c < 15 ? sep.c_str() : "");
|
||||
out += fmtformat("{:.9g}{}", (c / 4) == (c % 4) ? f : 0.0f,
|
||||
c < 15 ? sep : "");
|
||||
} else if (islit && lit->typespec().is_float()) {
|
||||
float f = lit->floatval();
|
||||
for (int c = 0; c < 16; ++c)
|
||||
out += Strutil::sprintf("%.9g%s", (c / 4) == (c % 4) ? f : 0.0f,
|
||||
c < 15 ? sep.c_str() : "");
|
||||
out += fmtformat("{:.9g}{}", (c / 4) == (c % 4) ? f : 0.0f,
|
||||
c < 15 ? sep : "");
|
||||
} else if (init && init->typespec() == type
|
||||
&& init->nodetype() == ASTNode::type_constructor_node) {
|
||||
ASTtype_constructor* ctr = (ASTtype_constructor*)init;
|
||||
@@ -728,23 +729,21 @@ ASTNode::one_default_literal(const Symbol* sym, ASTNode* init, std::string& out,
|
||||
}
|
||||
if (nargs == 1) {
|
||||
for (int c = 0; c < 16; ++c)
|
||||
out += Strutil::sprintf("%.9g%s",
|
||||
(c / 4) == (c % 4) ? f[0] : 0.0f,
|
||||
c < 15 ? sep.c_str() : "");
|
||||
out += fmtformat("{:.9g}{}",
|
||||
(c / 4) == (c % 4) ? f[0] : 0.0f,
|
||||
c < 15 ? sep : "");
|
||||
} else {
|
||||
for (int c = 0; c < 16; ++c)
|
||||
out += Strutil::sprintf("%.9g%s", f[c],
|
||||
c < 15 ? sep.c_str() : "");
|
||||
out += fmtformat("{:.9g}{}", f[c], c < 15 ? sep : "");
|
||||
}
|
||||
} else {
|
||||
for (int c = 0; c < 16; ++c)
|
||||
out += Strutil::sprintf("0%s", c < 15 ? sep.c_str() : "");
|
||||
out += fmtformat("0{}", c < 15 ? sep : "");
|
||||
completed = false;
|
||||
}
|
||||
} else if (type.is_string()) {
|
||||
if (islit && lit->typespec().is_string())
|
||||
out += Strutil::sprintf("\"%s\"",
|
||||
Strutil::escape_chars(lit->strval()));
|
||||
out += fmtformat("\"{}\"", Strutil::escape_chars(lit->strval()));
|
||||
else {
|
||||
out += "\"\""; // FIXME?
|
||||
completed = false;
|
||||
@@ -903,8 +902,8 @@ ASTNode::codegen_initlist(ref init, TypeSpec type, Symbol* sym)
|
||||
for (int i = 0; init && i < structspec->numfields();
|
||||
init = init->next(), ++i) {
|
||||
const StructSpec::FieldSpec& field(structspec->field(i));
|
||||
ustring fieldname = ustring::sprintf("%s.%s", sym->mangled(),
|
||||
field.name);
|
||||
ustring fieldname = ustring::fmtformat("{}.{}", sym->mangled(),
|
||||
field.name);
|
||||
Symbol* fieldsym = m_compiler->symtab().find_exact(fieldname);
|
||||
if (paraminit) {
|
||||
OSL_DASSERT(nodetype() == variable_declaration_node);
|
||||
@@ -919,10 +918,10 @@ ASTNode::codegen_initlist(ref init, TypeSpec type, Symbol* sym)
|
||||
}
|
||||
|
||||
if (paraminit) {
|
||||
// Warn early about struct array paramters.
|
||||
// Warn early about struct array parameters.
|
||||
// Handling this will likely need changes to oso format.
|
||||
if (type.is_structure_array()) {
|
||||
errorf("array of struct are not allowed as parameters");
|
||||
errorfmt("array of struct are not allowed as parameters");
|
||||
return;
|
||||
}
|
||||
// For parameter initialization, don't really generate ops if it
|
||||
@@ -1073,8 +1072,8 @@ ASTNode::codegen_struct_initializers(ref init, Symbol* sym, bool is_constructor,
|
||||
init = init->next(), ++i) {
|
||||
// Structure element -- assign to the i-th member field
|
||||
const StructSpec::FieldSpec& field(structspec->field(i));
|
||||
ustring fieldname = ustring::sprintf("%s.%s", sym->mangled(),
|
||||
field.name);
|
||||
ustring fieldname = ustring::fmtformat("{}.{}", sym->mangled(),
|
||||
field.name);
|
||||
Symbol* fieldsym = m_compiler->symtab().find_exact(fieldname);
|
||||
if (fieldsym->typespec().is_structure_based()
|
||||
&& (init->nodetype() == type_constructor_node
|
||||
@@ -1240,8 +1239,8 @@ ASTindex::codegen_copy_struct_array_element(StructSpec* structspec,
|
||||
// struct within struct -- recurse!
|
||||
codegen_copy_struct_array_element(
|
||||
type.structspec(),
|
||||
ustring::sprintf("%s.%s", destname, field.name),
|
||||
ustring::sprintf("%s.%s", srcname, field.name), index);
|
||||
ustring::fmtformat("{}.{}", destname, field.name),
|
||||
ustring::fmtformat("{}.{}", srcname, field.name), index);
|
||||
} else {
|
||||
OSL_ASSERT(!type.is_array());
|
||||
Symbol *dfield, *sfield;
|
||||
@@ -1464,7 +1463,7 @@ ASTunary_expression::codegen(Symbol* dest)
|
||||
if (m_function_overload) {
|
||||
// A little crazy, but we temporarily construct an ASTfunction_call
|
||||
// in order to codegen this overloaded operator.
|
||||
ustring funcname = ustring::sprintf("__operator__%s__", opword());
|
||||
ustring funcname = ustring::fmtformat("__operator__{}__", opword());
|
||||
ASTfunction_call fc(m_compiler, funcname, expr().get(),
|
||||
m_function_overload);
|
||||
fc.typecheck(typespec());
|
||||
@@ -1512,10 +1511,10 @@ ASTbinary_expression::codegen(Symbol* dest)
|
||||
// in order to codegen this overloaded operator. Slightly tricky
|
||||
// is that we need to concatenate our left and right arguments into
|
||||
// an arg list.
|
||||
ustring funcname = ustring::sprintf("__operator__%s__", opword());
|
||||
ustring funcname = ustring::fmtformat("__operator__{}__", opword());
|
||||
if (left()->nextptr() || right()->nextptr()) {
|
||||
errorf("Overloaded %s cannot be passed arguments %s and %s",
|
||||
funcname, left()->nodetypename(), right()->nodetypename());
|
||||
errorfmt("Overloaded %s cannot be passed arguments {} and {}",
|
||||
funcname, left()->nodetypename(), right()->nodetypename());
|
||||
return dest;
|
||||
}
|
||||
ref args = left();
|
||||
@@ -1995,10 +1994,10 @@ ASTfunction_call::codegen_arg(SymbolPtrVec& argdest, SymbolPtrVec& index1,
|
||||
&& !equivalent(origarg->typespec(), form->typespec())
|
||||
&& form->nodetype() == variable_declaration_node
|
||||
&& ((ASTvariable_declaration*)form)->is_output()) {
|
||||
errorf("Cannot pass '%s %s' as argument %d to %s\n\t"
|
||||
"because it is an output parameter that must be a %s",
|
||||
origarg->typespec(), origarg->name(), argnum + 1,
|
||||
user_function()->func()->name(), form->typespec());
|
||||
errorfmt("Cannot pass '{} {}' as argument {} to {}\n\t"
|
||||
"because it is an output parameter that must be a %s",
|
||||
origarg->typespec(), origarg->name(), argnum + 1,
|
||||
user_function()->func()->name(), form->typespec());
|
||||
}
|
||||
}
|
||||
if (thisarg) {
|
||||
@@ -2007,7 +2006,7 @@ ASTfunction_call::codegen_arg(SymbolPtrVec& argdest, SymbolPtrVec& index1,
|
||||
index2.push_back(ind2);
|
||||
index3.push_back(ind3);
|
||||
} else
|
||||
arg->errorf("Invalid argument to function");
|
||||
arg->errorfmt("Invalid argument to function");
|
||||
}
|
||||
|
||||
|
||||
@@ -2023,8 +2022,8 @@ ASTfunction_call::struct_pair_all_fields(StructSpec* structspec, ustring formal,
|
||||
// struct within struct -- recurse!
|
||||
struct_pair_all_fields(
|
||||
type.structspec(),
|
||||
ustring::sprintf("%s.%s", formal, field.name),
|
||||
ustring::sprintf("%s.%s", actual, field.name), arrayindex);
|
||||
ustring::fmtformat("{}.{}", formal, field.name),
|
||||
ustring::fmtformat("{}.{}", actual, field.name), arrayindex);
|
||||
} else {
|
||||
Symbol *fsym, *asym;
|
||||
m_compiler->struct_field_pair(structspec, fi, formal, actual, fsym,
|
||||
|
||||
+100
-97
@@ -131,7 +131,7 @@ OSLCompilerImpl::preprocess_file(const std::string& filename,
|
||||
// Read file contents into a string
|
||||
std::string instring;
|
||||
if (!OIIO::Filesystem::read_text_file(filename, instring)) {
|
||||
errorf(ustring(filename), 0, "Could not open \"%s\"\n", filename);
|
||||
errorfmt(ustring(filename), 0, "Could not open \"{}\"\n", filename);
|
||||
return false;
|
||||
}
|
||||
return preprocess_buffer(instring, filename, stdoslpath, defines,
|
||||
@@ -148,11 +148,11 @@ OSLCompilerImpl::preprocess_buffer(const std::string& buffer,
|
||||
const std::vector<std::string>& includepaths,
|
||||
std::string& result)
|
||||
{
|
||||
using OIIO::Strutil::fmt::format;
|
||||
std::string instring;
|
||||
if (!stdoslpath.empty()) {
|
||||
instring
|
||||
= OIIO::Strutil::sprintf("#include \"%s\"\n",
|
||||
OIIO::Strutil::escape_chars(stdoslpath));
|
||||
instring = format("#include \"{}\"\n",
|
||||
OIIO::Strutil::escape_chars(stdoslpath));
|
||||
// Note: because we're turning this from a regular string into a
|
||||
// double-quoted string injected into the OSL parse stream, we need
|
||||
// to fully escape any backslashes used in Windows file paths. We
|
||||
@@ -217,14 +217,13 @@ OSLCompilerImpl::preprocess_buffer(const std::string& buffer,
|
||||
|
||||
clang::PreprocessorOptions& preprocOpts = inst.getPreprocessorOpts();
|
||||
preprocOpts.UsePredefines = 0;
|
||||
preprocOpts.addMacroDef(OIIO::Strutil::sprintf("OSL_VERSION_MAJOR=%d",
|
||||
OSL_LIBRARY_VERSION_MAJOR));
|
||||
preprocOpts.addMacroDef(OIIO::Strutil::sprintf("OSL_VERSION_MINOR=%d",
|
||||
OSL_LIBRARY_VERSION_MINOR));
|
||||
preprocOpts.addMacroDef(OIIO::Strutil::sprintf("OSL_VERSION_PATCH=%d",
|
||||
OSL_LIBRARY_VERSION_PATCH));
|
||||
preprocOpts.addMacroDef(
|
||||
OIIO::Strutil::sprintf("OSL_VERSION=%d", OSL_LIBRARY_VERSION_CODE));
|
||||
format("OSL_VERSION_MAJOR={}", OSL_LIBRARY_VERSION_MAJOR));
|
||||
preprocOpts.addMacroDef(
|
||||
format("OSL_VERSION_MINOR={}", OSL_LIBRARY_VERSION_MINOR));
|
||||
preprocOpts.addMacroDef(
|
||||
format("OSL_VERSION_PATCH={}", OSL_LIBRARY_VERSION_PATCH));
|
||||
preprocOpts.addMacroDef(format("OSL_VERSION={}", OSL_LIBRARY_VERSION_CODE));
|
||||
for (auto&& d : defines) {
|
||||
if (d[1] == 'D')
|
||||
preprocOpts.addMacroDef(d.c_str() + 2);
|
||||
@@ -245,7 +244,7 @@ OSLCompilerImpl::preprocess_buffer(const std::string& buffer,
|
||||
while (preproc_errors.size()
|
||||
&& preproc_errors[preproc_errors.size() - 1] == '\n')
|
||||
preproc_errors.erase(preproc_errors.size() - 1);
|
||||
errorf(ustring(), -1, "%s", preproc_errors);
|
||||
errorfmt(ustring(), -1, "{}", preproc_errors);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -342,8 +341,8 @@ find_stdoslpath(const std::vector<std::string>& includepaths)
|
||||
|
||||
// If that doesn't work, look in a bunch of likely places.
|
||||
|
||||
std::string install_loc = OIIO::Strutil::sprintf("%s/stdosl.h",
|
||||
OSL_SHADER_INSTALL_DIR);
|
||||
std::string install_loc
|
||||
= OIIO::Strutil::fmt::format("{}/stdosl.h", OSL_SHADER_INSTALL_DIR);
|
||||
if (OIIO::Filesystem::exists(install_loc))
|
||||
return ustring(install_loc);
|
||||
|
||||
@@ -407,7 +406,7 @@ OSLCompilerImpl::compile(string_view filename,
|
||||
string_view stdoslpath)
|
||||
{
|
||||
if (!OIIO::Filesystem::exists(filename)) {
|
||||
errorf(ustring(), 0, "Input file \"%s\" not found", filename);
|
||||
errorfmt(ustring(), 0, "Input file \"{}\" not found", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -425,7 +424,7 @@ OSLCompilerImpl::compile(string_view filename,
|
||||
stdoslpath = find_stdoslpath(includepaths);
|
||||
}
|
||||
if (stdoslpath.empty() || !OIIO::Filesystem::exists(stdoslpath))
|
||||
warningf(ustring(filename), 0, "Unable to find \"stdosl.h\"");
|
||||
warningfmt(ustring(filename), 0, "Unable to find \"stdosl.h\"");
|
||||
else {
|
||||
// Add the directory of stdosl.h to the include paths
|
||||
includepaths.push_back(OIIO::Filesystem::parent_path(stdoslpath));
|
||||
@@ -445,7 +444,7 @@ OSLCompilerImpl::compile(string_view filename,
|
||||
if (shader())
|
||||
shader()->typecheck();
|
||||
else
|
||||
errorf(ustring(), 0, "No shader function defined");
|
||||
errorfmt(ustring(), 0, "No shader function defined");
|
||||
}
|
||||
|
||||
// Print the parse tree if there were no errors
|
||||
@@ -474,8 +473,8 @@ OSLCompilerImpl::compile(string_view filename,
|
||||
OIIO::ofstream oso_output;
|
||||
OIIO::Filesystem::open(oso_output, m_output_filename);
|
||||
if (!oso_output.good()) {
|
||||
errorf(ustring(), 0, "Could not open \"%s\"",
|
||||
m_output_filename);
|
||||
errorfmt(ustring(), 0, "Could not open \"{}\"",
|
||||
m_output_filename);
|
||||
return false;
|
||||
}
|
||||
OSL_DASSERT(m_osofile == nullptr);
|
||||
@@ -487,8 +486,8 @@ OSLCompilerImpl::compile(string_view filename,
|
||||
|
||||
oso_output.close();
|
||||
if (!oso_output.good()) {
|
||||
errorf(ustring(), 0, "Failed to write to \"%s\"",
|
||||
m_output_filename);
|
||||
errorfmt(ustring(), 0, "Failed to write to \"{}\"",
|
||||
m_output_filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -521,7 +520,7 @@ OSLCompilerImpl::compile_buffer(string_view sourcecode, std::string& osobuffer,
|
||||
stdoslpath = find_stdoslpath(includepaths);
|
||||
}
|
||||
if (stdoslpath.empty() || !OIIO::Filesystem::exists(stdoslpath))
|
||||
warningf(ustring(filename), 0, "Unable to find \"stdosl.h\"");
|
||||
warningfmt(ustring(filename), 0, "Unable to find \"stdosl.h\"");
|
||||
|
||||
std::string preprocess_result;
|
||||
if (!preprocess_buffer(sourcecode, filename, stdoslpath, defines,
|
||||
@@ -537,7 +536,7 @@ OSLCompilerImpl::compile_buffer(string_view sourcecode, std::string& osobuffer,
|
||||
if (shader())
|
||||
shader()->typecheck();
|
||||
else
|
||||
errorf(ustring(), 0, "No shader function defined");
|
||||
errorfmt(ustring(), 0, "No shader function defined");
|
||||
}
|
||||
|
||||
// Print the parse tree if there were no errors
|
||||
@@ -591,7 +590,7 @@ OSLCompilerImpl::write_dependency_file(string_view filename)
|
||||
? stdout
|
||||
: OIIO::Filesystem::fopen(m_deps_filename, "w"));
|
||||
if (depfile) {
|
||||
OIIO::Strutil::fprintf(depfile, "%s: %s", target, filename);
|
||||
OSL::print(depfile, "{}: {}", target, filename);
|
||||
for (const auto& dep : m_file_dependencies) {
|
||||
if (OIIO::Strutil::ends_with(dep, "stdosl.h")
|
||||
&& !m_generate_system_deps)
|
||||
@@ -600,14 +599,15 @@ OSLCompilerImpl::write_dependency_file(string_view filename)
|
||||
continue; // skip pseudo files
|
||||
if (dep == filename)
|
||||
continue; // skip this file, since we already put it first
|
||||
OIIO::Strutil::fprintf(depfile, " \\\n %s", dep);
|
||||
OSL::print(depfile, " \\\n {}", dep);
|
||||
}
|
||||
OIIO::Strutil::fprintf(depfile, "\n");
|
||||
OSL::print(depfile, "\n");
|
||||
if (depfile != stdout)
|
||||
fclose(depfile);
|
||||
} else {
|
||||
errorf(ustring(), 0, "Could not open dependency file '%s' for writing",
|
||||
m_deps_filename);
|
||||
errorfmt(ustring(), 0,
|
||||
"Could not open dependency file '{}' for writing",
|
||||
m_deps_filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,11 +675,11 @@ OSLCompilerImpl::write_oso_metadata(const ASTNode* metanode) const
|
||||
bool ok = metavar->param_default_literals(metasym, metavar->init().get(),
|
||||
pdl, ",");
|
||||
if (ok) {
|
||||
osof("%%meta{%s,%s,%s} ", ts, metasym->name(), pdl);
|
||||
osofmt("%meta{{{},{},{}}} ", ts, metasym->name(), pdl);
|
||||
} else {
|
||||
errorf(metanode->sourcefile(), metanode->sourceline(),
|
||||
"Don't know how to print metadata %s (%s) with node type %s",
|
||||
metasym->name(), ts, metavar->init()->nodetypename());
|
||||
errorfmt(metanode->sourcefile(), metanode->sourceline(),
|
||||
"Don't know how to print metadata {} ({}) with node type {}",
|
||||
metasym->name(), ts, metavar->init()->nodetypename());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,18 +694,18 @@ OSLCompilerImpl::write_oso_const_value(const ConstantSymbol* sym) const
|
||||
int nelements = std::max(1, type.arraylen);
|
||||
if (elemtype == TypeDesc::STRING)
|
||||
for (int i = 0; i < nelements; ++i)
|
||||
osof("\"%s\"%s", OIIO::Strutil::escape_chars(sym->get_string(i)),
|
||||
nelements > 1 ? " " : "");
|
||||
osofmt("\"{}\"{}", OIIO::Strutil::escape_chars(sym->get_string(i)),
|
||||
nelements > 1 ? " " : "");
|
||||
else if (elemtype == TypeDesc::INT)
|
||||
for (int i = 0; i < nelements; ++i)
|
||||
osof("%d%s", sym->get_int(i), nelements > 1 ? " " : "");
|
||||
osofmt("{}{}", sym->get_int(i), nelements > 1 ? " " : "");
|
||||
else if (elemtype == TypeDesc::FLOAT)
|
||||
for (int i = 0; i < nelements; ++i)
|
||||
osof("%.9g%s", sym->floatval(i), nelements > 1 ? " " : "");
|
||||
osofmt("{}{}", sym->floatval(i), nelements > 1 ? " " : "");
|
||||
else if (equivalent(elemtype, TypeDesc::TypeVector))
|
||||
for (int i = 0; i < nelements; ++i) {
|
||||
Vec3 v = sym->get_vec3(i);
|
||||
osof("%.9g %.9g %.9g%s", v.x, v.y, v.z, nelements > 1 ? " " : "");
|
||||
osofmt("{} {} {}{}", v.x, v.y, v.z, nelements > 1 ? " " : "");
|
||||
}
|
||||
else {
|
||||
OSL_ASSERT(0 && "Don't know how to output this constant type");
|
||||
@@ -718,8 +718,8 @@ void
|
||||
OSLCompilerImpl::write_oso_symbol(const Symbol* sym)
|
||||
{
|
||||
// symtype / datatype / name
|
||||
osof("%s\t%s\t%s", sym->symtype_shortname(), sym->typespec(),
|
||||
sym->mangled());
|
||||
osofmt("{}\t{}\t{}", sym->symtype_shortname(), sym->typespec(),
|
||||
sym->mangled());
|
||||
|
||||
ASTvariable_declaration* v = NULL;
|
||||
if (sym->node()
|
||||
@@ -730,13 +730,13 @@ OSLCompilerImpl::write_oso_symbol(const Symbol* sym)
|
||||
bool isparam = (sym->symtype() == SymTypeParam
|
||||
|| sym->symtype() == SymTypeOutputParam);
|
||||
if (sym->symtype() == SymTypeConst) {
|
||||
osof("\t");
|
||||
osofmt("\t");
|
||||
write_oso_const_value(static_cast<const ConstantSymbol*>(sym));
|
||||
osof("\t");
|
||||
osofmt("\t");
|
||||
} else if (v && isparam) {
|
||||
std::string out;
|
||||
v->param_default_literals(sym, v->init().get(), out);
|
||||
osof("\t%s\t", out);
|
||||
osofmt("\t{}\t", out);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -749,15 +749,15 @@ OSLCompilerImpl::write_oso_symbol(const Symbol* sym)
|
||||
if (v) {
|
||||
for (ASTNode::ref m = v->meta(); m; m = m->next()) {
|
||||
if (hints++ == 0)
|
||||
osof("\t");
|
||||
osofmt("\t");
|
||||
write_oso_metadata(m.get());
|
||||
}
|
||||
}
|
||||
|
||||
// %read and %write give the range of ops over which a symbol is used.
|
||||
osof("%c%%read{%d,%d} %%write{%d,%d}", hints++ ? ' ' : '\t',
|
||||
sym->firstread(), sym->lastread(), sym->firstwrite(),
|
||||
sym->lastwrite());
|
||||
osofmt("{}%read{{{},{}}} %write{{{},{}}}", hints++ ? ' ' : '\t',
|
||||
sym->firstread(), sym->lastread(), sym->firstwrite(),
|
||||
sym->lastwrite());
|
||||
|
||||
// %struct, %structfields, and %structfieldtypes document the
|
||||
// definition of a structure and which other symbols comprise the
|
||||
@@ -771,28 +771,29 @@ OSLCompilerImpl::write_oso_symbol(const Symbol* sym)
|
||||
fieldlist += structspec->field(i).name.string();
|
||||
signature += code_from_type(structspec->field(i).type);
|
||||
}
|
||||
osof("%c%%struct{\"%s\"} %%structfields{%s} %%structfieldtypes{\"%s\"} %%structnfields{%d}",
|
||||
hints++ ? ' ' : '\t', structspec->mangled(), fieldlist, signature,
|
||||
structspec->numfields());
|
||||
osofmt(
|
||||
"{}%struct{{\"{}\"}} %structfields{{{}}} %structfieldtypes{{\"{}\"}} %structnfields{{{}}}",
|
||||
hints++ ? ' ' : '\t', structspec->mangled(), fieldlist, signature,
|
||||
structspec->numfields());
|
||||
}
|
||||
// %mystruct and %mystructfield document the symbols holding structure
|
||||
// fields, linking them back to the structures they are part of.
|
||||
if (sym->fieldid() >= 0) {
|
||||
ASTvariable_declaration* vd = (ASTvariable_declaration*)sym->node();
|
||||
if (vd)
|
||||
osof("%c%%mystruct{%s} %%mystructfield{%d}", hints++ ? ' ' : '\t',
|
||||
vd->sym()->mangled(), sym->fieldid());
|
||||
osofmt("{}%mystruct{{{}}} %mystructfield{{{}}}",
|
||||
hints++ ? ' ' : '\t', vd->sym()->mangled(), sym->fieldid());
|
||||
}
|
||||
|
||||
// %derivs hint marks symbols that need to carry derivatives
|
||||
if (sym->has_derivs())
|
||||
osof("%c%%derivs", hints++ ? ' ' : '\t');
|
||||
osofmt("{}%derivs", hints++ ? ' ' : '\t');
|
||||
|
||||
// %initexpr hint marks parameters whose default is the result of code
|
||||
// that must be executed (an expression, like =noise(P) or =u), rather
|
||||
// than a true default value that is statically known (like =3.14).
|
||||
if (isparam && sym->has_init_ops())
|
||||
osof("%c%%initexpr", hints++ ? ' ' : '\t');
|
||||
osofmt("{}%initexpr", hints++ ? ' ' : '\t');
|
||||
|
||||
#if 0 // this is recomputed by the runtime optimizer, no need to bloat the .oso with these
|
||||
|
||||
@@ -812,22 +813,22 @@ OSLCompilerImpl::write_oso_symbol(const Symbol* sym)
|
||||
inputdeps.push_back (d);
|
||||
if (inputdeps.size()) {
|
||||
if (hints++ == 0)
|
||||
osof("\t");
|
||||
osof(" %%depends{");
|
||||
osofmt("\t");
|
||||
osofmt(" %depends{{");
|
||||
int deps = 0;
|
||||
for (size_t i = 0; i < inputdeps.size(); ++i) {
|
||||
if (inputdeps[i]->symtype() == SymTypeTemp &&
|
||||
inputdeps[i]->dealias() != inputdeps[i])
|
||||
continue; // Skip aliased temporaries
|
||||
if (deps++)
|
||||
osof(",");
|
||||
osof("%s", inputdeps[i]->mangled());
|
||||
osofmt(",");
|
||||
osofmt("{}", inputdeps[i]->mangled());
|
||||
}
|
||||
osof("}");
|
||||
osofmt("}}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
osof("\n");
|
||||
osofmt("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -837,23 +838,23 @@ OSLCompilerImpl::write_oso_file(string_view options,
|
||||
string_view preprocessed_source)
|
||||
{
|
||||
OSL_DASSERT(m_osofile && m_osofile->good());
|
||||
osof("OpenShadingLanguage %d.%02d\n", OSO_FILE_VERSION_MAJOR,
|
||||
OSO_FILE_VERSION_MINOR);
|
||||
osof("# Compiled by oslc %s\n", OSL_LIBRARY_VERSION_STRING);
|
||||
osof("# options: %s\n", options);
|
||||
osofmt("OpenShadingLanguage {}.{:02d}\n", OSO_FILE_VERSION_MAJOR,
|
||||
OSO_FILE_VERSION_MINOR);
|
||||
osofmt("# Compiled by oslc {}\n", OSL_LIBRARY_VERSION_STRING);
|
||||
osofmt("# options: {}\n", options);
|
||||
|
||||
ASTshader_declaration* shaderdecl = shader_decl();
|
||||
osof("%s %s", shaderdecl->shadertypename(), shaderdecl->shadername());
|
||||
osofmt("{} {}", shaderdecl->shadertypename(), shaderdecl->shadername());
|
||||
|
||||
// output global hints and metadata
|
||||
int hints = 0;
|
||||
for (ASTNode::ref m = shaderdecl->metadata(); m; m = m->next()) {
|
||||
if (hints++ == 0)
|
||||
osof("\t");
|
||||
osofmt("\t");
|
||||
write_oso_metadata(m.get());
|
||||
}
|
||||
|
||||
osof("\n");
|
||||
osofmt("\n");
|
||||
|
||||
// Output params, so they are first
|
||||
for (auto&& s : symtab()) {
|
||||
@@ -877,7 +878,7 @@ OSLCompilerImpl::write_oso_file(string_view options,
|
||||
ustring lastmethod("___uninitialized___");
|
||||
for (auto& op : m_ircode) {
|
||||
if (lastmethod != op.method()) {
|
||||
osof("code %s\n", op.method());
|
||||
osofmt("code {}\n", op.method());
|
||||
lastmethod = op.method();
|
||||
lastfile = ustring();
|
||||
lastline = -1;
|
||||
@@ -887,25 +888,25 @@ OSLCompilerImpl::write_oso_file(string_view options,
|
||||
ustring file = op.sourcefile();
|
||||
int line = op.sourceline();
|
||||
if (file != lastfile || line != lastline)
|
||||
osof("# %s:%d\n# %s\n", file, line,
|
||||
retrieve_source(file, line));
|
||||
osofmt("# {}:{}\n# {}\n", file, line,
|
||||
retrieve_source(file, line));
|
||||
}
|
||||
|
||||
// Op name
|
||||
osof("\t%s", op.opname());
|
||||
osofmt("\t{}", op.opname());
|
||||
|
||||
// Register arguments
|
||||
if (op.nargs())
|
||||
osof(op.opname().length() < 8 ? "\t\t" : "\t");
|
||||
osofmt(op.opname().length() < 8 ? "\t\t" : "\t");
|
||||
for (int i = 0; i < op.nargs(); ++i) {
|
||||
int arg = op.firstarg() + i;
|
||||
osof("%s ", m_opargs[arg]->dealias()->mangled());
|
||||
osofmt("{} ", m_opargs[arg]->dealias()->mangled());
|
||||
}
|
||||
|
||||
// Jump targets
|
||||
for (size_t i = 0; i < Opcode::max_jumps; ++i)
|
||||
if (op.jump(i) >= 0)
|
||||
osof("%d ", op.jump(i));
|
||||
osofmt("{} ", op.jump(i));
|
||||
|
||||
//
|
||||
// Opcode Hints
|
||||
@@ -919,55 +920,56 @@ OSLCompilerImpl::write_oso_file(string_view options,
|
||||
if (!op.sourcefile().empty()) {
|
||||
if (op.sourcefile() != lastfile) {
|
||||
lastfile = op.sourcefile();
|
||||
osof("%c%%filename{\"%s\"}", firsthint ? '\t' : ' ', lastfile);
|
||||
osofmt("{}%filename{{\"{}\"}}", firsthint ? '\t' : ' ',
|
||||
lastfile);
|
||||
firsthint = false;
|
||||
}
|
||||
if (op.sourceline() != lastline) {
|
||||
lastline = op.sourceline();
|
||||
osof("%c%%line{%d}", firsthint ? '\t' : ' ', lastline);
|
||||
osofmt("{}%line{{{}}}", firsthint ? '\t' : ' ', lastline);
|
||||
firsthint = false;
|
||||
}
|
||||
}
|
||||
|
||||
// %argrw documents which arguments are read, written, or both (rwW).
|
||||
if (op.nargs()) {
|
||||
osof("%c%%argrw{\"", firsthint ? '\t' : ' ');
|
||||
osofmt("{}%argrw{{\"", firsthint ? '\t' : ' ');
|
||||
for (int i = 0; i < op.nargs(); ++i) {
|
||||
if (op.argwrite(i))
|
||||
osof(op.argread(i) ? "W" : "w");
|
||||
osofmt(op.argread(i) ? "W" : "w");
|
||||
else
|
||||
osof(op.argread(i) ? "r" : "-");
|
||||
osofmt(op.argread(i) ? "r" : "-");
|
||||
}
|
||||
osof("\"}");
|
||||
osofmt("\"}}");
|
||||
firsthint = false;
|
||||
}
|
||||
|
||||
// %argderivs documents which arguments have derivs taken of
|
||||
// them by the op.
|
||||
if (op.argtakesderivs_all()) {
|
||||
osof(" %%argderivs{");
|
||||
osofmt(" %argderivs{{");
|
||||
int any = 0;
|
||||
for (int i = 0; i < op.nargs(); ++i)
|
||||
if (op.argtakesderivs(i)) {
|
||||
if (any++)
|
||||
osof(",");
|
||||
osof("%d", i);
|
||||
osofmt(",");
|
||||
osofmt("{}", i);
|
||||
}
|
||||
osof("}");
|
||||
osofmt("}}");
|
||||
firsthint = false;
|
||||
}
|
||||
|
||||
osof("\n");
|
||||
osofmt("\n");
|
||||
}
|
||||
|
||||
// If no code, still need a code marker
|
||||
if (lastmethod != main_method_name())
|
||||
osof("code %s\n", main_method_name());
|
||||
osofmt("code {}\n", main_method_name());
|
||||
|
||||
osof("\tend\n");
|
||||
osofmt("\tend\n");
|
||||
|
||||
if (m_embed_source)
|
||||
osof("%%preprocessed_source\n%s\n", preprocessed_source);
|
||||
osofmt("%preprocessed_source\n{}\n", preprocessed_source);
|
||||
|
||||
m_osofile = NULL;
|
||||
}
|
||||
@@ -1071,7 +1073,8 @@ const char*
|
||||
OSLCompilerImpl::type_c_str(const TypeSpec& type) const
|
||||
{
|
||||
if (type.is_structure())
|
||||
return ustring::sprintf("struct %s", type.structspec()->name()).c_str();
|
||||
return ustring::fmtformat("struct {}", type.structspec()->name())
|
||||
.c_str();
|
||||
else
|
||||
return type.c_str();
|
||||
}
|
||||
@@ -1092,8 +1095,8 @@ OSLCompilerImpl::struct_field_pair(Symbol* sym1, Symbol* sym2, int fieldnum,
|
||||
const StructSpec::FieldSpec& field(structspec->field(fieldnum));
|
||||
// Construct mangled names that describe the symbols for the
|
||||
// individual fields
|
||||
ustring name1 = ustring::sprintf("%s.%s", sym1->mangled(), field.name);
|
||||
ustring name2 = ustring::sprintf("%s.%s", sym2->mangled(), field.name);
|
||||
ustring name1 = ustring::fmtformat("{}.{}", sym1->mangled(), field.name);
|
||||
ustring name2 = ustring::fmtformat("{}.{}", sym2->mangled(), field.name);
|
||||
// Retrieve the symbols
|
||||
field1 = symtab().find_exact(name1);
|
||||
field2 = symtab().find_exact(name2);
|
||||
@@ -1109,8 +1112,8 @@ OSLCompilerImpl::struct_field_pair(const StructSpec* structspec, int fieldnum,
|
||||
{
|
||||
// Find the FieldSpec for the field we are interested in
|
||||
const StructSpec::FieldSpec& field(structspec->field(fieldnum));
|
||||
ustring name1 = ustring::sprintf("%s.%s", sym1, field.name);
|
||||
ustring name2 = ustring::sprintf("%s.%s", sym2, field.name);
|
||||
ustring name1 = ustring::fmtformat("{}.{}", sym1, field.name);
|
||||
ustring name2 = ustring::fmtformat("{}.{}", sym2, field.name);
|
||||
// Retrieve the symbols
|
||||
field1 = symtab().find_exact(name1);
|
||||
field2 = symtab().find_exact(name2);
|
||||
@@ -1128,15 +1131,15 @@ OSLCompilerImpl::check_write_legality(const Opcode& op, int opnum,
|
||||
{
|
||||
// We can never write to constant symbols
|
||||
if (sym->symtype() == SymTypeConst) {
|
||||
errorf(op.sourcefile(), op.sourceline(),
|
||||
"Attempted to write to a constant value");
|
||||
errorfmt(op.sourcefile(), op.sourceline(),
|
||||
"Attempted to write to a constant value");
|
||||
}
|
||||
|
||||
// Params can only write if it's part of their initialization
|
||||
if (sym->symtype() == SymTypeParam
|
||||
&& (opnum < sym->initbegin() || opnum >= sym->initend())) {
|
||||
errorf(op.sourcefile(), op.sourceline(),
|
||||
"cannot write to non-output parameter \"%s\"", sym->name());
|
||||
errorfmt(op.sourcefile(), op.sourceline(),
|
||||
"cannot write to non-output parameter \"{}\"", sym->name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1302,7 +1305,7 @@ OSLCompilerImpl::track_variable_dependencies()
|
||||
// This naivite will never miss a dependency, but it may
|
||||
// overestimate dependencies. (Hence we call this "conservative"
|
||||
// rather than "wrong.") We deem this acceptable for now, since
|
||||
// it's so much easer to implement the conservative dependency
|
||||
// it's so much easier to implement the conservative dependency
|
||||
// analysis, and it's not yet clear that getting it closer to
|
||||
// optimal will have any performance impact on final shaders. Also
|
||||
// because this is probably no worse than the "dependency slop" that
|
||||
|
||||
@@ -77,69 +77,69 @@ public:
|
||||
|
||||
/// Error reporting
|
||||
template<typename... Args>
|
||||
void errorf(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
void errorfmt(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
std::string msg = OIIO::Strutil::sprintf(format, args...);
|
||||
std::string msg = OIIO::Strutil::fmt::format(format, args...);
|
||||
if (msg.size() && msg.back() == '\n') // trim extra newline
|
||||
msg.pop_back();
|
||||
if (filename.size())
|
||||
m_errhandler->errorf("%s:%d: error: %s", filename, line, msg);
|
||||
m_errhandler->errorfmt("{}:{}: error: {}", filename, line, msg);
|
||||
else
|
||||
m_errhandler->errorf("error: %s", msg);
|
||||
m_errhandler->errorfmt("error: {}", msg);
|
||||
m_err = true;
|
||||
}
|
||||
|
||||
/// Warning reporting
|
||||
template<typename... Args>
|
||||
void warningf(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
void warningfmt(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
if (nowarn(filename, line))
|
||||
return; // skip if the filename/line is on the nowarn list
|
||||
std::string msg = OIIO::Strutil::sprintf(format, args...);
|
||||
std::string msg = OIIO::Strutil::fmt::format(format, args...);
|
||||
if (msg.size() && msg.back() == '\n') // trim extra newline
|
||||
msg.pop_back();
|
||||
if (m_err_on_warning) {
|
||||
errorf(filename, line, "%s", msg);
|
||||
errorfmt(filename, line, "{}", msg);
|
||||
return;
|
||||
}
|
||||
if (filename.size())
|
||||
m_errhandler->warningf("%s:%d: warning: %s", filename, line, msg);
|
||||
m_errhandler->warningfmt("{}:{}: warning: {}", filename, line, msg);
|
||||
else
|
||||
m_errhandler->warningf("warning: %s", msg);
|
||||
m_errhandler->warningfmt("warning: {}", msg);
|
||||
}
|
||||
|
||||
/// Info reporting
|
||||
template<typename... Args>
|
||||
void infof(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
void infofmt(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
std::string msg = OIIO::Strutil::sprintf(format, args...);
|
||||
std::string msg = OIIO::Strutil::fmt::format(format, args...);
|
||||
if (msg.size() && msg.back() == '\n') // trim extra newline
|
||||
msg.pop_back();
|
||||
if (filename.size())
|
||||
m_errhandler->infof("%s:%d: info: %s", filename, line, msg);
|
||||
m_errhandler->infofmt("{}:{}: info: {}", filename, line, msg);
|
||||
else
|
||||
m_errhandler->infof("info: %s", msg);
|
||||
m_errhandler->infofmt("info: {}", msg);
|
||||
}
|
||||
|
||||
/// message reporting
|
||||
template<typename... Args>
|
||||
void messagef(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
void messagefmt(ustring filename, int line, const char* format,
|
||||
const Args&... args) const
|
||||
{
|
||||
OSL_DASSERT(format && format[0]);
|
||||
std::string msg = OIIO::Strutil::sprintf(format, args...);
|
||||
std::string msg = OIIO::Strutil::fmt::format(format, args...);
|
||||
if (msg.size() && msg.back() == '\n') // trim extra newline
|
||||
msg.pop_back();
|
||||
if (filename.size())
|
||||
m_errhandler->messagef("%s:%d: %s", filename, line, msg);
|
||||
m_errhandler->messagefmt("{}:{}: {}", filename, line, msg);
|
||||
else
|
||||
m_errhandler->messagef("%s", msg);
|
||||
m_errhandler->messagefmt("{}", msg);
|
||||
}
|
||||
|
||||
/// Have we hit an error?
|
||||
@@ -390,10 +390,11 @@ private:
|
||||
void write_oso_metadata(const ASTNode* metanode) const;
|
||||
void write_dependency_file(string_view filename);
|
||||
|
||||
// Output text to the osofile, using std::format formatting conventions.
|
||||
template<typename... Args>
|
||||
inline void osof(const char* fmt, const Args&... args) const
|
||||
inline void osofmt(const char* fmt, const Args&... args) const
|
||||
{
|
||||
(*m_osofile) << OIIO::Strutil::sprintf(fmt, args...);
|
||||
fmt::print(*m_osofile, fmt, args...);
|
||||
}
|
||||
|
||||
void track_variable_lifetimes()
|
||||
@@ -489,7 +490,7 @@ private:
|
||||
int m_main_method_start; ///< Instruction where 'main' starts
|
||||
bool m_declaring_shader_formals; ///< Are we declaring shader formals?
|
||||
std::set<std::pair<ustring, int>> m_nowarn_lines; ///< Lines for 'nowarn'
|
||||
typedef std::unordered_map<ustring, std::string, ustringHash> FCMap;
|
||||
typedef std::unordered_map<ustring, std::string> FCMap;
|
||||
FCMap m_filecontents_map; ///< Contents of source files we've seen
|
||||
ustring m_last_sourcefile; ///< Last filename for retrieve_source
|
||||
std::string* m_last_filecontents = nullptr; //< Last file contents
|
||||
|
||||
+53
-49
@@ -28,6 +28,10 @@
|
||||
#pragma clang diagnostic ignored "-Wparentheses-equality"
|
||||
#endif
|
||||
|
||||
#if (OSL_CLANG_VERSION >= 150000) || (OSL_INTEL_CLANG_VERSION >= 140000)
|
||||
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
@@ -248,11 +252,11 @@ formal_param
|
||||
// Grab the current declaration type, modify it to be array
|
||||
TypeSpec t = oslcompiler->current_typespec();
|
||||
if (! t.is_structure() && ! t.is_triple() && ! t.is_matrix())
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Can't use '= {...}' initializer "
|
||||
"except with arrays, structs, vectors, "
|
||||
"or matrix (%s)", $3);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Can't use '= {{...}}' initializer "
|
||||
"except with arrays, structs, vectors, "
|
||||
"or matrix ({})", $3);
|
||||
auto var = new ASTvariable_declaration (oslcompiler, t,
|
||||
ustring($3), $4 /*init*/,
|
||||
oslcompiler->declaring_shader_formals() /*isparam*/,
|
||||
@@ -294,9 +298,9 @@ metadatum
|
||||
TypeDesc simple = osllextype ($1);
|
||||
simple.arraylen = $3;
|
||||
if (simple.arraylen < 1)
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length for %s", $2);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length for {}", $2);
|
||||
TypeSpec t (simple, false);
|
||||
auto var = new ASTvariable_declaration (oslcompiler, t,
|
||||
ustring ($2), $4, false,
|
||||
@@ -338,13 +342,13 @@ struct_declaration
|
||||
ustring name ($2);
|
||||
Symbol *s = oslcompiler->symtab().clash (name);
|
||||
if (s) {
|
||||
oslcompiler->errorf(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"\"%s\" already declared in this scope", name);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"\"{}\" already declared in this scope", name);
|
||||
// FIXME -- print the file and line of the other definition
|
||||
}
|
||||
if (OIIO::Strutil::starts_with (name, "___")) {
|
||||
oslcompiler->errorf(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"\"%s\" : sorry, can't start with three underscores", name);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"\"{}\" : sorry, can't start with three underscores", name);
|
||||
}
|
||||
oslcompiler->symtab().new_struct (name);
|
||||
}
|
||||
@@ -375,10 +379,10 @@ typed_field
|
||||
TypeSpec t = oslcompiler->current_typespec();
|
||||
StructSpec *s = oslcompiler->symtab().current_struct();
|
||||
if (s->lookup_field (name) >= 0)
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Field \"%s\" already exists in struct \"%s\"",
|
||||
name, s->name());
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Field \"{}\" already exists in struct \"{}\"",
|
||||
name, s->name());
|
||||
else
|
||||
oslcompiler->symtab().add_struct_field (t, name);
|
||||
$$ = 0;
|
||||
@@ -390,15 +394,15 @@ typed_field
|
||||
TypeSpec t = oslcompiler->current_typespec();
|
||||
t.make_array ($2);
|
||||
if (t.arraylength() < 1)
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length for %s", name);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length for {}", name);
|
||||
StructSpec *s = oslcompiler->symtab().current_struct();
|
||||
if (s->lookup_field (name) >= 0)
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Field \"%s\" already exists in struct \"%s\"",
|
||||
name, s->name());
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Field \"{}\" already exists in struct \"{}\"",
|
||||
name, s->name());
|
||||
else
|
||||
oslcompiler->symtab().add_struct_field (t, name);
|
||||
$$ = 0;
|
||||
@@ -434,9 +438,9 @@ def_expression
|
||||
TypeSpec t = oslcompiler->current_typespec();
|
||||
t.make_array ($2);
|
||||
if ($2 < 1)
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length for %s", $1);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length for {}", $1);
|
||||
$$ = new ASTvariable_declaration (oslcompiler, t,
|
||||
ustring($1), $3, false, false, false,
|
||||
true /* initlist */, @1.first_line);
|
||||
@@ -445,11 +449,11 @@ def_expression
|
||||
{
|
||||
TypeSpec t = oslcompiler->current_typespec();
|
||||
if (! t.is_structure() && ! t.is_triple() && ! t.is_matrix())
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Can't use '= {...}' initializer "
|
||||
"except with arrays, struct, vectors, "
|
||||
"or matrix (%s)", $1);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Can't use '= {{...}}' initializer "
|
||||
"except with arrays, struct, vectors, "
|
||||
"or matrix ({})", $1);
|
||||
$$ = new ASTvariable_declaration (oslcompiler, t,
|
||||
ustring($1), $2, false, false, false,
|
||||
true /* initlist */, @1.first_line);
|
||||
@@ -483,10 +487,10 @@ compound_initializer
|
||||
| '{' '}'
|
||||
{
|
||||
if (!oslcompiler->declaring_shader_formals())
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Empty compound initializers '{ }' "
|
||||
"only allowed for shader parameters.");
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Empty compound initializers '{{ }}' "
|
||||
"only allowed for shader parameters.");
|
||||
$$ = new ASTcompound_initializer (oslcompiler, nullptr);
|
||||
$$->sourceline (@1.first_line);
|
||||
}
|
||||
@@ -566,9 +570,9 @@ arrayspec
|
||||
: '[' INT_LITERAL ']'
|
||||
{
|
||||
if ($2 < 1)
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length (%d)", $2);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Invalid array length ({})", $2);
|
||||
$$ = $2;
|
||||
}
|
||||
| '[' ']' { $$ = -1; }
|
||||
@@ -594,9 +598,9 @@ typespec
|
||||
oslcompiler->current_typespec (TypeSpec ("", s->typespec().structure()));
|
||||
else {
|
||||
oslcompiler->current_typespec (TypeSpec (TypeDesc::UNKNOWN));
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Unknown struct name: %s", $1);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Unknown struct name: {}", $1);
|
||||
}
|
||||
$$ = 0;
|
||||
}
|
||||
@@ -635,9 +639,9 @@ typespec_or_shadertype
|
||||
oslcompiler->current_typespec (TypeSpec ("", s->typespec().structure()));
|
||||
else {
|
||||
oslcompiler->current_typespec (TypeSpec (TypeDesc::UNKNOWN));
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Unknown struct name: %s", $1);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"Unknown struct name: {}", $1);
|
||||
}
|
||||
$$ = (int)ShaderType::Unknown;
|
||||
}
|
||||
@@ -797,9 +801,9 @@ expression
|
||||
// color x = Cd * (a, b, c); // same as: x = Cd * c
|
||||
// when they really meant
|
||||
// color x = Cd * color(a, b, c);
|
||||
oslcompiler->warningf(oslcompiler->filename(),
|
||||
@1.first_line,
|
||||
"Comma operator inside parenthesis is probably an error -- it is not a vector/color.");
|
||||
oslcompiler->warningfmt(oslcompiler->filename(),
|
||||
@1.first_line,
|
||||
"Comma operator inside parenthesis is probably an error -- it is not a vector/color.");
|
||||
}
|
||||
$$ = $2;
|
||||
}
|
||||
@@ -1094,8 +1098,8 @@ string_literal_group
|
||||
void
|
||||
OSL::pvt::yyerror (YYLTYPE* yylloc_param, void* yyscanner, OSLCompilerImpl* oslcompiler, const char* err)
|
||||
{
|
||||
oslcompiler->errorf(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Syntax error: %s", err);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Syntax error: {}", err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+33
-28
@@ -7,6 +7,11 @@
|
||||
/** Lexical scanner for Open Shading Language
|
||||
**/
|
||||
|
||||
%top{
|
||||
/* Include this first to avoid warnings about re-definitions on windows */
|
||||
#include <stdint.h>
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Definitions section
|
||||
************************************************************/
|
||||
@@ -176,10 +181,10 @@ OSL_NAMESPACE_EXIT
|
||||
"protected"|"short"|"signed"|"sizeof"|"static"|"struct" | \
|
||||
"switch"|"template"|"this"|"true"|"typedef"|"uniform" | \
|
||||
"union"|"unsigned"|"varying"|"virtual" {
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"'%s' is a reserved word",
|
||||
yytext);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"'{}' is a reserved word",
|
||||
yytext);
|
||||
SETLINE;
|
||||
return (yylval->i=RESERVED);
|
||||
}
|
||||
@@ -198,10 +203,10 @@ OSL_NAMESPACE_EXIT
|
||||
// we do not detect overflow when the value is INT_MAX+1,
|
||||
// because negation happens later and -(INT_MAX+1) == INT_MIN
|
||||
if (llval > ((long long)INT_MAX)+1) {
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"integer overflow, value must be between %d and %d.",
|
||||
INT_MIN, INT_MAX);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"integer overflow, value must be between {} and {}.",
|
||||
INT_MIN, INT_MAX);
|
||||
}
|
||||
yylval->i = (int)llval;
|
||||
SETLINE;
|
||||
@@ -212,10 +217,10 @@ OSL_NAMESPACE_EXIT
|
||||
// we do not detect overflow when the value is INT_MAX+1,
|
||||
// because negation happens later and -(INT_MAX+1) == INT_MIN
|
||||
if (llval > ((long long)UINT_MAX)+1) {
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"integer overflow, value must be between %d and %d.",
|
||||
INT_MIN, INT_MAX);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"integer overflow, value must be between {} and {}.",
|
||||
INT_MIN, INT_MAX);
|
||||
}
|
||||
yylval->i = (int)llval;
|
||||
SETLINE;
|
||||
@@ -300,8 +305,8 @@ preprocess (const char *str, OSLCompilerImpl* oslcompiler, YYLTYPE* yyloc_param)
|
||||
while (*p == ' ' || *p == '\t')
|
||||
p++;
|
||||
if (*p != '#') {
|
||||
oslcompiler->errorf(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Possible bug in shader preprocess");
|
||||
oslcompiler->errorfmt(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Possible bug in shader preprocess");
|
||||
SETLINE;
|
||||
return;
|
||||
}
|
||||
@@ -315,30 +320,30 @@ preprocess (const char *str, OSLCompilerImpl* oslcompiler, YYLTYPE* yyloc_param)
|
||||
if (pragmatype == "error") {
|
||||
string_view msg;
|
||||
if (OIIO::Strutil::parse_string(line, msg))
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(), "%s", msg);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(), "{}", msg);
|
||||
else
|
||||
oslcompiler->errorf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"<unknown error>");
|
||||
oslcompiler->errorfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"<unknown error>");
|
||||
}
|
||||
else if (pragmatype == "warning") {
|
||||
string_view msg;
|
||||
if (OIIO::Strutil::parse_string(line, msg))
|
||||
oslcompiler->warningf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(), "%s", msg);
|
||||
oslcompiler->warningfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(), "{}", msg);
|
||||
else
|
||||
oslcompiler->warningf(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"<unknown warning>");
|
||||
oslcompiler->warningfmt(oslcompiler->filename(),
|
||||
oslcompiler->lineno(),
|
||||
"<unknown warning>");
|
||||
}
|
||||
else if (OIIO::Strutil::iequals (pragmatype, "osl")) {
|
||||
string_view pragmaname = OIIO::Strutil::parse_word (line);
|
||||
if (pragmaname == "nowarn") {
|
||||
oslcompiler->pragma_nowarn ();
|
||||
} else {
|
||||
oslcompiler->warningf(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Unknown pragma '%s'", pragmaname);
|
||||
oslcompiler->warningfmt(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Unknown pragma '{}'", pragmaname);
|
||||
}
|
||||
}
|
||||
// N.B. Any other pragmas that don't start with "osl" are ignored
|
||||
@@ -377,8 +382,8 @@ preprocess (const char *str, OSLCompilerImpl* oslcompiler, YYLTYPE* yyloc_param)
|
||||
}
|
||||
oslcompiler->lineno (line);
|
||||
} else {
|
||||
oslcompiler->errorf(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Unrecognized preprocessor command: #%s", p);
|
||||
oslcompiler->errorfmt(oslcompiler->filename(), oslcompiler->lineno(),
|
||||
"Unrecognized preprocessor command: #{}", p);
|
||||
}
|
||||
}
|
||||
SETLINE;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace pvt { // OSL::pvt
|
||||
std::string
|
||||
Symbol::mangled() const
|
||||
{
|
||||
std::string result = scope() ? Strutil::sprintf("___%d_%s", scope(), m_name)
|
||||
std::string result = scope() ? fmtformat("___{}_{}", scope(), m_name)
|
||||
: m_name.string();
|
||||
return result; // Force NRVO (named value return optimization)
|
||||
}
|
||||
@@ -43,9 +43,9 @@ Symbol::unmangled() const
|
||||
const char*
|
||||
Symbol::symtype_shortname(SymType s)
|
||||
{
|
||||
OSL_DASSERT((int)s >= 0 && (int)s < (int)SymTypeType);
|
||||
OSL_DASSERT((int)s >= 0 && (int)s < (int)SymTypeLast);
|
||||
static const char* names[] = { "param", "oparam", "local", "temp",
|
||||
"global", "const", "func" };
|
||||
"global", "const", "func", "typename" };
|
||||
return names[(int)s];
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ Symbol::symtype_shortname(SymType s)
|
||||
std::string
|
||||
StructSpec::mangled() const
|
||||
{
|
||||
return scope() ? Strutil::sprintf("___%d_%s", scope(), m_name)
|
||||
: m_name.string();
|
||||
return scope() ? fmtformat("___{}_{}", scope(), m_name) : m_name.string();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
///
|
||||
class SymbolTable {
|
||||
public:
|
||||
typedef std::unordered_map<ustring, Symbol*, ustringHash> ScopeTable;
|
||||
typedef std::unordered_map<ustring, Symbol*> ScopeTable;
|
||||
typedef std::vector<ScopeTable> ScopeTableStack;
|
||||
typedef SymbolPtrVec::iterator iterator;
|
||||
typedef SymbolPtrVec::const_iterator const_iterator;
|
||||
|
||||
+161
-128
@@ -65,7 +65,8 @@ ASTfunction_declaration::typecheck(TypeSpec expected)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTvariable_declaration::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTvariable_declaration::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
typecheck_children(m_typespec);
|
||||
ASTNode* init = this->init().get();
|
||||
@@ -79,7 +80,7 @@ TypeSpec ASTvariable_declaration::typecheck(TypeSpec /*expected*/)
|
||||
if (m_typespec.is_structure() && !m_initlist
|
||||
&& et.structure() != vt.structure()) {
|
||||
// Can't do: struct foo = 1
|
||||
errorf("Cannot initialize %s %s = %s", vt, name(), et);
|
||||
errorfmt("Cannot initialize {} {} = {}", vt, name(), et);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ TypeSpec ASTvariable_declaration::typecheck(TypeSpec /*expected*/)
|
||||
// typecheck method.
|
||||
if (init->nodetype() == compound_initializer_node) {
|
||||
if (init->nextptr())
|
||||
errorf("compound_initializer should be the only initializer");
|
||||
errorfmt("compound_initializer should be the only initializer");
|
||||
init = ((ASTcompound_initializer*)init)->initlist().get();
|
||||
if (!init)
|
||||
return m_typespec;
|
||||
@@ -106,10 +107,10 @@ TypeSpec ASTvariable_declaration::typecheck(TypeSpec /*expected*/)
|
||||
if (!assignable(vt, et)) {
|
||||
// Special case: for int=float, it's just a warning.
|
||||
if (vt.is_int() && et.is_float())
|
||||
warningf("Assignment may lose precision: %s %s = %s", vt, name(),
|
||||
et);
|
||||
warningfmt("Assignment may lose precision: {} {} = {}", vt, name(),
|
||||
et);
|
||||
else
|
||||
errorf("Cannot assign %s %s = %s", vt, name(), et);
|
||||
errorfmt("Cannot assign {} {} = {}", vt, name(), et);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -118,7 +119,8 @@ TypeSpec ASTvariable_declaration::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTvariable_ref::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTvariable_ref::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
m_is_lvalue = true; // A var ref is an lvalue
|
||||
return m_typespec;
|
||||
@@ -126,7 +128,8 @@ TypeSpec ASTvariable_ref::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTpreincdec::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTpreincdec::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
typecheck_children();
|
||||
m_is_lvalue = var()->is_lvalue();
|
||||
@@ -136,11 +139,12 @@ TypeSpec ASTpreincdec::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTpostincdec::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTpostincdec::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
typecheck_children();
|
||||
if (!var()->is_lvalue())
|
||||
errorf("%s can only be applied to an lvalue", nodetypename());
|
||||
errorfmt("{} can only be applied to an lvalue", nodetypename());
|
||||
m_is_lvalue = false;
|
||||
m_typespec = var()->typespec();
|
||||
return m_typespec;
|
||||
@@ -148,29 +152,30 @@ TypeSpec ASTpostincdec::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTindex::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTindex::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
typecheck_children();
|
||||
const char* indextype = "";
|
||||
TypeSpec t = lvalue()->typespec();
|
||||
if (t.is_structure()) {
|
||||
errorf("Cannot use [] indexing on a struct");
|
||||
errorfmt("Cannot use [] indexing on a struct");
|
||||
return TypeSpec();
|
||||
}
|
||||
if (t.is_closure()) {
|
||||
errorf("Cannot use [] indexing on a closure");
|
||||
errorfmt("Cannot use [] indexing on a closure");
|
||||
return TypeSpec();
|
||||
}
|
||||
if (index3()) {
|
||||
if (!t.is_array() && !t.elementtype().is_matrix())
|
||||
errorf("[][][] only valid for a matrix array");
|
||||
errorfmt("[][][] only valid for a matrix array");
|
||||
m_typespec = TypeDesc::FLOAT;
|
||||
} else if (t.is_array()) {
|
||||
indextype = "array";
|
||||
m_typespec = t.elementtype();
|
||||
if (index2()) {
|
||||
if (t.aggregate() == TypeDesc::SCALAR)
|
||||
errorf("can't use [][] on a simple array");
|
||||
errorfmt("can't use [][] on a simple array");
|
||||
m_typespec = TypeDesc::FLOAT;
|
||||
}
|
||||
} else if (t.aggregate() == TypeDesc::VEC3) {
|
||||
@@ -180,7 +185,7 @@ TypeSpec ASTindex::typecheck(TypeSpec /*expected*/)
|
||||
tnew.vecsemantics = TypeDesc::NOXFORM;
|
||||
m_typespec = tnew;
|
||||
if (index2())
|
||||
errorf("can't use [][] on a %s", t);
|
||||
errorfmt("can't use [][] on a {}", t);
|
||||
} else if (t.aggregate() == TypeDesc::MATRIX44) {
|
||||
indextype = "component";
|
||||
TypeDesc tnew = t.simpletype();
|
||||
@@ -188,17 +193,18 @@ TypeSpec ASTindex::typecheck(TypeSpec /*expected*/)
|
||||
tnew.vecsemantics = TypeDesc::NOXFORM;
|
||||
m_typespec = tnew;
|
||||
if (!index2())
|
||||
errorf("must use [][] on a matrix, not just []");
|
||||
errorfmt("must use [][] on a matrix, not just []");
|
||||
} else {
|
||||
errorf("can only use [] indexing for arrays or multi-component types");
|
||||
errorfmt(
|
||||
"can only use [] indexing for arrays or multi-component types");
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
// Make sure the indices (children 1+) are integers
|
||||
for (size_t c = 1; c < nchildren(); ++c)
|
||||
if (!child(c)->typespec().is_int())
|
||||
errorf("%s index must be an integer, not a %s", indextype,
|
||||
index()->typespec());
|
||||
errorfmt("{} index must be an integer, not a {}", indextype,
|
||||
index()->typespec());
|
||||
|
||||
// If the thing we're indexing is an lvalue, so is the indexed element
|
||||
m_is_lvalue = lvalue()->is_lvalue();
|
||||
@@ -230,7 +236,8 @@ ASTstructselect::typecheck(TypeSpec expected)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTconditional_statement::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTconditional_statement::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
typecheck_list(cond());
|
||||
m_compiler->push_nesting(false);
|
||||
@@ -240,15 +247,16 @@ TypeSpec ASTconditional_statement::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
TypeSpec c = cond()->typespec();
|
||||
if (c.is_structure())
|
||||
errorf("Cannot use a struct as an 'if' condition");
|
||||
errorfmt("Cannot use a struct as an 'if' condition");
|
||||
if (c.is_array())
|
||||
errorf("Cannot use an array as an 'if' condition");
|
||||
errorfmt("Cannot use an array as an 'if' condition");
|
||||
return m_typespec = TypeDesc(TypeDesc::NONE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTloop_statement::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTloop_statement::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
typecheck_list(init());
|
||||
m_compiler->push_nesting(true);
|
||||
@@ -259,34 +267,36 @@ TypeSpec ASTloop_statement::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
TypeSpec c = cond()->typespec();
|
||||
if (c.is_closure())
|
||||
errorf("Cannot use a closure as an '%s' condition", opname());
|
||||
errorfmt("Cannot use a closure as an '{}' condition", opname());
|
||||
if (c.is_structure())
|
||||
errorf("Cannot use a struct as an '%s' condition", opname());
|
||||
errorfmt("Cannot use a struct as an '{}' condition", opname());
|
||||
if (c.is_array())
|
||||
errorf("Cannot use an array as an '%s' condition", opname());
|
||||
errorfmt("Cannot use an array as an '{}' condition", opname());
|
||||
return m_typespec = TypeDesc(TypeDesc::NONE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTloopmod_statement::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTloopmod_statement::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
if (m_compiler->nesting_level(true /*loops*/) < 1)
|
||||
errorf("Cannot '%s' here -- not inside a loop.", opname());
|
||||
errorfmt("Cannot '{}' here -- not inside a loop.", opname());
|
||||
return m_typespec = TypeDesc(TypeDesc::NONE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTassign_expression::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTassign_expression::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
TypeSpec vt = var()->typecheck(); // Type of the variable
|
||||
TypeSpec et = expr()->typecheck(vt); // Type of the expression assigned
|
||||
m_typespec = vt;
|
||||
|
||||
if (!var()->is_lvalue()) {
|
||||
errorf("Can't assign via %s to something that isn't an lvalue",
|
||||
opname());
|
||||
errorfmt("Can't assign via {} to something that isn't an lvalue",
|
||||
opname());
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
@@ -307,7 +317,7 @@ TypeSpec ASTassign_expression::typecheck(TypeSpec /*expected*/)
|
||||
return m_typespec;
|
||||
}
|
||||
}
|
||||
errorf("Cannot assign %s %s = %s", vt, varname, et);
|
||||
errorfmt("Cannot assign {} {} = {}", vt, varname, et);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -326,7 +336,7 @@ TypeSpec ASTassign_expression::typecheck(TypeSpec /*expected*/)
|
||||
if (vts == ets)
|
||||
return m_typespec = vt;
|
||||
// Otherwise, a structure mismatch
|
||||
errorf("Cannot assign %s %s = %s", vt, varname, et);
|
||||
errorfmt("Cannot assign {} {} = {}", vt, varname, et);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -334,10 +344,10 @@ TypeSpec ASTassign_expression::typecheck(TypeSpec /*expected*/)
|
||||
if (!assignable(vt, et)) {
|
||||
// Special case: for int=float, it's just a warning.
|
||||
if (vt.is_int() && et.is_float())
|
||||
warningf("Assignment may lose precision: %s %s = %s", vt, varname,
|
||||
et);
|
||||
warningfmt("Assignment may lose precision: {} {} = {}", vt, varname,
|
||||
et);
|
||||
else
|
||||
errorf("Cannot assign %s %s = %s", vt, varname, et);
|
||||
errorfmt("Cannot assign {} {} = {}", vt, varname, et);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -346,7 +356,8 @@ TypeSpec ASTassign_expression::typecheck(TypeSpec /*expected*/)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTreturn_statement::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTreturn_statement::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
FunctionSymbol* myfunc = m_compiler->current_function();
|
||||
if (myfunc) {
|
||||
@@ -357,14 +368,14 @@ TypeSpec ASTreturn_statement::typecheck(TypeSpec /*expected*/)
|
||||
// will also catch returning a value from a void function.
|
||||
TypeSpec et = expr()->typecheck(myfunc->typespec());
|
||||
if (!assignable(myfunc->typespec(), et)) {
|
||||
errorf("Cannot return a '%s' from '%s %s()'", et,
|
||||
myfunc->typespec(), myfunc->name());
|
||||
errorfmt("Cannot return a '{}' from '{} {}()'", et,
|
||||
myfunc->typespec(), myfunc->name());
|
||||
}
|
||||
} else {
|
||||
// If we are not returning a value, it must be a void function.
|
||||
if (!myfunc->typespec().is_void())
|
||||
errorf("You must return a '%s' from function '%s'",
|
||||
myfunc->typespec(), myfunc->name());
|
||||
errorfmt("You must return a '{}' from function '{}'",
|
||||
myfunc->typespec(), myfunc->name());
|
||||
}
|
||||
myfunc->encountered_return();
|
||||
} else {
|
||||
@@ -372,7 +383,7 @@ TypeSpec ASTreturn_statement::typecheck(TypeSpec /*expected*/)
|
||||
// be from the main shader body. That's fine (it's equivalent
|
||||
// to calling exit()), but it can't return a value.
|
||||
if (expr())
|
||||
errorf("Cannot return a value from a shader body");
|
||||
errorfmt("Cannot return a value from a shader body");
|
||||
}
|
||||
return TypeSpec(); // TODO: what should be returned here?
|
||||
}
|
||||
@@ -402,14 +413,14 @@ ASTunary_expression::typecheck(TypeSpec expected)
|
||||
}
|
||||
|
||||
if (t.is_structure() || t.is_array()) {
|
||||
errorf("Can't do '%s' to a %s.", opname(), t);
|
||||
errorfmt("Can't do '{}' to a {}.", opname(), t);
|
||||
return TypeSpec();
|
||||
}
|
||||
switch (m_op) {
|
||||
case Sub:
|
||||
case Add:
|
||||
if (!(t.is_closure() || t.is_numeric())) {
|
||||
errorf("Can't do '%s' to a %s.", opname(), t);
|
||||
errorfmt("Can't do '{}' to a {}.", opname(), t);
|
||||
return TypeSpec();
|
||||
}
|
||||
m_typespec = t;
|
||||
@@ -419,12 +430,12 @@ ASTunary_expression::typecheck(TypeSpec expected)
|
||||
break;
|
||||
case Compl:
|
||||
if (!t.is_int()) {
|
||||
errorf("Operator '~' can only be done to an int");
|
||||
errorfmt("Operator '~' can only be done to an int");
|
||||
return TypeSpec();
|
||||
}
|
||||
m_typespec = t;
|
||||
break;
|
||||
default: errorf("unknown unary operator");
|
||||
default: errorfmt("unknown unary operator");
|
||||
}
|
||||
return m_typespec;
|
||||
}
|
||||
@@ -467,7 +478,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
|
||||
TypeSpec returntype = m_compiler->type_from_code(code, &advance);
|
||||
code += advance;
|
||||
if (code[0] && check_simple_arg(l, code, true) && code[0]
|
||||
&& check_simple_arg(r, code, true) && !code[0]) {
|
||||
&& check_simple_arg(r, code, true) && !code[0]) { // NOSONAR
|
||||
return m_typespec = returntype;
|
||||
}
|
||||
}
|
||||
@@ -477,7 +488,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
|
||||
|
||||
// No binary ops work on structs or arrays
|
||||
if (l.is_structure() || r.is_structure() || l.is_array() || r.is_array()) {
|
||||
errorf("Not allowed: '%s %s %s'", l, opname(), r);
|
||||
errorfmt("Not allowed: '{} {} {}'", l, opname(), r);
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
@@ -507,7 +518,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
|
||||
return m_typespec = TypeDesc::TypeInt;
|
||||
}
|
||||
// If we got this far, it's an op that's not allowed
|
||||
errorf("Not allowed: '%s %s %s'", l, opname(), r);
|
||||
errorfmt("Not allowed: '{} {} {}'", l, opname(), r);
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
@@ -581,11 +592,11 @@ ASTbinary_expression::typecheck(TypeSpec expected)
|
||||
// nonzeroness), but always return int.
|
||||
return m_typespec = TypeDesc::TypeInt;
|
||||
|
||||
default: errorf("unknown binary operator");
|
||||
default: errorfmt("unknown binary operator");
|
||||
}
|
||||
|
||||
// If we got this far, it's an op that's not allowed
|
||||
errorf("Not allowed: '%s %s %s'", l, opname(), r);
|
||||
errorfmt("Not allowed: '{} {} {}'", l, opname(), r);
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
@@ -600,15 +611,15 @@ ASTternary_expression::typecheck(TypeSpec expected)
|
||||
TypeSpec f = typecheck_list(falseexpr(), expected);
|
||||
|
||||
if (c.is_closure())
|
||||
errorf("Cannot use a closure as a condition");
|
||||
errorfmt("Cannot use a closure as a condition");
|
||||
if (c.is_structure())
|
||||
errorf("Cannot use a struct as a condition");
|
||||
errorfmt("Cannot use a struct as a condition");
|
||||
if (c.is_array())
|
||||
errorf("Cannot use an array as a condition");
|
||||
errorfmt("Cannot use an array as a condition");
|
||||
|
||||
// No arrays
|
||||
if (t.is_array() || t.is_array()) {
|
||||
errorf("Not allowed: '%s ? %s : %s'", c, t, f);
|
||||
if (t.is_array() || f.is_array()) {
|
||||
errorfmt("Not allowed: '{} ? {} : {}'", c, t, f);
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
@@ -617,7 +628,7 @@ ASTternary_expression::typecheck(TypeSpec expected)
|
||||
if (assignable(t, f) || assignable(f, t))
|
||||
m_typespec = higherprecision(t.simpletype(), f.simpletype());
|
||||
else
|
||||
errorf("Not allowed: '%s ? %s : %s'", c, t, f);
|
||||
errorfmt("Not allowed: '{} ? {} : {}'", c, t, f);
|
||||
|
||||
return m_typespec;
|
||||
}
|
||||
@@ -634,7 +645,8 @@ ASTcomma_operator::typecheck(TypeSpec expected)
|
||||
|
||||
|
||||
|
||||
TypeSpec ASTtypecast_expression::typecheck(TypeSpec /*expected*/)
|
||||
TypeSpec
|
||||
ASTtypecast_expression::typecheck(TypeSpec /*expected*/)
|
||||
{
|
||||
// FIXME - closures
|
||||
typecheck_children(m_typespec);
|
||||
@@ -642,7 +654,7 @@ TypeSpec ASTtypecast_expression::typecheck(TypeSpec /*expected*/)
|
||||
if (!assignable(m_typespec, t) && !(m_typespec.is_int() && t.is_float())
|
||||
&& // (int)float is ok
|
||||
!(m_typespec.is_triple() && t.is_triple()))
|
||||
errorf("Cannot cast '%s' to '%s'", t, m_typespec);
|
||||
errorfmt("Cannot cast '{}' to '{}'", t, m_typespec);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -666,7 +678,7 @@ ASTtype_constructor::typecheck(TypeSpec expected, bool report, bool bind)
|
||||
if (expected.is_float()) {
|
||||
patterns = float_patterns;
|
||||
argexpected = TypeDesc::FLOAT;
|
||||
// ^^^ Since simetimes tht constructor `float(expr)` is used as a
|
||||
// ^^^ Since sometimes the constructor `float(expr)` is used as a
|
||||
// synonym for a cast `(float)expr`, we know that ambiguously typed
|
||||
// expressions should favor disambiguating to a float.
|
||||
} else if (expected.is_triple()) {
|
||||
@@ -686,7 +698,7 @@ ASTtype_constructor::typecheck(TypeSpec expected, bool report, bool bind)
|
||||
patterns = int_patterns;
|
||||
} else {
|
||||
if (report)
|
||||
errorf("Cannot construct type '%s'", expected);
|
||||
errorfmt("Cannot construct type '{}'", expected);
|
||||
return TypeSpec();
|
||||
}
|
||||
|
||||
@@ -706,15 +718,15 @@ ASTtype_constructor::typecheck(TypeSpec expected, bool report, bool bind)
|
||||
|
||||
// If we made it this far, no match could be found.
|
||||
if (report) {
|
||||
std::string err = OIIO::Strutil::sprintf("Cannot construct %s (",
|
||||
expected);
|
||||
std::string err = OIIO::Strutil::fmt::format("Cannot construct {} (",
|
||||
expected);
|
||||
for (ref a = args(); a; a = a->next()) {
|
||||
err += a->typespec().string();
|
||||
if (a->next())
|
||||
err += ", ";
|
||||
}
|
||||
err += ")";
|
||||
errorf("%s", err);
|
||||
errorfmt("{}", err);
|
||||
// FIXME -- it might be nice here to enumerate for the user all the
|
||||
// valid combinations.
|
||||
}
|
||||
@@ -750,7 +762,7 @@ public:
|
||||
|
||||
~TypeAdjuster()
|
||||
{
|
||||
// Commit infered types of all ASTcompound_initializers scanned.
|
||||
// Commit inferred types of all ASTcompound_initializers scanned.
|
||||
if (m_success) {
|
||||
for (auto&& initer : m_adjust) {
|
||||
ASTcompound_initializer* ciptr = std::get<0>(initer);
|
||||
@@ -775,9 +787,9 @@ public:
|
||||
if (m_mode & must_init_all) {
|
||||
m_success = false;
|
||||
if (errors()) {
|
||||
cinit->errorf("Empty initializer list not allowed to"
|
||||
"represent '%' here",
|
||||
to);
|
||||
cinit->errorfmt("Empty initializer list not allowed to "
|
||||
"represent '{}' here",
|
||||
to);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -840,9 +852,9 @@ public:
|
||||
|
||||
m_success = false;
|
||||
if (errors()) {
|
||||
init->errorf("Too %s initializers for a '%s'",
|
||||
nelem < expected.arraylength() ? "few" : "many",
|
||||
expected);
|
||||
init->errorfmt("Too {} initializers for a '{}'",
|
||||
nelem < expected.arraylength() ? "few" : "many",
|
||||
expected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,9 +900,9 @@ public:
|
||||
|
||||
m_success = false;
|
||||
if (errors() && (arg || nfields > ninits)) {
|
||||
parent->errorf("Too %s initializers for struct '%s'",
|
||||
ninits < nfields ? "few" : "many",
|
||||
structspec->name());
|
||||
parent->errorfmt("Too {} initializers for struct '{}'",
|
||||
ninits < nfields ? "few" : "many",
|
||||
structspec->name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,9 +992,9 @@ private:
|
||||
const StructSpec::FieldSpec* field = nullptr)
|
||||
{
|
||||
if (node->typecheck(expected) != expected &&
|
||||
// Alllow assignment with comparable type
|
||||
// Allow assignment with comparable type
|
||||
!assignable(expected, node->typespec()) &&
|
||||
// Alllow closure assignments to '0'
|
||||
// Allow closure assignments to '0'
|
||||
!(expected.is_closure() && !node->typespec().is_closure()
|
||||
&& node->typespec().is_int_or_float()
|
||||
&& node->nodetype() == literal_node
|
||||
@@ -992,11 +1004,11 @@ private:
|
||||
return false;
|
||||
|
||||
OSL_DASSERT(!spec || field);
|
||||
node->errorf("Can't assign '%s' to '%s%s'", node->typespec(),
|
||||
expected,
|
||||
!spec ? ""
|
||||
: Strutil::sprintf(" %s.%s", spec->name(),
|
||||
field->name));
|
||||
node->errorfmt("Can't assign '{}' to '{}{}'", node->typespec(),
|
||||
expected,
|
||||
!spec ? ""
|
||||
: Strutil::fmt::format(" {}.{}", spec->name(),
|
||||
field->name));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1010,7 +1022,7 @@ ASTcompound_initializer::typecheck(TypeSpec expected, unsigned mode)
|
||||
if (m_ctor || m_typespec.is_structure_based()
|
||||
|| m_typespec.simpletype().basetype != TypeDesc::UNKNOWN) {
|
||||
if (m_typespec != expected)
|
||||
errorf("Cannot construct type '%s'", expected);
|
||||
errorfmt("Cannot construct type '{}'", expected);
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
@@ -1053,6 +1065,8 @@ bool
|
||||
ASTNode::check_arglist(const char* /*funcname*/, ASTNode::ref arg,
|
||||
const char* formals, bool coerce, bool bind)
|
||||
{
|
||||
if (!formals)
|
||||
return false;
|
||||
// std::cerr << "ca " << funcname << " formals='" << formals << "\n";
|
||||
for (; arg; arg = arg->next()) {
|
||||
if (!*formals) // More formal args, but no more actual args
|
||||
@@ -1188,14 +1202,14 @@ ASTfunction_call::typecheck_printf_args(const char* format, ASTNode* arg)
|
||||
++format;
|
||||
char formatchar = *format++; // Also eat the format char
|
||||
if (!arg) {
|
||||
errorf(
|
||||
"%s has mismatched format string and arguments (not enough args)",
|
||||
errorfmt(
|
||||
"{} has mismatched format string and arguments (not enough args)",
|
||||
m_name);
|
||||
return false;
|
||||
}
|
||||
if (arg->typespec().is_structure_based()) {
|
||||
errorf("struct '%s' is not a valid argument",
|
||||
arg->typespec().structspec()->name());
|
||||
errorfmt("struct '{}' is not a valid argument",
|
||||
arg->typespec().structspec()->name());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1205,16 +1219,16 @@ ASTfunction_call::typecheck_printf_args(const char* format, ASTNode* arg)
|
||||
if ((arg->typespec().is_closure_based()
|
||||
|| simpletype.basetype == TypeDesc::STRING)
|
||||
&& formatchar != 's') {
|
||||
errorf(
|
||||
"%s has mismatched format string and arguments (arg %d needs %%s)",
|
||||
errorfmt(
|
||||
"{} has mismatched format string and arguments (arg {} needs %s)",
|
||||
m_name);
|
||||
return false;
|
||||
}
|
||||
if (simpletype.basetype == TypeDesc::INT && formatchar != 'd'
|
||||
&& formatchar != 'i' && formatchar != 'o' && formatchar != 'x'
|
||||
&& formatchar != 'X') {
|
||||
errorf(
|
||||
"%s has mismatched format string and arguments (arg %d needs %%d, %%i, %%o, %%x, or %%X)",
|
||||
errorfmt(
|
||||
"{} has mismatched format string and arguments (arg {} needs %d, %i, %o, %x, or %X)",
|
||||
m_name, argnum);
|
||||
return false;
|
||||
}
|
||||
@@ -1222,8 +1236,8 @@ ASTfunction_call::typecheck_printf_args(const char* format, ASTNode* arg)
|
||||
&& formatchar != 'g' && formatchar != 'c' && formatchar != 'e'
|
||||
&& formatchar != 'm' && formatchar != 'n' && formatchar != 'p'
|
||||
&& formatchar != 'v') {
|
||||
errorf(
|
||||
"%s has mismatched format string and arguments (arg %d needs %%f, %%g, or %%e)",
|
||||
errorfmt(
|
||||
"{} has mismatched format string and arguments (arg {} needs %f, %g, or %e)",
|
||||
m_name, argnum);
|
||||
return false;
|
||||
}
|
||||
@@ -1236,8 +1250,8 @@ ASTfunction_call::typecheck_printf_args(const char* format, ASTNode* arg)
|
||||
}
|
||||
}
|
||||
if (arg) {
|
||||
errorf("%s has mismatched format string and arguments (too many args)",
|
||||
m_name);
|
||||
errorfmt("{} has mismatched format string and arguments (too many args)",
|
||||
m_name);
|
||||
return false;
|
||||
}
|
||||
return true; // all ok
|
||||
@@ -1303,8 +1317,8 @@ ASTfunction_call::typecheck_builtin_specialcase()
|
||||
arg = arg->nextptr();
|
||||
typecheck_printf_args(format, arg);
|
||||
} else {
|
||||
warningf("%s() uses a format string that is not a constant.",
|
||||
m_name);
|
||||
warningfmt("{}() uses a format string that is not a constant.",
|
||||
m_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,8 +1393,8 @@ ASTfunction_call::typecheck_struct_constructor()
|
||||
m_typespec = m_sym->typespec();
|
||||
if (structspec->numfields() != (int)listlength(args())) {
|
||||
// Support a single argument which is an init-list of proper type?
|
||||
errorf(
|
||||
"Constructor for '%s' has the wrong number of arguments (expected %d, got %d)",
|
||||
errorfmt(
|
||||
"Constructor for '{}' has the wrong number of arguments (expected {}, got {})",
|
||||
structspec->name(), structspec->numfields(), listlength(args()));
|
||||
}
|
||||
|
||||
@@ -1607,7 +1621,7 @@ class CandidateFunctions {
|
||||
|
||||
default:
|
||||
// TODO: Scoring default function arguments would go here
|
||||
// Curently an unused formal argument, so no match at all.
|
||||
// Currently an unused formal argument, so no match at all.
|
||||
return kNoMatch;
|
||||
}
|
||||
OSL_DASSERT(*formals == 0);
|
||||
@@ -1672,8 +1686,8 @@ public:
|
||||
comma = ", ";
|
||||
}
|
||||
argstr += ")";
|
||||
return Strutil::sprintf("%s '%s'%s\n", msg, argstr,
|
||||
candidateMsg ? "\n Candidates are:" : "");
|
||||
return Strutil::fmt::format("{} '{}'{}\n", msg, argstr,
|
||||
candidateMsg ? "\n Candidates are:" : "");
|
||||
}
|
||||
|
||||
std::string reportFunction(FunctionSymbol* sym) const
|
||||
@@ -1684,10 +1698,10 @@ public:
|
||||
formals += advance;
|
||||
std::string msg = " ";
|
||||
if (ASTNode* decl = sym->node())
|
||||
msg += Strutil::sprintf("%s:%d\t", decl->sourcefile(),
|
||||
decl->sourceline());
|
||||
msg += Strutil::sprintf("%s %s (%s)\n", returntype, sym->name(),
|
||||
m_compiler->typelist_from_code(formals));
|
||||
msg += Strutil::fmt::format("{}:{}\t", decl->sourcefile(),
|
||||
decl->sourceline());
|
||||
msg += Strutil::fmt::format("{} {} ({})\n", returntype, sym->name(),
|
||||
m_compiler->typelist_from_code(formals));
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -1715,7 +1729,7 @@ public:
|
||||
"No matching function call to");
|
||||
for (FunctionSymbol* f = m_called; f; f = f->nextpoly())
|
||||
errmsg += reportFunction(f);
|
||||
caller->errorf("%s", errmsg);
|
||||
caller->errorfmt("{}", errmsg);
|
||||
return { nullptr, TypeSpec() };
|
||||
|
||||
case 1: // Success
|
||||
@@ -1840,17 +1854,17 @@ public:
|
||||
= reportAmbiguity(funcname, !warn /* "Candidates are" msg*/,
|
||||
"Ambiguous call to");
|
||||
if (warn) {
|
||||
errmsg += Strutil::sprintf(" Chosen function is:\n%s",
|
||||
reportFunction(c.first->sym));
|
||||
errmsg += Strutil::fmt::format(" Chosen function is:\n{}",
|
||||
reportFunction(c.first->sym));
|
||||
errmsg += " Other candidates are:\n";
|
||||
for (auto& candidate : m_candidates)
|
||||
if (candidate.sym != c.first->sym)
|
||||
errmsg += reportFunction(candidate.sym);
|
||||
caller->warningf("%s", errmsg);
|
||||
caller->warningfmt("{}", errmsg);
|
||||
} else {
|
||||
for (auto& candidate : m_candidates)
|
||||
errmsg += reportFunction(candidate.sym);
|
||||
caller->errorf("%s", errmsg);
|
||||
caller->errorfmt("{}", errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1982,7 +1996,7 @@ ASTfunction_call::typecheck(TypeSpec expected)
|
||||
any_args_are_compound_initializers = true;
|
||||
}
|
||||
|
||||
// Save the currently choosen symbol for error reporting later
|
||||
// Save the currently chosen symbol for error reporting later
|
||||
FunctionSymbol* poly = func();
|
||||
|
||||
CandidateFunctions candidates(m_compiler, expected, args(), poly);
|
||||
@@ -2013,9 +2027,9 @@ ASTfunction_call::typecheck(TypeSpec expected)
|
||||
if (Strutil::iequals(OSL_LEGACY, "use"))
|
||||
m_sym = legacy;
|
||||
if (as_warning)
|
||||
warningf("overload chosen differs from OSL 1.9\n%s", errmsg);
|
||||
warningfmt("overload chosen differs from OSL 1.9\n{}", errmsg);
|
||||
else
|
||||
errorf("overload chosen differs from OSL 1.9\n%s", errmsg);
|
||||
errorfmt("overload chosen differs from OSL 1.9\n{}", errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2036,21 +2050,40 @@ ASTfunction_call::typecheck(TypeSpec expected)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_sym != nullptr) {
|
||||
if (is_user_function()) {
|
||||
if (func()->number_of_returns() == 0
|
||||
&& !func()->typespec().is_void()) {
|
||||
errorf("non-void function \"%s\" had no 'return' statement.",
|
||||
func()->name());
|
||||
if (!m_sym)
|
||||
return TypeSpec(); // no match found
|
||||
|
||||
// Double check that any variables we pass to output params of the
|
||||
// function are themselves writable.
|
||||
if (is_user_function()) {
|
||||
ASTfunction_declaration* uf = user_function();
|
||||
int i = 0;
|
||||
ASTNode* f = uf->formals().get(); // formal param
|
||||
ASTNode* a = args().get(); // actual param
|
||||
for (; f && a; f = f->nextptr(), a = a->nextptr(), ++i) {
|
||||
OSL_DASSERT(f->nodetype() == ASTNode::variable_declaration_node);
|
||||
auto formal = (ASTvariable_declaration*)f;
|
||||
Symbol* dest_sym = nullptr;
|
||||
if (formal->is_output()
|
||||
&& !check_symbol_writeability(a, true, &dest_sym)) {
|
||||
OSL_DASSERT(dest_sym);
|
||||
warningfmt(
|
||||
"cannot write to non-output parameter \"{}\", as passed to function {}() as arg {} (output parameter \"{}\")",
|
||||
dest_sym->name(), func()->name(), i + 1, formal->name());
|
||||
}
|
||||
} else {
|
||||
// built-in
|
||||
typecheck_builtin_specialcase();
|
||||
}
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
return TypeSpec();
|
||||
if (is_user_function()) {
|
||||
if (func()->number_of_returns() == 0 && !func()->typespec().is_void()) {
|
||||
errorfmt("non-void function \"{}\" had no 'return' statement.",
|
||||
func()->name());
|
||||
}
|
||||
} else {
|
||||
// built-in
|
||||
typecheck_builtin_specialcase();
|
||||
}
|
||||
return m_typespec;
|
||||
}
|
||||
|
||||
|
||||
@@ -2117,7 +2150,7 @@ static const char * builtin_func_args [] = {
|
||||
"fprintf", "xss*", "!printf", NULL,
|
||||
"getattribute", "is?", "is?[]", "iss?", "iss?[]", "isi?", "isi?[]", "issi?", "issi?[]", "!rw", NULL, // FIXME -- further checking?
|
||||
"getmessage", "is?", "is?[]", "iss?", "iss?[]", "!rw", NULL,
|
||||
"gettextureinfo", "iss?", "iss?[]", "!rw", NULL, // FIXME -- further checking?
|
||||
"gettextureinfo", "iss?", "iss?[]", "isffs?", "isffs?[]", "!rw", NULL, // FIXME -- further checking?
|
||||
"hashnoise", NOISE_ARGS, NULL,
|
||||
"isconnected", "i?", NULL,
|
||||
"isconstant", "i?", NULL,
|
||||
@@ -2299,7 +2332,7 @@ OSLCompilerImpl::code_from_type(TypeSpec type) const
|
||||
std::string out;
|
||||
TypeDesc elem = type.elementtype().simpletype();
|
||||
if (type.is_structure() || type.is_structure_array()) {
|
||||
out = Strutil::sprintf("S%d", type.structure());
|
||||
out = Strutil::fmt::format("S{}", type.structure());
|
||||
} else if (type.is_closure() || type.is_closure_array()) {
|
||||
out = 'C';
|
||||
} else {
|
||||
@@ -2333,7 +2366,7 @@ OSLCompilerImpl::code_from_type(TypeSpec type) const
|
||||
if (type.is_unsized_array())
|
||||
out += "[]";
|
||||
else
|
||||
out += Strutil::sprintf("[%d]", type.arraylength());
|
||||
out += Strutil::fmt::format("[{}]", type.arraylength());
|
||||
}
|
||||
|
||||
return out;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user