Ansariel 2025-09-22 22:52:19 +02:00
commit 859ded3c58
341 changed files with 4312 additions and 4428 deletions

View File

@ -42,7 +42,7 @@ jobs:
needs: setup
strategy:
matrix:
runner: ${{ fromJson((github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/Second_Life')) && '["windows-large","macos-15-xlarge"]' || '["windows-latest","macos-15"]') }}
runner: ${{ fromJson((github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/Second_Life')) && '["windows-large","macos-15-xlarge"]' || '["windows-2022","macos-15-xlarge"]') }}
configuration: ${{ fromJson(needs.setup.outputs.configurations) }}
runs-on: ${{ matrix.runner }}
outputs:
@ -64,7 +64,7 @@ jobs:
# autobuild-package.xml.
AUTOBUILD_VCS_INFO: "true"
AUTOBUILD_VSVER: "170"
DEVELOPER_DIR: "/Applications/Xcode_16.1.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_16.4.app/Contents/Developer"
# Ensure that Linden viewer builds engage Bugsplat.
BUGSPLAT_DB: ${{ needs.setup.outputs.bugsplat_db }}
build_coverity: false
@ -93,12 +93,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Checkout build variables
uses: actions/checkout@v5
with:
repository: secondlife/build-variables
ref: master
ref: universal
path: .build-variables
- name: Checkout master-message-template
@ -306,7 +305,7 @@ jobs:
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
needs: build
runs-on: windows-latest
runs-on: windows-2022
steps:
- name: Sign and package Windows viewer
if: env.AZURE_KEY_VAULT_URI && env.AZURE_CERT_NAME && env.AZURE_CLIENT_ID && env.AZURE_CLIENT_SECRET && env.AZURE_TENANT_ID

View File

@ -23,4 +23,4 @@ jobs:
path-to-signatures: signatures.json
remote-organization-name: secondlife
remote-repository-name: cla-signatures
allowlist: callum@mbp.localdomain,rye@lindenlab.com
allowlist: callum@mbp.localdomain,rye@lindenlab.com,rye

1
.gitignore vendored
View File

@ -28,7 +28,6 @@ debian/files
debian/secondlife-appearance-utility*
debian/secondlife-viewer*
indra/.distcc
indra/cmake/*
indra/out/*
indra/packages/*

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ retry_cmd()
build_dir_Darwin()
{
echo build-darwin-x86_64
echo build-darwin-universal
}
build_dir_Linux()
@ -158,6 +158,7 @@ pre_build()
if [[ "$arch" == "Darwin" ]]
then
HAVOK=OFF
SIGNING=("-DENABLE_SIGNING:BOOL=YES" \
"-DSIGNING_IDENTITY:STRING=Developer ID Application: Linden Research, Inc.")
fi
@ -387,7 +388,7 @@ do
if `cat "$build_dir/build_ok"`
then
case "$variant" in
Release)
Release*)
if [ -r "$build_dir/autobuild-package.xml" ]
then
begin_section "Autobuild metadata"

View File

@ -43,9 +43,22 @@ A few packages must be installed on the build system. Some may already be instal
sudo apt install libgl1-mesa-dev libglu1-mesa-dev libpulse-dev build-essential python3-pip git libssl-dev libxinerama-dev libxrandr-dev libfontconfig-dev libfreetype6-dev gcc-11 cmake
```
### Optional: Set up a Python virtual environment
If you do not want to install the required Python packages into the default Python directory, you can optionally create a virtual environment.
- Create the Python virtual environment (only once):
`python -m venv .venv`
- Activate the virtual environment:
`source .venv/bin/activate`
- Activate the virtual environment each time you want to build.
- Type all the subsequent commands in this virtual environment.
- In case of issue or Python update, you can delete this .venv directory and create a new virtual environment again.
### Install Autobuild
Autobuild is a Linden Lab resource that does all the hard work.
If you created a Python virtual environment, activate it first.
You can install it using the same versions as our automated builds as follows:
```
sudo pip3 install --upgrade pip
@ -156,27 +169,36 @@ This will set up to compile with all defaults and without non-default libraries.
Available premade firestorm-specific build targets:
```
ReleaseFS (includes KDU, FMOD)
ReleaseFS_open (no KDU, no FMOD)
RelWithDebInfoFS_open (no KDU, no FMOD)
ReleaseFS (with KDU, with FMOD, no OpenSim)
ReleaseFS_AVX (with KDU, with FMOD, no OpenSim, optimized for AVX-enabled CPUs)
ReleaseFS_AVX2 (with KDU, with FMOD, no OpenSim, optimized for AVX2-enabled CPUs)
ReleaseFS_open ( no KDU, no FMOD, no OpenSim)
ReleaseOS ( no KDU, no FMOD, with OpenSim)
RelWithDebInfoFS (with KDU, with FMOD, no OpenSim, with debug info)
RelWithDebInfoFS_open ( no KDU, no FMOD, no OpenSim, with debug info)
RelWithDebInfoOS ( no KDU, no FMOD, with OpenSim, with debug info)
```
### Configuration Switches
There are a number of switches you can use to modify the configuration process. The name of each switch is followed by its type and then by the value you want to set.
- **LL_TESTS** (bool) controls if the tests are compiled and run. There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
- **clean** will cause autobuild to remove any previously compiled objects and fetched packages. It can be useful if you need to force a reload of all packages
- **package** will result in a bzip2 archive of the completed viewer. Enabled by default, you would have to use **-DPACKAGE:BOOL=Off** to disable it
- **chan** will set a unique channel (and the name) for the viewer, appending whatever is defined to "Firestorm-". By default, the channel is "private" followed by your computer's name.
- **fmodstudio** will tell autobuiild to use the FmodStudio package when compiling.
- **-A \<architecture\>** sets the target architecture, that is if you want to build a 32bit or 64bit viewer (32bit is default if omitted). You probably want to set this to `-A 64`.
- **--avx** will enable AVX optimizations for AVX-enabled CPUs. Mutually exclusive with --avx2.
- **--avx2** will enable AVX2 optimizations for AVX2-enabled CPUs. Mutually exclusive with --avx.
- **--clean** will cause autobuild to remove any previously compiled objects and fetched packages. It can be useful if you need to force a reload of all packages
- **--fmodstudio** will tell autobuiild to use the FmodStudio package when compiling.
- **--kdu** will tell autobuiild to use the KDU (Kakadu) package when compiling.
- **--package** makes sure all files are copied into viewers output directory. It will also result in a bzip2 archive of the completed viewer. Enabled by default, you would have to use **-DPACKAGE:BOOL=Off** to disable it
- **--chan \<channel name\>** will set a unique channel (and the name) for the viewer, appending whatever is defined to "Firestorm-". By default, the channel is "private" followed by your computer's name.
- **-LL_TESTS:BOOL=\<bool\>** controls if the tests are compiled and run. There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
Most switches start with a double-dash (\--). And if you use any switches you must enclose them with a double-dash at the start and an optional double-dash at the end.
> [!TIP]
> **OFF** and **NO** are the same as **FALSE**; anything else is considered to be **TRUE**
Examples:
### Examples: ###
```
autobuild configure -A 64 -c ReleaseFS_open -- -DLL_TESTS:BOOL=FALSE

View File

@ -14,21 +14,33 @@ The steps listed below are expected to be run from a shell prompt. Simply copy a
You will need to install the following tools:
### Xcode
- Xcode, It's a free download from Apple, but the latest version (12.x) is too new, so you will need to get an older version.
- To download a version that will work (11.7 in this case), go [here](https://developer.apple.com/download) and log in with an apple ID.
- Either find the 11.7 download in the list or use this [direct link](https://download.developer.apple.com/Developer_Tools/Xcode_11.7/Xcode_11.7.xip) (will prompt you to log in if you skipped the above step.)
XCode is a free download from Apple but you will need an Apple ID to login and access the download section. The current version used to compile Firestorm is 16.4.
- Go [here](https://developer.apple.com/download) and log in with an apple ID.
- Either find the 16.4 download in the list or use this [direct link](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_16.4/Xcode_16.4.xip) (will prompt you to log in if you skipped the above step.)
- Open the downloaded file and copy the Xcode application to the Applications folder.
- Open Xcode at least once to set up everything to compile the viewer later on.
- Test by running `clang --version` from the terminal window.
- It should report version 11 something (Apple clang version 11.0.3 (clang-1103.0.32.62) for example.)
- If it reports version 12, something is messed up and you installed Xcode 12.
- It should report version 17 something (Apple clang version 17.0.0 (clang-1700.0.13.5) for example).
- If it reports an inferior version, something is messed up and you installed another version of XCode. It might still work, but the supported version is currently 16.4.
### CMake
- Download [CMake](http://www.cmake.org/download) version 3.16.0 or higher
- Download [CMake](http://www.cmake.org/download) version 4.1.1 or higher
- Open the downloaded file and copy CMake to the Applications folder.
- You will need to install the command line links manually. To do this, run from the terminal: `sudo /Applications/CMake.app/Contents/MacOS/CMake --install`
- Again, test by running: `cmake --version` from the terminal window.
### Optional: Set up a Python virtual environment
If you do not want to install the required Python packages into the default Python directory, you can optionally create a virtual environment.
- Create the Python virtual environment (only once):
`python -m venv .venv`
- Activate the virtual environment:
`source .venv/bin/activate`
- Activate the virtual environment each time you want to build.
- Type all the subsequent commands in this virtual environment.
- In case of issue or Python update, you can delete this .venv directory and create a new virtual environment again.
### Pip
The pip Python package installation tool is required for the next step. To install it, run from terminal:
```
@ -38,63 +50,34 @@ sudo python3 get-pip.py
### Autobuild
The Linden Lab [Autobuild](https://github.com/secondlife/autobuild) tool.
- Activate your Python virtual environment if you created one earlier
- Use the following command to install it on your machine:
```
pip3 install --user -r requirements.txt
```
If you created a Python virtual environment, autobuild will be located in .venv/bin/autobuild and already added to $PATH. But if you did not create a virtual environment, do the following:
- Add it to your PATH environment variable so it can be found by the shell. The macOS-approved way to do this is to issue the following command (This change will not take effect until the next time you open a Terminal window.):
```
echo '~/Library/Python/3.7/bin/' | sudo tee /etc/paths.d/99-autobuild
echo '~/Library/Python/3.9/bin/' | sudo tee /etc/paths.d/99-autobuild
```
- If you do not want to close and re-open your terminal, type the following to add it your PATH (otherwise if you did close it down, re-open it as shown above [here](#obtaining-a-shell-to-work-with)):
```
export PATH=$PATH:~/Library/Python/3.7/bin/
export PATH=$PATH:~/Library/Python/3.9/bin/
```
- Check Autobuild version to be "autobuild 3.9.3" or higher: `autobuild --version`
- Once Autobuild is correctly installed, check Autobuild version to be "autobuild 3.9.6" or higher: `autobuild --version`
### Additional third party libraries
If you want to use licensed FMOD Studio API or KDU build libraries (they are optional) you have to provide these yourself. If you're building Firestorm as part of the project team, ask for the libraries for fmodstudio and kdu. Put them into `/opt/firestorm`.
If you want to use licensed FMOD Studio API or KDU (short for Kakadu) build libraries (they are optional) you have to provide these yourself. If you're building Firestorm as part of the project team, ask for the libraries for fmodstudio and kdu. Put them into `/opt/firestorm`. Some libraries like Kakadu or Havok require that you purchase a license so do not set the flags to include those packages if you do not have the according licenses.
If you're a community builder, you'll need to build these libraries yourself, then change your autobuild.xml file to point to your own versions, or create a different autobuild.xml with your customizations, and use this with autobuild instead of our default autobuild.xml. There are some examples of how to build FMOD Studio on the LL Wiki and opensource-dev mailing list.
We've created a non-KDU build target to make this easier. Everywhere you see "ReleaseFS" below, use "ReleaseFS_open" instead. This will perform the same build, using openjpeg instead of KDU and omitting FMOD Studio.
Available premade firestorm-specific build targets:
```
ReleaseFS (includes KDU, FMOD)
ReleaseFS_open (no KDU, no FMOD)
RelWithDebInfo_open (no KDU, no FMOD)
```
To build firestorm:
```
autobuild build -c ReleaseFS
```
Other examples:
```
autobuild configure -c ReleaseFS # basic configuration step, don't build, just configure
autobuild configure -c ReleaseFS -- --clean # clean the output area first, then configure
autobuild configure -c ReleaseFS -- --chan Private-Yourname # configure with a custom channel
autobuild build -c ReleaseFS --no-configure # default quick rebuild
autobuild build -c ReleaseFS --no-configure -- --clean # Clean rebuild
autobuild configure -c ReleaseFS_open -- # configure with no third-party libraries
autobuild configure -c ReleaseFS_open -- --fmodstudio # configure with FMOD Studio but no KDU
```
Any of the configure options can also be used (and do the same thing) with the build options. Typical LL autobuild configure options should also work, as long as they don't duplicate configuration we are already doing.
Logs: Look for logs in `build-darwin-x86_64/logs`.
Output: Look for output in `build-darwin-x86_64/newview/Release`.
You will probably want to have FMOD enabled and no Kakadu, in that case, you can use the ReleaseFS_open target with the --fmodstudio switch.
## Set up your source code tree
@ -124,6 +107,44 @@ Again, if you do not wish to restart your terminal:
export AUTOBUILD_VARIABLES_FILE=~/firestorm/fs-build-variables/variables
```
## Firestorm build targets
Available premade firestorm-specific build targets:
```
ReleaseFS (with KDU, with FMOD, no OpenSim)
ReleaseFS_open ( no KDU, no FMOD, no OpenSim)
ReleaseOS ( no KDU, no FMOD, with OpenSim)
RelWithDebInfoFS (with KDU, with FMOD, no OpenSim, with debug info)
RelWithDebInfoFS_open ( no KDU, no FMOD, no OpenSim, with debug info)
RelWithDebInfoOS ( no KDU, no FMOD, with OpenSim, with debug info)
```
To build firestorm:
```
autobuild build -c ReleaseFS
```
Other examples:
```
autobuild configure -c ReleaseFS # basic configuration step, don't build, just configure
autobuild configure -c ReleaseFS -- --clean # clean the output area first, then configure
autobuild configure -c ReleaseFS -- --chan Private-Yourname # configure with a custom channel
autobuild build -c ReleaseFS --no-configure # default quick rebuild
autobuild build -c ReleaseFS --no-configure -- --clean # Clean rebuild
autobuild configure -c ReleaseFS_open -- # configure with no third-party libraries
autobuild configure -c ReleaseFS_open -- --fmodstudio # configure with FMOD Studio but no KDU
```
Any of the configure options can also be used (and do the same thing) with the build options. Typical LL autobuild configure options should also work, as long as they don't duplicate configuration we are already doing.
Logs: Look for logs in `build-darwin-x86_64/logs`.
Output: Look for output in `build-darwin-x86_64/newview/Release`.
## Prepare third party libraries
Most third party libraries needed to build the viewer will be automatically downloaded for you and installed into the build directory within your source tree during compilation. Some need to be manually prepared and are not normally required when using an open source configuration (ReleaseFS_open).
@ -149,7 +170,7 @@ autobuild build
autobuild package --results-file result.txt
```
Near the top of the output you will see the package name written:
Near the top of the output you will see the package name written (version might differ):
```
wrote /Users/yourname/3p-fmodstudio/fmodstudio-2.01.05-darwin-202981448.tar.bz2
@ -157,7 +178,7 @@ wrote /Users/yourname/3p-fmodstudio/fmodstudio-2.01.05-darwin-202981448.tar.bz2
Additionally, a file `result.txt` has been created containing the md5 hash value of the package file, which you will need in the next step.
- Next, update Firestorms autobuild.xml file to use your FMOD Studio.
- Next, make a copy of Firestorms autobuild.xml named for example my_autobuild.xml to use your FMOD Studio.
```
cd ~/firestorm/phoenix-firestorm
@ -192,13 +213,18 @@ This will configure the viewer for compiling with all defaults and without third
There are a number of switches you can use to modify the configuration process. The name of each switch is followed by its type and then by the value you want to set.
- FMODSTUDIO (bool) controls if the FMOD Studio package is incorporated into the viewer. You must have performed the FMOD Studio installation steps in [FMOD Studio using autobuild](#fmod-studio-using-autobuild) for this to work. This is the switch the --fmodstudio build argument sets.
- LL_TESTS (bool) controls if the tests are compiled and run. There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
- **-A \<architecture\>** sets the target architecture, that is if you want to build a 32bit or 64bit viewer (32bit is default if omitted). You probably want to set this to `-A 64`.
- **--clean** will cause autobuild to remove any previously compiled objects and fetched packages. It can be useful if you need to force a reload of all packages
- **--fmodstudio** controls if the FMOD Studio package is incorporated into the viewer. You must have performed the FMOD Studio installation steps in [FMOD Studio using autobuild](#fmod-studio-using-autobuild) for this to work.
- **--kdu** will tell autobuiild to use the KDU (Kakadu) package when compiling.
- **--package** makes sure all files are copied into viewers output directory. It will also generate a DMG installer package
- **--chan \<channel name\>** will set a unique channel (and the name) for the viewer, appending whatever is defined to "Firestorm-". By default, the channel is "private" followed by your computer's name.
- **-LL_TESTS:BOOL=\<bool\>** controls if the tests are compiled and run. There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
> [!TIP]
> OFF and NO are the same as FALSE; anything else is considered to be TRUE
> **OFF** and **NO** are the same as **FALSE**; anything else is considered to be **TRUE**
Example:
### Example: ###
```
autobuild configure -A 64 -c ReleaseFS_open -- -DLL_TESTS:BOOL=FALSE -DFMODSTUDIO:BOOL=TRUE
@ -234,6 +260,8 @@ open build-darwin-x86_64/newview/Release
From here you can run it directly or copy it to the Applications folder for ease of finding and running later.
If you used the --package switch, you will also find the DMG installer package in `build-darwin-x86_64/newview`.
## Updating the viewer
If you want to update your self-compiled viewer, you don't have to go through this entire page again. Follow these steps to pull down any new code and re-compile.
@ -243,6 +271,7 @@ If you want to update your self-compiled viewer, you don't have to go through th
- If you have picked to do a clean build, run the following in the terminal window, otherwise skip to the next step: `rm -r build-darwin-x86_64`
- If you are using a custom autobuild.xml file, then run the following in the terminal window, otherwise skip this step: `export AUTOBUILD_CONFIG_FILE=my_autobuild.xml`
- Now, to pull down any new code, run the following in the terminal window: `git pull`
- If you are using a custom autobuild.xml file, compare my_autobuild.xml to autobuild.xml to see if anything has been updated and update your custom file accordingly.
- After any new code is downloaded, it needs to be reconfigured. Run the following in the terminal window: `autobuild configure -A 64 -c ReleaseFS_open`
- Finally, re-compile the viewer with the new changes. Again, in the terminal window, run: `autobuild build -A 64 -c ReleaseFS_open --no-configure`

View File

@ -28,14 +28,31 @@ All installations are done with default settings (unless told explicitly) - if y
> [!TIP]
> If you don't own a copy of a commercial edition of Visual Studio 2022 (e.g. Professional), you might consider installing the [Community version](https://visualstudio.microsoft.com/free-developer-offers)
### Tortoise Git
### Command Prompt vs Powershell
- Make sure that you use the Windows Command Prompt / Terminal (cmd.exe) and not Powershell or it won't detect the Visual Studio build tools properly.
- Download and install [TortoiseGit 2.9.0 or newer](https://tortoisegit.org) (64bit)
### Git
- If you prefer having a GUI for Git, download and install [TortoiseGit 2.17.0 or newer](https://tortoisegit.org) (64bit)
- Note: No option available to install as Administrator
- Use default options (path, components etc.) for Tortoise Git itself
- At some point, it will ask you to download and install Git for Windows
- You can install with default options **EXCEPT** when it asks for "Configuring the line endings conversion": You **MUST** select "Checkout as-is, commit as-is" here!
- If you prefer command line tools, you can also use and install the official [Git for Windows](https://git-scm.com/downloads/win).
- Uncheck "associate .sh files to be run with bash"
- Choose a good text editor such as VS Code or Sublime Text when asked to
- Select "Let Git decide the name of the initial branch"
- Select "Git from the command line and also from 3rd party software"
- Select "Use External SSH"
- Select "Use the native Windows Secure Channel library"
- Select "Checkout as-is, commit as-is" for line endings conversion.
- Select "Use Windows' default console window"
- Select "Fast-forward or merge"
- Select "Git Credential Manager"
- Check "Enable file system caching"
- Once installed, ensure that the git directory (C:\Program Files\Git\cmd) is in your PATH.
### CMake
- Download and install at least [CMake 3.16.0](http://www.cmake.org/download)
@ -56,9 +73,12 @@ All installations are done with default settings (unless told explicitly) - if y
- Add additional packages:
- Devel/patch
- Use default options for everything else
- Make sure that the following directory was added to your path and that it is placed before "%SystemRoot%\system32":
- Make sure that the following directory was added to your path and that it is placed before "%SystemRoot%\system32" but after CMake path (in case you installed CMake in Cygwin):
`C:\Cygwin64\bin`
> [!NOTE]
> The Cygwin terminal is only needed for testing. All commands for actually building the viewer will be run from the Windows command shell.
### Python
- Download and install the most recent version of [Python 3](https://www.python.org/downloads/windows)
@ -87,14 +107,25 @@ pip --version
If they all report sensible values and not "Command not found" errors, then you are in good shape.
> [!NOTE]
> The Cygwin terminal is only needed for testing. All commands for actually building the viewer will be run from the Windows command shell.
### Optional: Set up a Python virtual environment
If you do not want to install the required Python packages into the default Python directory, you can optionally create a virtual environment.
- Create the Python Virtual Environment (only once). Open Windows Command Prompt and navigate to the directory where you want to install the virtual environment. To create the virtual environment, enter:
`python -m venv <env_name>` (`<env_name>` is a placeholder for the name you want to use for the virtual environment)
- Activate the virtual environment by typing:
`<env_name>\Scripts\activate.bat`
- Activate the virtual environment each time you want to build.
- Type all the subsequent commands in this virtual environment.
- In case of issue or Python update, you can delete this directory for the virtual environemt and create a new one again.
### Set up Autobuild
- Install Autobuild
You can install autobuild and its dependencies using the `requirements.txt` file that is part of the repo, this will build using the same versions that our official builds use.
- Open Windows Command Prompt and enter: <code>pip install -r requirements.txt</code>
- Open Windows Command Prompt
- If you created a Python virtual environment earlier, activate it
- Enter: <code>pip install -r requirements.txt</code>
- Autobuild will be installed. **Earlier versions of Autobuild could be made to work by just putting the source files into your path correctly; this is no longer true - Autobuild _must_ be installed as described here.**
- Open Windows Command Prompt and enter:
`pip install git+https://github.com/secondlife/autobuild.git#egg=autobuild`
@ -136,7 +167,7 @@ git clone https://github.com/FirestormViewer/phoenix-firestorm.git
## Prepare third party libraries
Most third party libraries needed to build the viewer will be automatically downloaded for you and installed into the build directory within your source tree during compilation. Some need to be manually prepared and are not normally required when using an open source configuration (ReleaseFS_open).
Most third party libraries needed to build the viewer will be automatically downloaded for you and installed into the build directory within your source tree during compilation. Some need to be manually prepared and are not normally required when using an open source configuration (ReleaseFS_open). Some libraries like Kakadu or Havok requires you to purchase a license and you will need to figure out yourself how to build and use them.
> [!IMPORTANT]
> If you are manually building the third party libraries, you will have to build the correct version (32bit libraries for a 32bit viewer, 64bit versions for a 64bit viewer)!
@ -219,9 +250,14 @@ This will configure Firestorm to be built with all defaults and without third pa
Available premade firestorm-specific build targets:
```
ReleaseFS (includes KDU, FMOD)
ReleaseFS_open (no KDU, no FMOD)
RelWithDebInfoFS_open (no KDU, no FMOD)
ReleaseFS (with KDU, with FMOD, no OpenSim)
ReleaseFS_AVX (with KDU, with FMOD, no OpenSim, optimized for AVX-enabled CPUs)
ReleaseFS_AVX2 (with KDU, with FMOD, no OpenSim, optimized for AVX2-enabled CPUs)
ReleaseFS_open ( no KDU, no FMOD, no OpenSim)
ReleaseOS ( no KDU, no FMOD, with OpenSim)
RelWithDebInfoFS (with KDU, with FMOD, no OpenSim, with debug info)
RelWithDebInfoFS_open ( no KDU, no FMOD, no OpenSim, with debug info)
RelWithDebInfoOS ( no KDU, no FMOD, with OpenSim, with debug info)
```
> [!TIP]
@ -232,16 +268,20 @@ RelWithDebInfoFS_open (no KDU, no FMOD)
There are a number of switches you can use to modify the configuration process. The name of each switch is followed by its type and then by the value you want to set.
- -A \<architecture\> sets the target architecture, that is if you want to build a 32bit or 64bit viewer (32bit is default if omitted).
- --fmodstudio controls if the FMOD Studio package is incorporated into the viewer. You must have performed the FMOD Studio installation steps in [FMOD Studio using Autobuild](#fmod-studio-using-autobuild) for this to work.
- --package makes sure all files are copied into viewers output directory. You won't be able to start your compiled viewer if you don't enable package or do 'compile' it in VS.
- --chan \<channel name\> lets you define a custom channel name for the viewer
- -LL_TESTS:BOOL=\<bool\> controls if the tests are compiled and run. There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
- **-A \<architecture\>** sets the target architecture, that is if you want to build a 32bit or 64bit viewer (32bit is default if omitted). You probably want to set this to `-A 64`.
- **--avx** will enable AVX optimizations for AVX-enabled CPUs. Mutually exclusive with --avx2.
- **--avx2** will enable AVX2 optimizations for AVX2-enabled CPUs. Mutually exclusive with --avx.
- **--clean** will cause autobuild to remove any previously compiled objects and fetched packages. It can be useful if you need to force a reload of all packages.
- **--fmodstudio** controls if the FMOD Studio package is incorporated into the viewer. You must have performed the FMOD Studio installation steps in [FMOD Studio using Autobuild](#fmod-studio-using-autobuild) for this to work. You will not have any sound if you do not include FMOD.
- **--kdu** will tell autobuiild to use the KDU (Kakadu) package when compiling.
- **--package** makes sure all files are copied into viewers output directory. You won't be able to start your compiled viewer if you don't enable package or do 'compile' it in VS. It will also run NSIS to create a setup package.
- **--chan \<channel name\>** will set a unique channel (and the name) for the viewer, appending whatever is defined to "Firestorm-". By default, the channel is "private" followed by your computer's name.
- **-LL_TESTS:BOOL=\<bool\>** controls if the tests are compiled and run. There are quite a lot of them so excluding them is recommended unless you have some reason to need one or more of them.
> [!TIP]
> **OFF** and **NO** are the same as **FALSE**; anything else is considered to be **TRUE**
Examples:
### Examples: ###
- To build a 64bit viewer with FMOD Studio and to create an installer package, run this command in the Windows command window:
`autobuild configure -A 64 -c ReleaseFS_open -- --fmodstudio --package --chan MyViewer -DLL_TESTS:BOOL=FALSE`
@ -255,6 +295,8 @@ There are two ways to build the viewer: Via Windows command line or from within
### Building from the Windows command line
Make sure that you are using the Windows Command Prompt / Terminal (cmd.exe) and not Powershell.
If you are building with FMOD Studio and have followed the previous FMOD Studio setup instructions AND you are now using a new terminal you will need to reset the environment variable with
`set AUTOBUILD_CONFIG_FILE=my_autobuild.xml`

View File

@ -11,6 +11,12 @@
## We're not there yet, but once done, there is a kludge in Linking.cmake
# "if(${CMAKE_VERSION} VERSION_LESS "3.20.0")" that can also be removed
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.29.0")
cmake_policy(SET CMP0156 NEW)
endif()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.31.0")
cmake_policy(SET CMP0179 NEW)
endif()
set(ROOT_PROJECT_NAME "Firestorm" CACHE STRING
"The root project/makefile/solution name. Defaults to Firestorm.")
@ -33,6 +39,14 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF) # This slows down build massively
set(CMAKE_OPTIMIZE_DEPENDENCIES ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
# Speeds up cmake generation significantly in some cases
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)
include(Variables)
include(BuildVersion)
@ -74,7 +88,7 @@ endif(TESTBUILD AND TESTBUILDPERIOD)
#</FS:Ansariel>
#<FS:Beq> Support for custom Primfeed UA
option(FS_PF_USER_AGENT "Optional compiletime Primfeed useragent string" "")
option(FS_PF_USER_AGENT "Optional compile-time Primfeed user-agent string" "")
if (FS_PF_USER_AGENT)
add_compile_definitions(FS_PF_USER_AGENT="${FS_PF_USER_AGENT}")
message(STATUS "Compiling with custom Primfeed user-agent: ${FS_PF_USER_AGENT}")

View File

@ -34,7 +34,10 @@ add_compile_definitions(BOOST_BIND_GLOBAL_PLACEHOLDERS)
# Force enable SSE2 instructions in GLM per the manual
# https://github.com/g-truc/glm/blob/master/manual.md#section2_10
add_compile_definitions(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES=1 GLM_FORCE_SSE2=1 GLM_ENABLE_EXPERIMENTAL=1)
add_compile_definitions(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES=1 GLM_ENABLE_EXPERIMENTAL=1)
# SSE2NEON throws a pointless warning when compiler optimizations are enabled
add_compile_definitions(SSE2NEON_SUPPRESS_WARNINGS=1)
# Configure crash reporting
set(RELEASE_CRASH_REPORTING OFF CACHE BOOL "Enable use of crash reporting in release builds")
@ -87,6 +90,8 @@ if (WINDOWS)
NOMINMAX
# DOM_DYNAMIC # For shared library colladadom
_CRT_SECURE_NO_WARNINGS # Allow use of sprintf etc
_CRT_NONSTDC_NO_DEPRECATE # Allow use of sprintf etc
_CRT_OBSOLETE_NO_WARNINGS
_WINSOCK_DEPRECATED_NO_WARNINGS # Disable deprecated WinSock API warnings
)
add_compile_options(
@ -194,67 +199,43 @@ if (LINUX)
set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
endif (LINUX)
if (DARWIN)
# Use rpath loading on macos
set(CMAKE_MACOSX_RPATH TRUE)
# Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default
set(CLANG_DISABLE_FATAL_WARNINGS OFF)
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
set(DARWIN_extra_cstar_flags "-Wno-unused-local-typedef -Wno-deprecated-declarations")
#<FS:TS> Silence some more compiler warnings on Xcode 9
set(DARWIN_extra_cstar_flags "${DARWIN_extra_cstar_flags} -Wno-unused-const-variable -Wno-unused-private-field -Wno-potentially-evaluated-expression")
# Ensure that CMAKE_CXX_FLAGS has the correct -g debug information format --
# see Variables.cmake.
string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}"
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DARWIN_extra_cstar_flags}")
# NOTE: it's critical that the optimization flag is put in front.
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
set(ENABLE_SIGNING TRUE)
set(SIGNING_IDENTITY "Developer ID Application: The Phoenix Firestorm Project, Inc." )
# Ensure debug symbols are always generated
add_compile_options(-g --debug) # --debug is a clang synonym for -g that bypasses cmake behaviors
# required for clang-15/xcode-15 since our boost package still uses deprecated std::unary_function/binary_function
# see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#C++-Standard-Library
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
endif (DARWIN)
# Silence GL deprecation warnings
add_compile_definitions(GL_SILENCE_DEPRECATION=1)
set(ENABLE_SIGNING TRUE)
set(SIGNING_IDENTITY "Developer ID Application: The Phoenix Firestorm Project, Inc." )
endif(DARWIN)
if (LINUX OR DARWIN)
if (CMAKE_CXX_COMPILER MATCHES ".*clang")
set(CMAKE_COMPILER_IS_CLANGXX 1)
endif (CMAKE_CXX_COMPILER MATCHES ".*clang")
add_compile_options(-Wall -Wno-sign-compare -Wno-trigraphs -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable)
if (CMAKE_COMPILER_IS_GNUCXX)
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs")
elseif (CMAKE_COMPILER_IS_CLANGXX)
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# libstdc++ headers contain deprecated declarations that fail on clang
# macOS currently has many deprecated calls
add_compile_options(-Wno-unused-local-typedef)
endif()
if (NOT GCC_DISABLE_FATAL_WARNINGS)
set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
endif (NOT GCC_DISABLE_FATAL_WARNINGS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-stringop-truncation -Wno-parentheses -Wno-maybe-uninitialized)
endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND DARWIN AND XCODE_VERSION GREATER 4.9)
set(GCC_CXX_WARNINGS "$[GCC_WARNINGS] -Wno-reorder -Wno-unused-const-variable -Wno-format-extra-args -Wno-unused-private-field -Wno-unused-function -Wno-tautological-compare -Wno-empty-body -Wno-unused-variable -Wno-unused-value")
else (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND DARWIN AND XCODE_VERSION GREATER 4.9)
#elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Wno-unused-variable")
if (NOT GCC_DISABLE_FATAL_WARNINGS AND NOT CLANG_DISABLE_FATAL_WARNINGS)
add_compile_options(-Werror)
endif ()
if(LINUX)
set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Wno-unused-variable -Wno-pragmas -Wno-deprecated")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
set(GCC_CXX_WARNINGS "${GCC_CXX_WARNINGS} -Wno-c++20-compat")
endif()
set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m${ADDRESS_SIZE}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m${ADDRESS_SIZE}")
add_compile_options(${GCC_WARNINGS})
add_compile_options(-m${ADDRESS_SIZE})
endif (LINUX OR DARWIN)

View File

@ -9,36 +9,31 @@ use_system_binary( apr apr-util )
use_prebuilt_binary(apr_suite)
if (WINDOWS)
if (LLCOMMON_LINK_SHARED)
set(APR_selector "lib")
else (LLCOMMON_LINK_SHARED)
set(APR_selector "")
endif (LLCOMMON_LINK_SHARED)
target_link_libraries( ll::apr INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/${APR_selector}apr-1.lib
${ARCH_PREBUILT_DIRS_RELEASE}/${APR_selector}aprutil-1.lib
)
target_compile_definitions( ll::apr INTERFACE APR_DECLARE_STATIC=1 APU_DECLARE_STATIC=1 API_DECLARE_STATIC=1)
elseif (DARWIN)
if (LLCOMMON_LINK_SHARED)
set(APR_selector "0.dylib")
set(APRUTIL_selector "0.dylib")
else (LLCOMMON_LINK_SHARED)
set(APR_selector "a")
set(APRUTIL_selector "a")
endif (LLCOMMON_LINK_SHARED)
target_link_libraries( ll::apr INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.${APR_selector}
${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.${APR_selector}
iconv
)
else()
# linux
target_link_libraries( ll::apr INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.a
${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.a
rt
)
target_compile_definitions(ll::apr INTERFACE APR_DECLARE_STATIC=1 APU_DECLARE_STATIC=1 API_DECLARE_STATIC=1)
endif ()
target_include_directories( ll::apr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/apr-1 )
find_library(APR_LIBRARY
NAMES
apr-1.lib
libapr-1.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(APRUTIL_LIBRARY
NAMES
aprutil-1.lib
libaprutil-1.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::apr INTERFACE ${APR_LIBRARY} ${APRUTIL_LIBRARY})
if(DARWIN)
target_link_libraries(ll::apr INTERFACE iconv)
endif()
target_include_directories(ll::apr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/apr-1)
# <FS:Ansariel> Hotfix incorrect check in APR header
file(READ ${LIBS_PREBUILT_DIR}/include/apr-1/apr.h APR_HEADER_CONTENTS)
string(REPLACE "#if !(defined(__attribute__) || defined(__has_attribute))" "#if !defined(__attribute__)" APR_HEADER_CONTENTS "${APR_HEADER_CONTENTS}")
file(WRITE ${LIBS_PREBUILT_DIR}/include/apr-1/apr.h "${APR_HEADER_CONTENTS}")
# </FS:Ansariel>

View File

@ -9,24 +9,29 @@ use_system_binary(vorbis)
use_prebuilt_binary(ogg_vorbis)
target_include_directories( ll::vorbis SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include )
if (WINDOWS)
target_link_libraries(ll::vorbis INTERFACE
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libogg.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libogg.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisenc.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbisenc.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisfile.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbisfile.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbis.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbis.lib
)
else (WINDOWS)
target_link_libraries(ll::vorbis INTERFACE
# <FS:Zi> These must be in this order, or it won't link: vorbisenc vorbisfile vorbis ogg
${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisenc.a
${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisfile.a
${ARCH_PREBUILT_DIRS_RELEASE}/libvorbis.a
${ARCH_PREBUILT_DIRS_RELEASE}/libogg.a
)
endif (WINDOWS)
find_library(OGG_LIBRARY
NAMES
libogg.lib
libogg.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VORBIS_LIBRARY
NAMES
libvorbis.lib
libvorbis.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VORBISENC_LIBRARY
NAMES
libvorbisenc.lib
libvorbisenc.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VORBISFILE_LIBRARY
NAMES
libvorbisfile.lib
libvorbisfile.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::vorbis INTERFACE ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY} )

View File

@ -16,44 +16,74 @@ use_prebuilt_binary(boost)
# with the address size.
set(addrsfx "-x${ADDRESS_SIZE}")
if (WINDOWS)
target_link_libraries( ll::boost INTERFACE
libboost_context-mt${addrsfx}
libboost_fiber-mt${addrsfx}
libboost_filesystem-mt${addrsfx}
libboost_program_options-mt${addrsfx}
libboost_regex-mt${addrsfx}
libboost_system-mt${addrsfx}
libboost_thread-mt${addrsfx}
libboost_url-mt${addrsfx}
libboost_wave-mt${addrsfx})
elseif (LINUX)
target_link_libraries( ll::boost INTERFACE
# <FS:Zi> do not change the order: fiber first, context next, or SLPlugin will not build
boost_fiber-mt${addrsfx}
boost_context-mt${addrsfx}
boost_filesystem-mt${addrsfx}
boost_program_options-mt${addrsfx}
boost_regex-mt${addrsfx}
boost_system-mt${addrsfx}
boost_thread-mt${addrsfx}
boost_url-mt${addrsfx}
boost_wave-mt${addrsfx})
elseif (DARWIN)
target_link_libraries( ll::boost INTERFACE
boost_context-mt${addrsfx}
boost_fiber-mt${addrsfx}
boost_filesystem-mt${addrsfx}
boost_program_options-mt${addrsfx}
boost_regex-mt${addrsfx}
boost_system-mt${addrsfx}
boost_thread-mt${addrsfx}
boost_url-mt${addrsfx}
boost_wave-mt${addrsfx})
endif (WINDOWS)
find_library(BOOST_CONTEXT_LIBRARY
NAMES
boost_context-mt
boost_context-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_FIBER_LIBRARY
NAMES
boost_fiber-mt
boost_fiber-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_FILESYSTEM_LIBRARY
NAMES
boost_filesystem-mt
boost_filesystem-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_PROGRAMOPTIONS_LIBRARY
NAMES
boost_program_options-mt
boost_program_options-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_REGEX_LIBRARY
NAMES
boost_regex-mt
boost_regex-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_SYSTEM_LIBRARY
NAMES
boost_system-mt
boost_system-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_THREAD_LIBRARY
NAMES
boost_thread-mt
boost_thread-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_URL_LIBRARY
NAMES
boost_url-mt
boost_url-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
# <FS:Ansariel> LSL Preprocessor support
find_library(BOOST_WAVE_LIBRARY
NAMES
boost_wave-mt
boost_wave-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
# </FS:Ansariel>
target_link_libraries(ll::boost INTERFACE
${BOOST_FIBER_LIBRARY}
${BOOST_CONTEXT_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_PROGRAMOPTIONS_LIBRARY}
${BOOST_REGEX_LIBRARY}
${BOOST_SYSTEM_LIBRARY}
${BOOST_THREAD_LIBRARY}
${BOOST_URL_LIBRARY}
${BOOST_WAVE_LIBRARY}) # <FS:Ansariel> LSL Preprocessor support
if (LINUX)
set(BOOST_SYSTEM_LIBRARY ${BOOST_SYSTEM_LIBRARY} rt)
set(BOOST_THREAD_LIBRARY ${BOOST_THREAD_LIBRARY} rt)
target_link_libraries(ll::boost INTERFACE rt)
endif (LINUX)

View File

@ -29,7 +29,6 @@ elseif (DARWIN)
${ARCH_PREBUILT_DIRS_RELEASE}/libcef_dll_wrapper.a
${ARCH_PREBUILT_DIRS_RELEASE}/libdullahan.a
${APPKIT_LIBRARY}
"-F ${CEF_LIBRARY}"
)
elseif (LINUX)

View File

@ -55,9 +55,11 @@ set(cmake_SOURCE_FILES
Prebuilt.cmake
PulseAudio.cmake
Python.cmake
SSE2NEON.cmake
TemplateCheck.cmake
TinyEXR.cmake
TinyGLTF.cmake
Tracy.cmake
Tut.cmake
UI.cmake
UnixInstall.cmake

View File

@ -7,19 +7,13 @@ add_library( ll::libcurl INTERFACE IMPORTED )
use_system_binary(libcurl)
use_prebuilt_binary(curl)
if (WINDOWS)
target_link_libraries(ll::libcurl INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libcurl.lib
ll::openssl
ll::nghttp2
ll::zlib-ng
)
else ()
target_link_libraries(ll::libcurl INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libcurl.a
ll::openssl
ll::nghttp2
ll::zlib-ng
)
endif ()
find_library(CURL_LIBRARY
NAMES
libcurl.lib
libcurl.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libcurl INTERFACE ${CURL_LIBRARY} ll::openssl ll::nghttp2 ll::zlib-ng)
target_include_directories( ll::libcurl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -61,11 +61,6 @@ if(WINDOWS)
glod.dll # <FS:Beq> restore GLOD
)
if(LLCOMMON_LINK_SHARED)
set(release_files ${release_files} libapr-1.dll)
set(release_files ${release_files} libaprutil-1.dll)
endif()
# <FS:Ansariel> Only copy OpenJPEG dll if needed
if (NOT USE_KDU)
set(release_files ${release_files} openjp2.dll)
@ -196,15 +191,6 @@ elseif(DARWIN)
libgrowl++.dylib
)
if(LLCOMMON_LINK_SHARED)
set(release_files ${release_files}
libapr-1.0.dylib
libapr-1.dylib
libaprutil-1.0.dylib
libaprutil-1.dylib
)
endif()
if (TARGET ll::discord_sdk)
list(APPEND release_files libdiscord_partner_sdk.dylib)
endif ()
@ -275,13 +261,6 @@ elseif(LINUX)
libgmodule-2.0.a
libgobject-2.0.a
)
if(LLCOMMON_LINK_SHARED)
set(release_files ${release_files}
libapr-1.so.0
libaprutil-1.so.0
)
endif()
endif()
if (TARGET ll::fmodstudio)

View File

@ -2,18 +2,21 @@
include(Prebuilt)
include_guard()
add_library( ll::expat INTERFACE IMPORTED )
add_library(ll::expat INTERFACE IMPORTED)
use_system_binary(expat)
use_prebuilt_binary(expat)
if (WINDOWS)
target_compile_definitions( ll::expat INTERFACE XML_STATIC=1)
target_link_libraries( ll::expat INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libexpatd.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.lib)
else ()
target_link_libraries( ll::expat INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libexpat.a
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.a)
target_compile_definitions(ll::expat INTERFACE XML_STATIC=1)
endif ()
target_include_directories( ll::expat SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include )
find_library(EXPAT_LIBRARY
NAMES
libexpat.lib
libexpat.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::expat INTERFACE ${EXPAT_LIBRARY})
target_include_directories(ll::expat SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -9,9 +9,10 @@ use_system_binary(freetype)
use_prebuilt_binary(freetype)
target_include_directories( ll::freetype SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/freetype2/)
if (WINDOWS)
target_link_libraries( ll::freetype INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/freetype.lib)
else()
target_link_libraries( ll::freetype INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libfreetype.a)
endif()
find_library(FREETYPE_LIBRARY
NAMES
freetype.lib
libfreetype.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::freetype INTERFACE ${FREETYPE_LIBRARY})

View File

@ -8,17 +8,17 @@ use_prebuilt_binary(dictionaries)
add_library( ll::hunspell INTERFACE IMPORTED )
use_system_binary(hunspell)
use_prebuilt_binary(libhunspell)
if (WINDOWS)
target_compile_definitions( ll::hunspell INTERFACE HUNSPELL_STATIC=1)
target_link_libraries( ll::hunspell INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libhunspell.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell.lib
)
elseif(DARWIN)
target_link_libraries( ll::hunspell INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell-1.7.a
)
elseif(LINUX)
target_link_libraries( ll::hunspell INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell-1.7.a
)
endif()
find_library(HUNSPELL_LIBRARY
NAMES
libhunspell.lib
libhunspell-1.7.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::hunspell INTERFACE ${HUNSPELL_LIBRARY})
target_include_directories( ll::hunspell SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/hunspell)

View File

@ -8,13 +8,13 @@ add_library( ll::libjpeg INTERFACE IMPORTED )
use_system_binary(libjpeg)
use_prebuilt_binary(libjpeg-turbo)
if (LINUX)
target_link_libraries( ll::libjpeg INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a)
elseif (DARWIN)
target_link_libraries( ll::libjpeg INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a)
elseif (WINDOWS)
target_link_libraries( ll::libjpeg INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/jpeg.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/jpeg.lib)
endif (LINUX)
target_include_directories( ll::libjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)
find_library(JPEG_LIBRARY
NAMES
jpeg.lib
libjpeg.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libjpeg INTERFACE ${JPEG_LIBRARY})
target_include_directories(ll::libjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -92,6 +92,13 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
target_include_directories (PROJECT_${project}_TEST_${name} PRIVATE ${LIBS_OPEN_DIR}/test )
set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}")
if (DARWIN)
set_target_properties(PROJECT_${project}_TEST_${name}
PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH "@executable_path/Resources"
)
endif(DARWIN)
#
# Per-codefile additional / external project dep and lib dep property extraction
@ -225,7 +232,10 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
# test binaries always need to be signed for local development
set_target_properties(INTEGRATION_TEST_${testname}
PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-")
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH "@executable_path/Resources"
)
endif ()
# Add link deps to the executable

View File

@ -20,14 +20,28 @@ add_library( ll::kdu INTERFACE IMPORTED )
if (USE_KDU)
include(Prebuilt)
use_prebuilt_binary(kdu)
if (WINDOWS)
target_link_libraries( ll::kdu INTERFACE kdu${ND_KDU_SUFFIX}.lib)
find_library(KDU_LIBRARY
NAMES
kdu
kdu${ND_KDU_SUFFIX} // <FS> FS-specific naming
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
else (WINDOWS)
target_link_libraries( ll::kdu INTERFACE libkdu${ND_KDU_SUFFIX}.a)
find_library(KDU_LIBRARY
NAMES
libkdu.a
libkdu${ND_KDU_SUFFIX} // <FS> FS-specific naming
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
endif (WINDOWS)
target_link_libraries(ll::kdu INTERFACE ${KDU_LIBRARY})
target_include_directories( ll::kdu SYSTEM INTERFACE
${AUTOBUILD_INSTALL_DIR}/include/kdu
${LIBS_OPEN_DIR}/llkdu
)
#target_compile_definitions(ll::kdu INTERFACE KDU_NO_THREADS=1) // <FS:Ansariel> Enable KDU internal threading
endif (USE_KDU)

View File

@ -24,31 +24,35 @@ use_prebuilt_binary(colladadom)
use_prebuilt_binary(minizip-ng) # needed for colladadom
use_prebuilt_binary(libxml2)
if (WINDOWS)
target_link_libraries( ll::minizip-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/minizip.lib )
else()
target_link_libraries( ll::minizip-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libminizip.a )
endif()
find_library(MINIZIPNG_LIBRARY
NAMES
minizip.lib
libminizip.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::minizip-ng INTERFACE ${MINIZIPNG_LIBRARY})
find_library(LIBXML2_LIBRARY
NAMES
libxml2.lib
libxml2.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libxml INTERFACE ${LIBXML2_LIBRARY})
if (WINDOWS)
target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.lib Bcrypt.lib)
else()
target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.a)
target_link_libraries( ll::libxml INTERFACE Bcrypt.lib)
endif()
target_include_directories( ll::colladadom SYSTEM INTERFACE
${LIBS_PREBUILT_DIR}/include/collada
${LIBS_PREBUILT_DIR}/include/collada/1.4
)
if (WINDOWS)
target_link_libraries(ll::colladadom INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libcollada14dom23-s.lib ll::libxml ll::minizip-ng )
elseif (DARWIN)
target_link_libraries(ll::colladadom INTERFACE collada14dom ll::boost ll::libxml ll::minizip-ng)
elseif (LINUX)
# GLIB uses pcre, so we need to keep it for Linux
add_library( ll::pcre INTERFACE IMPORTED )
use_prebuilt_binary(pcre)
target_link_libraries( ll::pcre INTERFACE pcrecpp pcre )
target_link_libraries(ll::colladadom INTERFACE collada14dom ll::boost ll::libxml ll::minizip-ng)
endif()
find_library(COLLADADOM_LIBRARY
NAMES
libcollada14dom23-s.lib
collada14dom
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::colladadom INTERFACE ${COLLADADOM_LIBRARY} ll::boost ll::libxml ll::minizip-ng)

View File

@ -9,20 +9,16 @@ use_prebuilt_binary(vlc-bin)
set(LIBVLCPLUGIN ON CACHE BOOL
"LIBVLCPLUGIN support for the llplugin/llmedia test apps.")
if (WINDOWS)
target_link_libraries( ll::libvlc INTERFACE
libvlc.lib
libvlccore.lib
)
elseif (DARWIN)
target_link_libraries( ll::libvlc INTERFACE
libvlc.dylib
libvlccore.dylib
)
elseif (LINUX)
# Specify a full path to make sure we get a static link
target_link_libraries( ll::libvlc INTERFACE
${LIBS_PREBUILT_DIR}/lib/libvlc.a
${LIBS_PREBUILT_DIR}/lib/libvlccore.a
)
endif (WINDOWS)
find_library(VLC_LIBRARY
NAMES
libvlc.lib
libvlc.dylib
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VLCCORE_LIBRARY
NAMES
libvlccore.lib
libvlccore.dylib
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libvlc INTERFACE ${VLC_LIBRARY} ${VLCCORE_LIBRARY})

View File

@ -38,9 +38,10 @@ endif ()
# windows) and CMAKE_BUILD_TYPE on Makefile based generators (like linux). The reason for this is
# that CMAKE_BUILD_TYPE is essentially meaningless at configuration time for IDE generators and
# CMAKE_CFG_INTDIR is meaningless at build time for Makefile generators
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/$<LOWER_CASE:$<CONFIG>>)
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/release)
if(NOT DARWIN)
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/$<LOWER_CASE:$<CONFIG>>)
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/release)
endif(NOT DARWIN)
add_library( ll::oslibraries INTERFACE IMPORTED )
@ -74,6 +75,8 @@ else()
find_library(APPKIT_LIBRARY AppKit)
find_library(COREAUDIO_LIBRARY CoreAudio)
find_library(COREGRAPHICS_LIBRARY CoreGraphics)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
target_link_libraries( ll::oslibraries INTERFACE
${COCOA_LIBRARY}
@ -82,6 +85,8 @@ else()
${CARBON_LIBRARY}
${APPKIT_LIBRARY}
${COREAUDIO_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${COREGRAPHICS_LIBRARY}
)
endif()

View File

@ -9,12 +9,12 @@ add_library( ll::meshoptimizer INTERFACE IMPORTED )
use_system_binary(meshoptimizer)
use_prebuilt_binary(meshoptimizer)
if (WINDOWS)
target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer.lib)
elseif (LINUX)
target_link_libraries( ll::meshoptimizer INTERFACE libmeshoptimizer.a)
elseif (DARWIN)
target_link_libraries( ll::meshoptimizer INTERFACE libmeshoptimizer.a)
endif (WINDOWS)
find_library(MESHOPTIMIZER_LIBRARY
NAMES
meshoptimizer.lib
libmeshoptimizer.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer)
target_link_libraries(ll::meshoptimizer INTERFACE ${MESHOPTIMIZER_LIBRARY})
target_include_directories(ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer)

View File

@ -13,12 +13,15 @@ if (NDOF)
use_prebuilt_binary(open-libndofdev)
endif (WINDOWS OR DARWIN)
if (WINDOWS)
target_link_libraries( ll::ndof INTERFACE libndofdev)
elseif (DARWIN OR LINUX)
target_link_libraries( ll::ndof INTERFACE ndofdev)
endif (WINDOWS)
target_compile_definitions( ll::ndof INTERFACE LIB_NDOF=1)
find_library(NDOF_LIBRARY
NAMES
libndofdev
ndofdev
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::ndof INTERFACE ${NDOF_LIBRARY})
target_compile_definitions(ll::ndof INTERFACE LIB_NDOF=1)
endif (NDOF)

View File

@ -6,11 +6,12 @@ add_library( ll::nghttp2 INTERFACE IMPORTED )
use_system_binary(nghttp2)
use_prebuilt_binary(nghttp2)
if (WINDOWS)
# <FS:Ansariel> ARCH_PREBUILT_DIRS_RELEASE is "." and would cause searching for the lib in the wrong place when not using VS
##target_link_libraries( ll::nghttp2 INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/nghttp2.lib)
target_link_libraries( ll::nghttp2 INTERFACE nghttp2.lib)
else ()
target_link_libraries( ll::nghttp2 INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libnghttp2.a)
endif ()
find_library(NGHTTP2_LIBRARY
NAMES
nghttp2.lib
libnghttp2.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::nghttp2 INTERFACE ${NGHTTP2_LIBRARY})
target_include_directories( ll::nghttp2 SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/nghttp2)

View File

@ -8,7 +8,7 @@ include_guard()
# to have memory leaks, has no option to play music streams
# It probably makes sense to to completely remove it
set(USE_OPENAL OFF CACHE BOOL "Enable OpenAL")
set(USE_OPENAL ON CACHE BOOL "Enable OpenAL")
# <FS:Zi> Always download the libopenal.so library on Linux for SLVoice
if (LINUX)
@ -28,20 +28,21 @@ if (USE_OPENAL)
target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1)
use_prebuilt_binary(openal)
if(WINDOWS)
target_link_libraries( ll::openal INTERFACE
OpenAL32
alut
)
elseif(LINUX)
target_link_libraries( ll::openal INTERFACE
openal
alut
)
else()
target_link_libraries( ll::openal INTERFACE
openal
alut
)
endif()
find_library(OPENAL_LIBRARY
NAMES
OpenAL32
openal
libopenal.dylib
libopenal.so
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(ALUT_LIBRARY
NAMES
alut
libalut.dylib
libalut.so
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::openal INTERFACE ${OPENAL_LIBRARY} ${ALUT_LIBRARY})
endif ()

View File

@ -1,11 +1,22 @@
# -*- cmake -*-
include(Prebuilt)
include_guard()
include(Prebuilt)
include(Linking)
add_library( ll::openjpeg INTERFACE IMPORTED )
use_system_binary(openjpeg)
use_prebuilt_binary(openjpeg)
target_link_libraries(ll::openjpeg INTERFACE openjp2 )
target_include_directories( ll::openjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/openjpeg)
find_library(OPENJPEG_LIBRARY
NAMES
openjp2
openjp2.lib
libopenjp2.a
libopenjp2.so
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::openjpeg INTERFACE ${OPENJPEG_LIBRARY})
target_include_directories(ll::openjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/openjpeg)

View File

@ -7,12 +7,24 @@ add_library( ll::openssl INTERFACE IMPORTED )
use_system_binary(openssl)
use_prebuilt_binary(openssl)
if (WINDOWS)
target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.lib ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.lib Crypt32.lib)
elseif (LINUX)
target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.a ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.a dl)
else()
target_link_libraries(ll::openssl INTERFACE ssl crypto)
endif (WINDOWS)
target_include_directories( ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)
find_library(SSL_LIBRARY
NAMES
libssl.lib
libssl.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(CRYPTO_LIBRARY
NAMES
libcrypto.lib
libcrypto.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::openssl INTERFACE ${SSL_LIBRARY} ${CRYPTO_LIBRARY})
if (WINDOWS)
target_link_libraries(ll::openssl INTERFACE Crypt32.lib)
endif (WINDOWS)
target_include_directories(ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -14,9 +14,12 @@ add_library( ll::libpng INTERFACE IMPORTED )
use_system_binary(libpng)
use_prebuilt_binary(libpng)
if (WINDOWS)
target_link_libraries(ll::libpng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libpng16.lib)
else()
target_link_libraries(ll::libpng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libpng16.a)
endif()
target_include_directories( ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16)
find_library(LIBPNG_LIBRARY
NAMES
libpng16.lib
libpng16.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libpng INTERFACE ${LIBPNG_LIBRARY})
target_include_directories(ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16)

View File

@ -1,5 +1,7 @@
# -*- cmake -*-
include(OpenGL)
add_library( ll::pluginlibraries INTERFACE IMPORTED )
if (WINDOWS)
@ -13,4 +15,6 @@ if (WINDOWS)
)
endif (WINDOWS)
target_link_libraries( ll::pluginlibraries INTERFACE OpenGL::GL)
target_include_directories( ll::pluginlibraries INTERFACE ${CMAKE_SOURCE_DIR}/llimage ${CMAKE_SOURCE_DIR}/llrender)

View File

@ -0,0 +1,12 @@
# -*- cmake -*-
include(Prebuilt)
add_library(ll::sse2neon INTERFACE IMPORTED)
if (DARWIN)
use_system_binary(sse2neon)
use_prebuilt_binary(sse2neon)
target_include_directories( ll::sse2neon SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/sse2neon)
endif()

View File

@ -15,6 +15,7 @@ endif()
if (USE_TRACY)
option(USE_TRACY_ON_DEMAND "Use on-demand Tracy profiling." ON)
option(USE_TRACY_LOCAL_ONLY "Disallow remote Tracy profiling." OFF)
option(USE_TRACY_GPU "Use Tracy GPU profiling" OFF)
use_prebuilt_binary(tracy)
@ -30,9 +31,8 @@ if (USE_TRACY)
target_compile_definitions(ll::tracy INTERFACE -DTRACY_NO_BROADCAST=1 -DTRACY_ONLY_LOCALHOST=1)
endif ()
# GHA runners don't always provide invariant TSC support, but always build with LL_TESTS enabled
if (DARWIN AND LL_TESTS)
target_compile_definitions(ll::tracy INTERFACE -DTRACY_TIMER_FALLBACK=1)
if (USE_TRACY_GPU AND NOT DARWIN) # Tracy OpenGL mode is incompatible with macOS/iOS
target_compile_definitions(ll::tracy INTERFACE -DLL_PROFILER_ENABLE_TRACY_OPENGL=1)
endif ()
# See: indra/llcommon/llprofiler.h

View File

@ -144,52 +144,19 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DARWIN 1)
string(REGEX MATCH "-mmacosx-version-min=([^ ]+)" scratch "$ENV{LL_BUILD}")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}" CACHE STRING "macOS Deploy Target" FORCE)
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = '${CMAKE_OSX_DEPLOYMENT_TARGET}'")
string(REGEX MATCH "-stdlib=([^ ]+)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY = '${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY}'")
string(REGEX MATCH " -g([^ ]*)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "${CMAKE_MATCH_1}")
# -gdwarf-2 is passed in LL_BUILD according to 00-COMPILE-LINK-RUN.txt.
# However, when CMake 3.9.2 sees -gdwarf-2, it silently deletes the whole -g
# switch, producing no symbols at all! The same thing happens if we specify
# plain -g ourselves, i.e. CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT is
# the empty string. Specifying -gdwarf-with-dsym or just -gdwarf drives a
# different CMake behavior: it substitutes plain -g. As of 2017-09-19,
# viewer-build-variables/variables still passes -gdwarf-2, which is the
# no-symbols case. Set -gdwarf, triggering CMake to substitute plain -g --
# at least that way we should get symbols, albeit mangled ones. It Would Be
# Nice if CMake's behavior could be predicted from a consistent mental
# model, instead of only observed experimentally.
string(REPLACE "dwarf-2" "dwarf"
CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT
"${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT = '${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}'")
# Use dwarf symbols for most libraries for compilation speed
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'")
# allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var
set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
if ("${sysroot_idx}" LESS 0)
message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
endif ()
math(EXPR sysroot_idx "${sysroot_idx} + 1")
list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
endif()
message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS ssse3)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.2)
# we must hard code this to off for now. xcode's built in signing does not
# handle embedded app bundles such as CEF and others. Any signing for local
# development must be done after the build as we do in viewer_manifest.py for
@ -204,9 +171,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "")
set(CMAKE_XCODE_ATTRIBUTE_DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
set(CMAKE_OSX_ARCHITECTURES "${ARCH}")
string(REPLACE "i686" "i386" CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
string(REPLACE "AMD64" "x86_64" CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "macOS Build Arch" FORCE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Default deploy grid

View File

@ -1,32 +1,24 @@
# -*- cmake -*-
include_guard()
include(Linking)
include(Prebuilt)
include_guard()
add_library( ll::webrtc INTERFACE IMPORTED )
target_include_directories( ll::webrtc SYSTEM INTERFACE "${LIBS_PREBUILT_DIR}/include/webrtc" "${LIBS_PREBUILT_DIR}/include/webrtc/third_party/abseil-cpp")
use_prebuilt_binary(webrtc)
if (WINDOWS)
target_link_libraries( ll::webrtc INTERFACE webrtc.lib )
elseif (DARWIN)
FIND_LIBRARY(COREAUDIO_LIBRARY CoreAudio)
FIND_LIBRARY(COREGRAPHICS_LIBRARY CoreGraphics)
FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox)
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
find_library(WEBRTC_LIBRARY
NAMES
webrtc
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries( ll::webrtc INTERFACE
libwebrtc.a
${COREAUDIO_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${COREGRAPHICS_LIBRARY}
${COREFOUNDATION_LIBRARY}
${COCOA_LIBRARY}
)
target_link_libraries( ll::webrtc INTERFACE ${WEBRTC_LIBRARY} )
if (DARWIN)
target_link_libraries( ll::webrtc INTERFACE ll::oslibraries )
elseif (LINUX)
target_link_libraries( ll::webrtc INTERFACE libwebrtc.a X11 )
endif (WINDOWS)
target_link_libraries( ll::webrtc INTERFACE X11 )
endif ()

View File

@ -11,11 +11,14 @@ if(USE_CONAN )
endif()
use_prebuilt_binary(zlib-ng)
if (WINDOWS)
target_link_libraries( ll::zlib-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/zlib.lib )
else()
target_link_libraries( ll::zlib-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libz.a )
endif (WINDOWS)
find_library(ZLIBNG_LIBRARY
NAMES
zlib.lib
libz.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::zlib-ng INTERFACE ${ZLIBNG_LIBRARY})
if( NOT LINUX )
target_include_directories( ll::zlib-ng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/zlib-ng)

View File

@ -1,8 +1,5 @@
# -*- cmake -*-
if (XXHASH_CMAKE_INCLUDED)
return()
endif (XXHASH_CMAKE_INCLUDED)
set (XXHASH_CMAKE_INCLUDED TRUE)
include_guard()
include(Prebuilt)
use_prebuilt_binary(xxhash)

View File

@ -1,13 +1,5 @@
# -*- cmake -*-
set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING
"The root project/makefile/solution name. Defaults to SecondLife.")
project(${ROOT_PROJECT_NAME})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(Variables)
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)

View File

@ -1,8 +1,3 @@
# -*- cmake -*-
add_subdirectory(llui_libtest)
IF (LLIMAGE_LIBTEST)
MESSAGE(STATUS "Build llimage_libtest")
add_subdirectory(llimage_libtest)
ELSE (LLIMAGE_LIBTEST)
MESSAGE(STATUS "Skip llimage_libtest")
ENDIF (LLIMAGE_LIBTEST)
add_subdirectory(llimage_libtest)

View File

@ -1,6 +1,7 @@
# -*- cmake -*-
# Integration tests of the llimage library (JPEG2000, PNG, jpeg, etc... images reading and writing)
if (LL_TESTS)
project (llimage_libtest)
@ -8,9 +9,7 @@ include(00-Common)
include(LLCommon)
include(LLImage)
include(LLMath)
include(LLImageJ2COJ)
include(LLKDU)
include(LLFileSystem)
set(llimage_libtest_SOURCE_FILES
llimage_libtest.cpp
@ -24,17 +23,9 @@ set(llimage_libtest_HEADER_FILES
list(APPEND llimage_libtest_SOURCE_FILES ${llimage_libtest_HEADER_FILES})
add_executable(llimage_libtest
WIN32
MACOSX_BUNDLE
${llimage_libtest_SOURCE_FILES}
)
set_target_properties(llimage_libtest
PROPERTIES
WIN32_EXECUTABLE
FALSE
)
# Libraries on which this application depends on
# Sort by high-level to low-level
target_link_libraries(llimage_libtest
@ -42,64 +33,9 @@ target_link_libraries(llimage_libtest
llfilesystem
llmath
llimage
llkdu
llimagej2coj
)
if (DARWIN)
# Path inside the app bundle where we'll need to copy libraries
set(LLIMAGE_LIBTEST_DESTINATION_DIR
${CMAKE_CURRENT_BINARY_DIR}/$<IF:$<BOOL:${LL_GENERATOR_IS_MULTI_CONFIG}>,$<CONFIG>,>/llimage_libtest.app/Contents/Resources
)
# Create the Contents/Resources directory
add_custom_command(
TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS
-E
make_directory
${LLIMAGE_LIBTEST_DESTINATION_DIR}
COMMENT "Creating Resources directory in app bundle."
)
else (DARWIN)
set(LLIMAGE_LIBTEST_DESTINATION_DIR
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/
)
endif (DARWIN)
get_target_property(BUILT_LLCOMMON llcommon LOCATION)
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_LLCOMMON} ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${BUILT_LLCOMMON}
)
if (DARWIN)
# Copy the required libraries to the package app
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libapr-1.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libapr-1.0.dylib
)
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libaprutil-1.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libaprutil-1.0.dylib
)
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib
)
foreach(expat ${EXPAT_COPY})
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat} ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat}
)
endforeach(expat)
endif (DARWIN)
if (WINDOWS)
# Check indra/test_apps/llplugintest/CMakeLists.txt for an example of what to copy over for Windows and how
endif (WINDOWS)
# Ensure people working on the viewer don't break this library
# *NOTE: This could be removed, or only built by TeamCity, if the build
# and link times become too long.
add_dependencies(viewer llimage_libtest)
endif(LL_TESTS)

View File

@ -43,6 +43,8 @@
#include "v4coloru.h"
#include "llsdserialize.h"
#include "llcleanup.h"
#include "lltrace.h"
#include "llfasttimer.h"
// system libraries
#include <iostream>
@ -573,10 +575,10 @@ int main(int argc, char** argv)
// Create the logging thread if required
if (LLFastTimer::sMetricLog)
if (LLTrace::BlockTimer::sMetricLog)
{
LLFastTimer::sLogLock = new LLMutex(NULL);
fast_timer_log_thread = new LogThread(LLFastTimer::sLogName);
LLTrace::BlockTimer::setLogLock(new LLMutex());
fast_timer_log_thread = new LogThread(LLTrace::BlockTimer::sLogName);
fast_timer_log_thread->start();
}
@ -618,9 +620,9 @@ int main(int argc, char** argv)
// Output perf data if requested by user
if (analyze_performance)
{
std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
std::string current_name = LLFastTimer::sLogName + ".slp";
std::string report_name = LLFastTimer::sLogName + "_report.csv";
std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
std::string current_name = LLTrace::BlockTimer::sLogName + ".slp";
std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv";
std::cout << "Analyzing performance, check report in : " << report_name << std::endl;
@ -628,9 +630,9 @@ int main(int argc, char** argv)
}
// Stop the perf gathering system if needed
if (LLFastTimer::sMetricLog)
if (LLTrace::BlockTimer::sMetricLog)
{
LLMetricPerformanceTesterBasic::deleteTester(LLFastTimer::sLogName);
LLMetricPerformanceTesterBasic::deleteTester(LLTrace::BlockTimer::sLogName);
sAllDone = true;
}

View File

@ -34,38 +34,6 @@
#include "llmath.h"
#include "llapr.h"
//#if LL_DARWIN
// MBW -- XXX -- Getting rid of SecondLifeVorbis for now
#if 0
#include "VorbisFramework.h"
#define vorbis_analysis mac_vorbis_analysis
#define vorbis_analysis_headerout mac_vorbis_analysis_headerout
#define vorbis_analysis_init mac_vorbis_analysis_init
#define vorbis_encode_ctl mac_vorbis_encode_ctl
#define vorbis_encode_setup_init mac_vorbis_encode_setup_init
#define vorbis_encode_setup_managed mac_vorbis_encode_setup_managed
#define vorbis_info_init mac_vorbis_info_init
#define vorbis_info_clear mac_vorbis_info_clear
#define vorbis_comment_init mac_vorbis_comment_init
#define vorbis_comment_clear mac_vorbis_comment_clear
#define vorbis_block_init mac_vorbis_block_init
#define vorbis_block_clear mac_vorbis_block_clear
#define vorbis_dsp_clear mac_vorbis_dsp_clear
#define vorbis_analysis_buffer mac_vorbis_analysis_buffer
#define vorbis_analysis_wrote mac_vorbis_analysis_wrote
#define vorbis_analysis_blockout mac_vorbis_analysis_blockout
#define ogg_stream_packetin mac_ogg_stream_packetin
#define ogg_stream_init mac_ogg_stream_init
#define ogg_stream_flush mac_ogg_stream_flush
#define ogg_stream_pageout mac_ogg_stream_pageout
#define ogg_page_eos mac_ogg_page_eos
#define ogg_stream_clear mac_ogg_stream_clear
#endif
// <FS:Ansariel> FIRE-17812: Increase sounds length to 60s on OpenSim
//S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg)
S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg, bool is_in_secondlife)

View File

@ -11,7 +11,7 @@ include(LLSharedLibs)
include(Copy3rdPartyLibs)
include(ZLIBNG)
include(Tracy)
include(SSE2NEON)
set(llcommon_SOURCE_FILES
apply.cpp
@ -311,6 +311,7 @@ target_link_libraries(
ll::boost
ll::oslibraries
ll::tracy
ll::sse2neon
)
target_include_directories(llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -12,7 +12,10 @@
#if ! defined(LL_FSYSPATH_H)
#define LL_FSYSPATH_H
#include <boost/iterator/transform_iterator.hpp>
#include <filesystem>
#include <string>
#include <string_view>
// While std::filesystem::path can be directly constructed from std::string on
// both Posix and Windows, that's not what we want on Windows. Per
@ -33,37 +36,43 @@
// char"), the "native narrow encoding" isn't UTF-8, so file paths containing
// non-ASCII characters get mangled.
//
// Once we're building with C++20, we could pass a UTF-8 std::string through a
// vector<char8_t> to engage std::filesystem::path's own UTF-8 conversion. But
// sigh, as of 2024-04-03 we're not yet there.
//
// Anyway, encapsulating the important UTF-8 conversions in our own subclass
// allows us to migrate forward to C++20 conventions without changing
// referencing code.
// Encapsulating the important UTF-8 conversions in our own subclass allows us
// to migrate forward to C++20 conventions without changing referencing code.
class fsyspath: public std::filesystem::path
{
using super = std::filesystem::path;
// In C++20 (__cpp_lib_char8_t), std::filesystem::u8path() is deprecated.
// std::filesystem::path(iter, iter) performs UTF-8 conversions when the
// value_type of the iterators is char8_t. While we could copy into a
// temporary std::u8string and from there into std::filesystem::path, to
// minimize string copying we'll define a transform_iterator that accepts
// a std::string_view::iterator and dereferences to char8_t.
struct u8ify
{
char8_t operator()(char c) const { return char8_t(c); }
};
using u8iter = boost::transform_iterator<u8ify, std::string_view::iterator>;
public:
// default
fsyspath() {}
// construct from UTF-8 encoded std::string
fsyspath(const std::string& path): super(std::filesystem::u8path(path)) {}
// construct from UTF-8 encoded const char*
fsyspath(const char* path): super(std::filesystem::u8path(path)) {}
// construct from UTF-8 encoded string
fsyspath(const std::string& path): fsyspath(std::string_view(path)) {}
fsyspath(const char* path): fsyspath(std::string_view(path)) {}
fsyspath(std::string_view path):
super(u8iter(path.begin(), u8ify()), u8iter(path.end(), u8ify()))
{}
// construct from existing path
fsyspath(const super& path): super(path) {}
fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
fsyspath& operator=(const std::string& p)
fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
fsyspath& operator=(const std::string& p) { return (*this) = std::string_view(p); }
fsyspath& operator=(const char* p) { return (*this) = std::string_view(p); }
fsyspath& operator=(std::string_view p)
{
super::operator=(std::filesystem::u8path(p));
return *this;
}
fsyspath& operator=(const char* p)
{
super::operator=(std::filesystem::u8path(p));
assign(u8iter(p.begin(), u8ify()), u8iter(p.end(), u8ify()));
return *this;
}

View File

@ -28,13 +28,6 @@
#define LL_LINDEN_COMMON_H
#include "llprofiler.h"
// <FS:Beq/> #if (TRACY_ENABLE)
#if (TRACY_ENABLE) && LL_PROFILER_ENABLE_TRACY_MEMORY
void *tracy_aligned_malloc(size_t size, size_t alignment);
void tracy_aligned_free(void *memblock);
#define _aligned_malloc(X, Y) tracy_aligned_malloc((X), (Y))
#define _aligned_free(X) tracy_aligned_free((X))
#endif
// *NOTE: Please keep includes here to a minimum!
//

View File

@ -229,7 +229,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
if(wargv[ii][1] == '-') ++offset;
#if LL_WINDOWS
name.assign(utf16str_to_utf8str(&wargv[ii][offset]));
name.assign(ll_convert_wide_to_string(&wargv[ii][offset]));
#else
name.assign(wstring_to_utf8str(&wargv[ii][offset]));
#endif
@ -253,7 +253,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
++ii;
#if LL_WINDOWS
value.assign(utf16str_to_utf8str((wargv[ii])));
value.assign(ll_convert_wide_to_string((wargv[ii])));
#else
value.assign(wstring_to_utf8str((wargv[ii])));
#endif

View File

@ -33,24 +33,12 @@
#include "lltracethreadrecorder.h"
#include "llcleanup.h"
thread_local bool gProfilerEnabled = false;
// <FS:Beq/> #if (TRACY_ENABLE)
#if (TRACY_ENABLE) && LL_PROFILER_ENABLE_TRACY_MEMORY
#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY && TRACY_ENABLE
// Override new/delete for tracy memory profiling
void* ll_tracy_new(size_t size)
{
void* ptr;
if (gProfilerEnabled)
{
//LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
ptr = (malloc)(size);
}
else
{
ptr = (malloc)(size);
}
void* ptr = (malloc)(size);
if (!ptr)
{
throw std::bad_alloc();
@ -59,6 +47,29 @@ void* ll_tracy_new(size_t size)
return ptr;
}
void* ll_tracy_aligned_new(size_t size, size_t alignment)
{
void* ptr = ll_aligned_malloc_fallback(size, alignment);
if (!ptr)
{
throw std::bad_alloc();
}
LL_PROFILE_ALLOC(ptr, size);
return ptr;
}
void ll_tracy_delete(void* ptr)
{
LL_PROFILE_FREE(ptr);
(free)(ptr);
}
void ll_tracy_aligned_delete(void* ptr)
{
LL_PROFILE_FREE(ptr);
ll_aligned_free_fallback(ptr);
}
void* operator new(size_t size)
{
return ll_tracy_new(size);
@ -69,18 +80,14 @@ void* operator new[](std::size_t count)
return ll_tracy_new(count);
}
void ll_tracy_delete(void* ptr)
void* operator new(size_t size, std::align_val_t align)
{
LL_PROFILE_FREE(ptr);
if (gProfilerEnabled)
{
//LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
(free)(ptr);
}
else
{
(free)(ptr);
}
return ll_tracy_aligned_new(size, (size_t)align);
}
void* operator new[](std::size_t count, std::align_val_t align)
{
return ll_tracy_aligned_new(count, (size_t)align);
}
void operator delete(void *ptr) noexcept
@ -93,27 +100,17 @@ void operator delete[](void* ptr) noexcept
ll_tracy_delete(ptr);
}
// C-style malloc/free can't be so easily overridden, so we define tracy versions and use
// a pre-processor #define in linden_common.h to redirect to them. The parens around the native
// functions below prevents recursive substitution by the preprocessor.
//
// Unaligned mallocs are rare in LL code but hooking them causes problems in 3p lib code (looking at
// you, Havok), so we'll only capture the aligned version.
void *tracy_aligned_malloc(size_t size, size_t alignment)
void operator delete(void *ptr, std::align_val_t align) noexcept
{
auto ptr = ll_aligned_malloc_fallback(size, alignment);
if (ptr) LL_PROFILE_ALLOC(ptr, size);
return ptr;
ll_tracy_aligned_delete(ptr);
}
void tracy_aligned_free(void *memblock)
void operator delete[](void* ptr, std::align_val_t align) noexcept
{
LL_PROFILE_FREE(memblock);
ll_aligned_free_fallback(memblock);
ll_tracy_aligned_delete(ptr);
}
#endif
#endif // TRACY_ENABLE && !LL_PROFILER_ENABLE_TRACY_OPENGL
//static
bool LLCommon::sAprInitialized = false;

View File

@ -79,7 +79,7 @@ namespace {
//
if (s.size())
{
OutputDebugString(utf8str_to_utf16str(s).c_str());
OutputDebugString(ll_convert<std::wstring>(s).c_str());
OutputDebugString(TEXT("\n"));
}
}

View File

@ -64,12 +64,7 @@ bool BlockTimer::sLog = false;
std::string BlockTimer::sLogName = "";
bool BlockTimer::sMetricLog = false;
#ifdef LL_DARWIN
//AO: Added ability to test this separately from other OS's
#define USE_RDTSC 0
#else
#endif
#if LL_LINUX || LL_DARWIN // AO: Add LL_DARWIN to this list now
#if LL_LINUX || (LL_DARWIN && LL_ARM64)
U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution
#else
U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution

View File

@ -30,9 +30,14 @@
#include "llinstancetracker.h"
#include "lltrace.h"
#include "lltreeiterators.h"
#include "llprocessor.h"
#if LL_X86 || LL_X86_64
#if LL_WINDOWS
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
#endif
#define LL_FAST_TIMER_ON 1
@ -68,35 +73,10 @@ public:
//
// Windows implementation of CPU clock
//
//
// NOTE: put back in when we aren't using platform sdk anymore
//
// because MS has different signatures for these functions in winnt.h
// need to rename them to avoid conflicts
//#define _interlockedbittestandset _renamed_interlockedbittestandset
//#define _interlockedbittestandreset _renamed_interlockedbittestandreset
//#include <intrin.h>
//#undef _interlockedbittestandset
//#undef _interlockedbittestandreset
//inline U32 getCPUClockCount32()
//{
// U64 time_stamp = __rdtsc();
// return (U32)(time_stamp >> 8);
//}
//
//// return full timer value, *not* shifted by 8 bits
//inline U64 getCPUClockCount64()
//{
// return __rdtsc();
//}
#if LL_FASTTIMER_USE_RDTSC
// shift off lower 8 bits for lower resolution but longer term timing
// on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing
#if LL_FASTTIMER_USE_RDTSC
static U32 getCPUClockCount32()
{
unsigned __int64 val = __rdtsc();
@ -162,26 +142,37 @@ public:
#endif // (LL_LINUX) && !(defined(__i386__) || defined(__amd64__))
// <FS:ND> Linux/Mac should honour LL_FASTTIMER_USE_RDTSC too
//#if (LL_LINUX || LL_DARWIN) && (defined(__i386__) || defined(__amd64__))
#if (LL_LINUX || LL_DARWIN) && (defined(__i386__) || defined(__amd64__)) && LL_FASTTIMER_USE_RDTSC
// </FS:ND>
#if LL_DARWIN && LL_ARM64
//
// Mac+Linux FAST x86 implementation of CPU clock
// Mac implementation of CPU clock - non-x86.
//
static U64 getCPUClockCount64()
{
return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
}
static U32 getCPUClockCount32()
{
U32 low(0),high(0);
__asm__ volatile (".byte 0x0f, 0x31": "=a"(low), "=d"(high) );
return (low>>8) | (high<<24);
return (U32)(getCPUClockCount64() >> 8);
}
#endif // LL_DARWIN && LL_ARM64
#if (LL_LINUX || LL_DARWIN) && (LL_X86 || LL_X86_64)
//
// Mac+Linux FAST x86 implementation of CPU clock
//
#if LL_FASTTIMER_USE_RDTSC
static U32 getCPUClockCount32()
{
U64 time_stamp = __rdtsc() >> 8U;
return static_cast<U32>(time_stamp);
}
static U64 getCPUClockCount64()
{
U32 low(0),high(0);
__asm__ volatile (".byte 0x0f, 0x31": "=a"(low), "=d"(high) );
return (U64)low | ( ((U64)high) << 32);
return static_cast<U64>(__rdtsc());
}
#endif
#endif
static BlockTimerStatHandle& getRootTimeBlock();

View File

@ -178,8 +178,7 @@ int LLFile::mkdir(const std::string& dirname, int perms)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
std::wstring utf16dirname = ll_convert<std::wstring>(dirname);
int rc = _wmkdir(utf16dirname.c_str());
#else
int rc = ::mkdir(dirname.c_str(), (mode_t)perms);
@ -201,8 +200,7 @@ int LLFile::rmdir(const std::string& dirname)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
std::wstring utf16dirname = ll_convert<std::wstring>(dirname);
int rc = _wrmdir(utf16dirname.c_str());
#else
int rc = ::rmdir(dirname.c_str());
@ -214,10 +212,8 @@ int LLFile::rmdir(const std::string& dirname)
LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfinder: ignore */
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
std::wstring utf16mode = ll_convert<std::wstring>(std::string(mode));
return _wfopen(utf16filename.c_str(),utf16mode.c_str());
#else
return ::fopen(filename.c_str(),mode); /* Flawfinder: ignore */
@ -227,10 +223,8 @@ LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawf
LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
std::wstring utf16mode = ll_convert<std::wstring>(std::string(mode));
return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);
#else
llassert(0);//No corresponding function on non-windows
@ -270,8 +264,7 @@ std::string LLFile::getContents(const std::string& filename)
int LLFile::remove(const std::string& filename, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
int rc = _wremove(utf16filename.c_str());
#else
int rc = ::remove(filename.c_str());
@ -282,10 +275,8 @@ int LLFile::remove(const std::string& filename, int supress_error)
int LLFile::rename(const std::string& filename, const std::string& newname, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8newname = newname;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16newname = utf8str_to_utf16str(utf8newname);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
std::wstring utf16newname = ll_convert<std::wstring>(newname);
int rc = _wrename(utf16filename.c_str(),utf16newname.c_str());
#else
int rc = ::rename(filename.c_str(),newname.c_str());
@ -360,8 +351,7 @@ bool LLFile::copy(const std::string& from, const std::string& to)
int LLFile::stat(const std::string& filename, llstat* filestatus)
{
#if LL_WINDOWS
std::string utf8filename = filename;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
// <FS:ND> Make sure no path does end in / or \. Otherwise _wstat fails
// See http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx (FindFileFirst)
@ -497,14 +487,14 @@ llifstream::llifstream() {}
// explicit
llifstream::llifstream(const std::string& _Filename, ios_base::openmode _Mode):
std::ifstream(utf8str_to_utf16str( _Filename ).c_str(),
std::ifstream(ll_convert<std::wstring>( _Filename ).c_str(),
_Mode | ios_base::in)
{
}
void llifstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
std::ifstream::open(utf8str_to_utf16str(_Filename).c_str(),
std::ifstream::open(ll_convert<std::wstring>(_Filename).c_str(),
_Mode | ios_base::in);
}
@ -516,14 +506,14 @@ llofstream::llofstream() {}
// explicit
llofstream::llofstream(const std::string& _Filename, ios_base::openmode _Mode):
std::ofstream(utf8str_to_utf16str( _Filename ).c_str(),
std::ofstream(ll_convert<std::wstring>( _Filename ).c_str(),
_Mode | ios_base::out)
{
}
void llofstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
std::ofstream::open(utf8str_to_utf16str( _Filename ).c_str(),
std::ofstream::open(ll_convert<std::wstring>( _Filename ).c_str(),
_Mode | ios_base::out);
}

View File

@ -255,6 +255,11 @@ void LLMD5::raw_digest(unsigned char* s) const
memcpy(s, digest, 16); /* Flawfinder: ignore */
}
#if LL_DARWIN
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
void LLMD5::hex_digest(char* s) const
{
if (!finalized)
@ -273,6 +278,10 @@ void LLMD5::hex_digest(char* s) const
s[32] = '\0';
}
#if LL_DARWIN
#pragma clang diagnostic pop
#endif
std::ostream& operator<<(std::ostream& stream, const LLMD5& context)
{
char s[33]; /* Flawfinder: ignore */

View File

@ -71,7 +71,11 @@ LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
#define ll_assert_aligned(ptr,alignment)
#endif
#if LL_ARM64
#include "sse2neon.h"
#else
#include <xmmintrin.h>
#endif
template <typename T> T* LL_NEXT_ALIGNED_ADDRESS(T* address)
{
@ -231,8 +235,6 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
#if defined(LL_WINDOWS)
void* ret = _aligned_malloc(size, 32);
#elif defined(LL_DARWIN)
void* ret = ll_aligned_malloc_fallback( size, 32 );
#else
void *ret;
if (0 != posix_memalign(&ret, 32, size))
@ -248,8 +250,31 @@ inline void ll_aligned_free_32(void *p)
LL_PROFILE_FREE(p);
#if defined(LL_WINDOWS)
_aligned_free(p);
#elif defined(LL_DARWIN)
ll_aligned_free_fallback( p );
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
inline void* ll_aligned_malloc_64(size_t size) // returned hunk MUST be freed with ll_aligned_free_32().
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
#if defined(LL_WINDOWS)
void* ret = _aligned_malloc(size, 64);
#else
void *ret;
if (0 != posix_memalign(&ret, 64, size))
return nullptr;
#endif
LL_PROFILE_ALLOC(ret, size);
return ret;
}
inline void ll_aligned_free_64(void *p)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
LL_PROFILE_FREE(p);
#if defined(LL_WINDOWS)
_aligned_free(p);
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
@ -261,19 +286,23 @@ LL_FORCE_INLINE void* ll_aligned_malloc(size_t size)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
void* ret;
if (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0)
if constexpr (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0)
{
ret = malloc(size);
LL_PROFILE_ALLOC(ret, size);
}
else if (ALIGNMENT == 16)
else if constexpr (ALIGNMENT == 16)
{
ret = ll_aligned_malloc_16(size);
}
else if (ALIGNMENT == 32)
else if constexpr (ALIGNMENT == 32)
{
ret = ll_aligned_malloc_32(size);
}
else if constexpr (ALIGNMENT == 64)
{
ret = ll_aligned_malloc_64(size);
}
else
{
ret = ll_aligned_malloc_fallback(size, ALIGNMENT);
@ -285,16 +314,20 @@ template<size_t ALIGNMENT>
LL_FORCE_INLINE void ll_aligned_free(void* ptr)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
if constexpr (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
{
LL_PROFILE_FREE(ptr);
free(ptr);
}
else if (ALIGNMENT == 16)
else if constexpr (ALIGNMENT == 16)
{
ll_aligned_free_16(ptr);
}
else if (ALIGNMENT == 32)
else if constexpr (ALIGNMENT == 32)
{
return ll_aligned_free_32(ptr);
}
else if constexpr (ALIGNMENT == 64)
{
return ll_aligned_free_32(ptr);
}
@ -310,6 +343,9 @@ LL_FORCE_INLINE void ll_aligned_free(void* ptr)
inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
#if defined(LL_ARM64)
memcpy(dst, src, bytes);
#else
assert(src != NULL);
assert(dst != NULL);
assert(bytes > 0);
@ -387,6 +423,7 @@ inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __
// </FS:ND>
#endif
}
#ifndef __DEBUG_PRIVATE_MEM__

View File

@ -92,6 +92,23 @@
#endif
#endif
// Set up CPU architecture defines
#if LL_MSVC && defined(_M_ARM64)
# define LL_ARM64 1
#elif LL_GNUC && (defined(__arm64__) || defined(__aarch64__))
# define LL_ARM64 1
#elif LL_MSVC && _M_X64
# define LL_X86_64 1
# define LL_X86 1
#elif LL_MSVC && _M_IX86
# define LL_X86 1
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
# define LL_X86_64 1
# define LL_X86 1
#elif LL_GNUC && ( defined(__i386__) )
# define LL_X86 1
#endif
// Deal with minor differences on Unixy OSes.
#if LL_DARWIN || LL_LINUX
// Different name, same functionality.
@ -134,11 +151,8 @@
#if LL_WINDOWS
#define LL_DLLEXPORT __declspec(dllexport)
#define LL_DLLIMPORT __declspec(dllimport)
#elif LL_LINUX
#define LL_DLLEXPORT __attribute__ ((visibility("default")))
#define LL_DLLIMPORT
#else
#define LL_DLLEXPORT
#define LL_DLLEXPORT __attribute__ ((visibility("default")))
#define LL_DLLIMPORT
#endif // LL_WINDOWS
@ -183,7 +197,7 @@
#define LL_TO_STRING_HELPER(x) #x
#define LL_TO_STRING(x) LL_TO_STRING_HELPER(x)
#define LL_TO_WSTRING_HELPER(x) L#x
#define LL_TO_WSTRING_HELPER(x) L## #x
#define LL_TO_WSTRING(x) LL_TO_WSTRING_HELPER(x)
#define LL_FILE_LINENO_MSG(msg) __FILE__ "(" LL_TO_STRING(__LINE__) ") : " msg
#define LL_GLUE_IMPL(x, y) x##y
@ -203,4 +217,16 @@
#define LL_PRETTY_FUNCTION __PRETTY_FUNCTION__
#endif
#if LL_ARM64
#define GLM_FORCE_NEON 1
#else
#define GLM_FORCE_SSE2 1
#endif
#if LL_ARM64
#define KDU_NEON_INTRINSICS 1
#else
#define KDU_X86_INTRINSICS 1
#endif
#endif // not LL_LINDEN_PREPROCESSOR_H

View File

@ -628,6 +628,8 @@ private:
#elif LL_DARWIN
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <mach/machine.h>
#include <sys/sysctl.h>
@ -638,25 +640,21 @@ public:
{
getCPUIDInfo();
uint64_t frequency = getSysctlInt64("hw.cpufrequency");
if (!frequency)
if (frequency == 0) // fallback to clockrate and tbfrequency
{
auto tbfrequency = getSysctlInt64("hw.tbfrequency");
struct clockinfo clockrate;
auto clockrate_len = sizeof(clockrate);
if (!sysctlbyname("kern.clockrate", &clockrate, &clockrate_len, NULL, 0))
frequency = tbfrequency * clockrate.hz;
frequency = getSysctlClockrate() * getSysctlInt64("hw.tbfrequency");
}
setInfo(eFrequency, (F64)frequency / (F64)1000000);
}
virtual ~LLProcessorInfoDarwinImpl() {}
virtual ~LLProcessorInfoDarwinImpl() = default;
private:
int getSysctlInt(const char* name)
{
int result = 0;
size_t len = sizeof(int);
int error = sysctlbyname(name, (void*)&result, &len, NULL, 0);
int error = sysctlbyname(name, (void*)&result, &len, nullptr, 0);
return error == -1 ? 0 : result;
}
@ -664,7 +662,7 @@ private:
{
uint64_t value = 0;
size_t size = sizeof(value);
int result = sysctlbyname(name, (void*)&value, &size, NULL, 0);
int result = sysctlbyname(name, (void*)&value, &size, nullptr, 0);
if ( result == 0 )
{
if ( size == sizeof( uint64_t ) )
@ -684,6 +682,14 @@ private:
return result == -1 ? 0 : value;
}
uint64_t getSysctlClockrate()
{
struct clockinfo clockrate{};
size_t size = sizeof(clockrate);
int error = sysctlbyname("kern.clockrate", &clockrate, &size, nullptr, 0);
return error == -1 ? 0 : clockrate.hz;
}
void getCPUIDInfo()
{
size_t len = 0;

View File

@ -28,20 +28,7 @@
#ifndef LLPROCESSOR_H
#define LLPROCESSOR_H
#include "llunits.h"
#if LL_MSVC && _M_X64
# define LL_X86_64 1
# define LL_X86 1
#elif LL_MSVC && _M_IX86
# define LL_X86 1
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
# define LL_X86_64 1
# define LL_X86 1
#elif LL_GNUC && ( defined(__i386__) )
# define LL_X86 1
#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
# define LL_PPC 1
#endif
#include "llpreprocessor.h"
class LLProcessorInfoImpl;

View File

@ -74,7 +74,6 @@
#define LL_PROFILER_CONFIGURATION LL_PROFILER_CONFIG_FAST_TIMER
#endif
extern thread_local bool gProfilerEnabled; // <FS:Beq/> This is being used to control memory allocations
// <FS:Beq> We use the active flag to control deferred profiling.
// It is functionally separate to the (poorly named) gProfilerEnabled flag
namespace LLProfiler
@ -93,14 +92,14 @@ namespace LLProfiler
#define LL_PROFILER_ENABLE_TRACY_OPENGL 1
// Enable RenderDoc labeling
#define LL_PROFILER_ENABLE_RENDER_DOC 0
//#define LL_PROFILER_ENABLE_RENDER_DOC 0
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY
#define LL_PROFILER_FRAME_END FrameMark;
// <FS:Beq> Note: this threadlocal forces memory colelction enabled from the start. It conflicts with deferred profiling.
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name ); gProfilerEnabled = true;
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name );
// </FS:Beq>
#define LL_PROFILER_THREAD_BEGIN(name) FrameMarkStart( name ); // C string
#define LL_PROFILER_THREAD_END(name) FrameMarkEnd( name ); // C string
@ -171,7 +170,7 @@ namespace LLProfiler
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER
#define LL_PROFILER_FRAME_END FrameMark;
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name ); gProfilerEnabled = true;
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name );
#define LL_PROFILER_THREAD_BEGIN(name) FrameMarkStart( name ); // C string
#define LL_PROFILER_THREAD_END(name) FrameMarkEnd( name ); // C string
@ -235,25 +234,22 @@ namespace LLProfiler
#endif // LL_PROFILER
#if LL_PROFILER_ENABLE_TRACY_OPENGL
#define LL_PROFILE_GPU_ZONE(name) TracyGpuZone(name);
#define LL_PROFILE_GPU_ZONEC(name,color) TracyGpuZoneC(name,color);
#define LL_PROFILE_GPU_ZONE(name) TracyGpuZone(name);
#define LL_PROFILE_GPU_ZONEC(name,color) TracyGpuZoneC(name,color);
#define LL_PROFILER_GPU_COLLECT TracyGpuCollect;
#define LL_PROFILER_GPU_CONTEXT TracyGpuContext;
#define LL_PROFILER_GPU_CONTEXT_NS(name, size) TracyGpuContext;TracyGpuContextName(name,size);
// disable memory tracking (incompatible with GPU tracing
#define LL_PROFILE_ALLOC(ptr, size) (void)(ptr); (void)(size);
#define LL_PROFILE_FREE(ptr) (void)(ptr);
#define LL_PROFILER_GPU_CONTEXT_NAMED TracyGpuContextName
#else
#define LL_PROFILE_GPU_ZONE(name) (void)name;
#define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color;
#define LL_PROFILE_GPU_ZONE(name) (void)name;
#define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color;
#define LL_PROFILER_GPU_COLLECT
#define LL_PROFILER_GPU_CONTEXT
#define LL_PROFILER_GPU_CONTEXT_NAMED(name) (void)name;
#define LL_PROFILER_GPU_CONTEXT_NS(name, size) (void)name;(void)size;
#endif // LL_PROFILER_ENABLE_TRACY_OPENGL
#define LL_LABEL_OBJECT_GL(type, name, length, label)
#if !LL_DARWIN && LL_PROFILER_CONFIGURATION > 1
#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY
#define LL_PROFILE_ALLOC(ptr, size) TracyAlloc(ptr, size);
#define LL_PROFILE_FREE(ptr) TracyFree(ptr);
#else
@ -261,8 +257,6 @@ namespace LLProfiler
#define LL_PROFILE_FREE(ptr) (void)(ptr);
#endif
#endif
#if LL_PROFILER_ENABLE_RENDER_DOC
#define LL_LABEL_OBJECT_GL(type, name, length, label) glObjectLabel(type, name, length, label);
#else

View File

@ -1518,8 +1518,8 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
std::wstringstream strStream;
S32 intDecimals = 0;
std::wstring wDecimals = utf8str_to_utf16str(decimals);
std::wstring wNumStr = utf8str_to_utf16str(numStr);
std::wstring wDecimals = ll_convert<std::wstring>(decimals);
std::wstring wNumStr = ll_convert<std::wstring>(numStr);
LLStringUtilBase<wchar_t>::convertToS32 (wDecimals, intDecimals);
if (!sLocale.empty())
{
@ -1542,7 +1542,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
if (LLStringUtilBase<wchar_t>::convertToS32(wNumStr, intStr))
{
strStream << intStr;
numStr = wstring_to_utf8str( strStream.str() );
numStr = ll_convert<std::string>(strStream.str());
}
}
else
@ -1552,7 +1552,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
if (LLStringUtilBase<wchar_t>::convertToF32(wNumStr, floatStr))
{
strStream << std::fixed << std::showpoint << std::setprecision(intDecimals) << floatStr;
numStr = wstring_to_utf8str( strStream.str() );
numStr = ll_convert<std::string>(strStream.str());
}
}
#else

View File

@ -199,6 +199,9 @@ LLOSInfo::LLOSInfo() :
GetSystemInfo(&si); //if it fails get regular system info
//(Warning: If GetSystemInfo it may result in incorrect information in a WOW64 machine, if the kernel fails to load)
#pragma warning(push)
#pragma warning(disable : 4996) // ignore 'deprecated.' GetVersionEx is deprecated
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
@ -217,6 +220,8 @@ LLOSInfo::LLOSInfo() :
}
}
#pragma warning(pop)
S32 ubr = 0; // Windows 10 Update Build Revision, can be retrieved from a registry
if (mMajorVer == 10)
{
@ -1355,7 +1360,7 @@ bool gunzip_file(const std::string& srcfile, const std::string& dstfile)
S32 bytes = 0;
tmpfile = dstfile + ".t";
#ifdef LL_WINDOWS
llutf16string utf16filename = utf8str_to_utf16str(srcfile);
std::wstring utf16filename = ll_convert<std::wstring>(srcfile);
src = gzopen_w(utf16filename.c_str(), "rb");
#else
src = gzopen(srcfile.c_str(), "rb");
@ -1399,7 +1404,7 @@ bool gzip_file(const std::string& srcfile, const std::string& dstfile)
tmpfile = dstfile + ".t";
#ifdef LL_WINDOWS
llutf16string utf16filename = utf8str_to_utf16str(tmpfile);
std::wstring utf16filename = ll_convert<std::wstring>(tmpfile);
dst = gzopen_w(utf16filename.c_str(), "wb");
#else
dst = gzopen(tmpfile.c_str(), "wb");

View File

@ -458,8 +458,8 @@ ElementT LLThreadSafeQueue<ElementT, QueueT>::pop(void)
// so we can finish draining the queue.
pop_result popped = pop_(lock1, value);
if (popped == POPPED)
// <FS:Ansariel> Prevent RVO elision
//return std::move(value);
// don't use std::move when returning local value because
// it prevents the compiler from optimizing with copy elision
return value;
// Once the queue is DONE, there will never be any more coming.

View File

@ -110,6 +110,17 @@ namespace tut
void stringize_object::test<3>()
{
//Tests rely on validity of wstring_to_utf8str()
#if LL_WINDOWS // Windows wstring is a 2byte UTF16 type
ensure_equals(ll_convert<std::string>(wstringize(c)), ll_convert<std::string>(std::wstring(L"c")));
ensure_equals(ll_convert<std::string>(wstringize(s)), ll_convert<std::string>(std::wstring(L"17")));
ensure_equals(ll_convert<std::string>(wstringize(i)), ll_convert<std::string>(std::wstring(L"34")));
ensure_equals(ll_convert<std::string>(wstringize(l)), ll_convert<std::string>(std::wstring(L"68")));
ensure_equals(ll_convert<std::string>(wstringize(f)), ll_convert<std::string>(std::wstring(L"3.14159")));
ensure_equals(ll_convert<std::string>(wstringize(d)), ll_convert<std::string>(std::wstring(L"3.14159")));
ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(std::wstring(L"abc def")));
ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(wstringize(abc.c_str())));
ensure_equals(ll_convert<std::string>(wstringize(def)), ll_convert<std::string>(std::wstring(L"def ghi")));
#else
ensure_equals(wstring_to_utf8str(wstringize(c)), wstring_to_utf8str(L"c"));
ensure_equals(wstring_to_utf8str(wstringize(s)), wstring_to_utf8str(L"17"));
ensure_equals(wstring_to_utf8str(wstringize(i)), wstring_to_utf8str(L"34"));
@ -119,6 +130,7 @@ namespace tut
ensure_equals(wstring_to_utf8str(wstringize(abc)), wstring_to_utf8str(L"abc def"));
ensure_equals(wstring_to_utf8str(wstringize(abc)), wstring_to_utf8str(wstringize(abc.c_str())));
ensure_equals(wstring_to_utf8str(wstringize(def)), wstring_to_utf8str(L"def ghi"));
#endif
// ensure_equals(wstring_to_utf8str(wstringize(llsd)), wstring_to_utf8str(L"{'abc':'abc def','d':r3.14159,'i':i34}"));
}
} // namespace tut

View File

@ -52,8 +52,6 @@
void init_curl();
void term_curl();
void ssl_thread_id_callback(CRYPTO_THREADID*);
void ssl_locking_callback(int mode, int type, const char * file, int line);
void usage(std::ostream & out);
// Default command line settings
@ -606,63 +604,15 @@ void WorkingSet::loadAssetUuids(FILE * in)
}
int ssl_mutex_count(0);
LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
void init_curl()
{
curl_global_init(CURL_GLOBAL_ALL);
ssl_mutex_count = CRYPTO_num_locks();
if (ssl_mutex_count > 0)
{
ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
for (int i(0); i < ssl_mutex_count; ++i)
{
ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
}
CRYPTO_set_locking_callback(ssl_locking_callback);
CRYPTO_THREADID_set_callback(ssl_thread_id_callback);
}
}
void term_curl()
{
CRYPTO_set_locking_callback(NULL);
for (int i(0); i < ssl_mutex_count; ++i)
{
delete ssl_mutex_list[i];
}
delete [] ssl_mutex_list;
}
void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid)
{
#if defined(WIN32)
CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread());
#else
CRYPTO_THREADID_set_pointer(pthreadid, pthread_self());
#endif
}
void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
{
if (type >= 0 && type < ssl_mutex_count)
{
if (mode & CRYPTO_LOCK)
{
ssl_mutex_list[type]->lock();
}
else
{
ssl_mutex_list[type]->unlock();
}
}
curl_global_cleanup();
}

View File

@ -41,11 +41,7 @@
#include "test_httpstatus.hpp"
#include "test_refcounted.hpp"
#include "test_httpoperation.hpp"
// As of 2019-06-28, test_httprequest.hpp consistently crashes on Mac Release
// builds for reasons not yet diagnosed.
#if ! (LL_DARWIN && LL_RELEASE)
#include "test_httprequest.hpp"
#endif
#include "test_httpheaders.hpp"
#include "test_httprequestqueue.hpp"
#include "_httpservice.h"
@ -53,9 +49,6 @@
#include "llproxy.h"
#include "llcleanup.h"
void ssl_thread_id_callback(CRYPTO_THREADID*);
void ssl_locking_callback(int mode, int type, const char * file, int line);
#if 0 // lltut provides main and runner
namespace tut
@ -80,27 +73,10 @@ int main()
#endif // 0
int ssl_mutex_count(0);
LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
void init_curl()
{
curl_global_init(CURL_GLOBAL_ALL);
ssl_mutex_count = CRYPTO_num_locks();
if (ssl_mutex_count > 0)
{
ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
for (int i(0); i < ssl_mutex_count; ++i)
{
ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
}
CRYPTO_set_locking_callback(ssl_locking_callback);
CRYPTO_THREADID_set_callback(ssl_thread_id_callback);
}
LLProxy::getInstance();
}
@ -108,39 +84,6 @@ void init_curl()
void term_curl()
{
SUBSYSTEM_CLEANUP(LLProxy);
CRYPTO_set_locking_callback(NULL);
for (int i(0); i < ssl_mutex_count; ++i)
{
delete ssl_mutex_list[i];
}
delete [] ssl_mutex_list;
}
void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid)
{
#if defined(WIN32)
CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread());
#else
CRYPTO_THREADID_set_pointer(pthreadid, pthread_self());
#endif
}
void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
{
if (type >= 0 && type < ssl_mutex_count)
{
if (mode & CRYPTO_LOCK)
{
ssl_mutex_list[type]->lock();
}
else
{
ssl_mutex_list[type]->unlock();
}
}
}

View File

@ -454,6 +454,10 @@ void HttpRequestTestObjectType::test<4>()
template <> template <>
void HttpRequestTestObjectType::test<5>()
{
#ifndef LL_WINDOWS
skip("Skip due to issues with testing pthread cancellation");
#endif
ScopedCurlInit ready;
set_test_name("HttpRequest Spin (soft) + NoOp + hard termination");
@ -517,6 +521,9 @@ void HttpRequestTestObjectType::test<5>()
template <> template <>
void HttpRequestTestObjectType::test<6>()
{
#ifndef LL_WINDOWS
skip("Skip due to issues with testing pthread cancellation");
#endif
ScopedCurlInit ready;
set_test_name("HttpRequest Spin + NoOp + hard termination");
@ -2779,7 +2786,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test_count; ++i)
{
char buffer[128];
sprintf(buffer, "/bug2295/%d/", i);
snprintf(buffer, sizeof(buffer), "/bug2295/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
@ -2810,7 +2817,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test2_count; ++i)
{
char buffer[128];
sprintf(buffer, "/bug2295/00000012/%d/", i);
snprintf(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
@ -2841,7 +2848,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test3_count; ++i)
{
char buffer[128];
sprintf(buffer, "/bug2295/inv_cont_range/%d/", i);
snprintf(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,

View File

@ -28,8 +28,6 @@
#include "_refcounted.h"
// disable all of this because it's hanging win64 builds?
#if ! (LL_WINDOWS && ADDRESS_SIZE == 64)
using namespace LLCoreInt;
namespace tut
@ -122,5 +120,4 @@ namespace tut
ensure(rc->getRefCount() == RefCounted::NOT_REF_COUNTED);
}
}
#endif // disabling on Win64
#endif // TEST_LLCOREINT_REF_COUNTED_H_

View File

@ -189,7 +189,7 @@ LLSD LLCrashLock::getProcessList()
bool LLCrashLock::fileExists(std::string filename)
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path file_path(utf8str_to_utf16str(filename));
boost::filesystem::path file_path(ll_convert<std::wstring>(filename));
#else
boost::filesystem::path file_path(filename);
#endif
@ -199,7 +199,7 @@ bool LLCrashLock::fileExists(std::string filename)
void LLCrashLock::cleanupProcess(std::string proc_dir)
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path dir_path(utf8str_to_utf16str(proc_dir));
boost::filesystem::path dir_path(ll_convert<std::wstring>(proc_dir));
#else
boost::filesystem::path dir_path(proc_dir);
#endif

View File

@ -107,7 +107,7 @@ std::vector<std::string> LLDir::getFilesInDir(const std::string &dirname)
//Returns a vector of fullpath filenames.
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path p(utf8str_to_utf16str(dirname));
boost::filesystem::path p(ll_convert<std::wstring>(dirname));
#else
boost::filesystem::path p(dirname);
#endif
@ -203,7 +203,7 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name)
try
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path dir_path(utf8str_to_utf16str(dir_name));
boost::filesystem::path dir_path(ll_convert<std::wstring>(dir_name));
#else
boost::filesystem::path dir_path(dir_name);
#endif

View File

@ -165,7 +165,7 @@ LLDir_Mac::LLDir_Mac()
mWorkingDir = getCurPath();
mLLPluginDir = mAppRODataDir + mDirDelimiter + "llplugin";
mLLPluginDir = mAppRODataDir + mDirDelimiter + "SLPlugin.app" + mDirDelimiter + "Contents" + mDirDelimiter + "Frameworks";
}
}

View File

@ -172,7 +172,7 @@ LLDir_Win32::LLDir_Win32()
{
w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash
}
mTempDir = utf16str_to_utf8str(llutf16string(w_str));
mTempDir = ll_convert<std::string>(std::wstring(w_str));
if (mOSUserDir.empty())
{
@ -231,7 +231,7 @@ LLDir_Win32::LLDir_Win32()
if (size)
{
w_str[size] = '\0';
mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str));
mExecutablePathAndName = ll_convert<std::string>(std::wstring(w_str));
auto path_end = mExecutablePathAndName.find_last_of('\\');
if (path_end != std::string::npos)
{
@ -243,19 +243,19 @@ LLDir_Win32::LLDir_Win32()
mExecutableFilename = mExecutablePathAndName;
}
GetCurrentDirectory(MAX_PATH, w_str);
mWorkingDir = utf16str_to_utf8str(llutf16string(w_str));
mWorkingDir = ll_convert<std::string>(std::wstring(w_str));
}
else
{
LL_WARNS("AppInit") << "Couldn't get APP path, assuming current directory!\n" << LL_ENDL;
GetCurrentDirectory(MAX_PATH, w_str);
mExecutableDir = utf16str_to_utf8str(llutf16string(w_str));
mExecutableDir = ll_convert<std::string>(std::wstring(w_str));
// Assume it's the current directory
}
#else
GetCurrentDirectory(MAX_PATH, w_str);
mExecutableDir = utf16str_to_utf8str(llutf16string(w_str));
mExecutableDir = ll_convert<std::string>(std::wstring(w_str));
#endif
@ -350,8 +350,8 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string &
WIN32_FIND_DATA FileData;
llutf16string pathname = utf8str_to_utf16str(dirname);
pathname += utf8str_to_utf16str(mask);
std::wstring pathname = ll_convert<std::wstring>(dirname);
pathname += ll_convert<std::wstring>(mask);
if ((count_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
{
@ -377,7 +377,7 @@ bool LLDir_Win32::getNextFileInDir(const std::string &dirname, const std::string
fname = "";
WIN32_FIND_DATAW FileData;
llutf16string pathname = utf8str_to_utf16str(dirname) + utf8str_to_utf16str(mask);
std::wstring pathname = ll_convert<std::wstring>(dirname) + ll_convert<std::wstring>(mask);
if (pathname != mCurrentDir)
{
@ -424,7 +424,7 @@ bool LLDir_Win32::getNextFileInDir(const std::string &dirname, const std::string
if (fileFound)
{
// convert from TCHAR to char
fname = utf16str_to_utf8str(FileData.cFileName);
fname = ll_convert<std::string>(std::wstring(FileData.cFileName));
}
return fileFound;
@ -435,7 +435,7 @@ std::string LLDir_Win32::getCurPath()
WCHAR w_str[MAX_PATH];
GetCurrentDirectory(MAX_PATH, w_str);
return utf16str_to_utf8str(llutf16string(w_str));
return ll_convert<std::string>(std::wstring(w_str));
}

View File

@ -51,7 +51,7 @@ public:
private:
void* mDirSearch_h{ nullptr };
llutf16string mCurrentDir;
std::wstring mCurrentDir;
};
#endif // LL_LLDIR_WIN32_H

View File

@ -31,6 +31,9 @@
#include "llerror.h"
#if LL_WINDOWS
#include "llwin32headers.h"
class LLDirectoryGuard
{
public:
@ -46,8 +49,8 @@ public:
(wcsncmp(mOrigDir,mFinalDir,mOrigDirLen)!=0))
{
// Dir has changed
std::string mOrigDirUtf8 = utf16str_to_utf8str(llutf16string(mOrigDir));
std::string mFinalDirUtf8 = utf16str_to_utf8str(llutf16string(mFinalDir));
std::string mOrigDirUtf8 = ll_convert<std::string>(std::wstring(mOrigDir));
std::string mFinalDirUtf8 = ll_convert<std::string>(std::wstring(mFinalDir));
LL_INFOS() << "Resetting working dir from " << mFinalDirUtf8 << " to " << mOrigDirUtf8 << LL_ENDL;
SetCurrentDirectory(mOrigDir);
}

View File

@ -52,7 +52,7 @@ LLDirIterator::Impl::Impl(const std::string &dirname, const std::string &mask)
: mIsValid(false)
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
fs::path dir_path(utf8str_to_utf16str(dirname));
fs::path dir_path(ll_convert<std::wstring>(dirname));
#else
fs::path dir_path(dirname);
#endif

View File

@ -124,7 +124,7 @@ void LLDiskCache::purge()
std::vector<file_info_t> file_info;
#if LL_WINDOWS
std::wstring cache_path(utf8str_to_utf16str(sCacheDir));
std::wstring cache_path(ll_convert<std::wstring>(sCacheDir));
#else
std::string cache_path(sCacheDir);
#endif
@ -416,7 +416,7 @@ void LLDiskCache::clearCache()
*/
boost::system::error_code ec;
#if LL_WINDOWS
std::wstring cache_path(utf8str_to_utf16str(sCacheDir));
std::wstring cache_path(ll_convert<std::wstring>(sCacheDir));
#else
std::string cache_path(sCacheDir);
#endif
@ -457,7 +457,7 @@ void LLDiskCache::removeOldVFSFiles()
boost::system::error_code ec;
#if LL_WINDOWS
std::wstring cache_path(utf8str_to_utf16str(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")));
std::wstring cache_path(ll_convert<std::wstring>(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")));
#else
std::string cache_path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""));
#endif
@ -522,7 +522,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string& dir, bool force)
*/
boost::system::error_code ec;
#if LL_WINDOWS
std::wstring dir_path(utf8str_to_utf16str(dir));
std::wstring dir_path(ll_convert<std::wstring>(dir));
#else
std::string dir_path(dir);
#endif

View File

@ -412,7 +412,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path)
boost::system::error_code ec;
#if LL_WINDOWS
// file last write time
const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec);
const std::time_t last_write_time = boost::filesystem::last_write_time(ll_convert<std::wstring>(file_path), ec);
if (ec.failed())
{
LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
@ -426,7 +426,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path)
// before the last one
if (delta_time > time_threshold)
{
boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec);
boost::filesystem::last_write_time(ll_convert<std::wstring>(file_path), cur_time, ec);
}
#else
// file last write time

View File

@ -435,7 +435,7 @@ namespace tut
for (counter=0, foundUnused=false; !foundUnused; counter++ )
{
char counterStr[3];
sprintf(counterStr, "%02d", counter);
snprintf(counterStr, sizeof(counterStr), "%02d", counter);
uniqueDir = dirbase + counterStr;
foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) );
}

