Skip to content

Commit 22b1698

Browse files
Merge pull request #679 from feniksa/master
Blender 4.1
2 parents ac3c961 + 4ab1cbc commit 22b1698

File tree

9 files changed

+150
-123
lines changed

9 files changed

+150
-123
lines changed

BlenderPkg/build_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ pushd ..
1919
./build.sh
2020
popd
2121

22-
python3.7 create_zip_addon.py
22+
python3.11 create_zip_addon.py

README-LNX.md

Lines changed: 99 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,103 @@
1-
### Addon Run/Use Linux Ubuntu Requirements
2-
3-
- Ubuntu 18.04.03
4-
5-
- AMD drivers from web site
6-
// The instruction is here: http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Install.aspx
7-
8-
- Blender 2.80 or later
9-
10-
- Embree
11-
12-
sudo apt-get install alien dpkg
13-
14-
cd /tmp
15-
wget https://github.com/embree/embree/releases/download/v2.12.0/embree-2.12.0.x86_64.rpm.tar.gz
16-
tar xzvf ./embree-2.12.0.x86_64.rpm.tar.gz
17-
sudo alien embree-lib-2.12.0-1.x86_64.rpm
18-
sudo dpkg -i embree-lib_2.12.0-2_amd64.deb
19-
20-
- OpenImageIO
21-
22-
sudo apt-get install libopenimageio1.6
23-
24-
- FreeImage
25-
sudo apt-get install libfreeimage-dev
26-
27-
28-
### ThirdParty libraries
29-
30-
There is ThirdParty repository included to the project as a submodule. Please update submodules:
31-
32-
Plugin includes 4 submodules:
33-
RadeonProRender SDK:
34-
[email protected]:Radeon-Pro/RadeonProRenderSDK.git
35-
36-
Shared components
37-
Image Processing Library:
38-
[email protected]:Radeon-Pro/RadeonProImageProcessingSDK.git
39-
40-
ThirdParty components and miscellaneous tools
41-
[email protected]:Radeon-Pro/RadeonProRenderThirdPartyComponents.git
42-
43-
All of them are included via SSH protocol. You will need to create and install SSH keys https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
44-
45-
Once SSH keys are installed update/checkout submodules for active branch
46-
47-
` git submodule update --init -f --recursive`
48-
49-
50-
### Build Requirements
51-
52-
sudo apt-get install \
53-
build-essential cmake python3-dev python3-pip \
54-
makeself patchelf \
55-
libpci-dev libdrm-dev opencl-headers
56-
57-
pip3 install numpy cffi imageio
58-
59-
// The pytest-v must be more then 3.0 it can be checked calling next command: pip3 show pytest
60-
61-
62-
### Build
1+
# Development environment preparation
2+
3+
1. Ubuntu 22.04.04 LTS
4+
2. Update system (required for update amdgpu linux drivers)
5+
```
6+
apt-get update
7+
apt-get upgrade
8+
```
9+
3. Download [amdgpu drivers for linux](https://www.amd.com/en/support/linux-drivers)
10+
4. Install amdgpu deb package (it setup official repo + required script for futher gpu driver install)
11+
```
12+
apt install ./amdgpu-install_*.deb
13+
```
14+
5. Install amdgpu driver itself
15+
```
16+
amdgpu-install
17+
```
18+
6. Reboot (required for amdgpu driver init)
19+
7. Download [blender 3.1](https://www.blender.org/download)
20+
8. Unpack somewhere
21+
9. Setup env. variable `BLENDER_EXE` and set to blender executable. For example:
22+
```
23+
echo "BLENDER_EXE=/home/feniks/bin/blender-4.1.0-linux-x64/blender" >> ~/.bashrc
24+
```
25+
26+
10. Install blender build dependencies
27+
```
28+
sudo apt-get install castxml python3.11 python3.11-dev \
29+
build-essential cmake \
30+
makeself patchelf libpci-dev libdrm-dev opencl-headers \
31+
libopenimageio-dev libfreeimage-dev libembree-dev
32+
```
33+
11. Install python deps
34+
```
35+
python3.11 -m pip install numpy cffi imageio pytest
36+
```
37+
12. Add to PATH required python binaries. For example:
38+
```
39+
echo "PATH=/home/amd/.local/bin:$PATH" >> ~/.bashrc
40+
```
41+
42+
43+
# Project build
44+
45+
> [!NOTE]
46+
> Dont forget to fetch project submodules `git submodule update --init -f --recursive`
47+
48+
To build project run command
49+
```
50+
./build.sh
51+
```
52+
53+
## Create shipment archive
54+
To create shipment archive, please, run script:
55+
```
56+
cd BlenderPkg
57+
./build.sh
58+
```
59+
Shipment package should be in `BuildPkg/.build` directory.
60+
61+
To install shipment build, run blender, select `Edit -> Preferences -> Addons -> Install`.
62+
Then activate "RadeonProRender"
63+
64+
# Run addon from source
65+
```
66+
export LD_LIBRARY_PATH=/usr/lib64
67+
python3.11 tests/commandline/run_blender.py $BLENDER_EXE tests/commandline/test_rpr.py
68+
// In the middle should be your path to Blender's executable file.
69+
```
70+
71+
# Debug with PyCharm in Linux
72+
1. Run pycharm, add project
73+
2. Add blender iterpretator. `Settings -> Python Iterpreter -> Add Iterpreter. Set blender python interpreter.
74+
For example, for blender 4.1 on my system:
75+
```
76+
/home/amd/blender-4.1.0-linux-x.64/4.1/python/bin/python3.11`
77+
```
78+
3. Run once script from project root:
79+
```
80+
./run_blender_with_rpr_Ubuntu.sh ~/blnddbg
81+
```
82+
4. Add Run/Debug configuration in Pycharm.
83+
1. Select Python from blender (see step 2)
84+
2. Select script. Set script path to cmd_tools/run_blender.py. For example:
85+
```
86+
/home/amd/workspace/RadeonProRenderBlenderAddon/cmd_tools/run_blender.py
87+
```
88+
3. In script argument, set path to blender and path to AMDProRender main script:
89+
```
90+
/home/amd/blender-4.1.0-linux-x64/blender /home/amd/workspace/RadeonProRenderBlenderAddon/cmd_tools/test_rpr.py
91+
```
92+
3. In `Working directory` select path from step 3. For example:
93+
```
94+
/home/amd/blnddbg
95+
```
96+
4. In `Environment variables` set:
97+
```
98+
PYTHONUNBUFFERED=1;RPR_BLENDER_DEBUG=1
99+
```
63100
64-
- Build the pyrpr and RPRHelper
65101
66-
python3 build.py
67102
68-
- run addon from source
69-
export LD_LIBRARY_PATH=/usr/lib64
70-
python3 tests/commandline/run_blender.py ~/blender/blender-2.78c-linux-glibc219-x86_64/blender tests/commandline/test_rpr.py
71-
// In the middle should be your path to Blender's executable file.
72103
73-
- make addon installer
74-
python3 build_zip_installer.py --target linux
75-
//this will make .zip that can be installed with Blender(User Preferences/Addons/InstallFromFile)

build.cmd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ if %vs_major%==15 or %vs_major%==16 (
6464
goto :eof
6565

6666
:build_plugin
67-
py -3.7 cmd_tools\create_sdk.py
68-
py -3.7 src\bindings\pyrpr\src\pyrprapi.py %castxml%
67+
py -3.11 cmd_tools\create_sdk.py
68+
py -3.11 src\bindings\pyrpr\src\pyrprapi.py %castxml%
6969

7070
set bindingsOk=.\bindings-ok
7171
if exist %bindingsOk% (
72-
py -3.7 build.py
73-
py -3.9 build.py
74-
py -3.10 build.py
72+
py -3.11 build.py
7573
) else (
7674
echo Compiling bindings failed
7775
)

build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
subprocess.check_call([sys.executable, 'rpr_load_store.py'])
4242
os.chdir(cwd)
4343

44-
if sys.version_info.major == 3 and sys.version_info.minor == 10:
45-
# we are going to build RPRBlenderHelper only for python 3.10
44+
if sys.version_info.major == 3 and sys.version_info.minor == 11:
45+
# we are going to build RPRBlenderHelper only for python 3.11
4646
os.chdir('RPRBlenderHelper')
4747
shutil.rmtree('.build', ignore_errors=True)
4848
os.makedirs('.build')
4949
os.chdir('.build')
5050
if 'Windows' == platform.system():
51-
subprocess.check_call(['cmake', '-G', 'Visual Studio 16 2019', '..'])
51+
subprocess.check_call(['cmake', '-G', 'Visual Studio 17 2022', '..'])
5252
else:
5353
subprocess.check_call(['cmake', '..'])
5454
subprocess.check_call(['cmake', '--build', '.', '--config', 'Release', '--clean-first'])

build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
#!/bin/bash
2+
13
cxml="/usr/bin/castxml"
24
if [ -f "$cxml" ]; then
3-
python3.7 cmd_tools/create_sdk.py
4-
python3.7 src/bindings/pyrpr/src/pyrprapi.py $cxml
5+
python3.11 cmd_tools/create_sdk.py
6+
python3.11 src/bindings/pyrpr/src/pyrprapi.py $cxml
57
if [ -f "./bindings-ok" ]; then
6-
python3.7 build.py
7-
python3.9 build.py
8-
python3.10 build.py
8+
python3.11 build.py
99
else
1010
echo Compiling bindings failed
1111
fi

run_blender_with_rpr_Ubuntu.sh

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
#**********************************************************************
4-
# Copyright 2020 Advanced Micro Devices, Inc
4+
# Copyright 2024 Advanced Micro Devices, Inc
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
@@ -18,16 +18,20 @@
1818
set -e
1919

2020
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21-
WORK_DIR=`mktemp -d -p /tmp rpr_blender_workdir_XXXXXXXX`
2221

23-
RPR_SDK="ThirdParty/RadeonProRender SDK/Linux-Ubuntu"
24-
IMAGE_FILTER_DIR="ThirdParty/RadeonProImageProcessing/Linux/Ubuntu"
25-
IMAGE_FILTER_LIBNAME="libRadeonImageFilters64.so"
26-
GLTF_DIR="ThirdParty/RadeonProRender-GLTF/Linux-Ubuntu/lib"
27-
GLTF_LIBNAME="libProRenderGLTF.so"
22+
RPR_SDK="$DIR/RadeonProRenderSDK"
23+
RIF_SDK="$DIR/RadeonProImageProcessingSDK"
2824

25+
WORK_DIR=$1
26+
USE_TMP=false
2927

30-
function init()
28+
if [ -z $WORK_DIR ]; then
29+
WORK_DIR=`mktemp -d -p /tmp rpr_blender_workdir_XXXXXXXX`
30+
echo "WORK_DIR not set. Use tmp workdir $WORK_DIR"
31+
USE_TMP=true
32+
fi
33+
34+
function prepare_runtime()
3135
{
3236
if [ ! -x "$BLENDER_EXE" ]; then
3337
echo "Could not find blender application. Please, specify BLENDER_EXE environment variable"
@@ -40,35 +44,37 @@ function init()
4044
fi
4145

4246
# link rpr libs to workdir
43-
for f in "$DIR/$RPR_SDK/lib/"*.so; do
44-
ln -s "$f" "$WORK_DIR/"
45-
done
46-
# link imageprocessing lib to workdir
47-
ln -s "$DIR/$IMAGE_FILTER_DIR/lib64/$IMAGE_FILTER_LIBNAME" "$WORK_DIR/"
47+
find "$RPR_SDK/RadeonProRender/binUbuntu20" -name "*.so" -type f -exec ln -sf {} "$WORK_DIR" \;
4848

49-
# link gltf lib to workdir
50-
ln -s "$DIR/$GLTF_DIR/$GLTF_LIBNAME" "$WORK_DIR/"
49+
# link hip kernels
50+
ln -sf $RPR_SDK/hipbin $WORK_DIR/hipbin
51+
52+
# link imageprocessing lib to workdir
53+
find "$RIF_SDK/Ubuntu20/Dynamic" -name "*.so" -type f -exec ln -sf {} "$WORK_DIR" \;
5154

5255
# link helper to workdir
53-
ln -s "$DIR/RPRBlenderHelper/.build/libRPRBlenderHelper.so" "$WORK_DIR/"
56+
ln -sf "$DIR/RPRBlenderHelper/.build/libRPRBlenderHelper.so" "$WORK_DIR/"
5457
}
5558

5659
# deletes the work directory
5760
function cleanup {
58-
rm -rf "$WORK_DIR"
61+
if $USE_TMP; then
62+
echo "drop tmpdir $WORK_DIR"
63+
rm -rf "$WORK_DIR"
64+
fi
5965
}
6066

6167
# register the cleanup function to be called on the EXIT signal
6268
trap cleanup EXIT
6369

6470
function main()
6571
{
66-
init
72+
prepare_runtime
6773

68-
export RPR_BLENDER_DEBUG=1
74+
export RPR_BLENDER_DEBUG=1
6975
export LD_LIBRARY_PATH="$WORK_DIR:$LD_LIBRARY_PATH"
7076

71-
python3 cmd_tools/run_blender.py "$BLENDER_EXE" cmd_tools/test_rpr.py
77+
python3.11 cmd_tools/run_blender.py "$BLENDER_EXE" cmd_tools/test_rpr.py
7278

7379
}
7480

src/bindings/pyrpr/rpr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ def export(json_file_name, dependencies, header_file_name, cffi_name, output_nam
9595
if not cffi_libs_dir.is_dir():
9696
cffi_libs_dir = Path(_cffi_backend.__file__).parent / 'cffi.libs'
9797

98-
for path in cffi_libs_dir.iterdir():
99-
if '.so' in path.suffixes:
100-
# copy library needed for cffi backend
101-
ffi_lib = str(path)
102-
shutil.copy(ffi_lib, str(build_dir))
98+
if cffi_libs_dir.is_dir():
99+
for path in cffi_libs_dir.iterdir():
100+
if '.so' in path.suffixes:
101+
# copy library needed for cffi backend
102+
ffi_lib = str(path)
103+
shutil.copy(ffi_lib, str(build_dir))
103104

104105
# change RPATH for cffi backend to find libffi in the same directory
105106
cffi_backend_path = (Path(build_dir) / Path(_cffi_backend.__file__).name).absolute()

src/rprblender/export/mesh.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,11 @@ def init_from_mesh(mesh: bpy.types.Mesh, calc_area=False, obj=None):
5757
uv_mesh = mesh
5858
if obj and obj.mode != 'OBJECT':
5959
mesh = obj.data
60-
# Looks more like Blender's bug that we have to check that mesh has calc_normals_split().
61-
# It is possible after deleting corresponded object with such mesh from the scene.
62-
if not hasattr(mesh, 'calc_normals_split'):
63-
log.warn("No calc_normals_split() in mesh", mesh)
64-
return None
60+
61+
# replacement for calc_normals_split()
62+
mesh.corner_normals
6563

6664
# preparing mesh to export
67-
mesh.calc_normals_split()
6865
mesh.calc_loop_triangles()
6966

7067
# getting mesh export data
@@ -84,14 +81,11 @@ def init_from_mesh(mesh: bpy.types.Mesh, calc_area=False, obj=None):
8481
data.uvs = []
8582
data.uv_indices = []
8683

87-
if not hasattr(mesh, 'calc_normals_split'):
88-
log.warn("No calc_normals_split() in mesh", mesh)
89-
uv_mesh = mesh
84+
uv_mesh = mesh
9085

91-
uv_mesh.calc_normals_split()
86+
uv_mesh.corner_normals
9287
uv_mesh.calc_loop_triangles()
9388

94-
9589
primary_uv = uv_mesh.rpr.primary_uv_layer
9690
if primary_uv:
9791
uvs = get_data_from_collection(primary_uv.data, 'uv', (len(primary_uv.data), 2))
@@ -263,7 +257,7 @@ def assign_materials(rpr_context: RPRContext, rpr_shape: pyrpr.Shape, obj: bpy.t
263257
rpr_shape.set_volume_material(rpr_volume)
264258

265259
# setting displacement material
266-
if mat.cycles.displacement_method in {'DISPLACEMENT', 'BOTH'}:
260+
if mat.displacement_method in {'DISPLACEMENT', 'BOTH'}:
267261
rpr_displacement = material.sync(rpr_context, mat, 'Displacement', obj=obj)
268262

269263
# HybridPro: displacement disappears in case we set displacement material that is already set

src/rprblender/nodes/blender_nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def get_normal_node(self):
144144
this returns a bumped normal, else returns a node_lookup N """
145145

146146
# TODO RPRContextHybridPro doesn't support MATERIAL_NODE_BUMP_MAP
147-
if self.material.cycles.displacement_method in {"BUMP", "BOTH"} and \
147+
if self.material.displacement_method in {"BUMP", "BOTH"} and \
148148
not isinstance(self.rpr_context, RPRContextHybridPro):
149149
displacement_input = self.get_input_link("Displacement")
150150
if displacement_input:

0 commit comments

Comments
 (0)