View File

@ -31,7 +31,9 @@
#include "llerror.h"
#include "llexception.h"
#if !LL_ARM64
jmp_buf LLImageJPEG::sSetjmpBuffer ;
#endif
LLImageJPEG::LLImageJPEG(S32 quality)
: LLImageFormatted(IMG_CODEC_JPEG),
mOutputBuffer( NULL ),
@ -78,12 +80,15 @@ bool LLImageJPEG::updateData()
//
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//except in the case of AARCH64/ARM64 where setjmp will crash
//
#if !LL_ARM64
if(setjmp(sSetjmpBuffer))
{
jpeg_destroy_decompress(&cinfo);
return false;
}
#endif
try
{
// Now we can initialize the JPEG decompression object.
@ -223,11 +228,13 @@ bool LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time)
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//
#if !LL_ARM64
if(setjmp(sSetjmpBuffer))
{
jpeg_destroy_decompress(&cinfo);
return true; // done
}
#endif
try
{
// Now we can initialize the JPEG decompression object.
@ -432,9 +439,10 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )
// Let the memory manager delete any temp files
jpeg_destroy(cinfo);
#if !LL_ARM64
// Return control to the setjmp point
longjmp(sSetjmpBuffer, 1) ;
#endif
}
// Decide whether to emit a trace or warning message.
@ -552,6 +560,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//
#if !LL_ARM64
if( setjmp(sSetjmpBuffer) )
{
// If we get here, the JPEG code has signaled an error.
@ -562,7 +571,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
mOutputBufferSize = 0;
return false;
}
#endif
try
{

View File

@ -78,7 +78,9 @@ protected:
S32 mEncodeQuality; // on a scale from 1 to 100
private:
#if !LL_ARM64
static jmp_buf sSetjmpBuffer; // To allow the library to abort.
#endif
};
#endif // LL_LLIMAGEJPEG_H

View File

@ -29,8 +29,6 @@
// this is defined so that we get static linking.
#include "openjpeg.h"
#include "event.h"
#include "cio.h"
// Factory function: see declaration in llimagej2c.cpp
LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl()
@ -51,6 +49,7 @@ std::string LLImageJ2COJ::getEngineInfo() const
// </FS:Ansariel>
}
#if WANT_VERBOSE_OPJ_SPAM
// Return string from message, eliminating final \n if present
static std::string chomp(const char* msg)
{
@ -66,27 +65,34 @@ static std::string chomp(const char* msg)
}
return message;
}
#endif
/**
sample error callback expecting a LLFILE* client object
*/
void error_callback(const char* msg, void*)
{
LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#endif
}
/**
sample warning callback expecting a LLFILE* client object
*/
void warning_callback(const char* msg, void*)
{
LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#endif
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char* msg, void*)
{
LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#if WANT_VERBOSE_OPJ_SPAM
LL_INFOS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#endif
}
// Divide a by 2 to the power of b and round upwards
@ -98,39 +104,13 @@ int ceildivpow2(int a, int b)
class JPEG2KBase
{
public:
JPEG2KBase() {}
JPEG2KBase() = default;
U8* buffer = nullptr;
OPJ_SIZE_T size = 0;
OPJ_OFF_T offset = 0;
};
#define WANT_VERBOSE_OPJ_SPAM LL_DEBUG
static void opj_info(const char* msg, void* user_data)
{
llassert(user_data);
#if WANT_VERBOSE_OPJ_SPAM
LL_INFOS("OpenJPEG") << msg << LL_ENDL;
#endif
}
static void opj_warn(const char* msg, void* user_data)
{
llassert(user_data);
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS("OpenJPEG") << msg << LL_ENDL;
#endif
}
static void opj_error(const char* msg, void* user_data)
{
llassert(user_data);
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS("OpenJPEG") << msg << LL_ENDL;
#endif
}
static OPJ_SIZE_T opj_read(void * buffer, OPJ_SIZE_T bytes, void* user_data)
{
llassert(user_data && buffer);
@ -286,11 +266,7 @@ public:
JPEG2KDecode(S8 discardLevel)
{
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
memset(&parameters, 0, sizeof(opj_dparameters_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
opj_set_default_decoder_parameters(&parameters);
parameters.cp_reduce = discardLevel;
}
@ -334,6 +310,11 @@ public:
decoder = opj_create_decompress(OPJ_CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_error_handler(decoder, error_callback, nullptr);
opj_set_warning_handler(decoder, warning_callback, nullptr);
opj_set_info_handler(decoder, info_callback, nullptr);
if (!opj_setup_decoder(decoder, &parameters))
{
return false;
@ -404,9 +385,9 @@ public:
decoder = opj_create_decompress(OPJ_CODEC_J2K);
opj_setup_decoder(decoder, &parameters);
opj_set_info_handler(decoder, opj_info, this);
opj_set_warning_handler(decoder, opj_warn, this);
opj_set_error_handler(decoder, opj_error, this);
opj_set_info_handler(decoder, info_callback, this);
opj_set_warning_handler(decoder, warning_callback, this);
opj_set_error_handler(decoder, error_callback, this);
if (stream)
{
@ -472,7 +453,6 @@ public:
private:
opj_dparameters_t parameters;
opj_event_mgr_t event_mgr;
opj_image_t* image = nullptr;
opj_codec_t* decoder = nullptr;
opj_stream_t* stream = nullptr;
@ -487,10 +467,6 @@ public:
JPEG2KEncode(const char* comment_text_in, bool reversible)
{
memset(&parameters, 0, sizeof(opj_cparameters_t));
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
opj_set_default_encoder_parameters(&parameters);
parameters.cod_format = OPJ_CODEC_J2K;
@ -558,6 +534,11 @@ public:
encoder = opj_create_compress(OPJ_CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_error_handler(encoder, error_callback, nullptr);
opj_set_warning_handler(encoder, warning_callback, nullptr);
opj_set_info_handler(encoder, info_callback, nullptr);
parameters.tcp_mct = (image->numcomps >= 3) ? 1 : 0; // no color transform for RGBA images
@ -581,10 +562,6 @@ public:
return false;
}
opj_set_info_handler(encoder, opj_info, this);
opj_set_warning_handler(encoder, opj_warn, this);
opj_set_error_handler(encoder, opj_error, this);
U32 width_tiles = (rawImageIn.getWidth() >> 6);
U32 height_tiles = (rawImageIn.getHeight() >> 6);
@ -789,7 +766,6 @@ public:
private:
opj_cparameters_t parameters;
opj_event_mgr_t event_mgr;
opj_image_t* image = nullptr;
opj_codec_t* encoder = nullptr;
opj_stream_t* stream = nullptr;

View File

@ -27,14 +27,6 @@ set(llkdu_HEADER_FILES
list(APPEND llkdu_SOURCE_FILES ${llkdu_HEADER_FILES})
# Our KDU package is built with KDU_X86_INTRINSICS in its .vcxproj file.
# Unless that macro is also set for every consumer build, KDU freaks out,
# spamming the viewer log with alignment FUD.
set_source_files_properties(${llkdu_SOURCE_FILES}
PROPERTIES
COMPILE_DEFINITIONS
"KDU_X86_INTRINSICS")
if (USE_KDU)
add_library (llkdu ${llkdu_SOURCE_FILES})
@ -42,10 +34,7 @@ if (USE_KDU)
target_include_directories( llkdu INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# Add tests
# ND: llkdu tests are very strange as they include stubs for KDU classes/methods
# if not having access to the right KDU version this test will fail to compile, incidentally I do not
# have access to a matching version of KDU and thus cannot get this tests to compile
if (LL_TESTS_KDU)
if (LL_TESTS)
include(LLAddBuildTest)
include(Tut)
SET(llkdu_TEST_SOURCE_FILES
@ -62,6 +51,6 @@ if (USE_KDU)
set_property( SOURCE ${llkdu_TEST_SOURCE_FILES} PROPERTY LL_TEST_ADDITIONAL_INCLUDE_DIRS ${llimage_include_dir})
LL_ADD_PROJECT_UNIT_TESTS(llkdu "${llkdu_TEST_SOURCE_FILES}")
endif (LL_TESTS_KDU)
endif (LL_TESTS)
endif (USE_KDU)

View File

@ -166,14 +166,8 @@ private:
S32 mNumComponents;
bool mUseYCC;
kdu_dims mDims;
kdu_push_pull_params mParams;
kdu_sample_allocator mAllocator;
// <FS:ND> KDU 8.0.1 compatibiliy
#if KDU_MAJOR_VERSION >= 8
kdu_push_pull_params mPushPullParams;
#endif
// </FS:ND>
kdu_tile_comp mComps[4];
kdu_line_buf mLines[4];
kdu_pull_ifc mEngines[4];
@ -265,7 +259,7 @@ LLImageJ2CKDU::LLImageJ2CKDU() : LLImageJ2CImpl(),
mCodeStreamp(),
mTPosp(),
mTileIndicesp(),
mRawImagep(NULL),
mRawImagep(nullptr),
mDecodeState(),
mBlocksSize(-1),
mPrecinctsSize(-1),
@ -306,17 +300,17 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod
// two U32s and a pointer, so it's not as if it would be a huge overhead
// to allocate a new one every time.
// Also -- why is base.getData() tested specifically here? If that returns
// NULL, shouldn't we bail out of the whole method?
// nullptr, shouldn't we bail out of the whole method?
if (!mInputp && base.getData())
{
// The compressed data has been loaded
// Setup the source for the codestream
mInputp.reset(new LLKDUMemSource(base.getData(), data_size));
mInputp = std::make_unique<LLKDUMemSource>(base.getData(), data_size);
}
if (mInputp)
{
// This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset().
// This is LLKDUMemSource::reset(), not std::unique_ptr::reset().
mInputp->reset();
}
@ -326,12 +320,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod
// *TODO: This seems to be wrong. The base class should have no idea of
// how j2c compression works so no good way of computing what's the byte
// range to be used.
#if (KDU_MAJOR_VERSION*10000 + KDU_MINOR_VERSION*100 + KDU_PATCH_VERSION) >= 80200
mCodeStreamp->set_max_bytes(max_bytes, false);
#else
mCodeStreamp->set_max_bytes(max_bytes, true);
#endif
mCodeStreamp->set_max_bytes(max_bytes);
// If you want to flip or rotate the image for some reason, change
// the resolution, or identify a restricted region of interest, this is
@ -477,8 +466,8 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
mCodeStreamp->change_appearance(false, true, false);
// Apply loading discard level and cropping if required
kdu_dims* region_kdu = NULL;
if (region != NULL)
kdu_dims* region_kdu = nullptr;
if (region != nullptr)
{
region_kdu = new kdu_dims;
region_kdu->pos.x = region[0];
@ -495,7 +484,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
if (region_kdu)
{
delete region_kdu;
region_kdu = NULL;
region_kdu = nullptr;
}
// Resize raw_image according to the image to be decoded
@ -506,12 +495,12 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
if (!mTileIndicesp)
{
mTileIndicesp.reset(new kdu_dims);
mTileIndicesp = std::make_unique<kdu_dims>();
}
mCodeStreamp->get_valid_tiles(*mTileIndicesp);
if (!mTPosp)
{
mTPosp.reset(new kdu_coords);
mTPosp = std::make_unique<kdu_coords>();
mTPosp->y = 0;
mTPosp->x = 0;
}
@ -521,7 +510,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
base.setLastError(msg.what());
return false;
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -621,8 +610,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
kdu_coords offset = tile_dims.pos - dims.pos;
int row_gap = channels*dims.size.x; // inter-row separation
kdu_byte *buf = buffer + offset.y*row_gap + offset.x*channels;
mDecodeState.reset(new LLKDUDecodeState(tile, buf, row_gap,
mCodeStreamp.get()));
mDecodeState = std::make_unique<LLKDUDecodeState>(tile, buf, row_gap, mCodeStreamp.get());
}
// Do the actual processing
F32 remaining_time = limit_time ? decode_time - decode_timer.getElapsedTimeF32().value() : 0.0f;
@ -647,7 +635,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
cleanupCodeStream();
return true; // done
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -857,7 +845,7 @@ bool LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co
base.setLastError(msg.what());
return false;
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -891,7 +879,7 @@ bool LLImageJ2CKDU::getMetadata(LLImageJ2C &base)
base.setLastError(msg.what());
return false;
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -1023,8 +1011,8 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
//std::cout << "Parsing discard level = " << discard_level << std::endl;
// Create the input codestream object.
setupCodeStream(base, true, MODE_FAST);
mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, NULL);
mCodeStreamp->set_max_bytes(KDU_LONG_MAX,true);
mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, nullptr);
mCodeStreamp->set_max_bytes(KDU_LONG_MAX,false);
siz_params *siz_in = mCodeStreamp->access_siz();
// Create the output codestream object.
@ -1121,8 +1109,10 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
void set_default_colour_weights(kdu_params *siz)
{
kdu_params *enc = siz->access_cluster(ENC_params);
assert(enc != nullptr);
kdu_params *cod = siz->access_cluster(COD_params);
assert(cod != NULL);
assert(cod != nullptr);
bool can_use_ycc = true;
bool rev0 = false;
@ -1167,7 +1157,7 @@ void set_default_colour_weights(kdu_params *siz)
// </FS:Ansariel>
float weight;
if (cod->get(Clev_weights,0,0,weight) || cod->get(Cband_weights,0,0,weight))
if (enc->get(Clev_weights,0,0,weight) || enc->get(Cband_weights,0,0,weight))
{
// Weights already specified explicitly -> nothing to do
return;
@ -1176,17 +1166,16 @@ void set_default_colour_weights(kdu_params *siz)
// These example weights are adapted from numbers generated by Marcus Nadenau
// at EPFL, for a viewing distance of 15 cm and a display resolution of
// 300 DPI.
cod->parse_string("Cband_weights:C0="
enc->parse_string("Cband_weights:C0="
"{0.0901},{0.2758},{0.2758},"
"{0.7018},{0.8378},{0.8378},{1}");
cod->parse_string("Cband_weights:C1="
enc->parse_string("Cband_weights:C1="
"{0.0263},{0.0863},{0.0863},"
"{0.1362},{0.2564},{0.2564},"
"{0.3346},{0.4691},{0.4691},"
"{0.5444},{0.6523},{0.6523},"
"{0.7078},{0.7797},{0.7797},{1}");
cod->parse_string("Cband_weights:C2="
enc->parse_string("Cband_weights:C2="
"{0.0773},{0.1835},{0.1835},"
"{0.2598},{0.4130},{0.4130},"
"{0.5040},{0.6464},{0.6464},"
@ -1205,7 +1194,7 @@ byte buffer, spacing successive output samples apart by `gap' bytes
all necessary level shifting, type conversion, rounding and truncation. */
{
int width = src.get_width();
if (src.get_buf32() != NULL)
if (src.get_buf32() != nullptr)
{ // Decompressed samples have a 32-bit representation (integer or float)
assert(precision >= 8); // Else would have used 16 bit representation
kdu_sample32 *sp = src.get_buf32();
@ -1366,29 +1355,14 @@ LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap,
}
bool use_shorts = (mComps[c].get_bit_depth(true) <= 16);
mLines[c].pre_create(&mAllocator,mDims.size.x,mReversible[c],use_shorts,0,0);
// <FS:ND> KDU 8.0.1 compatibiliy
#if KDU_MAJOR_VERSION >= 8
if (res.which() == 0) // No DWT levels used
{
mEngines[c] = kdu_decoder(res.access_subband(LL_BAND),&mAllocator,mPushPullParams,use_shorts);
mEngines[c] = kdu_decoder(res.access_subband(LL_BAND), &mAllocator, mParams, use_shorts);
}
else
{
mEngines[c] = kdu_synthesis(res,&mAllocator,mPushPullParams,use_shorts);
mEngines[c] = kdu_synthesis(res, &mAllocator, mParams, use_shorts);
}
#else
// </FS:ND>
if (res.which() == 0) // No DWT levels used
{
mEngines[c] = kdu_decoder(res.access_subband(LL_BAND),&mAllocator,use_shorts);
}
else
{
mEngines[c] = kdu_synthesis(res,&mAllocator,use_shorts);
}
#endif // <FS:ND/> KDU 8.0.1 compatibiliy
}
mAllocator.finalize(*codestreamp); // Actually creates buffering resources
for (c = 0; c < mNumComponents; c++)
@ -1465,7 +1439,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod
this->codestream = codestream;
codestream.get_valid_tiles(valid_tile_indices);
tile_idx = valid_tile_indices.pos;
tile = codestream.open_tile(tile_idx,NULL);
tile = codestream.open_tile(tile_idx, nullptr);
// Set up the individual components
num_components = codestream.get_num_components(true);
@ -1474,7 +1448,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod
kdc_component_flow_control *comp = components;
for (n = 0; n < num_components; n++, comp++)
{
comp->line = NULL;
comp->line = nullptr;
comp->reader = img_in;
kdu_coords subsampling;
codestream.get_subsampling(n,subsampling,true);
@ -1491,12 +1465,12 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod
assert(num_components >= 0);
tile.set_components_of_interest(num_components);
max_buffer_memory = engine.create(codestream,tile,false,NULL,false,1,NULL,NULL,false);
max_buffer_memory = engine.create(codestream, tile, false, nullptr, false, 1, nullptr, nullptr,false);
}
kdc_flow_control::~kdc_flow_control()
{
if (components != NULL)
if (components != nullptr)
{
delete[] components;
}
@ -1523,8 +1497,8 @@ bool kdc_flow_control::advance_components()
if (comp->ratio_counter < 0)
{
found_line = true;
comp->line = engine.exchange_line(n,NULL,NULL);
assert(comp->line != NULL);
comp->line = engine.exchange_line(n,nullptr,nullptr);
assert(comp->line != nullptr);
if (comp->line->get_width())
{
comp->reader->get(n,*(comp->line),0);
@ -1551,9 +1525,9 @@ void kdc_flow_control::process_components()
assert(comp->ratio_counter >= 0);
assert(comp->remaining_lines > 0);
comp->remaining_lines--;
assert(comp->line != NULL);
engine.exchange_line(n,comp->line,NULL);
comp->line = NULL;
assert(comp->line != nullptr);
engine.exchange_line(n,comp->line,nullptr);
comp->line = nullptr;
}
}
}

View File

@ -27,15 +27,13 @@
#ifndef LL_LLIMAGEJ2CKDU_H
#define LL_LLIMAGEJ2CKDU_H
#include "llpreprocessor.h"
#include "llimagej2c.h"
//
// KDU core header files
//
//#ifdef LL_DARWIN
//#define KDU_NO_THREADS
//#endif
#include "kdu_elementary.h"
#include "kdu_messaging.h"
#include "kdu_params.h"
@ -44,7 +42,6 @@
#include "include_kdu_xxxx.h"
#include "kdu_sample_processing.h"
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
class LLKDUDecodeState;

View File

@ -27,11 +27,9 @@
#ifndef LL_LLKDUMEM_H
#define LL_LLKDUMEM_H
// Support classes for reading and writing from memory buffers in KDU
//#ifdef LL_DARWIN
//#define KDU_NO_THREADS
//#endif
#include "llpreprocessor.h"
// Support classes for reading and writing from memory buffers in KDU
#define kdu_xxxx "kdu_image.h"
#include "include_kdu_xxxx.h"
@ -57,9 +55,7 @@ public:
mCurPos = 0;
}
~LLKDUMemSource()
{
}
~LLKDUMemSource() = default;
int read(kdu_core::kdu_byte *buf, int num_bytes)
{
@ -97,9 +93,7 @@ public:
mOutputSize = &output_size;
}
~LLKDUMemTarget()
{
}
~LLKDUMemTarget() = default;
bool write(const kdu_core::kdu_byte *buf, int num_bytes)
{

View File

@ -80,6 +80,7 @@ U8* LLImageBase::getData() { return NULL; }
U8* LLImageBase::reallocateData(S32 ) { return NULL; }
void LLImageBase::sanityCheck() { }
void LLImageBase::setSize(S32 , S32 , S32 ) { }
bool LLImageBase::isBufferInvalid() const { return false; }
LLImageJ2CImpl::~LLImageJ2CImpl() { }
@ -139,18 +140,19 @@ int kdu_tile_comp::get_bit_depth(bool ) { return 8; }
bool kdu_tile_comp::get_reversible() { return false; }
int kdu_tile_comp::get_num_resolutions() { return 1; }
kdu_subband kdu_resolution::access_subband(int ) { kdu_subband a; return a; }
void kdu_resolution::get_dims(kdu_dims& ) { }
int kdu_resolution::which() { return 0; }
int kdu_resolution::get_valid_band_indices(int &) { return 1; }
kdu_synthesis::kdu_synthesis(kdu_resolution, kdu_sample_allocator*, bool, float, kdu_thread_env*, kdu_thread_queue*) { }
void kdu_resolution::get_dims(kdu_dims& ) const { }
int kdu_resolution::which() const { return 0; }
int kdu_resolution::get_valid_band_indices(int &) const { return 1; }
kdu_synthesis::kdu_synthesis(kdu_resolution, kdu_sample_allocator*, kdu_push_pull_params&, bool, float, kdu_thread_env*, kdu_thread_queue*) { }
//kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool) { }
kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool, kd_core_local::kd_coremem*) {}
kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool) {}
kdu_params::~kdu_params() { }
void kdu_params::destroy() { }
void kdu_params::set(const char* , int , int , bool ) { }
void kdu_params::set(const char* , int , int , int ) { }
void kdu_params::finalize_all(bool ) { }
void kdu_params::finalize_all(int, bool ) { }
void kdu_params::copy_from(kdu_params*, int, int, int, int, int, bool, bool, bool) { }
void kdu_params::copy_from(kdu_params*, int, int, int, int, int, bool, bool, bool, bool) { }
bool kdu_params::parse_string(const char*) { return false; }
bool kdu_params::get(const char*, int, int, bool&, bool, bool, bool) { return false; }
bool kdu_params::get(const char*, int, int, float&, bool, bool, bool) { return false; }
@ -159,13 +161,13 @@ kdu_params* kdu_params::access_relation(int, int, int, bool) { return NULL; }
kdu_params* kdu_params::access_cluster(const char*) { return NULL; }
void kdu_codestream::set_fast() { }
void kdu_codestream::set_fussy() { }
void kdu_codestream::get_dims(int, kdu_dims&, bool ) { }
void kdu_codestream::get_dims(int, kdu_dims&, bool ) const { }
int kdu_codestream::get_min_dwt_levels() { return 5; }
int kdu_codestream::get_max_tile_layers() { return 1; }
void kdu_codestream::change_appearance(bool, bool, bool, kdu_thread_env *) {}
void kdu_codestream::get_tile_dims(kdu_coords, int, kdu_dims&, bool ) { }
void kdu_codestream::destroy() { }
void kdu_codestream::collect_timing_stats(int ) { }
void kdu_codestream::collect_timing_stats(int ) const { }
void kdu_codestream::set_max_bytes(kdu_long, bool, bool ) { }
void kdu_codestream::get_valid_tiles(kdu_dims& ) { }
void kdu_codestream::create(
@ -182,19 +184,21 @@ void kdu_codestream::get_subsampling(int , kdu_coords&, bool ) { }
void kdu_codestream::flush(kdu_long *, int, kdu_uint16 *, bool, bool, double, kdu_thread_env*, int) { }
void kdu_codestream::set_resilient(bool ) { }
int kdu_codestream::get_num_components(bool ) { return 0; }
kdu_long kdu_codestream::get_total_bytes(bool ) { return 0; }
kdu_long kdu_codestream::get_total_bytes(bool ) const { return 0; }
kdu_long kdu_codestream::get_compressed_data_memory(bool ) const {return 0; }
void kdu_codestream::share_buffering(kdu_codestream ) { }
int kdu_codestream::get_num_tparts() { return 0; }
int kdu_codestream::get_num_tparts() const { return 0; }
int kdu_codestream::trans_out(kdu_long, kdu_long*, int, bool, kdu_thread_env* ) { return 0; }
bool kdu_codestream::ready_for_flush(kdu_thread_env*) { return false; }
siz_params* kdu_codestream::access_siz() { return NULL; }
kdu_tile kdu_codestream::open_tile(kdu_coords , kdu_thread_env* ) { kdu_tile a; return a; }
kdu_codestream_comment kdu_codestream::add_comment(kdu_thread_env*) { kdu_codestream_comment a; return a; }
kdu_codestream_comment kdu_codestream::get_comment(kdu_codestream_comment) { kdu_codestream_comment a; return a; };
void kdu_subband::close_block(kdu_block*, kdu_thread_env*) { }
void kdu_subband::get_valid_blocks(kdu_dims &indices) const { }
kdu_block * kdu_subband::open_block(kdu_coords, int *, kdu_thread_env *, int, bool) { return NULL; }
bool kdu_codestream_comment::put_text(const char*) { return false; }
const char *kdu_codestream_comment::get_text() { return nullptr; };
void kdu_customize_warnings(kdu_message*) { }
void kdu_customize_errors(kdu_message*) { }
kdu_long kdu_multi_analysis::create(
@ -209,16 +213,18 @@ kdu_long kdu_multi_analysis::create(
const kdu_push_pull_params*,
kdu_membroker*) { return kdu_long(0); }
void kdu_multi_analysis::destroy(kdu_thread_env *) {}
siz_params::siz_params() : kdu_params(NULL, false, false, false, false, false) { }
siz_params::siz_params(kd_core_local::kd_coremem*) : kdu_params(NULL, false, false, false, false, false) { }
siz_params::~siz_params() {}
void siz_params::finalize(bool ) { }
void siz_params::copy_with_xforms(kdu_params*, int, int, bool, bool, bool) { }
int siz_params::write_marker_segment(kdu_output*, kdu_params*, int) { return 0; }
int siz_params::write_marker_segment(kdu_output*, kdu_params*, int, int&) { return 0; }
bool siz_params::check_marker_segment(kdu_uint16, int, kdu_byte a[], int&) { return false; }
bool siz_params::read_marker_segment(kdu_uint16, int, kdu_byte a[], int) { return false; }
int siz_params::read_marker_segment(kdu_uint16 code, int num_bytes, kdu_byte bytes[], int tpart_idx) { return false; }
kdu_decoder::kdu_decoder(
kdu_subband subband,
kdu_sample_allocator*,
kdu_push_pull_params&,
bool, float, int,
kdu_thread_env*,
kdu_thread_queue*,

View File

@ -6,6 +6,7 @@ include(00-Common)
include(LLCommon)
include(bugsplat)
include(Boost)
include(SSE2NEON)
set(llmath_SOURCE_FILES
llbbox.cpp
@ -103,7 +104,7 @@ list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
add_library (llmath ${llmath_SOURCE_FILES})
target_link_libraries(llmath llcommon llmeshoptimizer)
target_link_libraries(llmath llcommon llmeshoptimizer ll::sse2neon)
target_include_directories( llmath INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# Add tests

View File

@ -95,6 +95,10 @@ private:
bool mEmpty; // Nothing has been added to this bbox yet
};
static_assert(std::is_trivially_copyable<LLBBox>::value, "LLBBox must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLBBox>::value, "LLBBox must be trivial move");
static_assert(std::is_standard_layout<LLBBox>::value, "LLBBox must be a standard layout type");
//LLBBox operator*(const LLBBox &a, const LLMatrix4 &b);

View File

@ -61,5 +61,8 @@ private:
LLBBoxLocal operator*(const LLBBoxLocal &a, const LLMatrix4 &b);
static_assert(std::is_trivially_copyable<LLBBoxLocal>::value, "LLBBoxLocal must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLBBoxLocal>::value, "LLBBoxLocal must be trivial move");
static_assert(std::is_standard_layout<LLBBoxLocal>::value, "LLBBoxLocal must be a standard layout type");
#endif // LL_BBOXLOCAL_H

View File

@ -40,7 +40,7 @@ class LLLine
public:
LLLine();
LLLine( const LLVector3& first_point, const LLVector3& second_point );
virtual ~LLLine() {};
~LLLine() = default;
void setPointDirection( const LLVector3& first_point, const LLVector3& second_point );
void setPoints( const LLVector3& first_point, const LLVector3& second_point );
@ -76,5 +76,8 @@ protected:
LLVector3 mDirection;
};
static_assert(std::is_trivially_copyable<LLLine>::value, "LLLine must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLLine>::value, "LLLine must be trivial move");
static_assert(std::is_standard_layout<LLLine>::value, "LLLine must be a standard layout type");
#endif

View File

@ -56,7 +56,7 @@ public:
//////////////////////////
// Ctor
LLMatrix3a() {}
LLMatrix3a() = default;
// Ctor for setting by columns
inline LLMatrix3a( const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2 );
@ -115,14 +115,18 @@ protected:
};
static_assert(std::is_trivial<LLMatrix3a>::value, "LLMatrix3a must be a trivial type");
class LLRotation : public LLMatrix3a
{
public:
LLRotation() {}
LLRotation() = default;
// Returns true if this rotation is orthonormal with det ~= 1
inline bool isOkRotation() const;
};
static_assert(std::is_trivial<LLRotation>::value, "LLRotation must be a trivial type");
#endif

View File

@ -36,10 +36,7 @@ class LLMatrix4a
public:
LL_ALIGN_16(LLVector4a mMatrix[4]);
LLMatrix4a()
{
}
LLMatrix4a() = default;
explicit LLMatrix4a(const LLMatrix4& val)
{
@ -228,6 +225,8 @@ public:
const LLVector4a& getTranslation() const { return mMatrix[3]; }
};
static_assert(std::is_trivial<LLMatrix4a>::value, "LLMatrix4a must be a trivial type");
inline LLVector4a rowMul(const LLVector4a &row, const LLMatrix4a &mat)
{
LLVector4a result;

View File

@ -43,7 +43,7 @@ class LLPlane
public:
// Constructors
LLPlane() {}; // no default constructor
LLPlane() = default;
LLPlane(const LLVector3 &p0, F32 d) { setVec(p0, d); }
LLPlane(const LLVector3 &p0, const LLVector3 &n) { setVec(p0, n); }
inline void setVec(const LLVector3 &p0, F32 d) { mV.set(p0[0], p0[1], p0[2], d); }
@ -104,6 +104,7 @@ private:
LLVector4a mV;
} LL_ALIGN_POSTFIX(16);
static_assert(std::is_trivial<LLPlane>::value, "LLPlane must be a trivial type");
#endif // LL_LLPLANE_H

View File

@ -174,6 +174,10 @@ public:
//static U32 mMultCount;
};
static_assert(std::is_trivially_copyable<LLQuaternion>::value, "LLQuaternion must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLQuaternion>::value, "LLQuaternion must be trivial move");
static_assert(std::is_standard_layout<LLQuaternion>::value, "LLQuaternion must be a standard layout type");
inline LLSD LLQuaternion::getValue() const
{
LLSD ret;

View File

@ -49,7 +49,7 @@ public:
//////////////////////////
// Ctor
LLQuaternion2() {}
LLQuaternion2() = default;
// Ctor from LLQuaternion
explicit LLQuaternion2( const class LLQuaternion& quat );
@ -102,4 +102,6 @@ protected:
};
static_assert(std::is_trivial<LLQuaternion2>::value, "LLQuaternion2 must be a trivial type");
#endif

View File

@ -51,10 +51,6 @@ public:
LLRectBase(): mLeft(0), mTop(0), mRight(0), mBottom(0)
{}
LLRectBase(const LLRectBase &r):
mLeft(r.mLeft), mTop(r.mTop), mRight(r.mRight), mBottom(r.mBottom)
{}
LLRectBase(Type left, Type top, Type right, Type bottom):
mLeft(left), mTop(top), mRight(right), mBottom(bottom)
{}
@ -295,4 +291,8 @@ template <class Type> LLRectBase<Type> LLRectBase<Type>::null(0,0,0,0);
typedef LLRectBase<S32> LLRect;
typedef LLRectBase<F32> LLRectf;
static_assert(std::is_trivially_copyable<LLRect>::value, "LLRect must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLRect>::value, "LLRect must be trivial move");
static_assert(std::is_standard_layout<LLRect>::value, "LLRect must be a standard layout type");
#endif

View File

@ -31,16 +31,26 @@
#error "Please include llmath.h before this file."
#endif
#if ( ( LL_DARWIN || LL_LINUX ) && !(__SSE2__) ) || ( LL_WINDOWS && ( _M_IX86_FP < 2 && ADDRESS_SIZE == 32 ) )
#error SSE2 not enabled. LLVector4a and related class will not compile.
// the check for this error case must be split into multiple parts
// because some versions of VS complain about '__SSE2__'
#if ( ( LL_DARWIN || LL_LINUX ) )
#if !(__SSE2__) && !(__arm64__) && !(__aarch64__)
#error SSE2 not enabled. LLVector4a and related class will not compile.
#endif
#elif ( LL_WINDOWS && ( _M_IX86_FP < 2 && ADDRESS_SIZE == 32 ) )
#error SSE2 not enabled. LLVector4a and related class will not compile.
#endif
#if !LL_WINDOWS
#include <stdint.h>
#endif
#if defined(__arm64__) || defined(__aarch64__)
#include "sse2neon.h"
#else
#include <xmmintrin.h>
#include <emmintrin.h>
#endif
#include "llmemory.h"
#include "llsimdtypes.h"

View File

@ -36,7 +36,7 @@ typedef __m128 LLQuad;
class LLBool32
{
public:
inline LLBool32() {}
inline LLBool32() = default;
inline LLBool32(int rhs) : m_bool(rhs) {}
inline LLBool32(unsigned int rhs) : m_bool(rhs) {}
inline LLBool32(bool rhs) { m_bool = static_cast<const int>(rhs); }
@ -46,13 +46,15 @@ public:
inline operator bool() const { return static_cast<const bool&>(m_bool); }
private:
int m_bool{ 0 };
int m_bool;
};
static_assert(std::is_trivial<LLBool32>::value, "LLBool32 must be a standard layout type");
class LLSimdScalar
{
public:
inline LLSimdScalar() {}
inline LLSimdScalar() = default;
inline LLSimdScalar(LLQuad q)
{
mQ = q;
@ -100,7 +102,9 @@ public:
}
private:
LLQuad mQ{};
LLQuad mQ;
};
static_assert(std::is_trivial<LLSimdScalar>::value, "LLSimdScalar must be a standard layout type");
#endif //LL_SIMD_TYPES_H

View File

@ -95,10 +95,7 @@ public:
////////////////////////////////////
//LLVector4a is plain data which should never have a default constructor or destructor(malloc&free won't trigger it)
LLVector4a()
{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
ll_assert_aligned(this,16);
}
LLVector4a() = default;
LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
{
@ -361,8 +358,6 @@ public:
////////////////////////////////////
// Do NOT add aditional operators without consulting someone with SSE experience
inline const LLVector4a& operator= ( const LLVector4a& rhs );
inline const LLVector4a& operator= ( const LLQuad& rhs );
inline operator LLQuad() const;
@ -378,9 +373,11 @@ public:
};
private:
LLQuad mQ{};
LLQuad mQ;
};
static_assert(std::is_trivial<LLVector4a>::value, "LLVector4a must be a trivial type");
inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)
{
min.setMin(min, p);

View File

@ -115,7 +115,7 @@ inline void LLVector4a::set(F32 x, F32 y, F32 z, F32 w)
// Set to all zeros
inline void LLVector4a::clear()
{
mQ = LLVector4a::getZero().mQ;
mQ = _mm_setzero_ps();
}
inline void LLVector4a::splat(const F32 x)
@ -272,6 +272,9 @@ inline void LLVector4a::setCross3(const LLVector4a& a, const LLVector4a& b)
// Set all elements to the dot product of the x, y, and z elements in a and b
inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)
{
#if (defined(__arm64__) || defined(__aarch64__))
mQ = _mm_dp_ps(a.mQ, b.mQ, 0x7f);
#else
// ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
// yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
@ -284,11 +287,15 @@ inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)
const __m128i zSplat = _mm_shuffle_epi32(_mm_castps_si128(ab), _MM_SHUFFLE( 2, 2, 2, 2 ));
// mQ = { a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
mQ = _mm_add_ps(_mm_castsi128_ps(zSplat), xPlusYSplat);
#endif
}
// Set all elements to the dot product of the x, y, z, and w elements in a and b
inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)
{
#if (defined(__arm64__) || defined(__aarch64__))
mQ = _mm_dp_ps(a.mQ, b.mQ, 0xff);
#else
// ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
// yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
@ -301,21 +308,29 @@ inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)
// mQ = { a[W]*b[W] + a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
mQ = _mm_add_ps(xPlusYSplat, zPlusWSplat);
#endif
}
// Return the 3D dot product of this vector and b
inline LLSimdScalar LLVector4a::dot3(const LLVector4a& b) const
{
#if (defined(__arm64__) || defined(__aarch64__))
return _mm_dp_ps(mQ, b.mQ, 0x7f);
#else
const LLQuad ab = _mm_mul_ps( mQ, b.mQ );
const LLQuad splatY = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(1, 1, 1, 1) ) );
const LLQuad splatZ = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(2, 2, 2, 2) ) );
const LLQuad xPlusY = _mm_add_ps( ab, splatY );
return _mm_add_ps( xPlusY, splatZ );
#endif
}
// Return the 4D dot product of this vector and b
inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const
{
#if (defined(__arm64__) || defined(__aarch64__))
return _mm_dp_ps(mQ, b.mQ, 0xff);
#else
// ab = { w, z, y, x }
const LLQuad ab = _mm_mul_ps( mQ, b.mQ );
// upperProdsInLowerElems = { y, x, y, x }
@ -325,6 +340,7 @@ inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const
// shuffled = { z+x, z+x, z+x, z+x }
const LLQuad shuffled = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128( sumOfPairs ), _MM_SHUFFLE(1, 1, 1, 1) ) );
return _mm_add_ss( sumOfPairs, shuffled );
#endif
}
// Normalize this vector with respect to the x, y, and z components only. Accurate to 22 bites of precision. W component is destroyed
@ -593,12 +609,6 @@ inline bool LLVector4a::equals3(const LLVector4a& rhs, F32 tolerance ) const
////////////////////////////////////
// Do NOT add aditional operators without consulting someone with SSE experience
inline const LLVector4a& LLVector4a::operator= ( const LLVector4a& rhs )
{
mQ = rhs.mQ;
return *this;
}
inline const LLVector4a& LLVector4a::operator= ( const LLQuad& rhs )
{
mQ = rhs;

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