1
1

Compare commits

..

362 Commits

Author SHA1 Message Date
f4dab64487 EEVEE: Move Closure definitions to gpu_shader_codegen_lib.glsl
This way they can be used as inputs to the closure eval functions.
2022-03-23 14:15:12 +01:00
6a7f603e70 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/CMakeLists.txt
#	source/blender/draw/intern/DRW_gpu_wrapper.hh
#	source/blender/draw/intern/draw_manager_exec.c
#	source/blender/gpu/GPU_storage_buffer.h
#	source/blender/gpu/intern/gpu_storage_buffer.cc
#	source/blender/gpu/intern/gpu_storage_buffer_private.hh
#	source/blender/gpu/opengl/gl_storage_buffer.cc
#	source/blender/gpu/opengl/gl_storage_buffer.hh
2022-03-18 21:13:33 +01:00
a65d9e22cd Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/CMakeLists.txt
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
#	source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_object_info.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_tex_environment.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_texture_coordinates.glsl
2022-03-18 20:00:11 +01:00
77b52bf9cf EEVEE: Add new experimental "EEVEE Next" option
This is supposed to hold the latest improvement from the EEVEE rewrite branch.
Note that a restart is necessary in order for the engine to appear.

The registration code is a bit convoluted as it needs to be after the WM_init.
2022-03-18 19:04:10 +01:00
3aac5c92bb EEVEE: Raytracing: Add back denoising step
Still work in progress.
2022-03-18 11:29:52 +01:00
3bc270327d DRW: gpu wrappers: Fix compilation in release mode 2022-03-17 22:18:52 +01:00
4e3148a547 GPUMaterial: Fix missing thickness output link 2022-03-17 22:18:12 +01:00
43529aaff3 GPUMaterial: Fix compilation error when shader use bump nodes 2022-03-17 22:17:36 +01:00
8e7e51bc2f GPUCodegen: Fix missing dependency of some nodes to object infos 2022-03-17 22:16:57 +01:00
007d4c9e0f EEVEE: Use compute shaders for lightprobe related filtering
This reduces the complexity and avoid framebuffer setup costs.

This also "remove" the prefiltering of the glossy cubemaps in favor
of a simple bilinear filtering of the mipchain.
2022-03-17 15:56:17 +01:00
36e355e1ad EEVEE: Fix race condition in HiZ downsample shader 2022-03-17 14:40:23 +01:00
ab3f66d7c8 GPUTexture: Add Cube view as 2D array
This is useful to read/write to the textures directly using compute
shaders and imageLoad/Store.
2022-03-17 14:39:03 +01:00
c50ba2f778 GPUCodegen: Add comment on the pass hash first check 2022-03-16 19:19:21 +01:00
6cc40796af EEVEE: Speedup: Add subsurface scattering bypass on principle BSDF
This is to avoid the cost of running another shading pass when not
needed.
2022-03-16 19:17:09 +01:00
7dd40c8ae8 EEVEE: Material: Fix issue with DRWShadingGroup reuse.
With the deferred pipeline, the materials needs different shading groups
depending on their matflags.

Note that this is potentially slower because execution order of shaders
may now be random. This might be fixed in a later commit.
2022-03-16 18:43:46 +01:00
9e30590eab EEVEE: Refactor indirect lighting pipeline to use compute
This matches better what hardware raytracing will be doing. Performances
are also more predictable.
2022-03-16 18:43:23 +01:00
ebd50e7f3a DRW: Expose stencil view in gpu_wrapper 2022-03-16 09:08:29 +01:00
0241227a06 Cleanup: DRW: Fix comments in DRW_gpu_wrapper 2022-03-16 09:07:57 +01:00
fd57ab3dd8 DRW: Add support for compute indirect command.
This just expose the GPU API through DRW.
2022-03-16 09:06:18 +01:00
91c5dd21a2 GPU: Add indirect dispatch support.
This uses a StorageBuf as the source of indirect dispatch argument.
The user needs to make sure the parameters are in the right order.

There is no support for argument offset for the moment as there is no
need for it. But this might be added in the future.

Note that the indirect buffer is synchronized at the backend level. This is
done for practical reasons and because this feature is almost always used
for GPU driven pipeline.
2022-03-16 09:01:36 +01:00
01118f0e53 GPU: StorageBuf: Add method to clear the buffer in place.
This is a faster way to clear a buffer instead of reuploading new data.
It is equivalent to `memset` and runs directly on the GPU.

This is better to clear huge buffers and to avoid the sync cost of data upload.
2022-03-16 08:42:12 +01:00
aa77d35cff Cleanup: SSBO: Rename ubo to ssbo in arguments. 2022-03-16 08:38:33 +01:00
2bcf75d6cc GPU: Add support for stencil buffer texturing mode.
This adds the possibility to read the stencil buffer inside shaders.
This is only available on GL 4.3 so use it accordingly.
2022-03-16 08:36:42 +01:00
00caf993f2 GL: Check texture framebuffer feedback only if not using compute pipeline.
This was getting in the way in multiple instances. Compute shaders dispatch
are still made in the presence of the last bound framebuffer even if they
do not interact with it.
2022-03-16 08:24:54 +01:00
02f77cbf99 GPUTexture: Fix bug in texture view creation
The switch case was based on an uninitialized value.
2022-03-11 16:46:32 +01:00
58e2ec18ae EEVEE: Deferred: Large refactor
This changes drastically the implementation to leverage arbitrary writes
in order to reduce complexity, memory usage and increase speed.

Since we are no longer dependent on the framebuffer requirement, we can
allocate bigger size texture that fits all views and avoid the extra.

Transparency, holdout and emissions are no longer deferred and are now
composited using dual source blending.

The indirect lighting and raytracing is still not functional but will
also gets a large refactor on its own
2022-03-03 21:16:54 +01:00
fbf4d8f8b5 GL: Add missing format in image layout conversion 2022-03-03 21:11:45 +01:00
d471c7d1c2 GPUShaderCreateInfo: Add explicit early_fragment_test 2022-03-03 21:10:55 +01:00
688d2eb6e7 EEVEE: Simplify Hi-Z pass by porting it to a single pass compute shader 2022-02-25 15:14:01 +01:00
fd82cf7099 DRW: Add simple texture view wrappers to draw::Texture 2022-02-25 15:14:01 +01:00
1304db6c52 GPUTexture: Expose layer & mip count 2022-02-25 01:05:09 +01:00
13a0aa8b2d Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_data.c
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/gpu/CMakeLists.txt
2022-02-24 22:53:59 +01:00
faf5333f0f EEVEE: Fix no shadow option 2022-02-22 16:21:04 +01:00
7de7a1a5cf EEVEE: Shadow: Improve the case of directional shadowmaps in ortho view
This is still far from perfect but it is better than not working
correctly.

The view/casters intersection bounds are too big and rough to
compute a decent tilemap level that is near the desire shadow pixels
density.

The algorithm works relatively ok if the sun direction is almost
parallel to the ortho view direction.
2022-02-22 16:07:07 +01:00
06487a4ba1 Merge branch 'master' into eevee-rewrite 2022-02-21 19:14:56 +01:00
9e0a2386cf DRW: Debug: Print fix missing last argument and support function call 2022-02-21 12:00:11 +01:00
5247b5aeda EEVEE: Fix build on MSVC 2022-02-21 10:05:30 +01:00
35ebf6cf02 EEVEE: Shadow: Fix out of bound access in page_list stage 2022-02-20 23:52:42 +01:00
24272c7780 EEVEE: Shadow: Add debug visual for the page cache 2022-02-20 23:10:59 +01:00
0451d556c2 EEVEE: Shadow: Fix defrag phase 2022-02-20 23:09:45 +01:00
04b49d5678 EEVEE: Shadow: Use debug_view for debug pass 2022-02-20 21:38:06 +01:00
5d27a78917 EEVEE: Shadows: Fix 2 small imprecision 2022-02-20 21:37:27 +01:00
fbf0c0e02b EEVEE: Shadow: Improve debug 2022-02-20 21:37:00 +01:00
2903c11c93 DRW: Debug print: add support for multithread printing
This is basic but each thread can now write one line without
overlapping with other threads.
2022-02-20 12:08:49 +01:00
5a20ef35b3 EEVEE: Shadow: Revisit the cache system
This allows removing the indirection for lods during shading since the
tile is not owner of the page unless it uses it.

The cache system is quite more complex but makes it easier to spot
errors since the pages are not scattered into the tile texture.

This also simplify allocation since the free heap is separated from the
cache.
2022-02-20 12:08:32 +01:00
70ec3d3a3e DRW: Add optional name to storage buffers 2022-02-19 21:04:41 +01:00
0503bbf989 Merge branch 'master' into eevee-rewrite 2022-02-18 22:48:56 +01:00
b75279e19b EEVEE: Shadow: Avoid loosing cached tiles updates in LOD levels 2022-02-18 21:29:49 +01:00
871c538509 EEVEE: Shadow: Avoid missing a load because of float imprecision 2022-02-18 21:28:31 +01:00
a082189c1d EEVEE: Improve shadow debug 2022-02-18 21:26:48 +01:00
e65f8c2579 EEVEE: Fix shader compilation 2022-02-18 21:24:37 +01:00
e3793186c0 EEVEE: Shadows: Compute max tile LOD visibility 2022-02-18 21:23:56 +01:00
471ea14ec1 EEVEE: Shadow: Add render page list to simplify the execution model 2022-02-18 21:14:27 +01:00
e32b3c95c5 Cleanup: EEVEE Remove NULL in .cc files 2022-02-18 21:08:57 +01:00
f0c75976d7 EEVEE: Fix use_scene_lights option 2022-02-18 21:07:10 +01:00
30bbd01fe0 DRW: Port draw_debug_lib to shader info 2022-02-18 21:05:05 +01:00
807624b602 Merge branch 'master' into eevee-rewrite 2022-02-17 18:16:36 +01:00
47b72c8e67 EEVEE: Fix forward material not appearing. 2022-02-16 14:52:25 +01:00
39963ffba1 Merge branch 'master' into eevee-rewrite 2022-02-16 14:41:12 +01:00
1d322894a1 Cleanup: Fix warnings 2022-02-15 00:32:53 +01:00
1ee03bc7ef Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_bloom.c
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_data.c
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lightcache.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lights.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/eevee_lut_gen.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_mist.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_occlusion.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_renderpasses.c
#	source/blender/draw/engines/eevee/eevee_sampling.c
#	source/blender/draw/engines/eevee/eevee_screen_raytrace.c
#	source/blender/draw/engines/eevee/eevee_shaders.c
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/draw/engines/eevee/eevee_shadows_cascade.c
#	source/blender/draw/engines/eevee/eevee_shadows_cube.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/eevee_temporal_sampling.c
#	source/blender/draw/engines/eevee/eevee_volumes.c
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_material_library.c
#	source/blender/gpu/opengl/gl_compute.cc
#	source/blender/makesrna/intern/rna_material.c
2022-02-15 00:32:40 +01:00
74bca81507 GLStorageBuf: Fix wrong enum for debug name 2022-02-15 00:12:15 +01:00
943315d16c EEVEE: Fix glossy filter 2022-02-14 23:55:12 +01:00
6c97a2eee8 EEVEE: Fix some GL errors and missing binds 2022-02-14 23:54:55 +01:00
b4b2af595e EEVEE: Fix shader compilation on Nvidia driver
There is some issues with referencing buffer variables in functions
when the buffer is not read & write.
2022-02-14 18:03:30 +01:00
b284b17844 Fix compilation in release mode 2022-02-14 18:01:37 +01:00
311f8ba794 DRW: Add null resource check instead of crashing 2022-02-09 11:34:54 +01:00
af82d0fec7 GPUCodegen: Fix attribute having GPU_NONE gputype 2022-02-09 11:34:54 +01:00
dc9e8a4075 EEVEE: Split directional light path
This should reduce VGPR now that the iterations are separated
2022-02-09 11:34:54 +01:00
da0a8e384e EEVEE: Fix shader not static 2022-02-09 11:34:54 +01:00
d73152b985 EEVEE: Disable raytracing 2022-02-09 11:34:54 +01:00
a9b0728bd4 EEVEE: Remove integer division 2022-02-09 11:34:54 +01:00
4bcc62a257 EEVEE: Fix light culling light count and padd culling tile buffer 2022-02-09 11:34:54 +01:00
89bef5adb2 GPUCodegen: Fix missing mat4 in function arguments 2022-02-09 11:34:54 +01:00
a02eee7e98 DRW: Add new draw_debug_print_lib.glsl
This lib allows any shader to use `print()` like functions for
logging and debugging shaders.

Usage is described in the comment at the top of the file.
2022-02-09 11:34:54 +01:00
4205629ea2 GLShader: Fix two small issues with compute shader generated code 2022-02-09 11:34:54 +01:00
dd6ee49d05 DRW: Add support for GPUStorageBuf in wrappers 2022-02-09 11:34:54 +01:00
9c36da1c34 DRW: Add support for GPUStorageBuf 2022-02-09 11:34:54 +01:00
4477ac7c8a GPU/GL: Add StorageBuf implementation
Almost 1:1 identical to UniformBuf implementation.
2022-02-08 23:17:31 +01:00
8a9f18d72c GPUShader: Fix crash when compilation error is a linking error 2022-02-08 23:15:52 +01:00
9d53e0cb07 EEVEE: Fix more float4x4 issues 2022-02-06 17:04:11 +01:00
e654975b1e EEVEE: Fix assert caused by division by 0 2022-02-06 17:02:10 +01:00
74a0a85181 GLDebug: Wrap glDispatch function into our debug wrappers 2022-02-06 17:01:10 +01:00
d02a3b4aeb EEVEE: Fix uninitialized texture issue.
This was happending on amdgpu-pro driver. `mix(a,b,1)` does not
garantee `b`.
2022-02-06 16:39:30 +01:00
de6d0db833 Merge branch 'master' into eevee-rewrite 2022-02-06 13:51:44 +01:00
6ebe1652d6 Merge branch 'master' into eevee-rewrite 2022-02-06 01:41:18 +01:00
9d44753ab8 EEVEE: Fix missing gpu_Layer in probe filter 2022-02-06 01:23:37 +01:00
03be5c4140 EEVEE: Fix dependencies to draw_view 2022-02-06 01:23:12 +01:00
f7cbd80bd9 EEVEE: Fix frustum_planes/corners references 2022-02-06 01:22:39 +01:00
3b812973fa GPUShaderCreateInfo: Add duplication error checking of dependency merging
As of now we do not allow additional infos duplication. We could in the future
but for now assert that this is not the case.
2022-02-06 01:21:07 +01:00
112c4345a3 DRW: Add preprocessor error if including common_view_lib.glsl without draw_view
This avoid making include mistake and potentially detect areas that do
not really need common_view_lib.glsl.
2022-02-06 01:18:56 +01:00
a3f79499b2 EEVEE: Fix float4x4 usage 2022-02-06 01:16:32 +01:00
26f413d1f8 BLI_float4x4: Add << operator and add ATTR_WARN_UNUSED_RESULT to identity() 2022-02-06 01:16:10 +01:00
ae024ca446 Merge branch 'master' into eevee-rewrite 2022-02-05 23:09:49 +01:00
6f531aba94 GPU: Debug: Avoid double printing of compilation issues
To avoid that, we simply filter using a debug group.
2022-02-05 23:07:53 +01:00
5c9ce9d066 DRW: Make use of shader shared header 2022-02-05 22:58:32 +01:00
29824c6ed3 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/gpu/CMakeLists.txt
2022-02-05 22:46:04 +01:00
e3027906d7 Merge branch 'master' into eevee-rewrite 2022-02-05 22:19:07 +01:00
ee6fafc615 GPUTexture: Fix missing cases in to_data_format() 2022-02-05 19:26:07 +01:00
94b35f9e9d GPU: Enable CLOG for gpu when --debug-gpu option is set
This is because all of the debug printing is done through CLog now. Without
it the is little point in this option.
2022-02-05 19:25:35 +01:00
ac9dd50384 GLShaderInterface: Fix missing in builtin SSBO support 2022-02-05 19:23:06 +01:00
a9fa50b6fb GL: Fix compute shader label error 2022-02-05 18:51:39 +01:00
b253532fa7 EEVEE: Fix missing resource binding 2022-02-05 18:51:11 +01:00
e58b397a2a EEVEE: Fix compilation on amdgpu-pro
Implementation only supports global scope shared variables and does not
like having the restrict qualifier on function inputs.
2022-02-05 18:48:28 +01:00
7dff6a074b Merge branch 'master' into eevee-rewrite 2022-02-05 14:00:04 +01:00
af49f0022a Codegen: Fix memory leak 2022-02-05 13:58:57 +01:00
9a31f13298 Merge branch 'master' into eevee-rewrite 2022-02-05 13:30:05 +01:00
b7e2e075c4 Cleanup: EEVEE: Remove unecessary internal C interface. 2022-02-05 13:27:53 +01:00
2f9a7d536d GLShaderInterface: Fix SSBO using the ubo mask
This might head lead to a crash when a shader uses both ubo and ssbo.
2022-02-05 13:22:30 +01:00
4717151495 EEVEE: Fix some broken renaming 2022-02-05 00:06:08 +01:00
031181a6b5 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/gpu/intern/gpu_shader_dependency.cc
2022-02-04 23:48:23 +01:00
df349a2214 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/intern/DRW_render.h
#	source/blender/draw/intern/draw_manager_data.c
2022-02-04 19:41:36 +01:00
792e3fc6ed GPU: Rewrite the function library system
Instead of using a manual list of dependency, the new implementation
scans all shader files beginning by `gpu_shader_material_` and extract
all function declarations.

This way we can deduce the internal dependencies between theses files.

This new implementation is merged with the manual pragma dependency system
uses by other shader files. This way it is compatible with the shader
logging system and does not require any string duplication during shader
building.
2022-02-04 15:47:03 +01:00
86ef6da834 GPUCodegen: Remove use of gpu_data_type_to_string 2022-02-04 15:20:26 +01:00
314f5b20d5 EEVEE: Fix more shader dependencie issues 2022-02-04 15:18:16 +01:00
b2b1c0102c GPUShader: Add optionnal dependency display in
This introduce `DEBUG_DEPENDENCIES` (not a cmake flag but a local define)
 which when set to 1, will list all the original files included in this
shader while omitting the generated / non original code.
2022-02-04 15:16:10 +01:00
6f16ca39a2 GPUShader: Remove some non useful error lines from log 2022-02-04 15:02:30 +01:00
31133d22b6 GPUShader: Fix issue when error row is 0
It would display the whole file instead of only the line.
2022-02-04 15:01:50 +01:00
b2d3960dc1 GLShader: Fix warning about ARB_conservative_depth even if the GL version supports it 2022-02-04 15:00:43 +01:00
bcd635e549 GPUShader: Improve error logging to support source:row layout
This is the layout used by the amdgpu-pro GL implementation.
This also add some sanitizing of the parse output because the bespoke
implementation has bogus error when it comes to compute shaders.
2022-02-04 14:59:31 +01:00
8af5e2d246 EEVEE: Fix more shader issues 2022-02-03 18:29:55 +01:00
c785a8e166 GPUShader: Avoid double typedef source inclusion 2022-02-03 18:28:45 +01:00
f6d1ba8235 EEVEE: Fix missing weight socket on multiple nodes 2022-02-03 18:18:28 +01:00
78e9d829de EEVEE: Fix shader compilations issues, resource bindings & naming 2022-02-03 13:45:41 +01:00
45885eaea3 GPUShader: Add better error message in case of incorrect dependency name 2022-02-03 12:55:58 +01:00
249717f394 GPUShaderLog: Add filename before error to improve debugging
This displays the error source such as IDE can find identify them
as path and let the programmer follow the direct link instead of
manual string search.

This only works for shaders compiling from unaltered sources as
it uses the source `char*` as key for filename search.
2022-02-03 12:44:32 +01:00
5b02f1c031 Cleanup: GPUShader: Avoid casting 2022-02-03 12:42:13 +01:00
e3f475c17c GPUTexture: Fix missing cases in validate_data_format 2022-02-03 12:30:03 +01:00
bc2e5845de Cleanup: GPUShader: Remove shader source duplication 2022-02-03 00:58:00 +01:00
e5dcd91755 DRW: Fix heatmap_gradient function messing error line number
For some reason on some GL implementation (amdgpu) this particular
syntaxes shift the error lines.

Remove the context lines by default as they are not useful anymore.
2022-02-03 00:24:30 +01:00
0ef24bb0e2 Cleanup: EEVEE: Naming 2022-02-02 23:47:38 +01:00
1b2eeb9c64 Cleanup: GPUShader: Reduce copy paste 2022-02-02 23:33:50 +01:00
0f964142b9 GPUShaderCreateInfo: Add basic debug print support 2022-02-02 22:14:44 +01:00
a0c8c932fb Cleanup: common_hair_lib.glsl: deduplicate functions definitions 2022-02-02 22:12:45 +01:00
e167c1cb89 EEVEE: Add material shader tests in the form of unused createInfos
This adds basic variations check at compile time in debug mode.
2022-02-02 22:11:44 +01:00
e9fe318e8e EEVEE: Fix more shader compilation issues 2022-02-02 22:11:26 +01:00
8a20e3f229 GPUShaderCreateInfo: Add automatic resource location
Turning this option on will recreate the slot number making sure
no slot overlaps.
2022-02-02 22:08:02 +01:00
664d31d40a Cleanup: Remove void argument to functions 2022-02-02 22:07:01 +01:00
088fc410d9 EEVEE: Finish implementing GPUShaderCreateInfo and fix compilation 2022-02-02 19:01:37 +01:00
6f3a119464 DRW: Add draw_gpencil info for gpencil geom type 2022-02-02 18:40:40 +01:00
7073959d48 GLShader: Add array macro
This is to support different array syntax
2022-02-02 18:38:16 +01:00
76a4fb223e GPUShaderCreateInfo: Fix strange crash when using std::cerr 2022-02-02 18:37:35 +01:00
a9a045fd2d GLShader: Fix image declaration 2022-02-02 18:37:03 +01:00
f39acfc874 GPUCodegen: Port to use shader create info
We now use ShaderCreateInfo as a way to setup the custom material
implementation.
This is more versatile and flexible while not require parsing of
snippets of code.
2022-02-02 18:36:50 +01:00
484c97707f Fix clang-tidy 2022-02-02 18:32:19 +01:00
81502a99b5 EEVEE: Add back support of raytrace_resolve_lib.glsl 2022-02-02 17:53:08 +01:00
9c6ceb4503 fix merge 2022-02-01 19:49:51 +01:00
08439aebf1 EEVEE: Use GPUShaderCreateInfo 2022-02-01 19:49:45 +01:00
4fd26cdd37 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_diffuse_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_glossy_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_trace_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
#	source/blender/draw/intern/draw_manager_shader.c
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_shader_log.cc
#	source/blender/gpu/shaders/material/gpu_shader_material_diffuse.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_refraction.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_subsurface_scattering.glsl
2022-02-01 19:38:54 +01:00
f7b03a7906 Merge branch 'master' into eevee-rewrite 2022-01-27 22:57:26 +01:00
39c7e19d43 Fix missing glsl file in cmake file 2022-01-27 22:55:15 +01:00
1f503d2ef5 Fix linker error on gpu_shader_builder.cc 2022-01-27 22:43:58 +01:00
9cc6d1dc32 Fix MainView constructor error on GCC < 9.4 2022-01-27 22:19:38 +01:00
8e7b535ce6 Fix NaN compilation error on MSVC 2022-01-27 21:39:42 +01:00
9b35b77716 Merge branch 'master' into eevee-rewrite 2022-01-27 21:38:05 +01:00
ea577c499f EEVEE: Make use of float4x4 instead of float[4][4] and rename vectors
This follows the type defined in `gpu_shader_shared_utils.h`.
2022-01-27 19:33:09 +01:00
0ea5f3fb5d Merge branch 'master' into eevee-rewrite 2022-01-27 18:46:38 +01:00
37cfceb7eb EEVEE: Make use of new DRW_gpu_wrapper.hh instead of eevee_wrapper.hh 2022-01-27 18:41:53 +01:00
c75f7143b6 Merge branch 'master' into eevee-rewrite 2022-01-27 17:05:11 +01:00
ea214f128e EEVEE: Fix compilation issues 2022-01-27 17:01:17 +01:00
848d35c57e EEVEE: Make use of DRW_gpu_wrappers 2022-01-27 17:00:58 +01:00
a3c416f864 Merge branch 'master' into eevee-rewrite 2022-01-27 16:21:02 +01:00
d0e86c1b78 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/intern/draw_manager_exec.c
2022-01-27 15:53:38 +01:00
338c0e5f90 Merge branch 'master' into eevee-rewrite 2022-01-27 14:59:50 +01:00
1f2b3cdd73 Comment eevee_raytrace_resolve_lib out to avoid compilation errors for now 2022-01-27 14:56:10 +01:00
032baf06f3 Merge branch 'draw-viewport-data' into eevee-rewrite 2022-01-27 12:34:42 +01:00
0bdf574ea2 Merge branch 'master' into draw-viewport-data 2022-01-26 22:05:55 +01:00
4226c484bd Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
#	release/scripts/startup/bl_ui/properties_data_camera.py
#	source/blender/blenkernel/BKE_camera.h
#	source/blender/blenkernel/BKE_node.h
#	source/blender/blenkernel/intern/camera.c
#	source/blender/blenlib/BLI_float2.hh
#	source/blender/blenlib/BLI_float3.hh
#	source/blender/blenlib/BLI_float4.hh
#	source/blender/blenlib/BLI_math_geom.h
#	source/blender/blenlib/intern/math_geom.c
#	source/blender/draw/CMakeLists.txt
#	source/blender/draw/engines/basic/basic_engine.c
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lightcache.c
#	source/blender/draw/engines/eevee/eevee_lightcache.h
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lights.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_occlusion.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_renderpasses.c
#	source/blender/draw/engines/eevee/eevee_sampling.c
#	source/blender/draw/engines/eevee/eevee_screen_raytrace.c
#	source/blender/draw/engines/eevee/eevee_shaders.c
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/draw/engines/eevee/eevee_shadows_cube.c
#	source/blender/draw/engines/eevee/eevee_temporal_sampling.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
#	source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_resolve_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
#	source/blender/draw/engines/eevee/shaders/random_lib.glsl
#	source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
#	source/blender/draw/engines/eevee/shaders/surface_lib.glsl
#	source/blender/draw/engines/eevee/shaders/surface_vert.glsl
#	source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
#	source/blender/draw/engines/external/external_engine.c
#	source/blender/draw/engines/gpencil/gpencil_engine.c
#	source/blender/draw/engines/image/image_engine.c
#	source/blender/draw/engines/overlay/overlay_engine.c
#	source/blender/draw/engines/select/select_engine.c
#	source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
#	source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl
#	source/blender/draw/engines/workbench/workbench_engine.c
#	source/blender/draw/engines/workbench/workbench_shader.c
#	source/blender/draw/intern/DRW_render.h
#	source/blender/draw/intern/draw_debug.h
#	source/blender/draw/intern/draw_manager_data.c
#	source/blender/draw/intern/draw_manager_exec.c
#	source/blender/draw/intern/draw_view_data.h
#	source/blender/gpu/CMakeLists.txt
#	source/blender/gpu/GPU_material.h
#	source/blender/gpu/GPU_shader.h
#	source/blender/gpu/GPU_state.h
#	source/blender/gpu/GPU_vertex_buffer.h
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_material.c
#	source/blender/gpu/intern/gpu_material_library.h
#	source/blender/gpu/intern/gpu_node_graph.c
#	source/blender/gpu/intern/gpu_texture_private.hh
#	source/blender/gpu/intern/gpu_vertex_buffer.cc
#	source/blender/gpu/opengl/gl_shader.cc
#	source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl
#	source/blender/nodes/shader/node_shader_tree.cc
#	source/blender/nodes/shader/nodes/node_shader_background.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
#	source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
#	source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc
#	source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc
#	source/blender/nodes/shader/nodes/node_shader_emission.cc
#	source/blender/nodes/shader/nodes/node_shader_holdout.cc
#	source/blender/nodes/shader/nodes/node_shader_output_material.cc
#	source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
#	source/blender/nodes/shader/nodes/node_shader_tex_coord.cc
#	source/blender/nodes/shader/nodes/node_shader_vector_transform.cc
#	source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc
#	source/blender/nodes/shader/nodes/node_shader_volume_principled.cc
#	source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc
#	source/blender/render/RE_pipeline.h
#	source/blender/render/intern/initrender.c
2022-01-26 22:03:58 +01:00
af87b6d8cb Merge branch 'master' into draw-viewport-data
# Conflicts:
#	source/blender/draw/DRW_engine_types.h
#	source/blender/draw/intern/draw_manager.c
#	source/blender/draw/intern/draw_manager.h
#	source/blender/draw/intern/draw_manager_profiling.c
#	source/blender/draw/intern/draw_manager_text.h
#	source/blender/draw/intern/draw_texture_pool.cc
#	source/blender/draw/intern/draw_texture_pool.h
#	source/blender/draw/intern/draw_view_data.cc
#	source/blender/draw/intern/draw_view_data.h
#	source/blender/editors/space_view3d/view3d_draw.c
#	source/blender/gpu/GPU_texture.h
#	source/blender/gpu/GPU_viewport.h
#	source/blender/gpu/intern/gpu_shader_create_info_private.hh
#	source/blender/gpu/intern/gpu_viewport.c
2022-01-26 20:27:16 +01:00
55a6a8900a EEVEE: Shadow: Avoid double rendering
The update flag was not being cleared after the opaque pass, making the
updates of the forward pass re-render the same tiles.
2021-12-10 18:19:47 +01:00
36bec765e2 EEVEE: Shadow: Add defrag shader and page debug buffer generator
The defrag shader make sure the free heap is free of holes. Making
the allocation more straightforward.

Since we now only reference the pages using the tiles, we introduce
a debug shader that produces an image with page data in a visual way.
This replaces the debug 8 option.

This also fixes some bug that were still present in the pipeline.
2021-12-10 17:25:37 +01:00
0a7c4afd21 EEVEE: Shadow: Split LOD masking to its own shader
This fixes an issue with tile reuse causing corruption.
2021-12-09 16:27:48 +01:00
021bf5b171 EEVEE: Light: Separate directional lights iteration
This separate the handling of directional lights (sun) into their
own loops. This will help reduce register pressure and remove some
pollution of the local light culling.

All sun lights are packed at the start of the light array.
2021-12-08 21:51:13 +01:00
181bc60214 EEVEE: Shadow: Add depth scan for tile tagging
We now scan the depth buffer after the prepass to tag the needed
shadow tiles.

This is much more precise than the bound box tagging which is now
reserved for transparent objects.

This also:
- fix pixel radius size.
- add a dedicated info buffer to avoid having one unused tile.
2021-12-08 13:02:28 +01:00
b23d9519d0 EEVEE: Shadow: Make punctual LOD selection based on pixel density
Until now the LOD selection was based on distance from camera.

Now it is based on receiver distance ratio. We compute the world
size of one view pixel along with the world size of one shadow texel.
By knowing one point distance to the light or to the view, we can
compute the pixel density ratio and deduce the corresponding LOD.

We use this to compute the min LOD during the visibility selection phase
and the "mean" LOD for usage tagging by BBoxes.

The tagging LOD is a crude approximation as it only uses the BBox
center.
2021-12-05 23:08:46 +01:00
7303a453aa EEVEE: Shadow: Add LOD system for punctual shadows
This makes every shadow setup pass aware of the LOD chain of the tilemap
for each cubemap face.

In the free phase, we mask any LOD page that is completely covered by
higher LOD. This avoir commiting memory twice or more per area.

In the allocation phase, we check for the last valid LOD and set it
in the LOD 0 meta data. We also store the actual page location in LOD0 but
do not mark it as allocated as the LOD tile has the ownership of the page.
2021-12-05 01:28:36 +01:00
26335dfc57 EEVEE: Light: Merge ShadowData into LightData
This is because the light indices can now change because of the
culling. So the shadow data needs to follow.
2021-12-03 22:41:37 +01:00
1b00ca3575 EEVEE: Light: Port light culling to GPU
This removes the light count limit for the forward shaded object. This
also provides a more efficient way of computing the culling directly on
the GPU. Moreover, this avoids doing multiple lighting passes for high
light counts in the deferred pipeline, improving performance.
2021-12-03 22:41:37 +01:00
68b0195bf3 GL: Add support for all image resource types 2021-11-23 21:19:34 +01:00
68602f3d87 DRW: Add DRW_shgroup_vertex_buffer_ref 2021-11-23 21:19:11 +01:00
a8a4f5f805 EEVEE: Shadow: New virtual shadowmap sampling
This adds clipmap level selection and final page coordinate computation.

This also fixes some issues with tilemaps tagging.
2021-11-18 23:19:54 +01:00
9bd070fbc2 GPU: Add more barrier types 2021-11-16 21:39:26 +01:00
7664e1dd79 EEVEE: Shadows: Virtual shadowmap part 2
This continue the effort to implement virtual shadow mapping.

This includes:
- Spot cone culling of tile.
- Tile vs. view frustum tagging.
- Shadowmap Page allocation / freeing.
- Rendering to 4K buffer only tiles that needs it.
- Copying to shadow atlas.
2021-11-14 19:35:41 +01:00
55af3361bf DRWView: Add frustum infos to uniform buffer
This way it is possible to do some culling on GPU.
2021-11-14 14:43:38 +01:00
fbfbc9f15d DRW: Add debug line buffer
This debug buffer is automatically bound if a shader is including
`common_debug_lib.glsl`. One buffer is created for each shading group
using such a shader.

The shader can then use the functions from that file to draw debug
lines. There is a hardcoded limit of line one buffer can contain. Make
sure to only output lines for a few threads at most.

Under the hood this uses a vertex buffer bound as SSBO that contains
the number of verts and all the positions and colors packed into 1 vec4.
We render by just rendering the whole buffer.
All unused vertices are initialized with NaN positions and will not be
drawn.
2021-11-14 14:42:54 +01:00
bf42246984 GPUTexture: Fix support / validation for integer textures
Some types were missing in the switch cases in order to convert them to
correct values.
2021-11-14 14:29:53 +01:00
761ba97601 BLI: Add more operator to float4
Straightforward.
2021-11-14 14:28:54 +01:00
ebb2b1120c EEVEE: Shadow: Add Tilemap lod debug and fix clipmap end distance 2021-11-09 23:20:50 +01:00
2b61ca8f34 GPUVertexBuf: Mark dirty when using GPU_vertbuf_get_data
This way buffers with dynamic usage can also use this function
to update their content.
2021-11-09 20:13:17 +01:00
9db0734a1e GPU: Bump shader to version 430 and support other image uniforms
This is required for new EEVEE features
2021-11-09 14:47:35 +01:00
9c4cf35414 EEVEE: Shadow: Implement Virtual Shadowmapping
This is a total refactor of how shadows are handled.

We use Virtual shadow maps with different Level of details to
ensure a somewhat evenly distributed precision.

The shadow test is a really crude shadow test that will be
improved in further commit.

There is a pool of 4096 Tilemaps that are distributed between
shadowed ligths. These tilemaps are 16x16 each and reference
shadow map pages that are allocated in an atlas. Pages are only
allocated if needed (i.e: visible for rendering an object).

Page management is done on GPU using compute shaders to reduce
CPU task.

On CPU only one draw pass per updated tilemaps is issued.

This reduces the memory requirement of shadowmapping large scenes
with many lights.
2021-11-09 14:47:23 +01:00
c92b2d8bc4 EEVEE: Camera: fix fallback camera projection matrix 2021-11-05 16:55:06 +01:00
2a6a06fab7 EEVEE: Update / remove obsolete properties in the UI. 2021-11-05 16:55:06 +01:00
fc6a430d8e EEVEE: Raytracing: Add denoise and move raytrace passes to raytracing module.
Denoising make use of more memory to store and reproject the result of
previous frame to reduce noise. This only works for viewport.

There is a final bilateral filter for cleaning up noise even more.
2021-11-05 16:55:06 +01:00
c746eeae93 DRW: Shading Group: Add compute dispatch with size reference
This way we can reuse the same DRWPass using dispatch for multiple views.
2021-11-05 16:55:06 +01:00
e5fadd8c84 EEVEE: Texture: Make ensure function return true if allocation occured 2021-11-05 16:55:06 +01:00
682e1bea7e EEVEE: Forward: Support raytracing
Screen space Raytracing is supported by alpha blended surfaces.
However only opaque surfaces will be visible to the rays. This means
Alpha blended surfaces cannot reflect or refract themselves.

Denoising is not possible on alpha blended surfaces. Many samples
are needed for noise free results.

Since the cost of tracing can be very high, raytracing will only be
enabled on demand, on a per-material basis.
2021-11-05 16:55:06 +01:00
75db7522c6 EEVEE: Gbuffer: Split file 2021-11-05 16:55:06 +01:00
96d354a84d EEVEE: Subsurface: Small optimisation & fix comparison 2021-11-05 16:55:06 +01:00
5905b11c07 EEVEE: Raytrace: Add Diffuse surface raytracing
This simply reuse the reflection raytracing pipeline but with another
ray distribution. Only direct lighting, distant lighting and emissive
light are visible to diffuse rays.

Subsurface effect is not visible but transmittance effect is visible
to diffuse rays.

Indirect diffuse light is processed by the SSS filter.
2021-11-05 16:55:06 +01:00
a97234574d EEVEE: Deffered: Change normal packing for better negative normals
The spheremap encoding has a singularity issue for inverted normals
which are used by the translucent BSDF. This fixes the issue.
2021-11-05 16:55:06 +01:00
282a0c90d1 EEVEE: Subsurface: Fix issue cause by HiZ mipmaps
The mip level needs to be 0 to avoid sampling coarser level.
2021-11-05 16:55:06 +01:00
b8ab3f2f52 EEVEE: Principled BSDF: Fix refraction roughness when GGX single-scatter 2021-11-05 16:55:06 +01:00
92a92fc60f EEVEE: Cleanup: Rename uvcoordsvar to uv and explicit output location 2021-11-05 16:55:06 +01:00
52a81b8175 EEVEE: Raytracing: Add back screen space raytracing
The new pipeline is now cleaner and allows for deferred refraction.

The refractions are more accurate but are not denoised for now. More
research needs to be done in this area.

There is no feedback buffer for now, so reflections of metallic surfaces
will appear black.

The same restriction on refractive materials still holds true. They will
not appear in screen space tracing of other non refractive surfaces.

However, refractive surfaces (non-blended) can now reflect themselves
and the other surfaces with screen space reflections.

Half res tracing is not implemented back yet.
2021-11-05 16:55:06 +01:00
55a85af05d EEVEE: Add eevee_build: precomputation and codegen at compile time
This is to automate the generation of reuse sample tables and maybe more
in the future. This is not designed to make compilation way longer than
expected.
2021-10-24 16:15:38 +02:00
3db3006d4c EEVEE: Port back HiZbuffer
Pretty much identical.

Texture format is now always `GPU_R32F` to remove some workarounds.
2021-10-24 16:13:04 +02:00
008fb3eed9 EEVEE: Fix Crash with some geometry type 2021-10-08 17:58:45 +02:00
b304514bd5 EEVEE: Transmittance: Add back light transmittance
Same as SSS this has been rewritten to support varying SSS radius.

Instead of relying on shadowmap hack to improve the transmittance
artifact (previously called translucency) we exposed a min thickness
output that will reduce the maximum of light bleeding that can happen
at the shading point. This is far from perfect but at least it is
tweakable.

The effect is now cheaper and the option to enable it is now gone.
It can always be artificially disabled by making the thickness bigger
than the sss radius.

The effect is always enabled for all SSS surfaces and will even be
applied on forward shaded object (alpha blend mode).
2021-10-08 17:58:45 +02:00
b0da401292 EEVEE: Material: Add thickness output
This only adds the output but the output is not yet used.

This thickness output is meant to control the aspect of subsurface,
refraction, absorption and volume shaders.

The value expected is the mean thickness inside the object at the
shading point. The source can be a vertex color or a texture map baked
from a raytracer.
2021-10-08 17:58:45 +02:00
ee7deb09cf EEVEE: Subsurface Scattering: New implementation
This new implementation follows the technique described in
"Efficient screen space subsurface scattering Siggraph 2018".

Compared to the old implementation it fixes a lot of issues at
the cost of it being slower. This fixes:
- Light leaking between different objects.
- Light leaking between different surfaces with different depths.
- SSS radii are now "texturable" per pixel. No SSS surfaces limits.
- Noise should be lower.
- Precomputation is only done once for all SSS surfaces which lowers the
  per material storage and precomputation time.

Implementation is also simpler as it is only a one pass processing.

We differ from the reference presentation by not precomputing the
RGB weights per samples. We actually compute them on the fly in order
to support varying SSS radii.

Notes:
- SSS IOR and SSS anisotropy are not supported.
- Object level light leak prevention might not work for high number of
  objects in the scene (> 1024). In this case light leak might occur.
  Adding or deleting (hidding) objects in the scene might change which
  objects can leak.
2021-10-08 17:58:45 +02:00
9f85107fef EEVEE: Fix smooth transition when using render borders
The first sample buffer is fullscreen and needs to have its uvs
corrected to match the render border viewport.
2021-10-08 17:58:42 +02:00
bcd5bd6cd5 EEVEE: Fix double Stroke color in Panel
The stroke color was displayed in the side panel and this must be used only in 3D View.
2021-10-06 12:08:59 +02:00
42d2c96d4c Wrapped related global vars into struct. 2021-10-04 14:45:30 +02:00
941fdefdb3 Move index from DrawEngineType to DRWRegisteredDrawEngine. 2021-10-04 14:36:47 +02:00
a0df3c4d51 Fix incorrect merge: missing function DRW_view_get_active. 2021-10-04 11:21:38 +02:00
6f773e289b EEVEE: Fix shader compilation caused by latest merge 2021-09-29 18:10:06 +02:00
d5f91a68c0 Merge branch 'draw-viewport-data' into eevee-rewrite 2021-09-29 18:06:17 +02:00
4984cba10d DRW: Fix implicit convertion warning on MSVC 2021-09-29 18:05:49 +02:00
e28ae32461 Merge branch 'draw-viewport-data' into eevee-rewrite 2021-09-29 17:26:03 +02:00
59a0099b9f Merge branch 'master' into draw-viewport-data 2021-09-29 17:25:16 +02:00
225c1b0708 Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/eevee_volumes.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
#	source/blender/draw/intern/DRW_render.h
#	source/blender/draw/intern/draw_cache.h
#	source/blender/gpu/GPU_material.h
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_material.c
#	source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_subsurface_scattering.glsl
#	source/blender/makesdna/DNA_gpencil_types.h
#	source/blender/makesdna/DNA_node_types.h
#	source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
#	source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
2021-09-29 17:24:30 +02:00
f8cfd7e288 Merge branch 'master' into draw-viewport-data
# Conflicts:
#	source/blender/draw/DRW_engine.h
#	source/blender/draw/intern/draw_manager.c
#	source/blender/draw/intern/draw_manager.h
2021-09-29 11:31:39 +02:00
dc0c074ac4 Cleanup: Remove compiler warning and fix some comments 2021-09-29 11:24:25 +02:00
2994b6dd98 EEVEE: Fix crash when destroying the Instance (in debug build)
This was caused by the StructArrayBuffer wrapper not being tagged as NonMovable.
The UBO was in fact being freed at creation time in debug build, but the
pointer was kept as valid in the copied wrapper.

Changing the higher level structure to not use the copy constructor to avoid this.
2021-09-29 11:14:34 +02:00
ab6a6ffed4 Cleanup: Remove compiler warnings 2021-09-29 11:14:34 +02:00
d3a825678a EEVEE: Film: Make smooth transition not rely on dtxl->color persistence
This is a needed change for the viewport compositor. The compositor
needs to draw to `dtxl->color` to have correct overlay / background
composition.

The solution here is to have a separate buffer that keeps the first
sample we blend from. This increases VRAM usage but it is the most
elegant option.
2021-09-15 17:15:40 +02:00
41c84bb08b EEVEE: More Windows 64bits changes
Missing in previous commit
2021-09-13 17:14:54 +02:00
9711cddbe0 EEVEE: Fix Windows 64bits error
Windows is different of Linux
2021-09-13 17:02:04 +02:00
85b6e6da4a EEVEE: Fix compiler errors in Windows 2021-09-12 19:37:59 +02:00
c51604e308 EEVEE: Use special depth shader to resolve the depth buffer
This was the cause of a bug on Intel Integrated GPU and might as well
impact other platforms.
2021-09-07 08:41:57 +02:00
9207920c1e EEVEE: LightGrid: Fix divide by zero leading to wrong world lighting
This integer divide by zero was evaluated to 0 on all platform but apple,
where it yields 1. The world lighting would then sample the 1 sample of the
first grid instead of its own sample.
2021-08-25 15:38:26 +02:00
f79788f767 EEVEE: Film: Fix undefined viewport color values after resizing
This was caused by the blend mode that was used even with full opacity.
This caused issues with the viewport was resized and the color of the
framebuffer becomes undefined, leading to undefined values in the blend
equation.

Another fix would be to clear the viewport color on resize inside the
GPUViewport.
2021-08-19 10:01:25 +02:00
c4287db151 EEVEE: Fix compilation on OSX platform
OSX driver does not support loose semicolon in code
2021-07-20 16:48:38 +02:00
62aa72dac8 Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
#	source/blender/blenlib/BLI_assert.h
#	source/blender/blenloader/intern/versioning_290.c
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lightcache.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lights.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_mist.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_occlusion.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_renderpasses.c
#	source/blender/draw/engines/eevee/eevee_screen_raytrace.c
#	source/blender/draw/engines/eevee/eevee_shaders.c
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/draw/engines/eevee/eevee_shadows_cascade.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/eevee_temporal_sampling.c
#	source/blender/draw/engines/eevee/eevee_volumes.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
#	source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl
#	source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
#	source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
#	source/blender/draw/engines/eevee/shaders/eevee_depth_of_field_tiles_flatten_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_resolve_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_trace_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
#	source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
#	source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
#	source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
#	source/blender/draw/engines/eevee/shaders/lights_lib.glsl
#	source/blender/draw/engines/eevee/shaders/random_lib.glsl
#	source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
#	source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
#	source/blender/draw/engines/eevee/shaders/surface_lib.glsl
#	source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl
#	source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
#	source/blender/draw/intern/draw_manager_shader.c
#	source/blender/draw/intern/shaders/common_math_lib.glsl
#	source/blender/gpu/CMakeLists.txt
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_shader.cc
#	source/blender/gpu/shaders/material/gpu_shader_material_geometry.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_subsurface_scattering.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
#	source/blender/nodes/shader/nodes/node_shader_output_aov.c
2021-07-19 23:04:20 +02:00
0053d2fc81 DRW: Move buffer & temp textures & framebuffer management to DrawManager
This is a necessary step for EEVEE's new arch. This moves more data
to the draw manager. This makes it easier to have the render or draw
engines manage their own data.

This makes more sense and cleans-up what the GPUViewport holds

Also rewrites the Texture pool manager to be in C++.

This also move the DefaultFramebuffer/TextureList and the engine related
data to a new `DRWViewData` struct. This struct manages the per view
(as in stereo view) engine data.

There is a bit of cleanup in the way the draw manager is setup.
We now use a temporary DRWData instead of creating a dummy viewport.

Differential Revision: https://developer.blender.org/D11966
2021-07-19 19:47:55 +02:00
6206a30519 EEVEE: GBuffer: Change layout
This change the gbuffer layout to use more of the hardware to converting
data back and forth. Normals are encoded as two 16 bits components and
colors as R11G11B10F format.

This was motivated by the need of better quality normals. The issue is
that this increase the GBuffer size consequently. In order to balance
this we chose to merge the refraction and Diffuse/SSS data to use the
same buffer. This means we need to stochastically chose one of these
layers (so noise appear). Given that Glass BSDFs are rarely mixed
with Diffuse BSDFs, we think this is a good tradeoff.
2021-07-19 19:01:09 +02:00
e3ff83a4a8 GPUFramebuffer: Bump maximum color attachement to 8
This is needed for EEVEE's new deferred render pipeline.
2021-07-15 17:26:03 +02:00
80b92467f0 GPU: Shader: Add debug context line count
This gives more detail, when the error line is misleading.
2021-07-03 14:45:26 +02:00
169a2a54d7 EEVEE: Fix crash caused by transparent material without prepass 2021-07-03 14:44:23 +02:00
d8ec228a76 GPUMaterial: Fix issue with displacement tree and partial derivatives 2021-07-01 00:02:42 +02:00
27adad0b0d GPUNodeTree: Fix issue with weight tree inversion and displacement
Displacement tree was also being tagged for copy and caused issue.
2021-06-30 23:56:03 +02:00
c4a3ba6f83 EEVEE: Hair: Add back shaded hair support
Same implementation as before but it is less intrusive towards the
shading Node glsl code.

Hair shaders also now supports displacement.
2021-06-30 23:55:37 +02:00
e962002db2 DRW: Fix crash in deferred compilation 2021-06-23 15:39:55 +02:00
3ad7832a8d EEVEE: Add back refraction support for lightprobes
Screen Space Raytracing support is still to come.
Both forward and deferred pipelines are supported.
2021-06-20 18:45:38 +02:00
209ab8c424 EEVEE: Cleanup: Replace lighting evaluation macro by functions
The functions need to be declared before main as prototypes.
The appended libs will use the resources (textures, UBOs) defined at
global scope.

This removes a bit of code duplication and some long macros.
2021-06-20 01:28:30 +02:00
94f813db70 DRW: ShaderLib: Add support for requesting lib to be appended to shader
Instead of appending using `BLENDER_REQUIRE`, shaders can now ask for
libs to be added after the shader's `main()` by using the
`BLENDER_REQUIRE_POST` pragma.
2021-06-19 18:01:26 +02:00
c844497aee EEVEE: Film: Fix accumulator precision when zoomed out
Use viewspace instead of world space to compute pixel projection.
This fix issues when camera is far from origin and float precision would
produce artifacts.
2021-06-19 18:00:53 +02:00
a6ae942540 EEVEE: Port back barycentric coordinates.
Nothing changed appart from the style of the integration which is
now fully on EEVEE's side.
2021-06-15 22:35:54 +02:00
1f262a461c GPUCodegen: Fix crash when there is no output node 2021-06-15 22:31:40 +02:00
4c816924e7 EEVEE: GPencil: Fix missing strokes
And comment velocity not implemented yet
2021-06-08 22:54:12 +02:00
a1459e1fcf EEVEE: Shadows: Modify view matrix instead of projection for each face
This is the same reason we changed back for lightprobes rendering:
To much area assume -Z is camera direction.
2021-06-08 22:30:36 +02:00
4260823e1e EEVEE: GPencil: Finish geometry support
This port the facing "flat" normal trick used by the gpencil engine
to EEVEE as well as the thickness mode.

The objects parameters are passed via the objectInfos UBO to avoid
much boiler plate code. However if this UBO grows too much we might have
to split it.

The normal trick for planar surfaces is quite simple to port to the
vertex shader even if it is less efficient.
However to compute it we need the objects bounds. This is passed as a
scale only through the orco factors. This will needs a bit of cleaning
at some points, with boundbox computed at object level.
2021-06-08 22:09:57 +02:00
89a002c4e3 EEVEE: Material: Add back support for backfacing and transparency
Nothing much different compared to the previous implementation.

The transparent BSDF and principled BSDF now detects when the material
is potentially transparent to select the best way to render it.
2021-06-07 19:49:00 +02:00
6c1e7868c7 EEVEE: LookDev: Move rendering to view render.
This makes is possible to have AA and correct blending of the
forward rendered spheres.

However, to avoid distorded spheres we need to not support Lookdev
in panoramic projection mode.

Also remove support for LookDev when using render border for now.
2021-06-06 16:36:02 +02:00
9b153666e7 EEVEE: FowardPass: Fix closure sampling, add emission & fix transparency 2021-06-06 16:36:02 +02:00
93881a2a8e EEVEE: LookDev: Add back overlay support
This differs a bit from old implementation.
- Instead of manually adjusting the viewport we correctly place the
  sphere in the vertex shader.
- Rendering happens after TAA accumulation: This is because we now
  support panoramic cameras and TAA would distort the spheres.
2021-06-06 16:36:02 +02:00
04f053c6a4 EEVEE: ForwardPass: Add lightprobe support & fix pipeline selection 2021-06-06 00:37:55 +02:00
d66b98e9c8 EEVEE: Patch lightprobe and light modules to handle zero lights/probes
This expose the capability of having no light and no probe (except the
world one) for specific views / code path.

The caller just need to pass 0 as extent to the `set_view()` function.

This is usefull for lookdev.
2021-06-05 23:46:27 +02:00
ae529ed93e BLI: int2: add more float operator to avoid incorrect implicit cast 2021-06-05 23:45:13 +02:00
581cb48c9e BLI: float2: add more operator and fix a typo 2021-06-05 23:44:44 +02:00
dc64186d75 EEVEE: Nodes: Fix environment texture node default mapping and ...
... empty image behavior
2021-06-05 16:00:44 +02:00
308d42d072 Merge branch 'draw-viewport-data' into eevee-rewrite 2021-06-05 15:38:33 +02:00
e6d94b83ba DRW: Fix memory leak of GPUTextures
The textures needs to be released by iterating. Not by using the
free callback.
2021-06-05 15:36:47 +02:00
3caf7ba32d EEVEE: Lookdev: Add back lighting support
This does not include reference spheres rendering.

The approach is a bit different than before.
Now we use a `bNodeTree` to control the rendering of lookdev. This
generates a `GPUMaterial` that is stored per `Instance`. This way
rendering lookdev is just updating the temp light cache using this
material as world material. Removing the use of custom shader.

This introduces a small hack in order to bind the studiolight hdri after
the nodetree glsl parsing.

The background display however is still using a custom shader in order
to sample the world cubemap with different roughness.

The view space option of the studiolight is now faster by using a
transform before shading instead of rebaking the lightprobe constantly.
This should not have any particular impact on render time.
2021-06-05 15:29:00 +02:00
b3084d23bf EEVEE: Light: Fix culling in orthographic view 2021-06-04 21:05:32 +02:00
7f5d787952 EEVEE: LightCache: Fix broken visibility sampling 2021-06-04 20:29:48 +02:00
79a5322fa4 EEVEE: LightCache: Fix broken light bounce 2021-06-04 19:52:03 +02:00
92aedc5eda EEVEE: Fix world probe rendering objects
Was leftover of a test.
2021-06-04 18:22:37 +02:00
33ff463ea1 EEVEE: GBuffer: Fix undefined behavior
When evaluating surfaces, the deferred passes needs to sample the
depth buffer. But it also test against the stancil buffer.

Moreover the sampler needs to be a 2D sampler which is not the case
for cubemaps and texture2Darrays.

To overcome this we simply copy the gbuffer depth to another
temp texture using framebuffer blitting.
2021-06-04 02:34:32 +02:00
7d3f65a044 EEVEE: Remove light specular during baking & fix bounce light 2021-06-04 02:33:44 +02:00
6d3c7a8281 EEVEE: LightProbe: Fix grid display and deduplicate code 2021-06-03 16:53:38 +02:00
8e6deba985 EEVEE: LightProbe: Fix light cache display visibility without overlays 2021-06-03 16:35:55 +02:00
d31e74d3f8 EEVEE: LightProbe: Fix wrong shading on other cube faces
Use modified viewmat instead of modified winmat. Too much code
assume conventional winmat.
2021-06-03 16:34:48 +02:00
bdcf0ccead EEVEE: LightProbe: Fix level bias and visibility filtering 2021-06-03 16:34:16 +02:00
c8b40c5fd6 EEVEE: Fix irradiance baking sample order 2021-06-03 16:33:48 +02:00
2dc9db65d7 EEVEE: Fix irradiance smoothing wrong 2021-06-03 15:17:44 +02:00
ff00c1d6eb EEVEE: Fix background transparent
Alpha of main output is transparency and not opacity.
2021-06-03 15:15:06 +02:00
1f5c3c9d74 EEVEE: LightCache: Port back cache Display
Nothing significantly different appart from codestyle.
2021-06-03 15:15:06 +02:00
d87161e574 BLI: float3: add division operator between 2 float3 2021-06-03 15:15:06 +02:00
14df74ea8b EEVEE: LightCache: Port baking
Some things differs from old implementation.
- Object visibility is filtered correctly without using a visibility
  callback (which is to be removed).

The implementation is also more high level using less low level tricks.

A dedicated LightProbeView is created for each lightprobe cubeface to
render using all pipeline (deferred and forward).

There is still a few things not working.
2021-06-03 15:15:06 +02:00
060c462f3a EEVEE: LightProbe: Finish loading and rendering of lightcache
Starting to port lightcache.c to c++.
2021-05-31 14:25:03 +02:00
25dd16a8cd EEVEE: Fix crash cause by world material without attributes 2021-05-30 22:48:40 +02:00
0fb1621594 EEVEE: Lightprobe: Add back lightprobe rendering support for world.
Only world probe is supported for now.

The new implementation diverge from the original by randomly
selecting one lightprobe instead of sampling them all.
This speeds-up rendering a bit.
2021-05-30 22:48:40 +02:00
5fb1b27d17 EEVEE: Lightprobe: Port back lightprobe filtering
No much change appart from code organization and structure.
2021-05-30 22:48:40 +02:00
6376b575d9 DRW: Add DRW_view_frustum_bsphere_get 2021-05-30 22:48:40 +02:00
31963c8d86 DRW: Increase shader library max supported lib count 2021-05-29 16:59:15 +02:00
4495060185 DRW: Add DRW_view_get_active 2021-05-29 16:44:00 +02:00
f4dbdd7b52 EEVEE: Lightprobe: Add simple world probe rendering and downsampling 2021-05-28 01:07:12 +02:00
e19c028cc4 EEVEE: Add back world nodetree support
Only for background for now.

Support is now not using defines and just use the correct globals and
uniforms to keep the same values as before.
2021-05-28 00:51:04 +02:00
f04011dd87 World: Add static default world
This is a small convenience. This let the render engine use this
default world if scene has no world.

World is black to keep the same behavior as before.
2021-05-27 04:52:21 +02:00
1bc0a70d94 EEVEE: Fix ModelMatrix in nodetree and wrong bump map output 2021-05-26 02:23:32 +02:00
2b6c70a780 EEVEE: Rework multi material handling
Shading groups are now created by the material_array_get functions
instead of passing a reference to be filled later. This avoids having
to wait later to maybe create a sub shading group.
This also simplifies different geomety type handling.
2021-05-26 02:02:46 +02:00
113c16d7a9 EEVEE/GPU: Nodes: Fix some BSDF nodes
Fix glass, principled and eevee specular shaders.
2021-05-24 20:45:58 +02:00
06ca1818d0 EEVEE: GPencil: Add basic support for gpencil geometry
This adds support for rendering gpencil objects.

There is a lot of features to implement specially the ones requiring
per object uniforms.
2021-05-24 20:43:25 +02:00
6c0d8c4b75 EEVEE: Material: Fix shader uuid to material type conversion 2021-05-24 18:13:55 +02:00
44bb4be66c DRW: Shader: Fix deferred compilation abortion
The case where a shader was queued but then requested as non deferred
was not handled correctly.
2021-05-24 18:12:24 +02:00
f7f1ee9e99 EEVEE: Add back split sum BSDF approximation
This improves the surface appearance of most bsdf.
2021-05-23 02:42:46 +02:00
e91df656f5 EEVEE: Material: Use weight to random sample closure per types
This adds a new closure selection method.

- In a first pass, weights are accumulated per output type (diffuse,
  reflection, refraction).
- A random threshold is then generated before evaluating the BSDF nodes
  again.
- During the evaluation pass the random threshold is decremented until
  it reaches 0. At this moment the current BSDF is sampled.

For this to work, I splited the evaluation and the weighting in two
functions for all BSDF. The `*_eval` nodes are generated as dangling
nodes from the graph and only serialized after the rest of the graph.
2021-05-23 00:39:56 +02:00
10cf16270a GPUMaterial: Add recalc flag workaround
Recalc flag on Material ID being unavailable to render engine, this
adds a simple way to detect material update by detecting shader creation
or update.
2021-05-22 03:05:24 +02:00
7d36a00d14 GPUNodeTree: Add weight tree inversion
This constructs a "mirror" nodetree that feeds the closure "shader"
nodes with their respective final weight.

The tree is mirrored using simple math nodes. This is quite messy but
this is the only way to proceed without introducing special nodes.
The other issue with this method is that inputs are all uniforms even
for unplugged socket on temporary math nodes with add bloat to the
shader uniform buffer structure.

Only the part relevant to the weighting is duplicated. Other connexions
with the shading tree are reuse.

All shader nodes are updated to receive a `Weight` hidden parameter.

The original shader mixing tree is preserve to let the choice of using
either way to weight the output.

For now this is only done for the output nodes. This will need to be
extended to Closure to RGBA sub-tree.
2021-05-22 02:55:41 +02:00
9a857d83a6 GPUNodeTree: Move closure socket implicit cast to ntreeGPUMaterialNodes
This reduces complexity of weighting closure in further dev.
2021-05-21 17:28:18 +02:00
25806227e8 GPUNode: Remove ssr_id and sss_id
These are not useful anymore.
2021-05-21 17:25:55 +02:00
6dc49ec992 GPU/EEVEE: Refactor codegen and nodetree support
This is the first step towards the new evaluation scheme of EEVEE
closures.

This commit contains:
- Removal of GPU_SOURCE_BUILTIN type, prefering global instead. This
  avoid many boilerplate code since most of the old builtins are now
  datas that are always present (i.e: view matrices, normals).
- Rewritting of codegen in C++ to use `std::stringstream`.
- Added a callback to let engine decide what to do with codegen code.
  This remove a lot of needs for defines because of code order
  dependency. The engine can insert the nodetree code in custom ways
  to create advance effects (i.e: add displacement or vertex lighting).
  Engine now returns final shader strings.
- Closure nodes evaluation replacment is a placeholder for now.
2021-05-20 23:51:52 +02:00
0c71240f14 EEVEE: Material: Add basic material logic
This is a port of the old material grouping. This is a bit more
clean as we use containers for each passes and other structures.

Nodetree is generated without major error for simple materials but
it is not yet used as closures are not outputed.
2021-05-18 15:39:40 +02:00
f46661428b DRWShaderLib: Add better debug output from missing lib 2021-05-03 16:37:17 +02:00
4500a90cdc EEVEE: Implementation of volume rendering
This adds the transparency and volume handling in the deferred
render pipeline.

Implementation is still unfinished.

To have better naming convention, I renamed object shader to surface.
2021-05-03 16:35:36 +02:00
99a5d49a38 EEVEE: Initial implementation of deferred shading
This introduce a fat Gbuffer layout that groups closure data in groups
of similar BSDF. The goal is to have at least one sample for each
group to avoid too much code complexity and expected worse performance.

There is a lot of room for buffer reuse to reduce memory usage but it is
 not considered a priority for now.
2021-04-30 15:57:38 +02:00
c59156dac7 DRWTexture: Add missing integer render-targets format support. 2021-04-30 15:56:15 +02:00
c7fb0d5c7b EEVEE: Add specular layer to temporary default material 2021-04-27 13:45:20 +02:00
f1a5c5f6cb EEVEE: Film/Sampling: Add smooth transition
Add a smooth transition to avoid flickering of stochastic effects such
as soft shadows.

This use a simple blend method to progressively reveal the render
after some low sample count to avoid most of the flickering.

Parameters are hardcoded for now.
2021-04-27 13:42:43 +02:00
556478c20e EEVEE: Shadow: Add back soft shadows support
We use a new RNG to avoid correlation artifacts between Anti-Aliasing
and Shadow samples (see T68594).

The new sequence is a leap halton sequence. This makes it good with
low number of samples and yield less correlation issues.

Another change is that we directly jitter the projection matrix instead
of rotating the view matrix. This is improving convergence time and
avoid passing a second matrix to the shader.

However this case lead to discontinuity artifacts at face boders.
We might want to revert to the old rotation method for this
reason even if convergence is slower.
2021-04-27 03:15:15 +02:00
5df8d5af8a EEVEE: Shadow: Add back shadow caster tracking
Compared to previous implementation this does track dupli objects.

There is a few optimizations left like using bitfield instead of bool
arrays.
2021-04-26 15:17:59 +02:00
1d3de154e2 EEVEE: Shadow: Simplify the shadow module
Now the shadows are linked to a `Light` object. The `Light` object is
linked to an `ObjectKey` to ensure persistence and deletion tracking.

The Uniform data are packed so that there is 1 `ShadowPunctualData`
per light in a `LightBatch`. This means there is only a shadowmap
limit to the number of `Shadow` in a scene.
2021-04-26 01:44:52 +02:00
4090bac8c8 EEVEE: Use C++ vector types 2021-04-24 23:03:21 +02:00
0932d508c8 BLI: Add more operator to float2/3 and int2/3 2021-04-24 23:02:50 +02:00
0fdd8a64b4 BLI: add int2 and int3 C++ support
Simple addition based on float2/3.
2021-04-24 21:58:03 +02:00
9dddfe2ef6 DRW: Debug: Add DRW_debug_view 2021-04-23 17:32:12 +02:00
e808500ba1 EEVEE: Shadow: Add Point light shadows support back
Difference with previous implementation:
- Better texture space usage of cone and area light shadow.
- Shadows are packed in an atlas. Reducing requirements for future
  features.
- Sampling is simpler because shadow matrix does everything.
2021-04-23 17:27:02 +02:00
2fd359684d EEVEE: Fix use after free crash 2021-04-21 22:35:00 +02:00
da91f87764 EEVEE: Check updates using recalc flag only an object maps.
This avoids having to reset accumulation if nothing affecting
eevee changes.
2021-04-21 22:06:52 +02:00
610294205f EEVEE: Light: Add back LTC area lights and lighting function
I did a small optimization pass to avoid some division and
redundant computation.

Also cleans-up the Light vector usage.
2021-04-19 14:29:38 +02:00
5697f96608 EEVEE: Light: 2.5D Culling: Initial implementation
This follows closely the implementation of 2.5D tiled light
culling described in the presentation:
"Improved Culling for Tiled and Clustered Rendering"
from Michal Drobot
http://advances.realtimerendering.com/s2017/2017_Sig_Improved_Culling_final.pdf

I chose the tile + Z binning approach for its high depth range support
and low CPU overhead & low memory consumption compared to the cluster
based culling. The cons is that the culling is a bit less precise in
some aspect but it is quite balanced.

The culling is done by the `Culling` object which is templated to easily
be reused for light probes cullg.

The Z-binning process is described starting from slide 20 in the
reference pdf.

I also implemented a debug pass to visualize false negative (light
culled when they shouldn't) and light evaluation density.
This is useful to detect failure case and hotspot. This could be exposed
as a developper only render pass in the future.

Some optimization of the reference implementation requires extensions
not yet added to GPU module and will be added later.
2021-04-18 17:30:36 +02:00
93b774a661 GPUTexture: Fix missing cases for integer textures 2021-04-18 01:15:19 +02:00
bf0ca28494 DRW: Fix const correctness 2021-04-18 01:14:48 +02:00
89af2b0485 EEVE: Lights: Implement simple culling scheme.
This has the basis of clustered light culling but does not yet do
it. The lights are only culled by frustum.

Its the same as if there was only one Cell for the entire Viewport.
2021-04-16 02:16:15 +02:00
ddc1be5556 EEVEE: Split shading passes to eevee_shading.cc 2021-04-15 01:05:42 +02:00
23584ee52f EEVEE: Refactor: Split implementation to .cc file
This also wrap GPUFrameBuffer & GPUTexture inside eevee:Framebuffer
and eevee:Texture to improve managment.

Another cleanup was to put all members of `Instance` public to
avoid much complexity in accessing the data with modules
dependencies.

Also split velocity View related data to `class Velocity` and
rename previous `Velocity` to `VelocityModule`
2021-04-15 00:49:32 +02:00
520962b3d6 EEVEE: Lights: Support infinite light count
Support infinite light count by dividing rendering into chucks of
LIGHT_MAX. Forward passes are just rendered again and deferred passes
(not implemented yet) will just have to have multiple light evaluation
passes.
2021-04-14 16:46:48 +02:00
017e9d852e EEVEE: Lights: Initial Work in progress implementation
Only supports simple point lights for now
2021-04-14 13:21:49 +02:00
ab55a1b67b DRW: Make draw_debug.h C++ compatible 2021-04-14 13:20:25 +02:00
9bf6fa974d Cleanup: EEVEE: RenderPasses: Use iterator 2021-04-14 12:08:44 +02:00
431a662f4f EEVEE: Add back object update and view update detection. 2021-04-14 00:24:05 +02:00
9c74f9322d EEVEE: Motion Blur: Fix cdf inversion and a typo 2021-04-12 23:06:55 +02:00
a4ae2b91c9 EEVEE: Motion Blur: Add back post process motion blur
This is almost the same thing as old implementation.
Differences:
- We clamp the motion vectors to their maximum when sampling the velocity buffer.
- Velocity rendering (and data manager) is separated from motion blur. This allows
  outputing the motion vector render pass and in the future use motion vectors to
  reproject older frames.
- Vector render pass support (only if motion blur is disabled, just like cycles).
- Velocity tiles are computed in one pass (simpler code, less CPU overhead, less
  VRAM usage, maybe a bit slower but imperceivable (< 0.3ms)).
- Two velocity passes are outputed, one for motion blur fx (applied per shading view)
  and one for the vector pass. This could be optimized further in the future.
- No current support for deformation & hair (to come).
2021-04-12 21:34:08 +02:00
0cd4896037 EEVEE: Add wrapper to simplify ubo managment 2021-04-10 01:40:19 +02:00
e540c9c47a EEVEE: Motion Blur: Add back accumulation logic
Bonus addition, support for shutter curve.

Compared to the old implementation, the per time step sync function
is lighter and localized. Also it does not require a full engine
"reboot" in order to work.

Also modifies camera setup to be compatible with future camera motion
blur.
2021-04-09 21:42:56 +02:00
f9b15edbde EEVEE: Motion Blur: Add back accumulation logic
Bonus addition, support for shutter curve.

Compared to the old implementation, the per time step sync function
is lighter and localized. Also it does not require a full engine
"reboot" in order to work.
2021-04-09 21:42:49 +02:00
1857fa8bc9 EEVEE: Depth Of Field: Fix ortho factor
When will it end? Is there some UB somewhere in cycles?
2021-04-08 23:13:10 +02:00
ac6e2b0083 EEVEE: Sampling: Add UBO containing LDS random numbers
We have many dimensions to avoid correlation between effects.
2021-04-08 23:11:51 +02:00
d18e74d822 DRW: Fix debug print of error in shader lib dependency. 2021-04-08 16:22:57 +02:00
8c753a2c80 GPUTexture: Fix max FBO attachement in panoramic view + dof + eevee 2021-04-08 16:22:14 +02:00
2a7d9d4515 EEVEE: Depth Of Field: Add back post process depth of field.
Pretty much identical to the previous implementation. With the exception
of a temporary noise function and some simplification of the CoC
computation. This also fixes issues with the Ortho depth of field.

Most of the files were modified to comply to new shader codestyle.

This also adds partial support of panoramic cameras (bokeh and
anamorphic is still buggy).
2021-04-08 16:17:04 +02:00
89f2d3427e EEVEE: Depth Of Field: Port back jittered dof
This cleansup a lot of confusion / complexity in the setup code.

Setup is closer to what cycles does now.

Also duplicates some buggy behavior of Cycles for now until this
is fixed.
2021-04-05 17:38:41 +02:00
309b90c955 Cleanup: BLI: Fix some const conrectness 2021-04-05 17:34:33 +02:00
a766ee6d5d EEVEE: Shader: Add preprocessor to have better shared enum definition
This removes the use of very ugly macros. Now we preprocess
the .hh string at startup to change enum definitions to a more
GLSL friendly variant.
2021-04-04 21:56:55 +02:00
ebf455daba Cleanup: DRW: Const correctness 2021-04-04 19:17:50 +02:00
fe9ea5d5cb Cleanup: EEVEE: Use class instead of struct and remove typedefs 2021-04-04 00:12:25 +02:00
8a2f400cf3 EEVEE: Reorganize ShadingView initialisation
This move view resolution handling to the `Camera` class that will
in the future clip and trim each view in panoramic projection.

There is a new `CameraView` that contains the `DRWView` and subview.
This way each `ShadingView` is associated to a unique `CameraView`.

ShadingView` & `CameraView` are all allocated & defined at creation time
but only the one activated by `Camera` will be rendered.
2021-04-03 23:43:23 +02:00
448d10a31a Cleanup: DRW: More const correctness 2021-04-03 23:40:48 +02:00
e0e1dd73bb EEVEE: Film: Add option to use log encoding
This option will make accumulation happen in a pre exposed logarithm
color space. This reduces the importance of bright pixels in the pixel
filter which will result in less aliasing in theses areas.

There is a few cases where one might want to disable this option to
match cycles better.
2021-04-03 23:40:26 +02:00
fa88f5af4c EEVEE: Render: Add back render mode
Render mode is really close to what the viewport render does.

Film output is done by resolving the data to the next (double buffered)
framebuffer and read back.

This also includes a bit of cleaning about naming of init() and sync()
functions.
2021-04-03 00:51:37 +02:00
fcb85633ea DRWView: Add getter for camtexco 2021-04-03 00:50:49 +02:00
935da83e2c Cleanup: RenderPipeline: Fix const correctness 2021-04-03 00:50:02 +02:00
ef174ffcb3 Cleanup: EEVEE: Renaming
- Add eevee_ prefix to shaders to avoid name clashing.
- remove plural of eevee_shaders.
- rename eevee_shared.hh to eevee_shader_shared.hh.
2021-04-02 14:44:44 +02:00
ad23570fa2 EEVEE: Film: Filtered accumulation with panoramic projection support
This commit adds the Film class that handles accumulation of color and
non-color data using arbitrary projection and filter size.

A weighted accumulation (sum) is done into a data buffer with an
additional weight buffer. The sum being per pixel, it allows the input
textures that are not aligned with the output pixel grid.

Panoramic projection works by rendering a cubemap (6 views) of the scene
at the camera position. The Film filter pass then gather the pixels
using the correct Panoramic projection ensuring correct Anti-Aliasing.

For Non-color data (depth, normals) we only keep the closest value to
the target pixel center (simulating a filter size of 0).

Color data is accumulated in a log space to improve AntiAliasing output.
This is hardcoded for now.

Larger filters have poor performance but are very fast to converge.

Code Wise: This commit rename some modules to avoid possible confusion
and have better meaning. Use namespace instead of prefixes.

Added a new eevee_shared.hh file to share structure and enum definitions
between GLSL and C++.
2021-04-01 22:37:50 +02:00
8777497c4b DNA: Camera: Add panoramic types and parameters
These are direct copy of Cycles parameters. Cycles parameters
unification will be done separately.
2021-04-01 21:38:53 +02:00
25af8b801d EEVEE: New basic drawing
TODO describe overall implementation here
2021-03-28 16:53:31 +02:00
829e2e4a24 EEVEE: Add new engine managed per viewport data
This was engine(s) can have arbitrarily persistent resources and
are responsible for freeing it properly.
2021-03-25 14:30:47 +01:00
09e1f276ff EEVEE: Remove EEVEE
Starting clean!
2021-03-25 13:15:35 +01:00
81632de706 DRW: Move mempool datas to a DRW managed struct.
Same idea as previous commit. This cleans-up the interface and put all
viewport related data inside the `DRWData` struct.

The draw manager is responsible for freeing it. That is the main point
of this all. In the future, we can have custom freeing method for each
engine.

This also move the DefaultFramebuffer/TextureList and the engine related
data to a new `DRWViewData` struct. This struct manages the per view
(as in stereo view) engine data.

There is a bit of cleanup in the way the draw manager is setup.
We now use a temporary DRWData instead of creating a dummy viewport.
2021-03-25 01:03:10 +01:00
f7cb19956f DRW: Move GPUViewport texture pool to DRW module
This makes more sense and cleans-up what the GPUViewport holds.

Also rewrite it to be in C++.
2021-03-22 23:53:42 +01:00
1874 changed files with 49819 additions and 88629 deletions

View File

@@ -205,7 +205,6 @@ ForEachMacros:
- FOREACH_SCENE_COLLECTION_BEGIN
- FOREACH_SCENE_OBJECT_BEGIN
- FOREACH_SELECTED_BASE_BEGIN
- FOREACH_SELECTED_BEZT_BEGIN
- FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN
- FOREACH_SELECTED_OBJECT_BEGIN
- FOREACH_TRANS_DATA_CONTAINER
@@ -265,11 +264,13 @@ ForEachMacros:
- SET_SLOT_PROBING_BEGIN
- MAP_SLOT_PROBING_BEGIN
- VECTOR_SET_SLOT_PROBING_BEGIN
- LIGHT_FOREACH_BEGIN_DIRECTIONAL
- LIGHT_FOREACH_BEGIN_LOCAL
- LIGHT_FOREACH_BEGIN_LOCAL_NO_CULL
StatementMacros:
- PyObject_HEAD
- PyObject_VAR_HEAD
- ccl_gpu_kernel_postfix
MacroBlockBegin: "^BSDF_CLOSURE_CLASS_BEGIN$"
MacroBlockEnd: "^BSDF_CLOSURE_CLASS_END$"

View File

@@ -284,7 +284,6 @@ option(WITH_IMAGE_TIFF "Enable LibTIFF Support" ON)
option(WITH_IMAGE_DDS "Enable DDS Image Support" ON)
option(WITH_IMAGE_CINEON "Enable CINEON and DPX Image Support" ON)
option(WITH_IMAGE_HDR "Enable HDR Image Support" ON)
option(WITH_IMAGE_WEBP "Enable WebP Image Support" OFF)
# Audio/Video format support
option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON)
@@ -409,8 +408,6 @@ option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debug
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
option(WITH_CYCLES_HYDRA_RENDER_DELEGATE "Build Cycles Hydra render delegate" OFF)
option(WITH_CYCLES_DEBUG_NAN "Build Cycles with additional asserts for detecting NaNs and invalid values" OFF)
option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
option(WITH_CYCLES_KERNEL_ASAN "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF)
@@ -446,7 +443,7 @@ if(NOT APPLE)
endif()
option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
set(CYCLES_HIP_BINARIES_ARCH gfx900 gfx906 gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 CACHE STRING "AMD HIP architectures to build binaries for")
set(CYCLES_HIP_BINARIES_ARCH gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 CACHE STRING "AMD HIP architectures to build binaries for")
mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
endif()
@@ -534,19 +531,6 @@ mark_as_advanced(
WITH_GPU_SHADER_BUILDER
)
# Metal
if (APPLE)
option(WITH_METAL_BACKEND "Use Metal for graphics instead of (or as well as) OpenGL on macOS." OFF)
mark_as_advanced(WITH_METAL_BACKEND)
else()
set(WITH_METAL_BACKEND OFF)
endif()
if (WITH_METAL_BACKEND)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
endif()
if(WIN32)
option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
mark_as_advanced(WITH_GL_ANGLE)
@@ -745,10 +729,9 @@ endif()
#-----------------------------------------------------------------------------
# Check for conflicting/unsupported configurations
if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE AND NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE)
if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE)
message(FATAL_ERROR
"At least one of WITH_BLENDER or WITH_CYCLES_STANDALONE "
"or WITH_CYCLES_HYDRA_RENDER_DELEGATE "
"must be enabled, nothing to do!"
)
endif()
@@ -1291,16 +1274,6 @@ else()
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
endif()
#-----------------------------------------------------------------------------
# Configure Metal.
if (WITH_METAL_BACKEND)
add_definitions(-DWITH_METAL_BACKEND)
# No need to add frameworks here, all the ones we need for Metal and
# Metal-OpenGL Interop are already being added by
# build_files/cmake/platform/platform_apple.cmake
endif()
#-----------------------------------------------------------------------------
# Configure OpenMP.
if(WITH_OPENMP)
@@ -1911,13 +1884,14 @@ if(WITH_BLENDER)
# source after intern and extern to gather all
# internal and external library information first, for test linking
add_subdirectory(source)
elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
elseif(WITH_CYCLES_STANDALONE)
add_subdirectory(intern/glew-mx)
add_subdirectory(intern/guardedalloc)
add_subdirectory(intern/libc_compat)
add_subdirectory(intern/sky)
add_subdirectory(intern/cycles)
add_subdirectory(extern/clew)
if(WITH_CYCLES_LOGGING)
if(NOT WITH_SYSTEM_GFLAGS)
add_subdirectory(extern/gflags)
@@ -1974,7 +1948,7 @@ if(FIRST_RUN)
set(_msg " - ${_setting}")
string(LENGTH "${_msg}" _len)
while("36" GREATER "${_len}")
while("32" GREATER "${_len}")
string(APPEND _msg " ")
math(EXPR _len "${_len} + 1")
endwhile()

View File

@@ -1,16 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
## Update and uncomment this in the release branch
# set(BLENDER_VERSION 3.1)
function(download_source dep)
set(TARGET_FILE ${${dep}_FILE})
set(TARGET_HASH_TYPE ${${dep}_HASH_TYPE})
set(TARGET_HASH ${${dep}_HASH})
if(PACKAGE_USE_UPSTREAM_SOURCES)
set(TARGET_URI ${${dep}_URI})
elseif(BLENDER_VERSION)
set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/tags/blender-${BLENDER_VERSION}-release/lib/packages/${TARGET_FILE})
else()
set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/trunk/lib/packages/${TARGET_FILE})
endif()

View File

@@ -52,14 +52,6 @@ add_dependencies(
external_boost
)
# Since USD 21.11 the libraries are prefixed with "usd_", i.e. "libusd_m.a" became "libusd_usd_m.a".
# See https://github.com/PixarAnimationStudios/USD/blob/release/CHANGELOG.md#2111---2021-11-01
if (USD_VERSION VERSION_LESS 21.11)
set(PXR_LIB_PREFIX "")
else()
set(PXR_LIB_PREFIX "usd_")
endif()
if(WIN32)
# USD currently demands python be available at build time
# and then proceeds not to use it, but still checks that the
@@ -73,14 +65,14 @@ if(WIN32)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_usd after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/ ${HARVEST_TARGET}/usd
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Release/${PXR_LIB_PREFIX}usd_m.lib ${HARVEST_TARGET}/usd/lib/lib${PXR_LIB_PREFIX}usd_m.lib
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Release/usd_m.lib ${HARVEST_TARGET}/usd/lib/libusd_m.lib
DEPENDEES install
)
endif()
if(BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_usd after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/lib ${HARVEST_TARGET}/usd/lib
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Debug/${PXR_LIB_PREFIX}usd_m_d.lib ${HARVEST_TARGET}/usd/lib/lib${PXR_LIB_PREFIX}usd_m_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Debug/usd_m_d.lib ${HARVEST_TARGET}/usd/lib/libusd_m_d.lib
DEPENDEES install
)
endif()
@@ -92,7 +84,7 @@ else()
# case (only the shared library). As a result, we need to grab the `libusd_m.a`
# file from the build directory instead of from the install directory.
ExternalProject_Add_Step(external_usd after_install
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/lib${PXR_LIB_PREFIX}usd_m.a ${HARVEST_TARGET}/usd/lib/lib${PXR_LIB_PREFIX}usd_m.a
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/libusd_m.a ${HARVEST_TARGET}/usd/lib/libusd_m.a
DEPENDEES install
)
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -32,12 +32,9 @@ FIND_PATH(USD_INCLUDE_DIR
DOC "Universal Scene Description (USD) header files"
)
# Since USD 21.11 the libraries are prefixed with "usd_", i.e. "libusd_m.a" became "libusd_usd_m.a".
# See https://github.com/PixarAnimationStudios/USD/blob/release/CHANGELOG.md#2111---2021-11-01
FIND_LIBRARY(USD_LIBRARY
NAMES
usd_usd_m usd_usd_ms usd_m usd_ms
${PXR_LIB_PREFIX}usd
usd_m usd_ms
NAMES_PER_DIR
HINTS
${_usd_SEARCH_DIRS}

View File

@@ -1,77 +0,0 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2022 Blender Foundation.
# - Find WebP library
# Find the native WebP includes and library
# This module defines
# WEBP_INCLUDE_DIRS, where to find WebP headers, Set when WebP is found.
# WEBP_LIBRARIES, libraries to link against to use WebP.
# WEBP_ROOT_DIR, The base directory to search for WebP.
# This can also be an environment variable.
# WEBP_FOUND, If false, do not try to use WebP.
#
# also defined, but not for general use are
# WEBP_LIBRARY, where to find the WEBP library.
# If WEBP_ROOT_DIR was defined in the environment, use it.
IF(NOT WEBP_ROOT_DIR AND NOT $ENV{WEBP_ROOT_DIR} STREQUAL "")
SET(WEBP_ROOT_DIR $ENV{WEBP_ROOT_DIR})
ENDIF()
SET(_webp_SEARCH_DIRS
${WEBP_ROOT_DIR}
/opt/lib/webp
)
FIND_PATH(WEBP_INCLUDE_DIR
NAMES
webp/types.h
HINTS
${_webp_SEARCH_DIRS}
PATH_SUFFIXES
include
)
SET(_webp_FIND_COMPONENTS
webp
webpmux
webpdemux
)
SET(_webp_LIBRARIES)
FOREACH(COMPONENT ${_webp_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
FIND_LIBRARY(WEBP_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
NAMES_PER_DIR
HINTS
${_webp_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
)
LIST(APPEND _webp_LIBRARIES "${WEBP_${UPPERCOMPONENT}_LIBRARY}")
ENDFOREACH()
IF(${WEBP_WEBP_LIBRARY_NOTFOUND})
set(WEBP_FOUND FALSE)
ELSE()
# handle the QUIETLY and REQUIRED arguments and set WEBP_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP DEFAULT_MSG _webp_LIBRARIES WEBP_INCLUDE_DIR)
IF(WEBP_FOUND)
get_filename_component(WEBP_LIBRARY_DIR ${WEBP_WEBP_LIBRARY} DIRECTORY)
SET(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR})
SET(WEBP_LIBRARIES ${_webp_LIBRARIES})
ELSE()
SET(WEBPL_PUGIXML_FOUND FALSE)
ENDIF()
ENDIF()
MARK_AS_ADVANCED(
WEBP_INCLUDE_DIR
WEBP_LIBRARY_DIR
)

View File

@@ -879,7 +879,7 @@ function(delayed_install
destination)
foreach(f ${files})
if(IS_ABSOLUTE ${f} OR "${base}" STREQUAL "")
if(IS_ABSOLUTE ${f})
set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${f})
else()
set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f})

View File

@@ -106,8 +106,8 @@ if(WIN32)
set(CPACK_WIX_LIGHT_EXTRA_FLAGS -dcl:medium)
endif()
set(CPACK_PACKAGE_EXECUTABLES "blender-launcher" "Blender")
set(CPACK_CREATE_DESKTOP_LINKS "blender-launcher" "Blender")
set(CPACK_PACKAGE_EXECUTABLES "blender-launcher" "blender")
set(CPACK_CREATE_DESKTOP_LINKS "blender-launcher" "blender")
include(CPack)

View File

@@ -232,15 +232,6 @@ if(WITH_IMAGE_TIFF)
endif()
endif()
if(WITH_IMAGE_WEBP)
set(WEBP_ROOT_DIR ${LIBDIR}/webp)
find_package(WebP)
if(NOT WEBP_FOUND)
message(WARNING "WebP not found, disabling WITH_IMAGE_WEBP")
set(WITH_IMAGE_WEBP OFF)
endif()
endif()
if(WITH_BOOST)
set(Boost_NO_BOOST_CMAKE ON)
set(BOOST_ROOT ${LIBDIR}/boost)

View File

@@ -368,14 +368,6 @@ if(WITH_PUGIXML)
endif()
endif()
if(WITH_IMAGE_WEBP)
set(WEBP_ROOT_DIR ${LIBDIR}/webp)
find_package_wrapper(WebP)
if(NOT WEBP_FOUND)
set(WITH_IMAGE_WEBP OFF)
endif()
endif()
if(WITH_OPENIMAGEIO)
find_package_wrapper(OpenImageIO)
set(OPENIMAGEIO_LIBRARIES

View File

@@ -39,12 +39,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(WITH_WINDOWS_STRIPPED_PDB OFF)
endif()
else()
if(WITH_BLENDER AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.28.29921) # MSVC 2019 16.9.16
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.28.29921) # MSVC 2019 16.9.16
message(FATAL_ERROR "Compiler is unsupported, MSVC 2019 16.9.16 or newer is required for building blender.")
endif()
endif()
if(WITH_BLENDER AND NOT WITH_PYTHON_MODULE)
if(NOT WITH_PYTHON_MODULE)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blender)
endif()
@@ -238,6 +238,7 @@ else()
endif()
if(NOT DEFINED LIBDIR)
# Setup 64bit and 64bit windows systems
if(CMAKE_CL_64)
message(STATUS "64 bit compiler detected.")
@@ -251,9 +252,6 @@ if(NOT DEFINED LIBDIR)
elseif(MSVC_VERSION GREATER 1919)
message(STATUS "Visual Studio 2019 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
elseif(MSVC_VERSION GREATER 1909)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
endif()
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
@@ -302,8 +300,9 @@ set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include)
set(ZLIB_LIBRARY ${LIBDIR}/zlib/lib/libz_st.lib)
set(ZLIB_DIR ${LIBDIR}/zlib)
windows_find_package(ZLIB) # we want to find before finding things that depend on it like png
windows_find_package(PNG)
windows_find_package(zlib) # we want to find before finding things that depend on it like png
windows_find_package(png)
if(NOT PNG_FOUND)
warn_hardcoded_paths(libpng)
set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include)
@@ -314,9 +313,9 @@ if(NOT PNG_FOUND)
endif()
set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
windows_find_package(JPEG REQUIRED)
windows_find_package(jpeg REQUIRED)
if(NOT JPEG_FOUND)
warn_hardcoded_paths(libjpeg)
warn_hardcoded_paths(jpeg)
set(JPEG_INCLUDE_DIR ${LIBDIR}/jpeg/include)
set(JPEG_LIBRARIES ${LIBDIR}/jpeg/lib/libjpeg.lib)
endif()
@@ -334,7 +333,7 @@ set(FREETYPE_LIBRARIES
${LIBDIR}/brotli/lib/brotlidec-static.lib
${LIBDIR}/brotli/lib/brotlicommon-static.lib
)
windows_find_package(Freetype REQUIRED)
windows_find_package(freetype REQUIRED)
if(WITH_FFTW3)
set(FFTW3 ${LIBDIR}/fftw3)
@@ -343,16 +342,6 @@ if(WITH_FFTW3)
set(FFTW3_LIBPATH ${FFTW3}/lib)
endif()
windows_find_package(WebP)
if(NOT WEBP_FOUND)
if(EXISTS ${LIBDIR}/webp)
set(WEBP_INCLUDE_DIRS ${LIBDIR}/webp/include)
set(WEBP_ROOT_DIR ${LIBDIR}/webp)
set(WEBP_LIBRARIES ${LIBDIR}/webp/lib/webp.lib ${LIBDIR}/webp/lib/webpdemux.lib ${LIBDIR}/webp/lib/webpmux.lib)
set(WEBP_FOUND ON)
endif()
endif()
if(WITH_OPENCOLLADA)
set(OPENCOLLADA ${LIBDIR}/opencollada)
@@ -400,9 +389,9 @@ if(WITH_CODEC_FFMPEG)
${LIBDIR}/ffmpeg/include
${LIBDIR}/ffmpeg/include/msvc
)
windows_find_package(FFmpeg)
if(NOT FFmpeg_FOUND)
warn_hardcoded_paths(FFmpeg)
windows_find_package(FFMPEG)
if(NOT FFMPEG_FOUND)
warn_hardcoded_paths(ffmpeg)
set(FFMPEG_LIBRARIES
${LIBDIR}/ffmpeg/lib/avcodec.lib
${LIBDIR}/ffmpeg/lib/avformat.lib
@@ -414,10 +403,10 @@ if(WITH_CODEC_FFMPEG)
endif()
if(WITH_IMAGE_OPENEXR)
windows_find_package(OpenEXR REQUIRED)
if(NOT OpenEXR_FOUND)
set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
set(OPENEXR_VERSION "2.1")
set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
set(OPENEXR_VERSION "2.1")
windows_find_package(OPENEXR REQUIRED)
if(NOT OPENEXR_FOUND)
warn_hardcoded_paths(OpenEXR)
set(OPENEXR ${LIBDIR}/openexr)
set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
@@ -531,20 +520,17 @@ if(WITH_BOOST)
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
endif()
set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
endif()
if(WITH_OPENIMAGEIO)
windows_find_package(OpenImageIO)
if(NOT OpenImageIO_FOUND)
set(OPENIMAGEIO ${LIBDIR}/OpenImageIO)
set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib)
set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib)
set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
endif()
set(OPENIMAGEIO ${LIBDIR}/OpenImageIO)
set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib)
set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib)
set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
@@ -575,38 +561,31 @@ if(WITH_LLVM)
message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.")
set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED})
endif()
endif()
if(WITH_OPENCOLORIO)
windows_find_package(OpenColorIO)
if(NOT OpenColorIO_FOUND)
set(OPENCOLORIO ${LIBDIR}/OpenColorIO)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
set(OPENCOLORIO_LIBRARIES
optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib
optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib
optimized ${OPENCOLORIO_LIBPATH}/libexpatMD.lib
optimized ${OPENCOLORIO_LIBPATH}/pystring.lib
debug ${OPENCOLORIO_LIBPATH}/OpencolorIO_d.lib
debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib
debug ${OPENCOLORIO_LIBPATH}/libexpatdMD.lib
debug ${OPENCOLORIO_LIBPATH}/pystring_d.lib
)
endif()
set(OPENCOLORIO ${LIBDIR}/OpenColorIO)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
set(OPENCOLORIO_LIBRARIES
optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib
optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib
optimized ${OPENCOLORIO_LIBPATH}/libexpatMD.lib
optimized ${OPENCOLORIO_LIBPATH}/pystring.lib
debug ${OPENCOLORIO_LIBPATH}/OpencolorIO_d.lib
debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib
debug ${OPENCOLORIO_LIBPATH}/libexpatdMD.lib
debug ${OPENCOLORIO_LIBPATH}/pystring_d.lib
)
set(OPENCOLORIO_DEFINITIONS "-DOpenColorIO_SKIP_IMPORTS")
endif()
if(WITH_OPENVDB)
windows_find_package(OpenVDB)
if(NOT OpenVDB_FOUND)
set(OPENVDB ${LIBDIR}/openVDB)
set(OPENVDB_LIBPATH ${OPENVDB}/lib)
set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib)
endif()
set(OPENVDB ${LIBDIR}/openVDB)
set(OPENVDB_LIBPATH ${OPENVDB}/lib)
set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib )
set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES)
endif()
@@ -645,24 +624,21 @@ if(WITH_IMAGE_OPENJPEG)
endif()
if(WITH_OPENSUBDIV)
set(OPENSUBDIV_INCLUDE_DIRS ${LIBDIR}/opensubdiv/include)
set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
set(OPENSUBDIV_LIBRARIES
optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
)
set(OPENSUBDIV_HAS_OPENMP TRUE)
set(OPENSUBDIV_HAS_TBB FALSE)
set(OPENSUBDIV_HAS_OPENCL TRUE)
set(OPENSUBDIV_HAS_CUDA FALSE)
set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
windows_find_package(OpenSubdiv)
if(NOT OpenSubdiv_FOUND)
set(OPENSUBDIV ${LIBDIR}/opensubdiv)
set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV}/include)
set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib)
set(OPENSUBDIV_LIBRARIES
optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
)
set(OPENSUBDIV_HAS_OPENMP TRUE)
set(OPENSUBDIV_HAS_TBB FALSE)
set(OPENSUBDIV_HAS_OPENCL TRUE)
set(OPENSUBDIV_HAS_CUDA FALSE)
set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
endif()
endif()
if(WITH_SDL)
@@ -683,15 +659,12 @@ if(WITH_SYSTEM_AUDASPACE)
endif()
if(WITH_TBB)
windows_find_package(TBB)
if(NOT TBB_FOUND)
set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
if(WITH_TBB_MALLOC_PROXY)
set(TBB_MALLOC_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbbmalloc.lib debug ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib)
add_definitions(-DWITH_TBB_MALLOC)
endif()
set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
if(WITH_TBB_MALLOC_PROXY)
set(TBB_MALLOC_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbbmalloc.lib debug ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib)
add_definitions(-DWITH_TBB_MALLOC)
endif()
endif()
@@ -710,6 +683,7 @@ if(WITH_OPENAL)
else()
set(OPENAL_LIBRARY ${OPENAL_LIBPATH}/wrap_oal.lib)
endif()
endif()
if(WITH_CODEC_SNDFILE)
@@ -754,7 +728,7 @@ endif()
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
windows_find_package(Embree)
if(NOT Embree_FOUND)
if(NOT EMBREE_FOUND)
set(EMBREE_INCLUDE_DIRS ${LIBDIR}/embree/include)
set(EMBREE_LIBRARIES
optimized ${LIBDIR}/embree/lib/embree3.lib
@@ -782,6 +756,7 @@ endif()
if(WITH_USD)
windows_find_package(USD)
if(NOT USD_FOUND)
set(USD_FOUND ON)
set(USD_INCLUDE_DIRS ${LIBDIR}/usd/include)
set(USD_RELEASE_LIB ${LIBDIR}/usd/lib/libusd_m.lib)
set(USD_DEBUG_LIB ${LIBDIR}/usd/lib/libusd_m_d.lib)

View File

@@ -1,4 +1,4 @@
# Doxyfile 1.9.3
# Doxyfile 1.9.1
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -93,6 +93,14 @@ ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all generated output in the proper direction.
# Possible values are: None, LTR, RTL and Context.
# The default value is: None.
OUTPUT_TEXT_DIRECTION = None
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
# descriptions after the members that are listed in the file and class
# documentation (similar to Javadoc). Set to NO to disable this.
@@ -250,16 +258,16 @@ TAB_SIZE = 4
# the documentation. An alias has the form:
# name=value
# For example adding
# "sideeffect=@par Side Effects:^^"
# "sideeffect=@par Side Effects:\n"
# will allow you to put the command \sideeffect (or @sideeffect) in the
# documentation, which will result in a user-defined paragraph with heading
# "Side Effects:". Note that you cannot put \n's in the value part of an alias
# to insert newlines (in the resulting output). You can put ^^ in the value part
# of an alias to insert a newline as if a physical newline was in the original
# file. When you need a literal { or } or , in the value part of an alias you
# have to escape them by means of a backslash (\), this can lead to conflicts
# with the commands \{ and \} for these it is advised to use the version @{ and
# @} or use a double escape (\\{ and \\})
# "Side Effects:". You can put \n's in the value part of an alias to insert
# newlines (in the resulting output). You can put ^^ in the value part of an
# alias to insert a newline as if a physical newline was in the original file.
# When you need a literal { or } or , in the value part of an alias you have to
# escape them by means of a backslash (\), this can lead to conflicts with the
# commands \{ and \} for these it is advised to use the version @{ and @} or use
# a double escape (\\{ and \\})
ALIASES =
@@ -304,8 +312,8 @@ OPTIMIZE_OUTPUT_SLICE = NO
# extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice,
# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL,
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
# tries to guess whether the code is fixed or free formatted code, this is the
# default for Fortran type files). For instance to make doxygen treat .inc files
@@ -458,7 +466,7 @@ LOOKUP_CACHE_SIZE = 3
# than 0 to get more control over the balance between CPU load and processing
# speed. At this moment only the input processing can be done using multiple
# threads. Since this is still an experimental feature the default is set to 1,
# which effectively disables parallel processing. Please report any issues you
# which efficively disables parallel processing. Please report any issues you
# encounter. Generating dot graphs in parallel is controlled by the
# DOT_NUM_THREADS setting.
# Minimum value: 0, maximum value: 32, default value: 1.
@@ -602,12 +610,6 @@ HIDE_SCOPE_NAMES = NO
HIDE_COMPOUND_REFERENCE= NO
# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class
# will show which file needs to be included to use the class.
# The default value is: YES.
SHOW_HEADERFILE = YES
# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
# the files that are included by a file in the documentation of that file.
# The default value is: YES.
@@ -765,8 +767,7 @@ FILE_VERSION_FILTER =
# output files in an output format independent way. To create the layout file
# that represents doxygen's defaults, run doxygen with the -l option. You can
# optionally specify a file name after the option, if omitted DoxygenLayout.xml
# will be used as the name of the layout file. See also section "Changing the
# layout of pages" for information.
# will be used as the name of the layout file.
#
# Note that if you run doxygen from a directory containing a file called
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
@@ -812,26 +813,18 @@ WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as documenting some parameters in
# a documented function twice, or documenting parameters that don't exist or
# using markup commands wrongly.
# potential errors in the documentation, such as not documenting some parameters
# in a documented function, or documenting parameters that don't exist or using
# markup commands wrongly.
# The default value is: YES.
WARN_IF_DOC_ERROR = YES
# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete
# function parameter documentation. If set to NO, doxygen will accept that some
# parameters have no documentation without warning.
# The default value is: YES.
WARN_IF_INCOMPLETE_DOC = YES
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
# are documented, but have no documentation for their parameters or return
# value. If set to NO, doxygen will only warn about wrong parameter
# documentation, but not about the absence of documentation. If EXTRACT_ALL is
# set to YES then this flag will automatically be disabled. See also
# WARN_IF_INCOMPLETE_DOC
# value. If set to NO, doxygen will only warn about wrong or incomplete
# parameter documentation, but not about the absence of documentation. If
# EXTRACT_ALL is set to YES then this flag will automatically be disabled.
# The default value is: NO.
WARN_NO_PARAMDOC = NO
@@ -857,10 +850,7 @@ WARN_FORMAT = "$file:$line: $text"
# The WARN_LOGFILE tag can be used to specify a file to which warning and error
# messages should be written. If left blank the output is written to standard
# error (stderr). In case the file specified cannot be opened for writing the
# warning and error messages are written to standard error. When as file - is
# specified the warning and error messages are written to standard output
# (stdout).
# error (stderr).
WARN_LOGFILE =
@@ -904,10 +894,10 @@ INPUT_ENCODING = UTF-8
#
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml,
# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C
# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd,
# *.vhdl, *.ucf, *.qsf and *.ice.
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl,
# *.ucf, *.qsf and *.ice.
FILE_PATTERNS =
@@ -949,7 +939,7 @@ EXCLUDE_PATTERNS = .svn \
# (namespaces, classes, functions, etc.) that should be excluded from the
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# ANamespace::AClass, ANamespace::*Test
# AClass::ANamespace, ANamespace::*Test
#
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/*
@@ -1234,7 +1224,7 @@ HTML_EXTRA_FILES =
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a color-wheel, see
# this color. Hue is specified as an angle on a colorwheel, see
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
# purple, and 360 is red again.
@@ -1244,7 +1234,7 @@ HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
# in the HTML output. For a value of 0 the output will use gray-scales only. A
# in the HTML output. For a value of 0 the output will use grayscales only. A
# value of 255 will produce the most vivid colors.
# Minimum value: 0, maximum value: 255, default value: 100.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1326,13 +1316,6 @@ GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
# This tag determines the URL of the docset feed. A documentation feed provides
# an umbrella under which multiple documentation sets from a single provider
# (such as a company or product suite) can be grouped.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_FEEDURL =
# This tag specifies a string that should uniquely identify the documentation
# set bundle. This should be a reverse domain-name style string, e.g.
# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
@@ -1358,12 +1341,8 @@ DOCSET_PUBLISHER_NAME = Publisher
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
# on Windows. In the beginning of 2021 Microsoft took the original page, with
# a.o. the download links, offline the HTML help workshop was already many years
# in maintenance mode). You can download the HTML help workshop from the web
# archives at Installation executable (see:
# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo
# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe).
# (see:
# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows.
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
@@ -1522,28 +1501,16 @@ DISABLE_INDEX = NO
# to work a browser that supports JavaScript, DHTML, CSS and frames is required
# (i.e. any modern browser). Windows users are probably better off using the
# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
# further fine tune the look of the index (see "Fine-tuning the output"). As an
# example, the default style sheet generated by doxygen has an example that
# shows how to put an image at the root of the tree instead of the PROJECT_NAME.
# Since the tree basically has the same information as the tab index, you could
# consider setting DISABLE_INDEX to YES when enabling this option.
# further fine-tune the look of the index. As an example, the default style
# sheet generated by doxygen has an example that shows how to put an image at
# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
# the same information as the tab index, you could consider setting
# DISABLE_INDEX to YES when enabling this option.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_TREEVIEW = NO
# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the
# FULL_SIDEBAR option determines if the side bar is limited to only the treeview
# area (value NO) or if it should extend to the full height of the window (value
# YES). Setting this to YES gives a layout similar to
# https://docs.readthedocs.io with more room for contents, but less room for the
# project logo, title, and description. If either GENERATE_TREEVIEW or
# DISABLE_INDEX is set to NO, this option has no effect.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
FULL_SIDEBAR = NO
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation.
#
@@ -1568,13 +1535,6 @@ TREEVIEW_WIDTH = 246
EXT_LINKS_IN_WINDOW = NO
# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email
# addresses.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
OBFUSCATE_EMAILS = YES
# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg
# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
@@ -1623,29 +1583,11 @@ FORMULA_MACROFILE =
USE_MATHJAX = NO
# With MATHJAX_VERSION it is possible to specify the MathJax version to be used.
# Note that the different versions of MathJax have different requirements with
# regards to the different settings, so it is possible that also other MathJax
# settings have to be changed when switching between the different MathJax
# versions.
# Possible values are: MathJax_2 and MathJax_3.
# The default value is: MathJax_2.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_VERSION = MathJax_2
# When MathJax is enabled you can set the default output format to be used for
# the MathJax output. For more details about the output format see MathJax
# version 2 (see:
# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3
# (see:
# http://docs.mathjax.org/en/latest/web/components/output.html).
# the MathJax output. See the MathJax site (see:
# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details.
# Possible values are: HTML-CSS (which is slower, but has the best
# compatibility. This is the name for Mathjax version 2, for MathJax version 3
# this will be translated into chtml), NativeMML (i.e. MathML. Only supported
# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This
# is the name for Mathjax version 3, for MathJax version 2 this will be
# translated into HTML-CSS) and SVG.
# compatibility), NativeMML (i.e. MathML) and SVG.
# The default value is: HTML-CSS.
# This tag requires that the tag USE_MATHJAX is set to YES.
@@ -1658,21 +1600,15 @@ MATHJAX_FORMAT = HTML-CSS
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from https://www.mathjax.org before deployment. The default value is:
# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2
# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3
# MathJax from https://www.mathjax.org before deployment.
# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
# extension names that should be enabled during MathJax rendering. For example
# for MathJax version 2 (see
# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions):
# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
# For example for MathJax version 3 (see
# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html):
# MATHJAX_EXTENSIONS = ams
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_EXTENSIONS =
@@ -1852,31 +1788,29 @@ PAPER_TYPE = a4
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a user-defined LaTeX header for
# the generated LaTeX document. The header should contain everything until the
# first chapter. If it is left blank doxygen will generate a standard header. It
# is highly recommended to start with a default header using
# doxygen -w latex new_header.tex new_footer.tex new_stylesheet.sty
# and then modify the file new_header.tex. See also section "Doxygen usage" for
# information on how to generate the default header that doxygen normally uses.
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
# generated LaTeX document. The header should contain everything until the first
# chapter. If it is left blank doxygen will generate a standard header. See
# section "Doxygen usage" for information on how to let doxygen write the
# default header to a separate file.
#
# Note: Only use a user-defined header if you know what you are doing!
# Note: The header is subject to change so you typically have to regenerate the
# default header when upgrading to a newer version of doxygen. The following
# commands have a special meaning inside the header (and footer): For a
# description of the possible markers and block names see the documentation.
# Note: Only use a user-defined header if you know what you are doing! The
# following commands have a special meaning inside the header: $title,
# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
# string, for the replacement values of the other commands the user is referred
# to HTML_HEADER.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HEADER =
# The LATEX_FOOTER tag can be used to specify a user-defined LaTeX footer for
# the generated LaTeX document. The footer should contain everything after the
# last chapter. If it is left blank doxygen will generate a standard footer. See
# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
# generated LaTeX document. The footer should contain everything after the last
# chapter. If it is left blank doxygen will generate a standard footer. See
# LATEX_HEADER for more information on how to generate a default footer and what
# special commands can be used inside the footer. See also section "Doxygen
# usage" for information on how to generate the default footer that doxygen
# normally uses. Note: Only use a user-defined footer if you know what you are
# doing!
# special commands can be used inside the footer.
#
# Note: Only use a user-defined footer if you know what you are doing!
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_FOOTER =
@@ -1921,7 +1855,8 @@ USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
# command to the generated LaTeX files. This will instruct LaTeX to keep running
# if errors occur, instead of asking the user for help.
# if errors occur, instead of asking the user for help. This option is also used
# when generating formulas in HTML.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1934,6 +1869,16 @@ LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
# code with syntax highlighting in the LaTeX output.
#
# Note that which sources are shown also depends on other settings such as
# SOURCE_BROWSER.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_SOURCE_CODE = NO
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. See
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
@@ -2014,6 +1959,16 @@ RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
# with syntax highlighting in the RTF output.
#
# Note that which sources are shown also depends on other settings such as
# SOURCE_BROWSER.
# The default value is: NO.
# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_SOURCE_CODE = NO
#---------------------------------------------------------------------------
# Configuration options related to the man page output
#---------------------------------------------------------------------------
@@ -2110,6 +2065,15 @@ GENERATE_DOCBOOK = NO
DOCBOOK_OUTPUT = docbook
# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
# program listings (including syntax highlighting and cross-referencing
# information) to the DOCBOOK output. Note that enabling this will significantly
# increase the size of the DOCBOOK output.
# The default value is: NO.
# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
DOCBOOK_PROGRAMLISTING = NO
#---------------------------------------------------------------------------
# Configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
@@ -2290,6 +2254,15 @@ EXTERNAL_PAGES = YES
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
# NO turns the diagrams off. Note that this option also works with HAVE_DOT
# disabled, but it is recommended to install and use dot, since it yields more
# powerful graphs.
# The default value is: YES.
CLASS_DIAGRAMS = NO
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
@@ -2346,16 +2319,13 @@ DOT_FONTSIZE = 10
DOT_FONTPATH =
# If the CLASS_GRAPH tag is set to YES (or GRAPH) then doxygen will generate a
# graph for each documented class showing the direct and indirect inheritance
# relations. In case HAVE_DOT is set as well dot will be used to draw the graph,
# otherwise the built-in generator will be used. If the CLASS_GRAPH tag is set
# to TEXT the direct and indirect inheritance relations will be shown as texts /
# links.
# Possible values are: NO, YES, TEXT and GRAPH.
# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
# each documented class showing the direct and indirect inheritance relations.
# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
CLASS_GRAPH = TEXT
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
# graph for each documented class showing the direct and indirect implementation
@@ -2482,13 +2452,6 @@ GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
# The DIR_GRAPH_MAX_DEPTH tag can be used to limit the maximum number of levels
# of child directories generated in directory dependency graphs by dot.
# Minimum value: 1, maximum value: 25, default value: 1.
# This tag requires that the tag DIRECTORY_GRAPH is set to YES.
DIR_GRAPH_MAX_DEPTH = 1
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. For an explanation of the image formats see the section
# output formats in the documentation of the dot tool (Graphviz (see:
@@ -2542,10 +2505,10 @@ MSCFILE_DIRS =
DIAFILE_DIRS =
# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
# path where java can find the plantuml.jar file or to the filename of jar file
# to be used. If left blank, it is assumed PlantUML is not used or called during
# a preprocessing step. Doxygen will generate a warning when it encounters a
# \startuml command in this case and will not generate output for the diagram.
# path where java can find the plantuml.jar file. If left blank, it is assumed
# PlantUML is not used or called during a preprocessing step. Doxygen will
# generate a warning when it encounters a \startuml command in this case and
# will not generate output for the diagram.
PLANTUML_JAR_PATH =
@@ -2607,8 +2570,6 @@ DOT_MULTI_TARGETS = YES
# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
# explaining the meaning of the various boxes and arrows in the dot generated
# graphs.
# Note: This tag requires that UML_LOOK isn't set, i.e. the doxygen internal
# graphical representation for inheritance and collaboration diagrams is used.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2617,8 +2578,8 @@ GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate
# files that are used to generate the various graphs.
#
# Note: This setting is not only used for dot files but also for msc temporary
# files.
# Note: This setting is not only used for dot files but also for msc and
# plantuml temporary files.
# The default value is: YES.
DOT_CLEANUP = YES

View File

@@ -41,7 +41,7 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
else:
layout.label(text="", translate=False, icon_value=icon)
# 'GRID' layout type should be as compact as possible (typically a single icon!).
elif self.layout_type == 'GRID':
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)

View File

@@ -73,7 +73,7 @@ class MESH_UL_vgroups_slow(bpy.types.UIList):
layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED'
layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False)
elif self.layout_type == 'GRID':
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
if flt_flag & self.VGROUP_EMPTY:
layout.enabled = False

View File

@@ -63,7 +63,6 @@ import os
import sys
import inspect
import shutil
import time
import logging
import warnings
@@ -400,7 +399,6 @@ MODULE_GROUPING = {
# converting bytes to strings, due to T30154
BLENDER_REVISION = str(bpy.app.build_hash, 'utf_8')
BLENDER_REVISION_TIMESTAMP = bpy.app.build_commit_timestamp
# '2.83.0 Beta' or '2.83.0' or '2.83.1'
BLENDER_VERSION_STRING = bpy.app.version_string
@@ -409,13 +407,9 @@ BLENDER_VERSION_DOTS = "%d.%d" % (bpy.app.version[0], bpy.app.version[1])
if BLENDER_REVISION != "Unknown":
# SHA1 Git hash
BLENDER_VERSION_HASH = BLENDER_REVISION
BLENDER_VERSION_HASH_HTML_LINK = "<a href=https://developer.blender.org/rB%s>%s</a>" % (BLENDER_VERSION_HASH, BLENDER_VERSION_HASH)
BLENDER_VERSION_DATE = time.strftime("%d/%m/%Y", time.localtime(BLENDER_REVISION_TIMESTAMP))
else:
# Fallback: Should not be used
BLENDER_VERSION_HASH = "Hash Unknown"
BLENDER_VERSION_HASH_HTML_LINK = BLENDER_VERSION_HASH
BLENDER_VERSION_DATE = time.strftime("%Y-%m-%d")
# '2_83'
BLENDER_VERSION_PATH = "%d_%d" % (bpy.app.version[0], bpy.app.version[1])
@@ -1758,12 +1752,11 @@ except ModuleNotFoundError:
fw("html_split_index = True\n")
fw("html_static_path = ['static']\n")
fw("templates_path = ['templates']\n")
fw("html_context = {'commit': '%s - %s'}\n" % (BLENDER_VERSION_HASH_HTML_LINK, BLENDER_VERSION_DATE))
fw("html_context = {'commit': '%s'}\n" % BLENDER_VERSION_HASH)
fw("html_extra_path = ['static/favicon.ico', 'static/blender_logo.svg']\n")
fw("html_favicon = 'static/favicon.ico'\n")
fw("html_logo = 'static/blender_logo.svg'\n")
# Disable default `last_updated` value, since this is the date of doc generation, not the one of the source commit.
fw("html_last_updated_fmt = None\n\n")
fw("html_last_updated_fmt = '%m/%d/%Y'\n\n")
fw("if html_theme == 'sphinx_rtd_theme':\n")
fw(" html_css_files = ['css/version_switch.css']\n")
fw(" html_js_files = ['js/version_switch.js']\n")

View File

@@ -1,27 +0,0 @@
Copyright (c) 2012 - present, Victor Zverovich
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- Optional exception to the license ---
As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.

View File

@@ -1,8 +0,0 @@
Project: {fmt}
URL: https://github.com/fmtlib/fmt
License: MIT
Upstream version: 8.1.1 (b6f4cea)
Local modifications:
- Took only files needed for Blender: LICENSE, README and include/fmt
folder's core.h, format-inl.h, format.h

View File

@@ -1,528 +0,0 @@
{fmt}
=====
.. image:: https://github.com/fmtlib/fmt/workflows/linux/badge.svg
:target: https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux
.. image:: https://github.com/fmtlib/fmt/workflows/macos/badge.svg
:target: https://github.com/fmtlib/fmt/actions?query=workflow%3Amacos
.. image:: https://github.com/fmtlib/fmt/workflows/windows/badge.svg
:target: https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows
.. image:: https://ci.appveyor.com/api/projects/status/ehjkiefde6gucy1v?svg=true
:target: https://ci.appveyor.com/project/vitaut/fmt
.. image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg
:alt: fmt is continuously fuzzed at oss-fuzz
:target: https://bugs.chromium.org/p/oss-fuzz/issues/list?\
colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\
Summary&q=proj%3Dfmt&can=1
.. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg
:alt: Ask questions at StackOverflow with the tag fmt
:target: https://stackoverflow.com/questions/tagged/fmt
**{fmt}** is an open-source formatting library providing a fast and safe
alternative to C stdio and C++ iostreams.
If you like this project, please consider donating to the BYSOL
Foundation that helps victims of political repressions in Belarus:
https://bysol.org/en/bs/general/.
`Documentation <https://fmt.dev>`__
Q&A: ask questions on `StackOverflow with the tag fmt
<https://stackoverflow.com/questions/tagged/fmt>`_.
Try {fmt} in `Compiler Explorer <https://godbolt.org/z/Eq5763>`_.
Features
--------
* Simple `format API <https://fmt.dev/latest/api.html>`_ with positional arguments
for localization
* Implementation of `C++20 std::format
<https://en.cppreference.com/w/cpp/utility/format>`__
* `Format string syntax <https://fmt.dev/latest/syntax.html>`_ similar to Python's
`format <https://docs.python.org/3/library/stdtypes.html#str.format>`_
* Fast IEEE 754 floating-point formatter with correct rounding, shortness and
round-trip guarantees
* Safe `printf implementation
<https://fmt.dev/latest/api.html#printf-formatting>`_ including the POSIX
extension for positional arguments
* Extensibility: `support for user-defined types
<https://fmt.dev/latest/api.html#formatting-user-defined-types>`_
* High performance: faster than common standard library implementations of
``(s)printf``, iostreams, ``to_string`` and ``to_chars``, see `Speed tests`_
and `Converting a hundred million integers to strings per second
<http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html>`_
* Small code size both in terms of source code with the minimum configuration
consisting of just three files, ``core.h``, ``format.h`` and ``format-inl.h``,
and compiled code; see `Compile time and code bloat`_
* Reliability: the library has an extensive set of `tests
<https://github.com/fmtlib/fmt/tree/master/test>`_ and is `continuously fuzzed
<https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20
Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1>`_
* Safety: the library is fully type safe, errors in format strings can be
reported at compile time, automatic memory management prevents buffer overflow
errors
* Ease of use: small self-contained code base, no external dependencies,
permissive MIT `license
<https://github.com/fmtlib/fmt/blob/master/LICENSE.rst>`_
* `Portability <https://fmt.dev/latest/index.html#portability>`_ with
consistent output across platforms and support for older compilers
* Clean warning-free codebase even on high warning levels such as
``-Wall -Wextra -pedantic``
* Locale-independence by default
* Optional header-only configuration enabled with the ``FMT_HEADER_ONLY`` macro
See the `documentation <https://fmt.dev>`_ for more details.
Examples
--------
**Print to stdout** (`run <https://godbolt.org/z/Tevcjh>`_)
.. code:: c++
#include <fmt/core.h>
int main() {
fmt::print("Hello, world!\n");
}
**Format a string** (`run <https://godbolt.org/z/oK8h33>`_)
.. code:: c++
std::string s = fmt::format("The answer is {}.", 42);
// s == "The answer is 42."
**Format a string using positional arguments** (`run <https://godbolt.org/z/Yn7Txe>`_)
.. code:: c++
std::string s = fmt::format("I'd rather be {1} than {0}.", "right", "happy");
// s == "I'd rather be happy than right."
**Print chrono durations** (`run <https://godbolt.org/z/K8s4Mc>`_)
.. code:: c++
#include <fmt/chrono.h>
int main() {
using namespace std::literals::chrono_literals;
fmt::print("Default format: {} {}\n", 42s, 100ms);
fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
}
Output::
Default format: 42s 100ms
strftime-like format: 03:15:30
**Print a container** (`run <https://godbolt.org/z/MjsY7c>`_)
.. code:: c++
#include <vector>
#include <fmt/ranges.h>
int main() {
std::vector<int> v = {1, 2, 3};
fmt::print("{}\n", v);
}
Output::
[1, 2, 3]
**Check a format string at compile time**
.. code:: c++
std::string s = fmt::format("{:d}", "I am not a number");
This gives a compile-time error in C++20 because ``d`` is an invalid format
specifier for a string.
**Write a file from a single thread**
.. code:: c++
#include <fmt/os.h>
int main() {
auto out = fmt::output_file("guide.txt");
out.print("Don't {}", "Panic");
}
This can be `5 to 9 times faster than fprintf
<http://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html>`_.
**Print with colors and text styles**
.. code:: c++
#include <fmt/color.h>
int main() {
fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,
"Hello, {}!\n", "world");
fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |
fmt::emphasis::underline, "Hello, {}!\n", "мир");
fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,
"Hello, {}!\n", "世界");
}
Output on a modern terminal:
.. image:: https://user-images.githubusercontent.com/
576385/88485597-d312f600-cf2b-11ea-9cbe-61f535a86e28.png
Benchmarks
----------
Speed tests
~~~~~~~~~~~
================= ============= ===========
Library Method Run Time, s
================= ============= ===========
libc printf 1.04
libc++ std::ostream 3.05
{fmt} 6.1.1 fmt::print 0.75
Boost Format 1.67 boost::format 7.24
Folly Format folly::format 2.23
================= ============= ===========
{fmt} is the fastest of the benchmarked methods, ~35% faster than ``printf``.
The above results were generated by building ``tinyformat_test.cpp`` on macOS
10.14.6 with ``clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT``, and taking the
best of three runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"``
or equivalent is filled 2,000,000 times with output sent to ``/dev/null``; for
further details refer to the `source
<https://github.com/fmtlib/format-benchmark/blob/master/src/tinyformat-test.cc>`_.
{fmt} is up to 20-30x faster than ``std::ostringstream`` and ``sprintf`` on
floating-point formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_)
and faster than `double-conversion <https://github.com/google/double-conversion>`_ and
`ryu <https://github.com/ulfjack/ryu>`_:
.. image:: https://user-images.githubusercontent.com/576385/
95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png
:target: https://fmt.dev/unknown_mac64_clang12.0.html
Compile time and code bloat
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The script `bloat-test.py
<https://github.com/fmtlib/format-benchmark/blob/master/bloat-test.py>`_
from `format-benchmark <https://github.com/fmtlib/format-benchmark>`_
tests compile time and code bloat for nontrivial projects.
It generates 100 translation units and uses ``printf()`` or its alternative
five times in each to simulate a medium sized project. The resulting
executable size and compile time (Apple LLVM version 8.1.0 (clang-802.0.42),
macOS Sierra, best of three) is shown in the following tables.
**Optimized build (-O3)**
============= =============== ==================== ==================
Method Compile Time, s Executable size, KiB Stripped size, KiB
============= =============== ==================== ==================
printf 2.6 29 26
printf+string 16.4 29 26
iostreams 31.1 59 55
{fmt} 19.0 37 34
Boost Format 91.9 226 203
Folly Format 115.7 101 88
============= =============== ==================== ==================
As you can see, {fmt} has 60% less overhead in terms of resulting binary code
size compared to iostreams and comes pretty close to ``printf``. Boost Format
and Folly Format have the largest overheads.
``printf+string`` is the same as ``printf`` but with extra ``<string>``
include to measure the overhead of the latter.
**Non-optimized build**
============= =============== ==================== ==================
Method Compile Time, s Executable size, KiB Stripped size, KiB
============= =============== ==================== ==================
printf 2.2 33 30
printf+string 16.0 33 30
iostreams 28.3 56 52
{fmt} 18.2 59 50
Boost Format 54.1 365 303
Folly Format 79.9 445 430
============= =============== ==================== ==================
``libc``, ``lib(std)c++`` and ``libfmt`` are all linked as shared libraries to
compare formatting function overhead only. Boost Format is a
header-only library so it doesn't provide any linkage options.
Running the tests
~~~~~~~~~~~~~~~~~
Please refer to `Building the library`__ for the instructions on how to build
the library and run the unit tests.
__ https://fmt.dev/latest/usage.html#building-the-library
Benchmarks reside in a separate repository,
`format-benchmarks <https://github.com/fmtlib/format-benchmark>`_,
so to run the benchmarks you first need to clone this repository and
generate Makefiles with CMake::
$ git clone --recursive https://github.com/fmtlib/format-benchmark.git
$ cd format-benchmark
$ cmake .
Then you can run the speed test::
$ make speed-test
or the bloat test::
$ make bloat-test
Migrating code
--------------
`clang-tidy-fmt <https://github.com/mikecrowe/clang-tidy-fmt>`_ provides clang
tidy checks for converting occurrences of ``printf`` and ``fprintf`` to
``fmt::print``.
Projects using this library
---------------------------
* `0 A.D. <https://play0ad.com/>`_: a free, open-source, cross-platform
real-time strategy game
* `2GIS <https://2gis.ru/>`_: free business listings with a city map
* `AMPL/MP <https://github.com/ampl/mp>`_:
an open-source library for mathematical programming
* `Aseprite <https://github.com/aseprite/aseprite>`_:
animated sprite editor & pixel art tool
* `AvioBook <https://www.aviobook.aero/en>`_: a comprehensive aircraft
operations suite
* `Blizzard Battle.net <https://battle.net/>`_: an online gaming platform
* `Celestia <https://celestia.space/>`_: real-time 3D visualization of space
* `Ceph <https://ceph.com/>`_: a scalable distributed storage system
* `ccache <https://ccache.dev/>`_: a compiler cache
* `ClickHouse <https://github.com/ClickHouse/ClickHouse>`_: analytical database
management system
* `CUAUV <https://cuauv.org/>`_: Cornell University's autonomous underwater
vehicle
* `Drake <https://drake.mit.edu/>`_: a planning, control, and analysis toolbox
for nonlinear dynamical systems (MIT)
* `Envoy <https://lyft.github.io/envoy/>`_: C++ L7 proxy and communication bus
(Lyft)
* `FiveM <https://fivem.net/>`_: a modification framework for GTA V
* `fmtlog <https://github.com/MengRao/fmtlog>`_: a performant fmtlib-style
logging library with latency in nanoseconds
* `Folly <https://github.com/facebook/folly>`_: Facebook open-source library
* `Grand Mountain Adventure
<https://store.steampowered.com/app/1247360/Grand_Mountain_Adventure/>`_:
A beautiful open-world ski & snowboarding game
* `HarpyWar/pvpgn <https://github.com/pvpgn/pvpgn-server>`_:
Player vs Player Gaming Network with tweaks
* `KBEngine <https://github.com/kbengine/kbengine>`_: an open-source MMOG server
engine
* `Keypirinha <https://keypirinha.com/>`_: a semantic launcher for Windows
* `Kodi <https://kodi.tv/>`_ (formerly xbmc): home theater software
* `Knuth <https://kth.cash/>`_: high-performance Bitcoin full-node
* `Microsoft Verona <https://github.com/microsoft/verona>`_:
research programming language for concurrent ownership
* `MongoDB <https://mongodb.com/>`_: distributed document database
* `MongoDB Smasher <https://github.com/duckie/mongo_smasher>`_: a small tool to
generate randomized datasets
* `OpenSpace <https://openspaceproject.com/>`_: an open-source
astrovisualization framework
* `PenUltima Online (POL) <https://www.polserver.com/>`_:
an MMO server, compatible with most Ultima Online clients
* `PyTorch <https://github.com/pytorch/pytorch>`_: an open-source machine
learning library
* `quasardb <https://www.quasardb.net/>`_: a distributed, high-performance,
associative database
* `Quill <https://github.com/odygrd/quill>`_: asynchronous low-latency logging library
* `QKW <https://github.com/ravijanjam/qkw>`_: generalizing aliasing to simplify
navigation, and executing complex multi-line terminal command sequences
* `redis-cerberus <https://github.com/HunanTV/redis-cerberus>`_: a Redis cluster
proxy
* `redpanda <https://vectorized.io/redpanda>`_: a 10x faster Kafka® replacement
for mission critical systems written in C++
* `rpclib <http://rpclib.net/>`_: a modern C++ msgpack-RPC server and client
library
* `Salesforce Analytics Cloud
<https://www.salesforce.com/analytics-cloud/overview/>`_:
business intelligence software
* `Scylla <https://www.scylladb.com/>`_: a Cassandra-compatible NoSQL data store
that can handle 1 million transactions per second on a single server
* `Seastar <http://www.seastar-project.org/>`_: an advanced, open-source C++
framework for high-performance server applications on modern hardware
* `spdlog <https://github.com/gabime/spdlog>`_: super fast C++ logging library
* `Stellar <https://www.stellar.org/>`_: financial platform
* `Touch Surgery <https://www.touchsurgery.com/>`_: surgery simulator
* `TrinityCore <https://github.com/TrinityCore/TrinityCore>`_: open-source
MMORPG framework
* `Windows Terminal <https://github.com/microsoft/terminal>`_: the new Windows
terminal
`More... <https://github.com/search?q=fmtlib&type=Code>`_
If you are aware of other projects using this library, please let me know
by `email <mailto:victor.zverovich@gmail.com>`_ or by submitting an
`issue <https://github.com/fmtlib/fmt/issues>`_.
Motivation
----------
So why yet another formatting library?
There are plenty of methods for doing this task, from standard ones like
the printf family of function and iostreams to Boost Format and FastFormat
libraries. The reason for creating a new library is that every existing
solution that I found either had serious issues or didn't provide
all the features I needed.
printf
~~~~~~
The good thing about ``printf`` is that it is pretty fast and readily available
being a part of the C standard library. The main drawback is that it
doesn't support user-defined types. ``printf`` also has safety issues although
they are somewhat mitigated with `__attribute__ ((format (printf, ...))
<https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC.
There is a POSIX extension that adds positional arguments required for
`i18n <https://en.wikipedia.org/wiki/Internationalization_and_localization>`_
to ``printf`` but it is not a part of C99 and may not be available on some
platforms.
iostreams
~~~~~~~~~
The main issue with iostreams is best illustrated with an example:
.. code:: c++
std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n";
which is a lot of typing compared to printf:
.. code:: c++
printf("%.2f\n", 1.23456);
Matthew Wilson, the author of FastFormat, called this "chevron hell". iostreams
don't support positional arguments by design.
The good part is that iostreams support user-defined types and are safe although
error handling is awkward.
Boost Format
~~~~~~~~~~~~
This is a very powerful library which supports both ``printf``-like format
strings and positional arguments. Its main drawback is performance. According to
various benchmarks, it is much slower than other methods considered here. Boost
Format also has excessive build times and severe code bloat issues (see
`Benchmarks`_).
FastFormat
~~~~~~~~~~
This is an interesting library which is fast, safe and has positional arguments.
However, it has significant limitations, citing its author:
Three features that have no hope of being accommodated within the
current design are:
* Leading zeros (or any other non-space padding)
* Octal/hexadecimal encoding
* Runtime width/alignment specification
It is also quite big and has a heavy dependency, STLSoft, which might be too
restrictive for using it in some projects.
Boost Spirit.Karma
~~~~~~~~~~~~~~~~~~
This is not really a formatting library but I decided to include it here for
completeness. As iostreams, it suffers from the problem of mixing verbatim text
with arguments. The library is pretty fast, but slower on integer formatting
than ``fmt::format_to`` with format string compilation on Karma's own benchmark,
see `Converting a hundred million integers to strings per second
<http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html>`_.
License
-------
{fmt} is distributed under the MIT `license
<https://github.com/fmtlib/fmt/blob/master/LICENSE.rst>`_.
Documentation License
---------------------
The `Format String Syntax <https://fmt.dev/latest/syntax.html>`_
section in the documentation is based on the one from Python `string module
documentation <https://docs.python.org/3/library/string.html#module-string>`_.
For this reason the documentation is distributed under the Python Software
Foundation license available in `doc/python-license.txt
<https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt>`_.
It only applies if you distribute the documentation of {fmt}.
Maintainers
-----------
The {fmt} library is maintained by Victor Zverovich (`vitaut
<https://github.com/vitaut>`_) and Jonathan Müller (`foonathan
<https://github.com/foonathan>`_) with contributions from many other people.
See `Contributors <https://github.com/fmtlib/fmt/graphs/contributors>`_ and
`Releases <https://github.com/fmtlib/fmt/releases>`_ for some of the names.
Let us know if your contribution is not listed or mentioned incorrectly and
we'll make it right.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
# Copyright 2011-2022 Blender Foundation
# Standalone or with Blender
if(NOT WITH_BLENDER)
if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
else()
set(WITH_CYCLES_BLENDER ON)
@@ -215,15 +215,6 @@ add_definitions(
-DCCL_NAMESPACE_END=}
)
include_directories(
SYSTEM
${BOOST_INCLUDE_DIR}
${OPENIMAGEIO_INCLUDE_DIRS}
${OPENEXR_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
${TBB_INCLUDE_DIRS}
)
if(WITH_CYCLES_DEBUG)
add_definitions(-DWITH_CYCLES_DEBUG)
endif()
@@ -264,6 +255,7 @@ endif()
if(WITH_CYCLES_EMBREE)
add_definitions(-DWITH_EMBREE)
add_definitions(-DEMBREE_STATIC_LIB)
include_directories(
SYSTEM
${EMBREE_INCLUDE_DIRS}
@@ -288,6 +280,7 @@ endif()
if(WITH_OPENIMAGEDENOISE)
add_definitions(-DWITH_OPENIMAGEDENOISE)
add_definitions(-DOIDN_STATIC_LIB)
include_directories(
SYSTEM
${OPENIMAGEDENOISE_INCLUDE_DIRS}
@@ -315,6 +308,17 @@ if(NOT OPENIMAGEIO_PUGIXML_FOUND)
add_definitions(-DWITH_SYSTEM_PUGIXML)
endif()
include_directories(
SYSTEM
${BOOST_INCLUDE_DIR}
${OPENIMAGEIO_INCLUDE_DIRS}
${OPENIMAGEIO_INCLUDE_DIRS}/OpenImageIO
${OPENEXR_INCLUDE_DIR}
${OPENEXR_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
${TBB_INCLUDE_DIRS}
)
if(CYCLES_STANDALONE_REPOSITORY)
include_directories(../third_party/atomic)
else()
@@ -331,14 +335,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
unset(_has_no_error_unused_macros)
endif()
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND (NOT WITH_USD))
message(STATUS "USD not found, disabling WITH_CYCLES_HYDRA_RENDER_DELEGATE")
set(WITH_CYCLES_HYDRA_RENDER_DELEGATE OFF)
endif()
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND (NOT WITH_BLENDER) AND (NOT WITH_CYCLES_STANDALONE))
set(CYCLES_INSTALL_PATH ${CYCLES_INSTALL_PATH}/hdCycles/resources)
endif()
if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
if(MSVC)
set(MAX_MSVC 1800)
@@ -399,10 +395,6 @@ if(WITH_GTESTS)
add_subdirectory(test)
endif()
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE)
add_subdirectory(hydra)
endif()
if(NOT WITH_BLENDER)
if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
delayed_do_install(${CMAKE_BINARY_DIR}/bin)
endif()

View File

@@ -11,7 +11,7 @@ set(INC
set(INC_SYS
)
set(LIB
set(LIBRARIES
cycles_device
cycles_kernel
cycles_scene
@@ -22,34 +22,28 @@ set(LIB
cycles_util
)
if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC)
list(APPEND INC_SYS
${ALEMBIC_INCLUDE_DIRS}
)
list(APPEND LIB
${ALEMBIC_LIBRARIES}
)
endif()
if(WITH_CYCLES_OSL)
list(APPEND LIB cycles_kernel_osl)
list(APPEND LIBRARIES cycles_kernel_osl)
endif()
if(CYCLES_STANDALONE_REPOSITORY)
list(APPEND LIB extern_sky)
list(APPEND LIBRARIES extern_sky)
else()
list(APPEND LIB bf_intern_sky)
list(APPEND LIBRARIES bf_intern_sky)
endif()
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
add_definitions(${GL_DEFINITIONS})
list(APPEND INC_SYS ${GLEW_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
list(APPEND LIB ${CYCLES_GL_LIBRARIES} ${CYCLES_GLEW_LIBRARIES} ${SDL2_LIBRARIES})
list(APPEND INC_SYS
${GLEW_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
)
list(APPEND LIBRARIES
${CYCLES_GL_LIBRARIES}
${SDL2_LIBRARIES}
)
endif()
cycles_external_libraries_append(LIB)
# Common configuration.
include_directories(${INC})
@@ -80,7 +74,8 @@ if(WITH_CYCLES_STANDALONE)
add_executable(cycles ${SRC} ${INC} ${INC_SYS})
unset(SRC)
target_link_libraries(cycles PRIVATE ${LIB})
target_link_libraries(cycles ${LIBRARIES})
cycles_target_link_libraries(cycles)
if(APPLE)
if(WITH_OPENCOLORIO)
@@ -123,12 +118,9 @@ if(WITH_CYCLES_CUBIN_COMPILER)
set(INC
../../../extern/cuew/include
)
set(LIB
)
cycles_external_libraries_append(LIB)
add_executable(cycles_cubin_cc ${SRC})
include_directories(${INC})
target_link_libraries(cycles_cubin_cc PRIVATE ${LIB})
cycles_target_link_libraries(cycles_cubin_cc)
unset(SRC)
unset(INC)
endif()

View File

@@ -121,9 +121,9 @@ static void session_init()
options.session->set_display_driver(make_unique<OpenGLDisplayDriver>(
window_opengl_context_enable, window_opengl_context_disable));
}
else
#endif
if (!options.output_filepath.empty()) {
if (!options.output_filepath.empty()) {
options.session->set_output_driver(make_unique<OIIOOutputDriver>(
options.output_filepath, options.output_pass, session_print));
}

View File

@@ -9,7 +9,6 @@
#include "graph/node_xml.h"
#include "scene/alembic.h"
#include "scene/background.h"
#include "scene/camera.h"
#include "scene/film.h"
@@ -193,31 +192,6 @@ static void xml_read_camera(XMLReadState &state, xml_node node)
cam->update(state.scene);
}
/* Alembic */
#ifdef WITH_ALEMBIC
static void xml_read_alembic(XMLReadState &state, xml_node graph_node)
{
AlembicProcedural *proc = state.scene->create_node<AlembicProcedural>();
xml_read_node(state, proc, graph_node);
for (xml_node node = graph_node.first_child(); node; node = node.next_sibling()) {
if (string_iequals(node.name(), "object")) {
string path;
if (xml_read_string(&path, node, "path")) {
ustring object_path(path, 0);
AlembicObject *object = static_cast<AlembicObject *>(
proc->get_or_create_object(object_path));
array<Node *> used_shaders = object->get_used_shaders();
used_shaders.push_back_slow(state.shader);
object->set_used_shaders(used_shaders);
}
}
}
}
#endif
/* Shader */
static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node)
@@ -673,11 +647,6 @@ static void xml_read_scene(XMLReadState &state, xml_node scene_node)
if (xml_read_string(&src, node, "src"))
xml_read_include(state, src);
}
#ifdef WITH_ALEMBIC
else if (string_iequals(node.name(), "alembic")) {
xml_read_alembic(state, node);
}
#endif
else
fprintf(stderr, "Unknown node \"%s\".\n", node.name());
}

View File

@@ -83,17 +83,6 @@ class CyclesRender(bpy.types.RenderEngine):
# viewport render
def view_update(self, context, depsgraph):
if not self.session:
# When starting a new render session in viewport (by switching
# viewport to Rendered shading) unpause the render. The way to think
# of it is: artist requests render, so we start to render.
# Do it for both original and evaluated scene so that Cycles
# immediately reacts to un-paused render.
cscene = context.scene.cycles
cscene_eval = depsgraph.scene_eval.cycles
if cscene.preview_pause or cscene_eval.preview_pause:
cscene.preview_pause = False
cscene_eval.preview_pause = False
engine.create(self, context.blend_data,
context.region, context.space_data, context.region_data)

View File

@@ -228,10 +228,6 @@ def list_render_passes(scene, srl):
else:
yield (aov.name, "RGB", 'COLOR')
# Light groups.
for lightgroup in srl.lightgroups:
yield ("Combined_%s" % lightgroup.name, "RGB", 'COLOR')
def register_passes(engine, scene, view_layer):
for name, channelids, channeltype in list_render_passes(scene, view_layer):

View File

@@ -65,8 +65,8 @@ enum_panorama_types = (
)
enum_curve_shape = (
('RIBBONS', "Rounded Ribbons", "Render curves as flat ribbons with rounded normals, for fast rendering"),
('THICK', "3D Curves", "Render curves as circular 3D geometry, for accurate results when viewing closely"),
('RIBBONS', "Rounded Ribbons", "Render hair as flat ribbon with rounded normals, for fast rendering"),
('THICK', "3D Curves", "Render hair as 3D curve, for accurate results when viewing hair close up"),
)
enum_use_layer_samples = (
@@ -428,14 +428,14 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
min_light_bounces: IntProperty(
name="Min Light Bounces",
description="Minimum number of light bounces. Setting this higher reduces noise in the first bounces, "
"but can also be less efficient for more complex geometry like curves and volumes",
"but can also be less efficient for more complex geometry like hair and volumes",
min=0, max=1024,
default=0,
)
min_transparent_bounces: IntProperty(
name="Min Transparent Bounces",
description="Minimum number of transparent bounces. Setting this higher reduces noise in the first bounces, "
"but can also be less efficient for more complex geometry like curves and volumes",
"but can also be less efficient for more complex geometry like hair and volumes",
min=0, max=1024,
default=0,
)
@@ -649,8 +649,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=False,
)
debug_use_hair_bvh: BoolProperty(
name="Use Curves BVH",
description="Use special type BVH optimized for curves (uses more ram but renders faster)",
name="Use Hair BVH",
description="Use special type BVH optimized for hair (uses more ram but renders faster)",
default=True,
)
debug_use_compact_bvh: BoolProperty(
@@ -1012,12 +1012,6 @@ class CyclesLightSettings(bpy.types.PropertyGroup):
"note that this will make the light invisible",
default=False,
)
is_caustics_light: BoolProperty(
name="Shadow Caustics",
description="Generate approximate caustics in shadows of refractive surfaces. "
"Lights, caster and receiver objects must have shadow caustics options set to enable this",
default=False,
)
@classmethod
def register(cls):
@@ -1034,12 +1028,6 @@ class CyclesLightSettings(bpy.types.PropertyGroup):
class CyclesWorldSettings(bpy.types.PropertyGroup):
is_caustics_light: BoolProperty(
name="Shadow Caustics",
description="Generate approximate caustics in shadows of refractive surfaces. "
"Lights, caster and receiver objects must have shadow caustics options set to enable this",
default=False,
)
sampling_method: EnumProperty(
name="Sampling Method",
description="How to sample the background light",
@@ -1238,21 +1226,6 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
subtype='DISTANCE',
)
is_caustics_caster: BoolProperty(
name="Cast Shadow Caustics",
description="With refractive materials, generate approximate caustics in shadows of this object. "
"Up to 10 bounces inside this object are taken into account. Lights, caster and receiver objects "
"must have shadow caustics options set to enable this",
default=False,
)
is_caustics_receiver: BoolProperty(
name="Receive Shadow Caustics",
description="Receive approximate caustics from refractive materials in shadows on this object. "
"Lights, caster and receiver objects must have shadow caustics options set to enable this",
default=False,
)
@classmethod
def register(cls):
bpy.types.Object.cycles = PointerProperty(
@@ -1270,7 +1243,7 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
shape: EnumProperty(
name="Shape",
description="Form of curves",
description="Form of hair",
items=enum_curve_shape,
default='RIBBONS',
)
@@ -1284,8 +1257,8 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Scene.cycles_curves = PointerProperty(
name="Cycles Curves Rendering Settings",
description="Cycles curves rendering settings",
name="Cycles Hair Rendering Settings",
description="Cycles hair rendering settings",
type=cls,
)
@@ -1507,7 +1480,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
col.label(text="and NVIDIA driver version 470 or newer", icon='BLANK1')
elif device_type == 'HIP':
import sys
col.label(text="Requires discrete AMD GPU with Vega architecture", icon='BLANK1')
col.label(text="Requires discrete AMD GPU with RDNA architecture", icon='BLANK1')
if sys.platform[:3] == "win":
col.label(text="and AMD Radeon Pro 21.Q4 driver or newer", icon='BLANK1')
elif device_type == 'METAL':

View File

@@ -11,8 +11,8 @@ from bl_ui.utils import PresetPanel
from bpy.types import Panel
from bl_ui.properties_grease_pencil_common import GreasePencilSimplifyPanel
from bl_ui.properties_render import draw_curves_settings
from bl_ui.properties_view_layer import ViewLayerCryptomattePanel, ViewLayerAOVPanel, ViewLayerLightgroupsPanel
from bl_ui.properties_render import draw_hair_settings
from bl_ui.properties_view_layer import ViewLayerCryptomattePanel, ViewLayerAOVPanel
class CyclesPresetPanel(PresetPanel, Panel):
COMPAT_ENGINES = {'CYCLES'}
@@ -336,8 +336,8 @@ class CYCLES_RENDER_PT_subdivision(CyclesButtonsPanel, Panel):
col.prop(cscene, "dicing_camera")
class CYCLES_RENDER_PT_curves(CyclesButtonsPanel, Panel):
bl_label = "Curves"
class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
bl_label = "Hair"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
@@ -353,13 +353,13 @@ class CYCLES_RENDER_PT_curves(CyclesButtonsPanel, Panel):
if ccscene.shape == 'RIBBONS':
col.prop(ccscene, "subdivisions", text="Curve Subdivisions")
class CYCLES_RENDER_PT_curves_viewport_display(CyclesButtonsPanel, Panel):
class CYCLES_RENDER_PT_hair_viewport_display(CyclesButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_parent_id = "CYCLES_RENDER_PT_curves"
bl_parent_id = "CYCLES_RENDER_PT_hair"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
draw_curves_settings(self, context)
draw_hair_settings(self, context)
class CYCLES_RENDER_PT_volumes(CyclesButtonsPanel, Panel):
bl_label = "Volumes"
@@ -757,7 +757,7 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col = layout.column(heading="Include")
col.prop(view_layer, "use_sky", text="Environment")
col.prop(view_layer, "use_solid", text="Surfaces")
col.prop(view_layer, "use_strand", text="Curves")
col.prop(view_layer, "use_strand", text="Hair")
col.prop(view_layer, "use_volumes", text="Volumes")
col = layout.column(heading="Use")
@@ -883,12 +883,6 @@ class CYCLES_RENDER_PT_passes_aov(CyclesButtonsPanel, ViewLayerAOVPanel):
bl_parent_id = "CYCLES_RENDER_PT_passes"
class CYCLES_RENDER_PT_passes_lightgroups(CyclesButtonsPanel, ViewLayerLightgroupsPanel):
bl_label = "Light Groups"
bl_context = "view_layer"
bl_parent_id = "CYCLES_RENDER_PT_passes"
class CYCLES_PT_post_processing(CyclesButtonsPanel, Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
@@ -1099,10 +1093,6 @@ class CYCLES_OBJECT_PT_shading_shadow_terminator(CyclesButtonsPanel, Panel):
bl_parent_id = "CYCLES_OBJECT_PT_shading"
bl_context = "object"
@classmethod
def poll(cls, context):
return context.object.type != 'LIGHT'
def draw(self, context):
layout = self.layout
layout.use_property_split = True
@@ -1120,10 +1110,6 @@ class CYCLES_OBJECT_PT_shading_gi_approximation(CyclesButtonsPanel, Panel):
bl_parent_id = "CYCLES_OBJECT_PT_shading"
bl_context = "object"
@classmethod
def poll(cls, context):
return context.object.type != 'LIGHT'
def draw(self, context):
layout = self.layout
layout.use_property_split = True
@@ -1139,52 +1125,6 @@ class CYCLES_OBJECT_PT_shading_gi_approximation(CyclesButtonsPanel, Panel):
col.prop(cob, "ao_distance")
class CYCLES_OBJECT_PT_shading_caustics(CyclesButtonsPanel, Panel):
bl_label = "Caustics"
bl_parent_id = "CYCLES_OBJECT_PT_shading"
bl_context = "object"
@classmethod
def poll(cls, context):
return CyclesButtonsPanel.poll(context) and not use_metal(context) and context.object.type != 'LIGHT'
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
ob = context.object
cob = ob.cycles
col.prop(cob, "is_caustics_caster")
col.prop(cob, "is_caustics_receiver")
class CYCLES_OBJECT_PT_lightgroup(CyclesButtonsPanel, Panel):
bl_label = "Light Group"
bl_parent_id = "CYCLES_OBJECT_PT_shading"
bl_context = "object"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
ob = context.object
view_layer = context.view_layer
row = layout.row(align=True)
row.use_property_decorate = False
sub = row.column(align=True)
sub.prop_search(ob, "lightgroup", view_layer, "lightgroups", text="Light Group", results_are_suggestions=True)
sub = row.column(align=True)
sub.active = bool(ob.lightgroup) and not any(lg.name == ob.lightgroup for lg in view_layer.lightgroups)
sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="").name = ob.lightgroup
class CYCLES_OBJECT_PT_visibility(CyclesButtonsPanel, Panel):
bl_label = "Visibility"
bl_context = "object"
@@ -1360,8 +1300,6 @@ class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
sub.active = not (light.type == 'AREA' and clamp.is_portal)
sub.prop(clamp, "cast_shadow")
sub.prop(clamp, "use_multiple_importance_sampling", text="Multiple Importance")
if not use_metal(context):
sub.prop(clamp, "is_caustics_light", text="Shadow Caustics")
if light.type == 'AREA':
col.prop(clamp, "is_portal", text="Portal")
@@ -1437,21 +1375,10 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel):
layout.use_property_split = True
world = context.world
view_layer = context.view_layer
if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
layout.prop(world, "color")
row = layout.row(align=True)
row.use_property_decorate = False
sub = row.column(align=True)
sub.prop_search(world, "lightgroup", view_layer, "lightgroups", text="Light Group", results_are_suggestions=True)
sub = row.column(align=True)
sub.active = bool(world.lightgroup) and not any(lg.name == world.lightgroup for lg in view_layer.lightgroups)
sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="").name = world.lightgroup
class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
@@ -1569,8 +1496,6 @@ class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
subsub.active = cworld.sampling_method == 'MANUAL'
subsub.prop(cworld, "sample_map_resolution")
sub.prop(cworld, "max_bounces")
sub.prop(cworld, "is_caustics_light", text="Shadow Caustics")
class CYCLES_WORLD_PT_settings_volume(CyclesButtonsPanel, Panel):
@@ -2232,8 +2157,8 @@ classes = (
CYCLES_RENDER_PT_light_paths_fast_gi,
CYCLES_RENDER_PT_volumes,
CYCLES_RENDER_PT_subdivision,
CYCLES_RENDER_PT_curves,
CYCLES_RENDER_PT_curves_viewport_display,
CYCLES_RENDER_PT_hair,
CYCLES_RENDER_PT_hair_viewport_display,
CYCLES_RENDER_PT_simplify,
CYCLES_RENDER_PT_simplify_viewport,
CYCLES_RENDER_PT_simplify_render,
@@ -2258,7 +2183,6 @@ classes = (
CYCLES_RENDER_PT_passes_light,
CYCLES_RENDER_PT_passes_crypto,
CYCLES_RENDER_PT_passes_aov,
CYCLES_RENDER_PT_passes_lightgroups,
CYCLES_RENDER_PT_filter,
CYCLES_RENDER_PT_override,
CYCLES_PT_post_processing,
@@ -2269,8 +2193,6 @@ classes = (
CYCLES_OBJECT_PT_shading,
CYCLES_OBJECT_PT_shading_shadow_terminator,
CYCLES_OBJECT_PT_shading_gi_approximation,
CYCLES_OBJECT_PT_shading_caustics,
CYCLES_OBJECT_PT_lightgroup,
CYCLES_OBJECT_PT_visibility,
CYCLES_OBJECT_PT_visibility_ray_visibility,
CYCLES_OBJECT_PT_visibility_culling,

View File

@@ -114,9 +114,6 @@ void BlenderSync::sync_light(BL::Object &b_parent,
light->set_cast_shadow(get_boolean(clight, "cast_shadow"));
light->set_use_mis(get_boolean(clight, "use_multiple_importance_sampling"));
/* caustics light */
light->set_use_caustics(get_boolean(clight, "is_caustics_light"));
light->set_max_bounces(get_int(clight, "max_bounces"));
if (b_ob_info.real_object != b_ob_info.iter_object) {
@@ -143,9 +140,6 @@ void BlenderSync::sync_light(BL::Object &b_parent,
light->set_use_scatter((visibility & PATH_RAY_VOLUME_SCATTER) != 0);
light->set_is_shadow_catcher(b_ob_info.real_object.is_shadow_catcher());
/* lightgroup */
light->set_lightgroup(ustring(b_ob_info.real_object.lightgroup()));
/* tag */
light->tag_update(scene);
}
@@ -182,9 +176,6 @@ void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal)
/* force enable light again when world is resynced */
light->set_is_enabled(true);
/* caustic light */
light->set_use_caustics(get_boolean(cworld, "is_caustics_light"));
light->tag_update(scene);
light_map.set_recalc(b_world);
}

View File

@@ -66,8 +66,9 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info)
}
/* Other object types that are not meshes but evaluate to meshes are presented to render engines
* as separate instance objects. Metaballs have not been affected by that change yet. */
if (type == BL::Object::type_META) {
* as separate instance objects. Metaballs and surface objects have not been affected by that
* change yet. */
if (type == BL::Object::type_SURFACE || type == BL::Object::type_META) {
return true;
}
@@ -297,12 +298,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
}
object->set_ao_distance(ao_distance);
bool is_caustics_caster = get_boolean(cobject, "is_caustics_caster");
object->set_is_caustics_caster(is_caustics_caster);
bool is_caustics_receiver = get_boolean(cobject, "is_caustics_receiver");
object->set_is_caustics_receiver(is_caustics_receiver);
/* sync the asset name for Cryptomatte */
BL::Object parent = b_ob.parent();
ustring parent_name;
@@ -342,9 +337,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
object->set_random_id(hash_uint2(hash_string(object->name.c_str()), 0));
}
/* lightgroup */
object->set_lightgroup(ustring(b_ob.lightgroup()));
object->tag_update(scene);
}
@@ -430,7 +422,7 @@ static float4 lookup_instance_property(BL::DepsgraphObjectInstance &b_instance,
return value;
}
return zero_float4();
return make_float4(0.0f);
}
bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object)
@@ -629,8 +621,10 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
bool has_subdivision_modifier = false;
BL::MeshSequenceCacheModifier b_mesh_cache(PointerRNA_NULL);
/* Experimental as Blender does not have good support for procedurals at the moment. */
if (experimental) {
/* Experimental as Blender does not have good support for procedurals at the moment, also
* only available in preview renders since currently do not have a good cache policy, the
* data being loaded at once for all the frames. */
if (experimental && b_v3d) {
b_mesh_cache = object_mesh_cache_find(b_ob, &has_subdivision_modifier);
use_procedural = b_mesh_cache && b_mesh_cache.cache_file().use_render_procedural();
}

View File

@@ -271,7 +271,6 @@ static ShaderNode *add_node(Scene *scene,
curves->set_min_x(min_x);
curves->set_max_x(max_x);
curves->set_curves(curve_mapping_curves);
curves->set_extrapolate(mapping.extend() == mapping.extend_EXTRAPOLATED);
node = curves;
}
if (b_node.is_a(&RNA_ShaderNodeVectorCurve)) {
@@ -285,7 +284,6 @@ static ShaderNode *add_node(Scene *scene,
curves->set_min_x(min_x);
curves->set_max_x(max_x);
curves->set_curves(curve_mapping_curves);
curves->set_extrapolate(mapping.extend() == mapping.extend_EXTRAPOLATED);
node = curves;
}
else if (b_node.is_a(&RNA_ShaderNodeFloatCurve)) {
@@ -299,7 +297,6 @@ static ShaderNode *add_node(Scene *scene,
curve->set_min_x(min_x);
curve->set_max_x(max_x);
curve->set_curve(curve_mapping_curve);
curve->set_extrapolate(mapping.extend() == mapping.extend_EXTRAPOLATED);
node = curve;
}
else if (b_node.is_a(&RNA_ShaderNodeValToRGB)) {
@@ -1532,8 +1529,6 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
background->set_use_shader(view_layer.use_background_shader ||
viewport_parameters.use_custom_shader());
background->set_lightgroup(ustring(b_world ? b_world.lightgroup() : ""));
background->tag_update(scene);
}

View File

@@ -745,20 +745,6 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
}
}
/* Light Group passes. */
BL::ViewLayer::lightgroups_iterator b_lightgroup_iter;
for (b_view_layer.lightgroups.begin(b_lightgroup_iter);
b_lightgroup_iter != b_view_layer.lightgroups.end();
++b_lightgroup_iter) {
BL::Lightgroup b_lightgroup(*b_lightgroup_iter);
string name = string_printf("Combined_%s", b_lightgroup.name().c_str());
b_engine.add_pass(name.c_str(), 3, "RGB", b_view_layer.name().c_str());
Pass *pass = pass_add(scene, PASS_COMBINED, name.c_str(), PassMode::NOISY);
pass->set_lightgroup(ustring(b_lightgroup.name()));
}
scene->film->set_pass_alpha_threshold(b_view_layer.pass_alpha_threshold());
}

View File

@@ -203,7 +203,7 @@ BVHObjectBinning::BVHObjectBinning(const BVHRange &job,
bestSAH = min(sah, bestSAH);
}
int4 mask = float3_to_float4(cent_bounds_.size()) <= zero_float4();
int4 mask = float3_to_float4(cent_bounds_.size()) <= make_float4(0.0f);
bestSAH = insert<3>(select(mask, make_float4(FLT_MAX), bestSAH), FLT_MAX);
/* find best dimension */

View File

@@ -19,11 +19,7 @@ endmacro()
if(CYCLES_STANDALONE_REPOSITORY)
if(APPLE)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin")
else()
set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin_arm64")
endif()
set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin")
elseif(WIN32)
if(CMAKE_CL_64)
set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/win64_vc15")
@@ -52,24 +48,18 @@ if(CYCLES_STANDALONE_REPOSITORY)
endif()
endif()
if(DEFINED _cycles_lib_dir)
message(STATUS "Using precompiled libraries at ${_cycles_lib_dir}")
endif()
# Avoid namespace pollustion.
unset(LIBDIR_NATIVE_ABI)
unset(LIBDIR_CENTOS7_ABI)
endif()
if(EXISTS ${_cycles_lib_dir})
_set_default(ALEMBIC_ROOT_DIR "${_cycles_lib_dir}/alembic")
_set_default(BOOST_ROOT "${_cycles_lib_dir}/boost")
_set_default(BLOSC_ROOT_DIR "${_cycles_lib_dir}/blosc")
_set_default(EMBREE_ROOT_DIR "${_cycles_lib_dir}/embree")
_set_default(GLEW_ROOT_DIR "${_cycles_lib_dir}/glew")
_set_default(JPEG_ROOT "${_cycles_lib_dir}/jpeg")
_set_default(LLVM_ROOT_DIR "${_cycles_lib_dir}/llvm")
_set_default(CLANG_ROOT_DIR "${_cycles_lib_dir}/llvm")
_set_default(OPENCOLORIO_ROOT_DIR "${_cycles_lib_dir}/opencolorio")
_set_default(OPENEXR_ROOT_DIR "${_cycles_lib_dir}/openexr")
_set_default(OPENIMAGEDENOISE_ROOT_DIR "${_cycles_lib_dir}/openimagedenoise")
@@ -79,7 +69,6 @@ if(CYCLES_STANDALONE_REPOSITORY)
_set_default(OPENVDB_ROOT_DIR "${_cycles_lib_dir}/openvdb")
_set_default(OSL_ROOT_DIR "${_cycles_lib_dir}/osl")
_set_default(PNG_ROOT "${_cycles_lib_dir}/png")
_set_default(PUGIXML_ROOT_DIR "${_cycles_lib_dir}/pugixml")
_set_default(TBB_ROOT_DIR "${_cycles_lib_dir}/tbb")
_set_default(TIFF_ROOT "${_cycles_lib_dir}/tiff")
_set_default(ZLIB_ROOT "${_cycles_lib_dir}/zlib")
@@ -91,23 +80,6 @@ if(CYCLES_STANDALONE_REPOSITORY)
endif()
endif()
###########################################################################
# USD
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_HYDRA_RENDER_DELEGATE)
set(WITH_USD ON)
endif()
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE)
find_package(pxr CONFIG REQUIRED PATHS ${PXR_ROOT} ${USD_ROOT} NO_DEFAULT_PATH)
if(pxr_FOUND)
set(PXR_LIBRARY_DIR ${PXR_CMAKE_DIR}/lib)
set(USD_INCLUDE_DIRS ${PXR_INCLUDE_DIRS})
else()
set(WITH_USD OFF)
endif()
endif()
###########################################################################
# Zlib
###########################################################################
@@ -120,7 +92,7 @@ if(CYCLES_STANDALONE_REPOSITORY)
set(ZLIB_LIBRARY ${_cycles_lib_dir}/zlib/lib/libz_st.lib)
set(ZLIB_DIR ${_cycles_lib_dir}/zlib)
set(ZLIB_FOUND ON)
elseif(NOT APPLE)
else()
find_package(ZLIB REQUIRED)
endif()
endif()
@@ -154,45 +126,32 @@ if(CYCLES_STANDALONE_REPOSITORY)
-DOIIO_STATIC_DEFINE
)
set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO_ROOT_DIR}/include)
set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR} ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO)
# Special exceptions for libraries which needs explicit debug version
set(OPENIMAGEIO_LIBRARIES
set(OPENIMAGEIO_LIBRARY
optimized ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO.lib
optimized ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO_Util.lib
debug ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO_d.lib
debug ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO_Util_d.lib
)
endif()
set(PUGIXML_INCLUDE_DIR ${PUGIXML_ROOT_DIR}/include)
set(PUGIXML_LIBRARIES
optimized ${PUGIXML_ROOT_DIR}/lib/pugixml.lib
debug ${PUGIXML_ROOT_DIR}/lib/pugixml_d.lib
)
find_package(OpenImageIO REQUIRED)
if(OPENIMAGEIO_PUGIXML_FOUND)
set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}")
set(PUGIXML_LIBRARIES "")
else()
find_package(OpenImageIO REQUIRED)
if(OPENIMAGEIO_PUGIXML_FOUND)
set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO")
set(PUGIXML_LIBRARIES "")
else()
find_package(PugiXML REQUIRED)
endif()
find_package(PugiXML REQUIRED)
endif()
# Dependencies
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENJPEG_INCLUDE_DIR ${OPENJPEG}/include/openjpeg-2.3)
set(OPENJPEG_LIBRARIES ${_cycles_lib_dir}/openjpeg/lib/openjp2${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
find_package(OpenJPEG REQUIRED)
set(OPENJPEG_LIBRARY ${_cycles_lib_dir}/openjpeg/lib/openjp2${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
find_package(JPEG REQUIRED)
find_package(OpenJPEG REQUIRED)
find_package(TIFF REQUIRED)
if(EXISTS ${_cycles_lib_dir})
set(PNG_NAMES png16 libpng16 png libpng)
endif()
find_package(PNG REQUIRED)
endif()
@@ -202,71 +161,76 @@ endif()
if(CYCLES_STANDALONE_REPOSITORY)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENEXR_INCLUDE_DIR ${OPENEXR_ROOT_DIR}/include)
set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_ROOT_DIR}/include/OpenEXR)
set(OPENEXR_LIBRARIES
set(OPENEXR_IEX_LIBRARY
optimized ${OPENEXR_ROOT_DIR}/lib/Iex_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/Half_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/IlmImf_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/Imath_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/IlmThread_s.lib
debug ${OPENEXR_ROOT_DIR}/lib/Iex_s_d.lib
)
set(OPENEXR_HALF_LIBRARY
optimized ${OPENEXR_ROOT_DIR}/lib/Half_s.lib
debug ${OPENEXR_ROOT_DIR}/lib/Half_s_d.lib
)
set(OPENEXR_ILMIMF_LIBRARY
optimized ${OPENEXR_ROOT_DIR}/lib/IlmImf_s.lib
debug ${OPENEXR_ROOT_DIR}/lib/IlmImf_s_d.lib
)
set(OPENEXR_IMATH_LIBRARY
optimized ${OPENEXR_ROOT_DIR}/lib/Imath_s.lib
debug ${OPENEXR_ROOT_DIR}/lib/Imath_s_d.lib
)
set(OPENEXR_ILMTHREAD_LIBRARY
optimized ${OPENEXR_ROOT_DIR}/lib/IlmThread_s.lib
debug ${OPENEXR_ROOT_DIR}/lib/IlmThread_s_d.lib
)
else()
find_package(OpenEXR REQUIRED)
endif()
find_package(OpenEXR REQUIRED)
endif()
###########################################################################
# OpenShadingLanguage & LLVM
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OSL)
if(EXISTS ${_cycles_lib_dir})
set(LLVM_STATIC ON)
endif()
if(WITH_CYCLES_OSL)
if(CYCLES_STANDALONE_REPOSITORY)
if(EXISTS ${_cycles_lib_dir})
set(LLVM_STATIC ON)
endif()
if(MSVC AND EXISTS ${_cycles_lib_dir})
# TODO(sergey): On Windows llvm-config doesn't give proper results for the
# library names, use hardcoded libraries for now.
file(GLOB _llvm_libs_release ${LLVM_ROOT_DIR}/lib/*.lib)
file(GLOB _llvm_libs_debug ${LLVM_ROOT_DIR}/debug/lib/*.lib)
set(_llvm_libs)
foreach(_llvm_lib_path ${_llvm_libs_release})
get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE)
list(APPEND _llvm_libs optimized ${_llvm_lib_name})
endforeach()
foreach(_llvm_lib_path ${_llvm_libs_debug})
get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE)
list(APPEND _llvm_libs debug ${_llvm_lib_name})
endforeach()
set(LLVM_LIBRARY ${_llvm_libs})
unset(_llvm_lib_name)
unset(_llvm_lib_path)
unset(_llvm_libs)
unset(_llvm_libs_debug)
unset(_llvm_libs_release)
set(OSL_INCLUDE_DIR ${OSL_ROOT_DIR}/include)
set(OSL_LIBRARIES
optimized ${OSL_ROOT_DIR}/lib/oslcomp.lib
optimized ${OSL_ROOT_DIR}/lib/oslexec.lib
optimized ${OSL_ROOT_DIR}/lib/oslquery.lib
debug ${OSL_ROOT_DIR}/lib/oslcomp_d.lib
debug ${OSL_ROOT_DIR}/lib/oslexec_d.lib
debug ${OSL_ROOT_DIR}/lib/oslquery_d.lib
${PUGIXML_LIBRARIES}
)
find_program(OSL_COMPILER NAMES oslc PATHS ${OSL_ROOT_DIR}/bin)
else()
find_package(OSL REQUIRED)
find_package(LLVM REQUIRED)
find_package(Clang REQUIRED)
if(MSVC AND EXISTS ${_cycles_lib_dir})
# TODO(sergey): On Windows llvm-config doesn't give proper results for the
# library names, use hardcoded libraries for now.
file(GLOB _llvm_libs_release ${LLVM_ROOT_DIR}/lib/*.lib)
file(GLOB _llvm_libs_debug ${LLVM_ROOT_DIR}/debug/lib/*.lib)
set(_llvm_libs)
foreach(_llvm_lib_path ${_llvm_libs_release})
get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE)
list(APPEND _llvm_libs optimized ${_llvm_lib_name})
endforeach()
foreach(_llvm_lib_path ${_llvm_libs_debug})
get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE)
list(APPEND _llvm_libs debug ${_llvm_lib_name})
endforeach()
set(LLVM_LIBRARY ${_llvm_libs})
unset(_llvm_lib_name)
unset(_llvm_lib_path)
unset(_llvm_libs)
unset(_llvm_libs_debug)
unset(_llvm_libs_release)
set(OSL_LIBRARIES
optimized ${OSL_ROOT_DIR}/lib/oslcomp.lib
optimized ${OSL_ROOT_DIR}/lib/oslexec.lib
optimized ${OSL_ROOT_DIR}/lib/oslquery.lib
optimized ${OSL_ROOT_DIR}/lib/pugixml.lib
debug ${OSL_ROOT_DIR}/lib/oslcomp_d.lib
debug ${OSL_ROOT_DIR}/lib/oslexec_d.lib
debug ${OSL_ROOT_DIR}/lib/oslquery_d.lib
debug ${OSL_ROOT_DIR}/lib/pugixml_d.lib
)
endif()
endif()
endif()
@@ -274,23 +238,22 @@ endif()
# OpenColorIO
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENCOLORIO)
set(WITH_OPENCOLORIO ON)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO_ROOT_DIR}/include)
set(OPENCOLORIO_LIBRARIES
optimized ${OPENCOLORIO_ROOT_DIR}/lib/OpenColorIO.lib
optimized ${OPENCOLORIO_ROOT_DIR}/lib/libyaml-cpp.lib
optimized ${OPENCOLORIO_ROOT_DIR}/lib/libexpatMD.lib
optimized ${OPENCOLORIO_ROOT_DIR}/lib/pystring.lib
debug ${OPENCOLORIO_ROOT_DIR}/lib/OpencolorIO_d.lib
debug ${OPENCOLORIO_ROOT_DIR}/lib/libyaml-cpp_d.lib
debug ${OPENCOLORIO_ROOT_DIR}/lib/libexpatdMD.lib
debug ${OPENCOLORIO_ROOT_DIR}/lib/pystring_d.lib
)
else()
if(WITH_CYCLES_OPENCOLORIO)
if(CYCLES_STANDALONE_REPOSITORY)
find_package(OpenColorIO REQUIRED)
set(WITH_OPENCOLORIO ON)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENCOLORIO_LIBPATH ${_cycles_lib_dir}/opencolorio/lib)
set(OPENCOLORIO_LIBRARIES
optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib
optimized ${OPENCOLORIO_LIBPATH}/tinyxml.lib
optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib
debug ${OPENCOLORIO_LIBPATH}/OpencolorIO_d.lib
debug ${OPENCOLORIO_LIBPATH}/tinyxml_d.lib
debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib
)
endif()
endif()
endif()
@@ -311,61 +274,22 @@ if(CYCLES_STANDALONE_REPOSITORY)
endif()
endif()
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(BOOST_INCLUDE_DIR ${BOOST_ROOT}/include)
set(BOOST_VERSION_HEADER ${BOOST_INCLUDE_DIR}/boost/version.hpp)
if(EXISTS ${BOOST_VERSION_HEADER})
file(STRINGS "${BOOST_VERSION_HEADER}" BOOST_LIB_VERSION REGEX "#define BOOST_LIB_VERSION ")
if(BOOST_LIB_VERSION MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"")
set(BOOST_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
if(NOT BOOST_VERSION)
message(FATAL_ERROR "Unable to determine Boost version")
endif()
set(BOOST_POSTFIX "vc141-mt-x64-${BOOST_VERSION}.lib")
set(BOOST_DEBUG_POSTFIX "vc141-mt-gd-x64-${BOOST_VERSION}.lib")
set(BOOST_LIBRARIES
optimized ${BOOST_ROOT}/lib/libboost_date_time-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_iostreams-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_filesystem-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_regex-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_system-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_thread-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_chrono-${BOOST_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_date_time-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_iostreams-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_filesystem-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_regex-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_system-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_thread-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_chrono-${BOOST_DEBUG_POSTFIX}
)
if(WITH_CYCLES_OSL)
set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
optimized ${BOOST_ROOT}/lib/libboost_wave-${BOOST_POSTFIX}
debug ${BOOST_ROOT}/lib/libboost_wave-${BOOST_DEBUG_POSTFIX})
endif()
else()
set(__boost_packages iostreams filesystem regex system thread date_time)
if(WITH_CYCLES_OSL)
list(APPEND __boost_packages wave)
endif()
find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED)
if(NOT Boost_FOUND)
# Try to find non-multithreaded if -mt not found, this flag
# doesn't matter for us, it has nothing to do with thread
# safety, but keep it to not disturb build setups.
set(Boost_USE_MULTITHREADED OFF)
find_package(Boost 1.48 COMPONENTS ${__boost_packages})
endif()
unset(__boost_packages)
set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
set(__boost_packages filesystem regex system thread date_time)
if(WITH_CYCLES_OSL)
list(APPEND __boost_packages wave)
endif()
find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED)
if(NOT Boost_FOUND)
# Try to find non-multithreaded if -mt not found, this flag
# doesn't matter for us, it has nothing to do with thread
# safety, but keep it to not disturb build setups.
set(Boost_USE_MULTITHREADED OFF)
find_package(Boost 1.48 COMPONENTS ${__boost_packages})
endif()
unset(__boost_packages)
set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
endif()
@@ -373,30 +297,47 @@ endif()
# Embree
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_EMBREE)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(EMBREE_INCLUDE_DIRS ${EMBREE_ROOT_DIR}/include)
set(EMBREE_LIBRARIES
optimized ${EMBREE_ROOT_DIR}/lib/embree3.lib
optimized ${EMBREE_ROOT_DIR}/lib/embree_avx2.lib
optimized ${EMBREE_ROOT_DIR}/lib/embree_avx.lib
optimized ${EMBREE_ROOT_DIR}/lib/embree_sse42.lib
optimized ${EMBREE_ROOT_DIR}/lib/lexers.lib
optimized ${EMBREE_ROOT_DIR}/lib/math.lib
optimized ${EMBREE_ROOT_DIR}/lib/simd.lib
optimized ${EMBREE_ROOT_DIR}/lib/tasking.lib
optimized ${EMBREE_ROOT_DIR}/lib/sys.lib
debug ${EMBREE_ROOT_DIR}/lib/embree3_d.lib
debug ${EMBREE_ROOT_DIR}/lib/embree_avx2_d.lib
debug ${EMBREE_ROOT_DIR}/lib/embree_avx_d.lib
debug ${EMBREE_ROOT_DIR}/lib/embree_sse42_d.lib
debug ${EMBREE_ROOT_DIR}/lib/lexers_d.lib
debug ${EMBREE_ROOT_DIR}/lib/math_d.lib
debug ${EMBREE_ROOT_DIR}/lib/simd_d.lib
debug ${EMBREE_ROOT_DIR}/lib/sys_d.lib
debug ${EMBREE_ROOT_DIR}/lib/tasking_d.lib
)
else()
if(WITH_CYCLES_EMBREE)
if(CYCLES_STANDALONE_REPOSITORY)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(EMBREE_TASKING_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/tasking.lib
debug ${EMBREE_ROOT_DIR}/lib/tasking_d.lib
)
set(EMBREE_EMBREE3_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/embree3.lib
debug ${EMBREE_ROOT_DIR}/lib/embree3_d.lib
)
set(EMBREE_EMBREE_AVX_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/embree_avx.lib
debug ${EMBREE_ROOT_DIR}/lib/embree_avx_d.lib
)
set(EMBREE_EMBREE_AVX2_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/embree_avx2.lib
debug ${EMBREE_ROOT_DIR}/lib/embree_avx2_d.lib
)
set(EMBREE_EMBREE_SSE42_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/embree_sse42.lib
debug ${EMBREE_ROOT_DIR}/lib/embree_sse42_d.lib
)
set(EMBREE_LEXERS_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/lexers.lib
debug ${EMBREE_ROOT_DIR}/lib/lexers_d.lib
)
set(EMBREE_MATH_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/math.lib
debug ${EMBREE_ROOT_DIR}/lib/math_d.lib
)
set(EMBREE_SIMD_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/simd.lib
debug ${EMBREE_ROOT_DIR}/lib/simd_d.lib
)
set(EMBREE_SYS_LIBRARY
optimized ${EMBREE_ROOT_DIR}/lib/sys.lib
debug ${EMBREE_ROOT_DIR}/lib/sys_d.lib
)
endif()
find_package(Embree 3.8.0 REQUIRED)
endif()
endif()
@@ -405,45 +346,29 @@ endif()
# Logging
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_LOGGING)
find_package(Glog REQUIRED)
find_package(Gflags REQUIRED)
if(WITH_CYCLES_LOGGING)
if(CYCLES_STANDALONE_REPOSITORY)
find_package(Glog REQUIRED)
find_package(Gflags REQUIRED)
endif()
endif()
###########################################################################
# OpenSubdiv
###########################################################################
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND PXR_LIBRARY_DIR AND (WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV))
find_library(OPENSUBDIV_LIBRARY_CPU_DEBUG_PXR NAMES osdCPU_d osdCPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
find_library(OPENSUBDIV_LIBRARY_GPU_DEBUG_PXR NAMES osdGPU_d osdGPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
find_library(OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR NAMES osdCPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
find_library(OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR NAMES osdGPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
if(OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR AND OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR)
set(OPENSUBDIV_INCLUDE_DIRS ${PXR_INCLUDE_DIRS})
set(OPENSUBDIV_LIBRARIES
optimized ${OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR}
optimized ${OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR}
debug ${OPENSUBDIV_LIBRARY_CPU_DEBUG_PXR}
debug ${OPENSUBDIV_LIBRARY_GPU_DEBUG_PXR}
)
endif()
endif()
if(WITH_CYCLES_OPENSUBDIV)
if(CYCLES_STANDALONE_REPOSITORY)
find_package(OpenSubdiv REQUIRED)
set(WITH_OPENSUBDIV ON)
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENSUBDIV)
set(WITH_OPENSUBDIV ON)
if(NOT OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR OR NOT OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_ROOT_DIR}/include)
set(OPENSUBDIV_LIBRARIES
optimized ${OPENSUBDIV_ROOT_DIR}/lib/osdCPU.lib
optimized ${OPENSUBDIV_ROOT_DIR}/lib/osdGPU.lib
debug ${OPENSUBDIV_ROOT_DIR}/lib/osdCPU_d.lib
debug ${OPENSUBDIV_ROOT_DIR}/lib/osdGPU_d.lib
)
else()
find_package(OpenSubdiv REQUIRED)
endif()
endif()
endif()
@@ -452,29 +377,18 @@ endif()
# OpenVDB
###########################################################################
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND PXR_LIBRARY_DIR AND (WITH_OPENVDB OR WITH_CYCLES_OPENVDB))
find_library(OPENVDB_LIBRARY_PXR NAMES openvdb PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
if(OPENVDB_LIBRARY_PXR)
set(OPENVDB_INCLUDE_DIRS ${PXR_INCLUDE_DIRS})
set(OPENVDB_LIBRARIES ${OPENVDB_LIBRARY_PXR})
endif()
endif()
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENVDB)
set(WITH_OPENVDB ON)
set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES)
if(NOT OPENVDB_LIBRARY_PXR)
find_package(OpenVDB REQUIRED)
if(WITH_CYCLES_OPENVDB)
if(CYCLES_STANDALONE_REPOSITORY)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(BLOSC_LIBRARY
optimized ${BLOSC_ROOT_DIR}/lib/libblosc.lib
debug ${BLOSC_ROOT_DIR}/lib/libblosc_d.lib
)
else()
find_package(Blosc REQUIRED)
optimized ${BLOSC_ROOT_DIR}/lib/libblosc.lib
debug ${BLOSC_ROOT_DIR}/lib/libblosc_d.lib)
endif()
find_package(OpenVDB REQUIRED)
find_package(Blosc REQUIRED)
set(WITH_OPENVDB ON)
set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES)
endif()
endif()
@@ -482,21 +396,21 @@ endif()
# OpenImageDenoise
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENIMAGEDENOISE)
set(WITH_OPENIMAGEDENOISE ON)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENIMAGEDENOISE_INCLUDE_DIRS ${OPENIMAGEDENOISE_ROOT_DIR}/include)
set(OPENIMAGEDENOISE_LIBRARIES
optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise.lib
optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common.lib
optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl.lib
debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise_d.lib
debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common_d.lib
debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl_d.lib
)
else()
if(WITH_CYCLES_OPENIMAGEDENOISE)
if(CYCLES_STANDALONE_REPOSITORY)
find_package(OpenImageDenoise REQUIRED)
set(WITH_OPENIMAGEDENOISE ON)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENIMAGEDENOISE_LIBRARIES
optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise.lib
optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common.lib
optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl.lib
debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise_d.lib
debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common_d.lib
debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl_d.lib)
endif()
endif()
endif()
@@ -504,30 +418,15 @@ endif()
# TBB
###########################################################################
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND PXR_LIBRARY_DIR)
find_library(TBB_LIBRARY_DEBUG_PXR NAMES tbb_debug tbb PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
find_library(TBB_LIBRARY_RELEASE_PXR NAMES tbb PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH)
if(TBB_LIBRARY_RELEASE_PXR)
set(TBB_INCLUDE_DIRS ${PXR_INCLUDE_DIRS})
set(TBB_LIBRARIES
optimized ${TBB_LIBRARY_RELEASE_PXR}
debug ${TBB_LIBRARY_DEBUG_PXR}
if(CYCLES_STANDALONE_REPOSITORY)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(TBB_LIBRARY
optimized ${TBB_ROOT_DIR}/lib/tbb.lib
debug ${TBB_ROOT_DIR}/lib/debug/tbb_debug.lib
)
endif()
endif()
if(CYCLES_STANDALONE_REPOSITORY)
if(NOT TBB_LIBRARY_RELEASE_PXR)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(TBB_INCLUDE_DIRS ${TBB_ROOT_DIR}/include)
set(TBB_LIBRARIES
optimized ${TBB_ROOT_DIR}/lib/tbb.lib
debug ${TBB_ROOT_DIR}/lib/tbb_debug.lib
)
else()
find_package(TBB REQUIRED)
endif()
endif()
find_package(TBB REQUIRED)
endif()
###########################################################################
@@ -535,41 +434,16 @@ endif()
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY)
if((WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI) OR
WITH_CYCLES_HYDRA_RENDER_DELEGATE)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(GLEW_LIBRARY "${_cycles_lib_dir}/opengl/lib/glew.lib")
set(GLEW_INCLUDE_DIR "${_cycles_lib_dir}/opengl/include")
add_definitions(-DGLEW_STATIC)
else()
find_package(GLEW REQUIRED)
endif()
set(CYCLES_GLEW_LIBRARIES ${GLEW_LIBRARY})
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(GLEW_LIBRARY "${_cycles_lib_dir}/opengl/lib/glew.lib")
set(GLEW_INCLUDE_DIR "${_cycles_lib_dir}/opengl/include")
add_definitions(-DGLEW_STATIC)
endif()
find_package(GLEW REQUIRED)
else()
# Workaround for unconventional variable name use in Blender.
set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_PATH}")
set(CYCLES_GLEW_LIBRARIES bf_intern_glew_mx ${BLENDER_GLEW_LIBRARIES})
endif()
###########################################################################
# Alembic
###########################################################################
if(WITH_CYCLES_ALEMBIC)
if(CYCLES_STANDALONE_REPOSITORY)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(ALEMBIC_INCLUDE_DIRS ${_cycles_lib_dir}/alembic/include)
set(ALEMBIC_LIBRARIES
optimized ${_cycles_lib_dir}/alembic/lib/Alembic.lib
debug ${_cycles_lib_dir}/alembic/lib/Alembic_d.lib)
else()
find_package(Alembic REQUIRED)
endif()
set(WITH_ALEMBIC ON)
endif()
endif()
###########################################################################
@@ -579,25 +453,29 @@ endif()
# Detect system libraries again
if(EXISTS ${_cycles_lib_dir})
unset(CMAKE_IGNORE_PATH)
unset(_cycles_lib_dir)
endif()
###########################################################################
# OpenGL
###########################################################################
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
if(CYCLES_STANDALONE_REPOSITORY)
if(NOT DEFINED OpenGL_GL_PREFERENCE)
set(OpenGL_GL_PREFERENCE "LEGACY")
endif()
find_package(OpenGL REQUIRED)
set(CYCLES_GL_LIBRARIES ${OPENGL_gl_LIBRARY})
else()
set(CYCLES_GL_LIBRARIES ${BLENDER_GL_LIBRARIES})
if(CYCLES_STANDALONE_REPOSITORY)
if(NOT DEFINED OpenGL_GL_PREFERENCE)
set(OpenGL_GL_PREFERENCE "LEGACY")
endif()
find_package(OpenGL REQUIRED)
set(CYCLES_GL_LIBRARIES
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${GLEW_LIBRARY}
)
else()
set(CYCLES_GL_LIBRARIES
bf_intern_glew_mx
${BLENDER_GL_LIBRARIES}
${BLENDER_GLEW_LIBRARIES})
endif()
###########################################################################
@@ -607,7 +485,7 @@ endif()
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
# We can't use the version from the Blender precompiled libraries because
# it does not include the video subsystem.
find_package(SDL2 REQUIRED)
find_package(SDL2)
if(NOT SDL2_FOUND)
set(WITH_CYCLES_STANDALONE_GUI OFF)
@@ -638,6 +516,7 @@ if(WITH_CYCLES_CUDA_BINARIES OR NOT WITH_CUDA_DYNLOAD)
endif()
endif()
###########################################################################
# HIP
###########################################################################
@@ -675,15 +554,4 @@ if(WITH_CYCLES_DEVICE_METAL)
endif()
endif()
###########################################################################
# macOS
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY)
# On macOS, always use zlib from system.
if(APPLE)
set(ZLIB_ROOT /usr)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
endif()
endif()
unset(_cycles_lib_dir)

View File

@@ -73,44 +73,34 @@ macro(cycles_add_library target library_deps)
cycles_set_solution_folder(${target})
endmacro()
macro(cycles_external_libraries_append libraries)
macro(cycles_target_link_libraries target)
if(WITH_CYCLES_LOGGING)
list(APPEND ${libraries} ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES})
target_link_libraries(${target} ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES})
endif()
if(WITH_CYCLES_OSL)
list(APPEND ${libraries} ${OSL_LIBRARIES} ${CLANG_LIBRARIES} ${LLVM_LIBRARY})
target_link_libraries(${target} ${OSL_LIBRARIES} ${LLVM_LIBRARY})
endif()
if(WITH_CYCLES_EMBREE)
list(APPEND ${libraries} ${EMBREE_LIBRARIES})
target_link_libraries(${target} ${EMBREE_LIBRARIES})
endif()
if(WITH_OPENSUBDIV)
list(APPEND ${libraries} ${OPENSUBDIV_LIBRARIES})
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
if(WITH_OPENCOLORIO)
list(APPEND ${libraries} ${OPENCOLORIO_LIBRARIES})
if(APPLE)
list(APPEND ${libraries} "-framework IOKit")
endif()
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
endif()
if(WITH_OPENVDB)
list(APPEND ${libraries} ${OPENVDB_LIBRARIES} ${BLOSC_LIBRARIES})
target_link_libraries(${target} ${OPENVDB_LIBRARIES} ${BLOSC_LIBRARIES})
endif()
if(WITH_OPENIMAGEDENOISE)
list(APPEND ${libraries} ${OPENIMAGEDENOISE_LIBRARIES})
if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
list(APPEND ${libraries} "-framework Accelerate")
endif()
target_link_libraries(${target} ${OPENIMAGEDENOISE_LIBRARIES})
endif()
if(WITH_ALEMBIC)
list(APPEND ${libraries} ${ALEMBIC_LIBRARIES})
endif()
list(APPEND ${libraries}
target_link_libraries(
${target}
${OPENIMAGEIO_LIBRARIES}
${PNG_LIBRARIES}
${JPEG_LIBRARIES}
${TIFF_LIBRARY}
${WEBP_LIBRARIES}
${OPENJPEG_LIBRARIES}
${OPENEXR_LIBRARIES}
${OPENEXR_LIBRARIES} # For circular dependencies between libs.
@@ -124,26 +114,26 @@ macro(cycles_external_libraries_append libraries)
if(WITH_CYCLES_DEVICE_CUDA OR WITH_CYCLES_DEVICE_OPTIX)
if(WITH_CUDA_DYNLOAD)
list(APPEND ${libraries} extern_cuew)
target_link_libraries(${target} extern_cuew)
else()
list(APPEND ${libraries} ${CUDA_CUDA_LIBRARY})
target_link_libraries(${target} ${CUDA_CUDA_LIBRARY})
endif()
endif()
if(WITH_CYCLES_DEVICE_HIP AND WITH_HIP_DYNLOAD)
list(APPEND ${libraries} extern_hipew)
target_link_libraries(${target} extern_hipew)
endif()
if(UNIX AND NOT APPLE)
if(CYCLES_STANDALONE_REPOSITORY)
list(APPEND ${libraries} extern_libc_compat)
target_link_libraries(${target} extern_libc_compat)
else()
list(APPEND ${libraries} bf_intern_libc_compat)
target_link_libraries(${target} bf_intern_libc_compat)
endif()
endif()
if(NOT CYCLES_STANDALONE_REPOSITORY)
list(APPEND ${libraries} bf_intern_guardedalloc)
target_link_libraries(${target} bf_intern_guardedalloc)
endif()
endmacro()
@@ -153,13 +143,13 @@ macro(cycles_install_libraries target)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(
FILES
${TBB_ROOT_DIR}/bin/tbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX}
${TBB_ROOT_DIR}/lib/debug/tbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX}
${OPENVDB_ROOT_DIR}/bin/openvdb_d${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION $<TARGET_FILE_DIR:${target}>)
else()
install(
FILES
${TBB_ROOT_DIR}/bin/tbb${CMAKE_SHARED_LIBRARY_SUFFIX}
${TBB_ROOT_DIR}/lib/tbb${CMAKE_SHARED_LIBRARY_SUFFIX}
${OPENVDB_ROOT_DIR}/bin/openvdb${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION $<TARGET_FILE_DIR:${target}>)
endif()

View File

@@ -8,6 +8,7 @@ set(INC
set(INC_SYS
${GLEW_INCLUDE_DIR}
../../../extern/clew/include
)
if(WITH_CYCLES_DEVICE_OPTIX OR WITH_CYCLES_DEVICE_CUDA)
@@ -196,8 +197,7 @@ cycles_add_library(cycles_device "${LIB}" ${SRC})
source_group("cpu" FILES ${SRC_CPU})
source_group("cuda" FILES ${SRC_CUDA})
source_group("dummy" FILES ${SRC_DUMMY})
source_group("hip" FILES ${SRC_HIP})
source_group("multi" FILES ${SRC_MULTI})
source_group("metal" FILES ${SRC_METAL})
source_group("optix" FILES ${SRC_OPTIX})
source_group("common" FILES ${SRC_BASE} ${SRC_HEADERS})
source_group("common" FILES ${SRC} ${SRC_HEADERS})

View File

@@ -51,7 +51,7 @@ static inline bool hipSupportsDevice(const int hipDevId)
hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, hipDevId);
hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, hipDevId);
return (major >= 9);
return (major > 10) || (major == 10 && minor >= 1);
}
CCL_NAMESPACE_END

View File

@@ -1,151 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 Blender Foundation
#####################################################################
# Cycles Hydra render delegate
#####################################################################
set(INC
..
)
set(INC_SYS
${USD_INCLUDE_DIRS}
${GLEW_INCLUDE_DIR}
)
set(LIB
cycles_scene
cycles_session
cycles_graph
${CYCLES_GLEW_LIBRARIES}
)
cycles_external_libraries_append(LIB)
set(INC_HD_CYCLES
attribute.h
camera.h
config.h
curves.h
display_driver.h
field.h
geometry.h
geometry.inl
instancer.h
light.h
material.h
mesh.h
node_util.h
output_driver.h
pointcloud.h
render_buffer.h
render_delegate.h
render_pass.h
session.h
volume.h
)
set(SRC_HD_CYCLES
attribute.cpp
curves.cpp
camera.cpp
display_driver.cpp
field.cpp
instancer.cpp
light.cpp
material.cpp
mesh.cpp
node_util.cpp
output_driver.cpp
pointcloud.cpp
render_buffer.cpp
render_delegate.cpp
render_pass.cpp
session.cpp
volume.cpp
)
add_definitions(${GL_DEFINITIONS})
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
endif()
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
add_library(hdCyclesStatic STATIC
${SRC_HD_CYCLES}
${INC_HD_CYCLES}
)
target_compile_options(hdCyclesStatic
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/wd4003 /wd4244 /wd4506>
$<$<CXX_COMPILER_ID:GNU>:-Wno-float-conversion -Wno-double-promotion -Wno-deprecated>
)
target_compile_definitions(hdCyclesStatic
PRIVATE
GLOG_NO_ABBREVIATED_SEVERITIES=1
OSL_DEBUG=$<CONFIG:DEBUG>
TBB_USE_DEBUG=$<CONFIG:DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX=1>
)
target_link_libraries(hdCyclesStatic
PUBLIC
hd
hgi
hgiGL
PRIVATE
${LIB}
)
set(HdCyclesPluginName hdCycles)
add_library(${HdCyclesPluginName} SHARED
plugin.h
plugin.cpp
)
set_target_properties(${HdCyclesPluginName}
PROPERTIES PREFIX ""
)
target_compile_definitions(${HdCyclesPluginName}
PRIVATE
MFB_PACKAGE_NAME=${HdCyclesPluginName}
MFB_ALT_PACKAGE_NAME=${HdCyclesPluginName}
GLOG_NO_ABBREVIATED_SEVERITIES=1
OSL_DEBUG=$<CONFIG:DEBUG>
TBB_USE_DEBUG=$<CONFIG:DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX=1>
)
target_link_libraries(${HdCyclesPluginName}
hdCyclesStatic
)
if(WITH_CYCLES_BLENDER)
set(CYCLES_HYDRA_INSTALL_PATH "../")
else()
set(CYCLES_HYDRA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
# Put the root plugInfo.json one level up
delayed_install("${CMAKE_CURRENT_SOURCE_DIR}" "plugInfo.json" ${CMAKE_INSTALL_PREFIX})
endif()
delayed_install("" $<TARGET_FILE:${HdCyclesPluginName}> ${CYCLES_HYDRA_INSTALL_PATH})
set(PLUG_INFO_ROOT "..")
file(RELATIVE_PATH PLUG_INFO_LIBRARY_PATH "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}" "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}${CMAKE_SHARED_LIBRARY_SUFFIX}")
file(RELATIVE_PATH PLUG_INFO_RESOURCE_PATH "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}" "${CYCLES_INSTALL_PATH}")
configure_file(resources/plugInfo.json
${CMAKE_CURRENT_BINARY_DIR}/resources/plugInfo.json
@ONLY
)
delayed_install("${CMAKE_CURRENT_BINARY_DIR}/resources" "plugInfo.json" "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}/resources")

View File

@@ -1,71 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/attribute.h"
#include "scene/attribute.h"
#include "scene/geometry.h"
#include "scene/scene.h"
#include <pxr/base/gf/vec2f.h>
#include <pxr/base/gf/vec3f.h>
#include <pxr/base/gf/vec4f.h>
#include <pxr/base/vt/array.h>
#include <pxr/imaging/hd/tokens.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
void ApplyPrimvars(AttributeSet &attributes,
const ustring &name,
VtValue value,
AttributeElement elem,
AttributeStandard std)
{
const void *data = HdGetValueData(value);
size_t size = value.GetArraySize();
const HdType valueType = HdGetValueTupleType(value).type;
TypeDesc attrType = CCL_NS::TypeUnknown;
switch (valueType) {
case HdTypeFloat:
attrType = CCL_NS::TypeFloat;
size *= sizeof(float);
break;
case HdTypeFloatVec2:
attrType = CCL_NS::TypeFloat2;
size *= sizeof(float2);
static_assert(sizeof(GfVec2f) == sizeof(float2));
break;
case HdTypeFloatVec3: {
attrType = CCL_NS::TypeVector;
size *= sizeof(float3);
// The Cycles "float3" data type is padded to "float4", so need to convert the array
const auto &valueData = value.Get<VtVec3fArray>();
VtArray<float3> valueConverted;
valueConverted.reserve(valueData.size());
for (const GfVec3f &vec : valueData) {
valueConverted.push_back(make_float3(vec[0], vec[1], vec[2]));
}
data = valueConverted.data();
value = std::move(valueConverted);
break;
}
case HdTypeFloatVec4:
attrType = CCL_NS::TypeFloat4;
size *= sizeof(float4);
static_assert(sizeof(GfVec4f) == sizeof(float4));
break;
default:
TF_WARN("Unsupported attribute type %d", static_cast<int>(valueType));
return;
}
Attribute *const attr = attributes.add(name, attrType, elem);
attr->std = std;
assert(size == attr->buffer.size());
std::memcpy(attr->data(), data, size);
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,21 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "scene/attribute.h"
#include <pxr/base/vt/value.h>
#include <pxr/imaging/hd/types.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
void ApplyPrimvars(CCL_NS::AttributeSet &attributes,
const CCL_NS::ustring &name,
PXR_NS::VtValue value,
CCL_NS::AttributeElement elem,
CCL_NS::AttributeStandard std);
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,307 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/camera.h"
#include "scene/camera.h"
#include <pxr/base/gf/frustum.h>
#include <pxr/imaging/hd/sceneDelegate.h>
#include <pxr/usd/usdGeom/tokens.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
extern Transform convert_transform(const GfMatrix4d &matrix);
#if PXR_VERSION < 2102
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(projection)
(orthographic)
);
// clang-format on
#endif
HdCyclesCamera::HdCyclesCamera(const SdfPath &sprimId) : HdCamera(sprimId)
{
#if PXR_VERSION >= 2102
// Synchronize default values
_horizontalAperture = _data.GetHorizontalAperture() * GfCamera::APERTURE_UNIT;
_verticalAperture = _data.GetVerticalAperture() * GfCamera::APERTURE_UNIT;
_horizontalApertureOffset = _data.GetHorizontalApertureOffset() * GfCamera::APERTURE_UNIT;
_verticalApertureOffset = _data.GetVerticalApertureOffset() * GfCamera::APERTURE_UNIT;
_focalLength = _data.GetFocalLength() * GfCamera::FOCAL_LENGTH_UNIT;
_clippingRange = _data.GetClippingRange();
_fStop = _data.GetFStop();
_focusDistance = _data.GetFocusDistance();
#endif
}
HdCyclesCamera::~HdCyclesCamera()
{
}
HdDirtyBits HdCyclesCamera::GetInitialDirtyBitsMask() const
{
return DirtyBits::AllDirty;
}
void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits)
{
if (*dirtyBits == DirtyBits::Clean) {
return;
}
VtValue value;
const SdfPath &id = GetId();
#if PXR_VERSION >= 2102
if (*dirtyBits & DirtyBits::DirtyTransform) {
sceneDelegate->SampleTransform(id, &_transformSamples);
for (size_t i = 0; i < _transformSamples.count; ++i) {
if (_transformSamples.times[i] == 0.0f) {
_transform = _transformSamples.values[i];
_data.SetTransform(_transform);
break;
}
}
}
#else
if (*dirtyBits & DirtyBits::DirtyViewMatrix) {
sceneDelegate->SampleTransform(id, &_transformSamples);
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->worldToViewMatrix);
if (!value.IsEmpty()) {
_worldToViewMatrix = value.Get<GfMatrix4d>();
_worldToViewInverseMatrix = _worldToViewMatrix.GetInverse();
_data.SetTransform(_worldToViewInverseMatrix);
}
}
#endif
#if PXR_VERSION < 2111
if (*dirtyBits & DirtyBits::DirtyProjMatrix) {
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->projectionMatrix);
if (!value.IsEmpty()) {
_projectionMatrix = value.Get<GfMatrix4d>();
const float focalLength = _data.GetFocalLength(); // Get default focal length
# if PXR_VERSION >= 2102
_data.SetFromViewAndProjectionMatrix(GetViewMatrix(), _projectionMatrix, focalLength);
# else
if (_projectionMatrix[2][3] < -0.5) {
_data.SetProjection(GfCamera::Perspective);
const float horizontalAperture = (2.0 * focalLength) / _projectionMatrix[0][0];
_data.SetHorizontalAperture(horizontalAperture);
_data.SetHorizontalApertureOffset(0.5 * horizontalAperture * _projectionMatrix[2][0]);
const float verticalAperture = (2.0 * focalLength) / _projectionMatrix[1][1];
_data.SetVerticalAperture(verticalAperture);
_data.SetVerticalApertureOffset(0.5 * verticalAperture * _projectionMatrix[2][1]);
_data.SetClippingRange(
GfRange1f(_projectionMatrix[3][2] / (_projectionMatrix[2][2] - 1.0),
_projectionMatrix[3][2] / (_projectionMatrix[2][2] + 1.0)));
}
else {
_data.SetProjection(GfCamera::Orthographic);
const float horizontalAperture = (2.0 / GfCamera::APERTURE_UNIT) / _projectionMatrix[0][0];
_data.SetHorizontalAperture(horizontalAperture);
_data.SetHorizontalApertureOffset(-0.5 * horizontalAperture * _projectionMatrix[3][0]);
const float verticalAperture = (2.0 / GfCamera::APERTURE_UNIT) / _projectionMatrix[1][1];
_data.SetVerticalAperture(verticalAperture);
_data.SetVerticalApertureOffset(-0.5 * verticalAperture * _projectionMatrix[3][1]);
const double nearMinusFarHalf = 1.0 / _projectionMatrix[2][2];
const double nearPlusFarHalf = nearMinusFarHalf * _projectionMatrix[3][2];
_data.SetClippingRange(
GfRange1f(nearPlusFarHalf + nearMinusFarHalf, nearPlusFarHalf - nearMinusFarHalf));
}
# endif
}
}
#endif
if (*dirtyBits & DirtyBits::DirtyWindowPolicy) {
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->windowPolicy);
if (!value.IsEmpty()) {
_windowPolicy = value.Get<CameraUtilConformWindowPolicy>();
}
}
if (*dirtyBits & DirtyBits::DirtyClipPlanes) {
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->clipPlanes);
if (!value.IsEmpty()) {
_clipPlanes = value.Get<std::vector<GfVec4d>>();
}
}
if (*dirtyBits & DirtyBits::DirtyParams) {
#if PXR_VERSION >= 2102
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->projection);
if (!value.IsEmpty()) {
_projection = value.Get<Projection>();
_data.SetProjection(_projection != Orthographic ? GfCamera::Perspective :
GfCamera::Orthographic);
}
#else
value = sceneDelegate->GetCameraParamValue(id, _tokens->projection);
if (!value.IsEmpty()) {
_data.SetProjection(value.Get<TfToken>() != _tokens->orthographic ? GfCamera::Perspective :
GfCamera::Orthographic);
}
#endif
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->horizontalAperture);
if (!value.IsEmpty()) {
const auto horizontalAperture = value.Get<float>();
#if PXR_VERSION >= 2102
_horizontalAperture = horizontalAperture;
#endif
_data.SetHorizontalAperture(horizontalAperture / GfCamera::APERTURE_UNIT);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->verticalAperture);
if (!value.IsEmpty()) {
const auto verticalAperture = value.Get<float>();
#if PXR_VERSION >= 2102
_verticalAperture = verticalAperture;
#endif
_data.SetVerticalAperture(verticalAperture / GfCamera::APERTURE_UNIT);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->horizontalApertureOffset);
if (!value.IsEmpty()) {
const auto horizontalApertureOffset = value.Get<float>();
#if PXR_VERSION >= 2102
_horizontalApertureOffset = horizontalApertureOffset;
#endif
_data.SetHorizontalApertureOffset(horizontalApertureOffset / GfCamera::APERTURE_UNIT);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->verticalApertureOffset);
if (!value.IsEmpty()) {
const auto verticalApertureOffset = value.Get<float>();
#if PXR_VERSION >= 2102
_verticalApertureOffset = verticalApertureOffset;
#endif
_data.SetVerticalApertureOffset(verticalApertureOffset / GfCamera::APERTURE_UNIT);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->focalLength);
if (!value.IsEmpty()) {
const auto focalLength = value.Get<float>();
#if PXR_VERSION >= 2102
_focalLength = focalLength;
#endif
_data.SetFocalLength(focalLength / GfCamera::FOCAL_LENGTH_UNIT);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->clippingRange);
if (!value.IsEmpty()) {
const auto clippingRange = value.Get<GfRange1f>();
#if PXR_VERSION >= 2102
_clippingRange = clippingRange;
#endif
_data.SetClippingRange(clippingRange);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->fStop);
if (!value.IsEmpty()) {
const auto fStop = value.Get<float>();
#if PXR_VERSION >= 2102
_fStop = fStop;
#endif
_data.SetFStop(fStop);
}
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->focusDistance);
if (!value.IsEmpty()) {
const auto focusDistance = value.Get<float>();
#if PXR_VERSION >= 2102
_focusDistance = focusDistance;
#endif
_data.SetFocusDistance(focusDistance);
}
}
*dirtyBits = DirtyBits::Clean;
}
void HdCyclesCamera::Finalize(HdRenderParam *renderParam)
{
HdCamera::Finalize(renderParam);
}
void HdCyclesCamera::ApplyCameraSettings(Camera *cam) const
{
ApplyCameraSettings(_data, _windowPolicy, cam);
array<Transform> motion(_transformSamples.count);
for (size_t i = 0; i < _transformSamples.count; ++i)
motion[i] = convert_transform(_transformSamples.values[i]) *
transform_scale(1.0f, 1.0f, -1.0f);
cam->set_motion(motion);
}
void HdCyclesCamera::ApplyCameraSettings(const GfCamera &dataUnconformedWindow,
CameraUtilConformWindowPolicy windowPolicy,
Camera *cam)
{
const float width = cam->get_full_width();
const float height = cam->get_full_height();
auto data = dataUnconformedWindow;
CameraUtilConformWindow(&data, windowPolicy, width / height);
static_assert(GfCamera::Perspective == CAMERA_PERSPECTIVE &&
GfCamera::Orthographic == CAMERA_ORTHOGRAPHIC);
cam->set_camera_type(static_cast<CameraType>(data.GetProjection()));
auto viewplane = data.GetFrustum().GetWindow();
auto focalLength = 1.0f;
if (data.GetProjection() == GfCamera::Perspective) {
viewplane *= 2.0 / viewplane.GetSize()[1]; // Normalize viewplane
focalLength = data.GetFocalLength() * 1e-3f;
cam->set_fov(GfDegreesToRadians(data.GetFieldOfView(GfCamera::FOVVertical)));
}
cam->set_sensorwidth(data.GetHorizontalAperture() * GfCamera::APERTURE_UNIT);
cam->set_sensorheight(data.GetVerticalAperture() * GfCamera::APERTURE_UNIT);
cam->set_nearclip(data.GetClippingRange().GetMin());
cam->set_farclip(data.GetClippingRange().GetMax());
cam->set_viewplane_left(viewplane.GetMin()[0]);
cam->set_viewplane_right(viewplane.GetMax()[0]);
cam->set_viewplane_bottom(viewplane.GetMin()[1]);
cam->set_viewplane_top(viewplane.GetMax()[1]);
if (data.GetFStop() != 0.0f) {
cam->set_focaldistance(data.GetFocusDistance());
cam->set_aperturesize(focalLength / (2.0f * data.GetFStop()));
}
cam->set_matrix(convert_transform(data.GetTransform()) * transform_scale(1.0f, 1.0f, -1.0f));
}
void HdCyclesCamera::ApplyCameraSettings(const GfMatrix4d &worldToViewMatrix,
const GfMatrix4d &projectionMatrix,
const std::vector<GfVec4d> &clipPlanes,
Camera *cam)
{
#if PXR_VERSION >= 2102
GfCamera data;
data.SetFromViewAndProjectionMatrix(worldToViewMatrix, projectionMatrix);
ApplyCameraSettings(data, CameraUtilFit, cam);
#else
TF_CODING_ERROR("Not implemented");
#endif
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,43 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/base/gf/camera.h>
#include <pxr/imaging/hd/camera.h>
#include <pxr/imaging/hd/timeSampleArray.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesCamera final : public PXR_NS::HdCamera {
public:
HdCyclesCamera(const PXR_NS::SdfPath &sprimId);
~HdCyclesCamera() override;
void ApplyCameraSettings(CCL_NS::Camera *targetCamera) const;
static void ApplyCameraSettings(const PXR_NS::GfCamera &cameraData,
PXR_NS::CameraUtilConformWindowPolicy windowPolicy,
CCL_NS::Camera *targetCamera);
static void ApplyCameraSettings(const PXR_NS::GfMatrix4d &worldToViewMatrix,
const PXR_NS::GfMatrix4d &projectionMatrix,
const std::vector<PXR_NS::GfVec4d> &clipPlanes,
CCL_NS::Camera *targetCamera);
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits) override;
void Finalize(PXR_NS::HdRenderParam *renderParam) override;
private:
PXR_NS::GfCamera _data;
PXR_NS::HdTimeSampleArray<PXR_NS::GfMatrix4d, 2> _transformSamples;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,45 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include <pxr/pxr.h>
#define CCL_NS ccl
#define CCL_NAMESPACE_USING_DIRECTIVE using namespace CCL_NS;
#define HD_CYCLES_NS HdCycles
#define HDCYCLES_NAMESPACE_OPEN_SCOPE \
namespace HD_CYCLES_NS { \
CCL_NAMESPACE_USING_DIRECTIVE; \
PXR_NAMESPACE_USING_DIRECTIVE;
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE }
namespace HD_CYCLES_NS {
class HdCyclesCamera;
class HdCyclesDelegate;
class HdCyclesSession;
class HdCyclesRenderBuffer;
} // namespace HD_CYCLES_NS
namespace CCL_NS {
class AttributeSet;
class BufferParams;
class Camera;
class Geometry;
class Hair;
class Light;
class Mesh;
class Object;
class ParticleSystem;
class Pass;
class PointCloud;
class Scene;
class Session;
class SessionParams;
class Shader;
class ShaderGraph;
class ShaderNode;
class Volume;
} // namespace CCL_NS

View File

@@ -1,210 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/curves.h"
#include "hydra/geometry.inl"
#include "scene/hair.h"
#include <pxr/imaging/hd/extComputationUtils.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesCurves::HdCyclesCurves(const SdfPath &rprimId
#if PXR_VERSION < 2102
,
const SdfPath &instancerId
#endif
)
: HdCyclesGeometry(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
)
{
}
HdCyclesCurves::~HdCyclesCurves()
{
}
HdDirtyBits HdCyclesCurves::GetInitialDirtyBitsMask() const
{
HdDirtyBits bits = HdCyclesGeometry::GetInitialDirtyBitsMask();
bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths |
HdChangeTracker::DirtyPrimvar | HdChangeTracker::DirtyTopology;
return bits;
}
HdDirtyBits HdCyclesCurves::_PropagateDirtyBits(HdDirtyBits bits) const
{
if (bits & (HdChangeTracker::DirtyTopology)) {
// Changing topology clears the geometry, so need to populate everything again
bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths |
HdChangeTracker::DirtyPrimvar;
}
return bits;
}
void HdCyclesCurves::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits, bool &rebuild)
{
if (HdChangeTracker::IsTopologyDirty(dirtyBits, GetId())) {
PopulateTopology(sceneDelegate);
}
if (dirtyBits & HdChangeTracker::DirtyPoints) {
PopulatePoints(sceneDelegate);
}
if (dirtyBits & HdChangeTracker::DirtyWidths) {
PopulateWidths(sceneDelegate);
}
if (dirtyBits & HdChangeTracker::DirtyPrimvar) {
PopulatePrimvars(sceneDelegate);
}
rebuild = (_geom->curve_keys_is_modified()) || (_geom->curve_radius_is_modified());
}
void HdCyclesCurves::PopulatePoints(HdSceneDelegate *sceneDelegate)
{
VtValue value;
for (const HdExtComputationPrimvarDescriptor &desc :
sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) {
if (desc.name == HdTokens->points) {
auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate);
const auto valueStoreIt = valueStore.find(desc.name);
if (valueStoreIt != valueStore.end()) {
value = std::move(valueStoreIt->second);
}
break;
}
}
if (value.IsEmpty()) {
value = GetPrimvar(sceneDelegate, HdTokens->points);
}
if (!value.IsHolding<VtVec3fArray>()) {
TF_WARN("Invalid points data for %s", GetId().GetText());
return;
}
const auto &points = value.UncheckedGet<VtVec3fArray>();
array<float3> pointsDataCycles;
pointsDataCycles.reserve(points.size());
for (const GfVec3f &point : points) {
pointsDataCycles.push_back_reserved(make_float3(point[0], point[1], point[2]));
}
_geom->set_curve_keys(pointsDataCycles);
}
void HdCyclesCurves::PopulateWidths(HdSceneDelegate *sceneDelegate)
{
VtValue value = GetPrimvar(sceneDelegate, HdTokens->widths);
const HdInterpolation interpolation = GetPrimvarInterpolation(sceneDelegate, HdTokens->widths);
if (!value.IsHolding<VtFloatArray>()) {
TF_WARN("Invalid widths data for %s", GetId().GetText());
return;
}
const auto &widths = value.UncheckedGet<VtFloatArray>();
array<float> radiusDataCycles;
radiusDataCycles.reserve(widths.size());
if (interpolation == HdInterpolationConstant) {
TF_VERIFY(widths.size() == 1);
const float constantRadius = widths[0] * 0.5f;
for (size_t i = 0; i < _geom->num_keys(); ++i) {
radiusDataCycles.push_back_reserved(constantRadius);
}
}
else if (interpolation == HdInterpolationVertex) {
TF_VERIFY(widths.size() == _geom->num_keys());
for (size_t i = 0; i < _geom->num_keys(); ++i) {
radiusDataCycles.push_back_reserved(widths[i] * 0.5f);
}
}
_geom->set_curve_radius(radiusDataCycles);
}
void HdCyclesCurves::PopulatePrimvars(HdSceneDelegate *sceneDelegate)
{
Scene *const scene = (Scene *)_geom->get_owner();
const std::pair<HdInterpolation, AttributeElement> interpolations[] = {
std::make_pair(HdInterpolationVertex, ATTR_ELEMENT_CURVE_KEY),
std::make_pair(HdInterpolationVarying, ATTR_ELEMENT_CURVE_KEY),
std::make_pair(HdInterpolationUniform, ATTR_ELEMENT_CURVE),
std::make_pair(HdInterpolationConstant, ATTR_ELEMENT_OBJECT),
};
for (const auto &interpolation : interpolations) {
for (const HdPrimvarDescriptor &desc :
GetPrimvarDescriptors(sceneDelegate, interpolation.first)) {
// Skip special primvars that are handled separately
if (desc.name == HdTokens->points || desc.name == HdTokens->widths) {
continue;
}
VtValue value = GetPrimvar(sceneDelegate, desc.name);
if (value.IsEmpty()) {
continue;
}
const ustring name(desc.name.GetString());
AttributeStandard std = ATTR_STD_NONE;
if (desc.role == HdPrimvarRoleTokens->textureCoordinate) {
std = ATTR_STD_UV;
}
else if (desc.name == HdTokens->displayColor &&
interpolation.first == HdInterpolationConstant) {
if (value.IsHolding<VtVec3fArray>() && value.GetArraySize() == 1) {
const GfVec3f color = value.UncheckedGet<VtVec3fArray>()[0];
_instances[0]->set_color(make_float3(color[0], color[1], color[2]));
}
}
// Skip attributes that are not needed
if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) ||
_geom->need_attribute(scene, name)) {
ApplyPrimvars(_geom->attributes, name, value, interpolation.second, std);
}
}
}
}
void HdCyclesCurves::PopulateTopology(HdSceneDelegate *sceneDelegate)
{
// Clear geometry before populating it again with updated topology
_geom->clear(true);
HdBasisCurvesTopology topology = GetBasisCurvesTopology(sceneDelegate);
_geom->reserve_curves(topology.GetNumCurves(), topology.CalculateNeededNumberOfControlPoints());
const VtIntArray vertCounts = topology.GetCurveVertexCounts();
for (int curve = 0, key = 0; curve < topology.GetNumCurves(); ++curve) {
// Always reference shader at index zero, which is the primitive material
_geom->add_curve(key, 0);
key += vertCounts[curve];
}
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,42 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "hydra/geometry.h"
#include <pxr/imaging/hd/basisCurves.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesCurves final : public HdCyclesGeometry<PXR_NS::HdBasisCurves, CCL_NS::Hair> {
public:
HdCyclesCurves(
const PXR_NS::SdfPath &rprimId
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId = {}
#endif
);
~HdCyclesCurves() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
private:
PXR_NS::HdDirtyBits _PropagateDirtyBits(PXR_NS::HdDirtyBits bits) const override;
void Populate(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdDirtyBits dirtyBits,
bool &rebuild) override;
void PopulatePoints(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulateWidths(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulatePrimvars(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulateTopology(PXR_NS::HdSceneDelegate *sceneDelegate);
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,240 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#ifdef _WIN32
// Include first to avoid "NOGDI" definition set in Cycles headers
# include <Windows.h>
#endif
#include "hydra/display_driver.h"
#include "hydra/render_buffer.h"
#include "hydra/session.h"
#include <GL/glew.h>
#include <pxr/imaging/hgiGL/texture.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesDisplayDriver::HdCyclesDisplayDriver(HdCyclesSession *renderParam, Hgi *hgi)
: _renderParam(renderParam), _hgi(hgi)
{
#ifdef _WIN32
hdc_ = GetDC(CreateWindowA("STATIC",
"HdCycles",
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0,
0,
64,
64,
NULL,
NULL,
GetModuleHandle(NULL),
NULL));
int pixelFormat = GetPixelFormat(wglGetCurrentDC());
PIXELFORMATDESCRIPTOR pfd = {sizeof(pfd)};
DescribePixelFormat((HDC)hdc_, pixelFormat, sizeof(pfd), &pfd);
SetPixelFormat((HDC)hdc_, pixelFormat, &pfd);
TF_VERIFY(gl_context_ = wglCreateContext((HDC)hdc_));
TF_VERIFY(wglShareLists(wglGetCurrentContext(), (HGLRC)gl_context_));
#endif
glewInit();
glGenBuffers(1, &gl_pbo_id_);
}
HdCyclesDisplayDriver::~HdCyclesDisplayDriver()
{
if (texture_) {
_hgi->DestroyTexture(&texture_);
}
glDeleteBuffers(1, &gl_pbo_id_);
#ifdef _WIN32
TF_VERIFY(wglDeleteContext((HGLRC)gl_context_));
DestroyWindow(WindowFromDC((HDC)hdc_));
#endif
}
void HdCyclesDisplayDriver::next_tile_begin()
{
}
bool HdCyclesDisplayDriver::update_begin(const Params &params,
int texture_width,
int texture_height)
{
#ifdef _WIN32
if (!hdc_ || !gl_context_) {
return false;
}
#endif
graphics_interop_activate();
if (gl_render_sync_) {
glWaitSync((GLsync)gl_render_sync_, 0, GL_TIMEOUT_IGNORED);
}
if (pbo_size_.x != params.full_size.x || pbo_size_.y != params.full_size.y) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_pbo_id_);
glBufferData(GL_PIXEL_UNPACK_BUFFER,
sizeof(half4) * params.full_size.x * params.full_size.y,
0,
GL_DYNAMIC_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
pbo_size_ = params.full_size;
}
need_update_ = true;
return true;
}
void HdCyclesDisplayDriver::update_end()
{
gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
graphics_interop_deactivate();
}
void HdCyclesDisplayDriver::flush()
{
graphics_interop_activate();
if (gl_upload_sync_) {
glWaitSync((GLsync)gl_upload_sync_, 0, GL_TIMEOUT_IGNORED);
}
if (gl_render_sync_) {
glWaitSync((GLsync)gl_render_sync_, 0, GL_TIMEOUT_IGNORED);
}
graphics_interop_deactivate();
}
half4 *HdCyclesDisplayDriver::map_texture_buffer()
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_pbo_id_);
const auto mapped_rgba_pixels = static_cast<half4 *>(
glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY));
if (need_clear_ && mapped_rgba_pixels) {
memset(mapped_rgba_pixels, 0, sizeof(half4) * pbo_size_.x * pbo_size_.y);
need_clear_ = false;
}
return mapped_rgba_pixels;
}
void HdCyclesDisplayDriver::unmap_texture_buffer()
{
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
DisplayDriver::GraphicsInterop HdCyclesDisplayDriver::graphics_interop_get()
{
GraphicsInterop interop_dst;
interop_dst.buffer_width = pbo_size_.x;
interop_dst.buffer_height = pbo_size_.y;
interop_dst.opengl_pbo_id = gl_pbo_id_;
interop_dst.need_clear = need_clear_;
need_clear_ = false;
return interop_dst;
}
void HdCyclesDisplayDriver::graphics_interop_activate()
{
mutex_.lock();
#ifdef _WIN32
// Do not change context if this is called in the main thread
if (wglGetCurrentContext() == nullptr) {
TF_VERIFY(wglMakeCurrent((HDC)hdc_, (HGLRC)gl_context_));
}
#endif
}
void HdCyclesDisplayDriver::graphics_interop_deactivate()
{
#ifdef _WIN32
if (wglGetCurrentContext() == gl_context_) {
TF_VERIFY(wglMakeCurrent(nullptr, nullptr));
}
#endif
mutex_.unlock();
}
void HdCyclesDisplayDriver::clear()
{
need_clear_ = true;
}
void HdCyclesDisplayDriver::draw(const Params &params)
{
const auto renderBuffer = static_cast<HdCyclesRenderBuffer *>(
_renderParam->GetDisplayAovBinding().renderBuffer);
if (!renderBuffer || // Ensure this render buffer matches the texture dimensions
(renderBuffer->GetWidth() != params.size.x || renderBuffer->GetHeight() != params.size.y)) {
return;
}
// Cycles 'DisplayDriver' only supports 'half4' format
TF_VERIFY(renderBuffer->GetFormat() == HdFormatFloat16Vec4);
const thread_scoped_lock lock(mutex_);
const GfVec3i dimensions(params.size.x, params.size.y, 1);
if (!texture_ || texture_->GetDescriptor().dimensions != dimensions) {
if (texture_) {
_hgi->DestroyTexture(&texture_);
}
HgiTextureDesc texDesc;
texDesc.usage = 0;
texDesc.format = HgiFormatFloat16Vec4;
texDesc.type = HgiTextureType2D;
texDesc.dimensions = dimensions;
texDesc.sampleCount = HgiSampleCount1;
texture_ = _hgi->CreateTexture(texDesc);
renderBuffer->SetResource(VtValue(texture_));
}
HgiGLTexture *const texture = dynamic_cast<HgiGLTexture *>(texture_.Get());
if (!texture || !need_update_ || pbo_size_.x != params.size.x || pbo_size_.y != params.size.y) {
return;
}
if (gl_upload_sync_) {
glWaitSync((GLsync)gl_upload_sync_, 0, GL_TIMEOUT_IGNORED);
}
glBindTexture(GL_TEXTURE_2D, texture->GetTextureId());
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_pbo_id_);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pbo_size_.x, pbo_size_.y, GL_RGBA, GL_HALF_FLOAT, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
gl_render_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
need_update_ = false;
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,61 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "session/display_driver.h"
#include "util/thread.h"
#include <pxr/imaging/hgi/hgi.h>
#include <pxr/imaging/hgi/texture.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesDisplayDriver final : public CCL_NS::DisplayDriver {
public:
HdCyclesDisplayDriver(HdCyclesSession *renderParam, Hgi *hgi);
~HdCyclesDisplayDriver();
private:
void next_tile_begin() override;
bool update_begin(const Params &params, int texture_width, int texture_height) override;
void update_end() override;
void flush() override;
CCL_NS::half4 *map_texture_buffer() override;
void unmap_texture_buffer() override;
GraphicsInterop graphics_interop_get() override;
void graphics_interop_activate() override;
void graphics_interop_deactivate() override;
void clear() override;
void draw(const Params &params) override;
HdCyclesSession *const _renderParam;
Hgi *const _hgi;
#ifdef _WIN32
void *hdc_ = nullptr;
void *gl_context_ = nullptr;
#endif
CCL_NS::thread_mutex mutex_;
PXR_NS::HgiTextureHandle texture_;
unsigned int gl_pbo_id_ = 0;
CCL_NS::int2 pbo_size_ = CCL_NS::make_int2(0, 0);
bool need_update_ = false;
std::atomic_bool need_clear_ = false;
void *gl_render_sync_ = nullptr;
void *gl_upload_sync_ = nullptr;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,90 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/field.h"
#include "hydra/session.h"
#include "scene/image_vdb.h"
#include "scene/scene.h"
#include <pxr/imaging/hd/sceneDelegate.h>
#include <pxr/usd/sdf/assetPath.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
#if PXR_VERSION < 2108
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(fieldName)
);
// clang-format on
#endif
#ifdef WITH_OPENVDB
class HdCyclesVolumeLoader : public VDBImageLoader {
public:
HdCyclesVolumeLoader(const std::string &filePath, const std::string &gridName)
: VDBImageLoader(gridName)
{
openvdb::io::File file(filePath);
file.setCopyMaxBytes(0);
if (file.open()) {
grid = file.readGrid(gridName);
}
}
};
#endif
HdCyclesField::HdCyclesField(const SdfPath &bprimId, const TfToken &typeId) : HdField(bprimId)
{
}
HdCyclesField::~HdCyclesField()
{
}
HdDirtyBits HdCyclesField::GetInitialDirtyBitsMask() const
{
return DirtyBits::DirtyParams;
}
void HdCyclesField::Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits)
{
#ifdef WITH_OPENVDB
VtValue value;
const SdfPath &id = GetId();
if (*dirtyBits & DirtyBits::DirtyParams) {
value = sceneDelegate->Get(id, HdFieldTokens->filePath);
if (value.IsHolding<SdfAssetPath>()) {
std::string filename = value.UncheckedGet<SdfAssetPath>().GetResolvedPath();
if (filename.empty()) {
filename = value.UncheckedGet<SdfAssetPath>().GetAssetPath();
}
# if PXR_VERSION >= 2108
value = sceneDelegate->Get(id, HdFieldTokens->fieldName);
# else
value = sceneDelegate->Get(id, _tokens->fieldName);
# endif
if (value.IsHolding<TfToken>()) {
ImageLoader *const loader = new HdCyclesVolumeLoader(
filename, value.UncheckedGet<TfToken>().GetString());
const SceneLock lock(renderParam);
ImageParams params;
params.frame = 0.0f;
_handle = lock.scene->image_manager->add_image(loader, params, false);
}
}
}
#endif
*dirtyBits = DirtyBits::Clean;
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,34 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "scene/image.h"
#include <pxr/imaging/hd/field.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesField final : public PXR_NS::HdField {
public:
HdCyclesField(const PXR_NS::SdfPath &bprimId, const PXR_NS::TfToken &typeId);
~HdCyclesField() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits) override;
CCL_NS::ImageHandle GetImageHandle() const
{
return _handle;
}
private:
CCL_NS::ImageHandle _handle;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,54 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/rprim.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
template<typename Base, typename CyclesBase> class HdCyclesGeometry : public Base {
public:
HdCyclesGeometry(const PXR_NS::SdfPath &rprimId
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId
#endif
);
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits,
const PXR_NS::TfToken &reprToken) override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
virtual void Finalize(PXR_NS::HdRenderParam *renderParam) override;
protected:
void _InitRepr(const PXR_NS::TfToken &reprToken, PXR_NS::HdDirtyBits *dirtyBits) override;
PXR_NS::HdDirtyBits _PropagateDirtyBits(PXR_NS::HdDirtyBits bits) const override;
virtual void Populate(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdDirtyBits dirtyBits,
bool &rebuild) = 0;
PXR_NS::HdInterpolation GetPrimvarInterpolation(PXR_NS::HdSceneDelegate *sceneDelegate,
const PXR_NS::TfToken &name) const;
CyclesBase *_geom = nullptr;
std::vector<CCL_NS::Object *> _instances;
private:
void Initialize(PXR_NS::HdRenderParam *renderParam);
void InitializeInstance(int index);
PXR_NS::GfMatrix4d _geomTransform;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,247 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/attribute.h"
#include "hydra/geometry.h"
#include "hydra/instancer.h"
#include "hydra/material.h"
#include "hydra/session.h"
#include "scene/geometry.h"
#include "scene/object.h"
#include "scene/scene.h"
#include "util/hash.h"
#include <pxr/imaging/hd/sceneDelegate.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
extern Transform convert_transform(const GfMatrix4d &matrix);
template<typename Base, typename CyclesBase>
HdCyclesGeometry<Base, CyclesBase>::HdCyclesGeometry(const SdfPath &rprimId
#if PXR_VERSION < 2102
,
const SdfPath &instancerId
#endif
)
: Base(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
),
_geomTransform(1.0)
{
}
template<typename Base, typename CyclesBase>
void HdCyclesGeometry<Base, CyclesBase>::_InitRepr(const TfToken &reprToken,
HdDirtyBits *dirtyBits)
{
TF_UNUSED(reprToken);
TF_UNUSED(dirtyBits);
}
template<typename Base, typename CyclesBase>
HdDirtyBits HdCyclesGeometry<Base, CyclesBase>::GetInitialDirtyBitsMask() const
{
return HdChangeTracker::DirtyPrimID | HdChangeTracker::DirtyTransform |
HdChangeTracker::DirtyMaterialId | HdChangeTracker::DirtyVisibility |
HdChangeTracker::DirtyInstancer;
}
template<typename Base, typename CyclesBase>
HdDirtyBits HdCyclesGeometry<Base, CyclesBase>::_PropagateDirtyBits(HdDirtyBits bits) const
{
return bits;
}
template<typename Base, typename CyclesBase>
void HdCyclesGeometry<Base, CyclesBase>::Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits,
const TfToken &reprToken)
{
TF_UNUSED(reprToken);
if (*dirtyBits == HdChangeTracker::Clean) {
return;
}
Initialize(renderParam);
#if PXR_VERSION >= 2102
Base::_UpdateInstancer(sceneDelegate, dirtyBits);
HdInstancer::_SyncInstancerAndParents(sceneDelegate->GetRenderIndex(), Base::GetInstancerId());
#endif
Base::_UpdateVisibility(sceneDelegate, dirtyBits);
const SceneLock lock(renderParam);
if (*dirtyBits & HdChangeTracker::DirtyMaterialId) {
#if HD_API_VERSION >= 37 && PXR_VERSION >= 2105
Base::SetMaterialId(sceneDelegate->GetMaterialId(Base::GetId()));
#else
Base::_SetMaterialId(sceneDelegate->GetRenderIndex().GetChangeTracker(),
sceneDelegate->GetMaterialId(Base::GetId()));
#endif
const auto material = static_cast<const HdCyclesMaterial *>(
sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material,
Base::GetMaterialId()));
array<Node *> usedShaders(1);
if (material && material->GetCyclesShader()) {
usedShaders[0] = material->GetCyclesShader();
}
else {
usedShaders[0] = lock.scene->default_surface;
}
for (Node *shader : usedShaders) {
static_cast<Shader *>(shader)->tag_used(lock.scene);
}
_geom->set_used_shaders(usedShaders);
}
const SdfPath &id = Base::GetId();
if (HdChangeTracker::IsPrimIdDirty(*dirtyBits, id)) {
// This needs to be corrected in the AOV
_instances[0]->set_pass_id(Base::GetPrimId() + 1);
}
if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) {
_geomTransform = sceneDelegate->GetTransform(id);
}
if (HdChangeTracker::IsTransformDirty(*dirtyBits, id) ||
HdChangeTracker::IsInstancerDirty(*dirtyBits, id)) {
const auto instancer = static_cast<HdCyclesInstancer *>(
sceneDelegate->GetRenderIndex().GetInstancer(Base::GetInstancerId()));
// Make sure the first object attribute is the instanceId
assert(_instances[0]->attributes.size() >= 1 &&
_instances[0]->attributes.front().name() == HdAovTokens->instanceId.GetString());
VtMatrix4dArray transforms;
if (instancer) {
transforms = instancer->ComputeInstanceTransforms(id);
_instances[0]->attributes.front() = ParamValue(HdAovTokens->instanceId.GetString(), +0.0f);
}
else {
// Default to a single instance with an identity transform
transforms.push_back(GfMatrix4d(1.0));
_instances[0]->attributes.front() = ParamValue(HdAovTokens->instanceId.GetString(), -1.0f);
}
const size_t oldSize = _instances.size();
const size_t newSize = transforms.size();
// Resize instance list
for (size_t i = newSize; i < oldSize; ++i) {
lock.scene->delete_node(_instances[i]);
}
_instances.resize(newSize);
for (size_t i = oldSize; i < newSize; ++i) {
_instances[i] = lock.scene->create_node<Object>();
InitializeInstance(static_cast<int>(i));
}
// Update transforms of all instances
for (size_t i = 0; i < transforms.size(); ++i) {
const Transform tfm = convert_transform(_geomTransform * transforms[i]);
_instances[i]->set_tfm(tfm);
}
}
if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) {
for (Object *instance : _instances) {
instance->set_visibility(Base::IsVisible() ? ~0 : 0);
}
}
// Must happen after material ID update, so that attribute decisions can be made
// based on it (e.g. check whether an attribute is actually needed)
bool rebuild = false;
Populate(sceneDelegate, *dirtyBits, rebuild);
if (_geom->is_modified() || rebuild) {
_geom->tag_update(lock.scene, rebuild);
}
for (Object *instance : _instances) {
instance->tag_update(lock.scene);
}
*dirtyBits = HdChangeTracker::Clean;
}
template<typename Base, typename CyclesBase>
void HdCyclesGeometry<Base, CyclesBase>::Finalize(HdRenderParam *renderParam)
{
if (!_geom && _instances.empty()) {
return;
}
const SceneLock lock(renderParam);
lock.scene->delete_node(_geom);
_geom = nullptr;
lock.scene->delete_nodes(set<Object *>(_instances.begin(), _instances.end()));
_instances.clear();
_instances.shrink_to_fit();
}
template<typename Base, typename CyclesBase>
void HdCyclesGeometry<Base, CyclesBase>::Initialize(HdRenderParam *renderParam)
{
if (_geom) {
return;
}
const SceneLock lock(renderParam);
// Create geometry
_geom = lock.scene->create_node<CyclesBase>();
_geom->name = Base::GetId().GetString();
// Create default instance
_instances.push_back(lock.scene->create_node<Object>());
InitializeInstance(0);
}
template<typename Base, typename CyclesBase>
void HdCyclesGeometry<Base, CyclesBase>::InitializeInstance(int index)
{
Object *instance = _instances[index];
instance->set_geometry(_geom);
instance->attributes.emplace_back(HdAovTokens->instanceId.GetString(),
_instances.size() == 1 ? -1.0f : static_cast<float>(index));
instance->set_color(make_float3(0.8f, 0.8f, 0.8f));
instance->set_random_id(hash_uint2(hash_string(_geom->name.c_str()), index));
}
template<typename Base, typename CyclesBase>
HdInterpolation HdCyclesGeometry<Base, CyclesBase>::GetPrimvarInterpolation(
HdSceneDelegate *sceneDelegate, const TfToken &name) const
{
for (int i = 0; i < HdInterpolationCount; ++i) {
for (const HdPrimvarDescriptor &desc :
Base::GetPrimvarDescriptors(sceneDelegate, static_cast<HdInterpolation>(i))) {
if (desc.name == name) {
return static_cast<HdInterpolation>(i);
}
}
}
return HdInterpolationCount;
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,138 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/instancer.h"
#include <pxr/base/gf/quatd.h>
#include <pxr/imaging/hd/sceneDelegate.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesInstancer::HdCyclesInstancer(HdSceneDelegate *delegate,
const SdfPath &instancerId
#if PXR_VERSION <= 2011
,
const SdfPath &parentId
#endif
)
: HdInstancer(delegate,
instancerId
#if PXR_VERSION <= 2011
,
parentId
#endif
)
{
}
HdCyclesInstancer::~HdCyclesInstancer()
{
}
#if PXR_VERSION > 2011
void HdCyclesInstancer::Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits)
{
_UpdateInstancer(sceneDelegate, dirtyBits);
if (HdChangeTracker::IsAnyPrimvarDirty(*dirtyBits, GetId())) {
SyncPrimvars();
}
}
#endif
void HdCyclesInstancer::SyncPrimvars()
{
HdSceneDelegate *const sceneDelegate = GetDelegate();
const HdDirtyBits dirtyBits =
sceneDelegate->GetRenderIndex().GetChangeTracker().GetInstancerDirtyBits(GetId());
for (const HdPrimvarDescriptor &desc :
sceneDelegate->GetPrimvarDescriptors(GetId(), HdInterpolationInstance)) {
if (!HdChangeTracker::IsPrimvarDirty(dirtyBits, GetId(), desc.name)) {
continue;
}
const VtValue value = sceneDelegate->Get(GetId(), desc.name);
if (value.IsEmpty()) {
continue;
}
if (desc.name == HdInstancerTokens->translate) {
_translate = value.Get<VtVec3fArray>();
}
else if (desc.name == HdInstancerTokens->rotate) {
_rotate = value.Get<VtVec4fArray>();
}
else if (desc.name == HdInstancerTokens->scale) {
_scale = value.Get<VtVec3fArray>();
}
else if (desc.name == HdInstancerTokens->instanceTransform) {
_instanceTransform = value.Get<VtMatrix4dArray>();
}
}
sceneDelegate->GetRenderIndex().GetChangeTracker().MarkInstancerClean(GetId());
}
VtMatrix4dArray HdCyclesInstancer::ComputeInstanceTransforms(const SdfPath &prototypeId)
{
#if PXR_VERSION <= 2011
SyncPrimvars();
#endif
const VtIntArray instanceIndices = GetDelegate()->GetInstanceIndices(GetId(), prototypeId);
const GfMatrix4d instanceTransform = GetDelegate()->GetInstancerTransform(GetId());
VtMatrix4dArray transforms;
transforms.reserve(instanceIndices.size());
for (int index : instanceIndices) {
GfMatrix4d transform = instanceTransform;
if (index < _translate.size()) {
GfMatrix4d translateMat(1);
translateMat.SetTranslate(_translate[index]);
transform *= translateMat;
}
if (index < _rotate.size()) {
GfMatrix4d rotateMat(1);
const GfVec4f &quat = _rotate[index];
rotateMat.SetRotate(GfQuatd(quat[0], quat[1], quat[2], quat[3]));
transform *= rotateMat;
}
if (index < _scale.size()) {
GfMatrix4d scaleMat(1);
scaleMat.SetScale(_scale[index]);
transform *= scaleMat;
}
if (index < _instanceTransform.size()) {
transform *= _instanceTransform[index];
}
transforms.push_back(transform);
}
VtMatrix4dArray resultTransforms;
if (const auto instancer = static_cast<HdCyclesInstancer *>(
GetDelegate()->GetRenderIndex().GetInstancer(GetParentId()))) {
for (const GfMatrix4d &parentTransform : instancer->ComputeInstanceTransforms(GetId())) {
for (const GfMatrix4d &localTransform : transforms) {
resultTransforms.push_back(parentTransform * localTransform);
}
}
}
else {
resultTransforms = std::move(transforms);
}
return resultTransforms;
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,45 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/base/gf/matrix4d.h>
#include <pxr/base/gf/vec3f.h>
#include <pxr/base/gf/vec4f.h>
#include <pxr/base/vt/array.h>
#include <pxr/imaging/hd/instancer.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesInstancer final : public PXR_NS::HdInstancer {
public:
HdCyclesInstancer(PXR_NS::HdSceneDelegate *delegate,
const PXR_NS::SdfPath &instancerId
#if PXR_VERSION <= 2011
,
const PXR_NS::SdfPath &parentId
#endif
);
~HdCyclesInstancer() override;
#if PXR_VERSION > 2011
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits) override;
#endif
PXR_NS::VtMatrix4dArray ComputeInstanceTransforms(const PXR_NS::SdfPath &prototypeId);
private:
void SyncPrimvars();
PXR_NS::VtVec3fArray _translate;
PXR_NS::VtVec4fArray _rotate;
PXR_NS::VtVec3fArray _scale;
PXR_NS::VtMatrix4dArray _instanceTransform;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,399 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/light.h"
#include "hydra/session.h"
#include "scene/light.h"
#include "scene/scene.h"
#include "scene/shader.h"
#include "scene/shader_graph.h"
#include "scene/shader_nodes.h"
#include "util/hash.h"
#include <pxr/imaging/hd/sceneDelegate.h>
#include <pxr/usd/sdf/assetPath.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
extern Transform convert_transform(const GfMatrix4d &matrix);
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(visibleInPrimaryRay)
);
// clang-format on
HdCyclesLight::HdCyclesLight(const SdfPath &sprimId, const TfToken &lightType)
: HdLight(sprimId), _lightType(lightType)
{
}
HdCyclesLight::~HdCyclesLight()
{
}
HdDirtyBits HdCyclesLight::GetInitialDirtyBitsMask() const
{
return DirtyBits::DirtyTransform | DirtyBits::DirtyParams;
}
void HdCyclesLight::Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits)
{
if (*dirtyBits == DirtyBits::Clean) {
return;
}
Initialize(renderParam);
const SceneLock lock(renderParam);
VtValue value;
const SdfPath &id = GetId();
if (*dirtyBits & DirtyBits::DirtyTransform) {
#if PXR_VERSION >= 2011
const Transform tfm = convert_transform(sceneDelegate->GetTransform(id));
#else
const Transform tfm = convert_transform(
sceneDelegate->GetLightParamValue(id, HdTokens->transform).Get<GfMatrix4d>());
#endif
_light->set_tfm(tfm);
_light->set_co(transform_get_column(&tfm, 3));
_light->set_dir(-transform_get_column(&tfm, 2));
if (_lightType == HdPrimTypeTokens->diskLight || _lightType == HdPrimTypeTokens->rectLight) {
_light->set_axisu(transform_get_column(&tfm, 0));
_light->set_axisv(transform_get_column(&tfm, 1));
}
}
if (*dirtyBits & DirtyBits::DirtyParams) {
float3 strength = make_float3(1.0f, 1.0f, 1.0f);
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->color);
if (!value.IsEmpty()) {
const auto color = value.Get<GfVec3f>();
strength = make_float3(color[0], color[1], color[2]);
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->exposure);
if (!value.IsEmpty()) {
strength *= exp2(value.Get<float>());
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->intensity);
if (!value.IsEmpty()) {
strength *= value.Get<float>();
}
// Cycles lights are normalized by default, so need to scale intensity if Hydra light is not
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->normalize);
const bool normalize = value.IsHolding<bool>() && value.UncheckedGet<bool>();
value = sceneDelegate->GetLightParamValue(id, _tokens->visibleInPrimaryRay);
if (!value.IsEmpty()) {
_light->set_use_camera(value.Get<bool>());
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->shadowEnable);
if (!value.IsEmpty()) {
_light->set_cast_shadow(value.Get<bool>());
}
if (_lightType == HdPrimTypeTokens->distantLight) {
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->angle);
if (!value.IsEmpty()) {
_light->set_angle(GfDegreesToRadians(value.Get<float>()));
}
}
else if (_lightType == HdPrimTypeTokens->diskLight) {
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->radius);
if (!value.IsEmpty()) {
const float size = value.Get<float>() * 2.0f;
_light->set_sizeu(size);
_light->set_sizev(size);
}
if (!normalize) {
const float radius = _light->get_sizeu() * 0.5f;
strength *= M_PI * radius * radius;
}
}
else if (_lightType == HdPrimTypeTokens->rectLight) {
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->width);
if (!value.IsEmpty()) {
_light->set_sizeu(value.Get<float>());
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->height);
if (!value.IsEmpty()) {
_light->set_sizev(value.Get<float>());
}
if (!normalize) {
strength *= _light->get_sizeu() * _light->get_sizeu();
}
}
else if (_lightType == HdPrimTypeTokens->sphereLight) {
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->radius);
if (!value.IsEmpty()) {
_light->set_size(value.Get<float>());
}
bool shaping = false;
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->shapingConeAngle);
if (!value.IsEmpty()) {
_light->set_spot_angle(GfDegreesToRadians(value.Get<float>()) * 2.0f);
shaping = true;
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->shapingConeSoftness);
if (!value.IsEmpty()) {
_light->set_spot_smooth(value.Get<float>());
shaping = true;
}
_light->set_light_type(shaping ? LIGHT_SPOT : LIGHT_POINT);
if (!normalize) {
const float radius = _light->get_size();
strength *= M_PI * radius * radius * 4.0f;
}
}
const bool visible = sceneDelegate->GetVisible(id);
// Disable invisible lights by zeroing the strength
// So 'LightManager::test_enabled_lights' updates the enabled flag correctly
if (!visible) {
strength = zero_float3();
}
_light->set_strength(strength);
_light->set_is_enabled(visible);
PopulateShaderGraph(sceneDelegate);
}
// Need to update shader graph when transform changes in case transform was baked into it
else if (_light->tfm_is_modified() && (_lightType == HdPrimTypeTokens->domeLight ||
_light->get_shader()->has_surface_spatial_varying)) {
PopulateShaderGraph(sceneDelegate);
}
if (_light->is_modified()) {
_light->tag_update(lock.scene);
}
*dirtyBits = DirtyBits::Clean;
}
void HdCyclesLight::PopulateShaderGraph(HdSceneDelegate *sceneDelegate)
{
auto graph = new ShaderGraph();
ShaderNode *outputNode = nullptr;
if (_lightType == HdPrimTypeTokens->domeLight) {
BackgroundNode *bgNode = graph->create_node<BackgroundNode>();
// Bake strength into shader graph, since only the shader is used for background lights
bgNode->set_color(_light->get_strength());
graph->add(bgNode);
graph->connect(bgNode->output("Background"), graph->output()->input("Surface"));
outputNode = bgNode;
}
else {
EmissionNode *emissionNode = graph->create_node<EmissionNode>();
emissionNode->set_color(one_float3());
emissionNode->set_strength(1.0f);
graph->add(emissionNode);
graph->connect(emissionNode->output("Emission"), graph->output()->input("Surface"));
outputNode = emissionNode;
}
VtValue value;
const SdfPath &id = GetId();
bool hasSpatialVarying = false;
bool hasColorTemperature = false;
if (sceneDelegate != nullptr) {
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->enableColorTemperature);
const bool enableColorTemperature = value.IsHolding<bool>() && value.UncheckedGet<bool>();
if (enableColorTemperature) {
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->colorTemperature);
if (value.IsHolding<float>()) {
BlackbodyNode *blackbodyNode = graph->create_node<BlackbodyNode>();
blackbodyNode->set_temperature(value.UncheckedGet<float>());
graph->add(blackbodyNode);
if (_lightType == HdPrimTypeTokens->domeLight) {
VectorMathNode *mathNode = graph->create_node<VectorMathNode>();
mathNode->set_math_type(NODE_VECTOR_MATH_MULTIPLY);
mathNode->set_vector2(_light->get_strength());
graph->add(mathNode);
graph->connect(blackbodyNode->output("Color"), mathNode->input("Vector1"));
graph->connect(mathNode->output("Vector"), outputNode->input("Color"));
}
else {
graph->connect(blackbodyNode->output("Color"), outputNode->input("Color"));
}
hasColorTemperature = true;
}
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->shapingIesFile);
if (value.IsHolding<SdfAssetPath>()) {
std::string filename = value.UncheckedGet<SdfAssetPath>().GetResolvedPath();
if (filename.empty()) {
filename = value.UncheckedGet<SdfAssetPath>().GetAssetPath();
}
TextureCoordinateNode *coordNode = graph->create_node<TextureCoordinateNode>();
coordNode->set_ob_tfm(_light->get_tfm());
coordNode->set_use_transform(true);
graph->add(coordNode);
IESLightNode *iesNode = graph->create_node<IESLightNode>();
iesNode->set_filename(ustring(filename));
graph->connect(coordNode->output("Normal"), iesNode->input("Vector"));
graph->connect(iesNode->output("Fac"), outputNode->input("Strength"));
hasSpatialVarying = true;
}
value = sceneDelegate->GetLightParamValue(id, HdLightTokens->textureFile);
if (value.IsHolding<SdfAssetPath>()) {
std::string filename = value.UncheckedGet<SdfAssetPath>().GetResolvedPath();
if (filename.empty()) {
filename = value.UncheckedGet<SdfAssetPath>().GetAssetPath();
}
ImageSlotTextureNode *textureNode = nullptr;
if (_lightType == HdPrimTypeTokens->domeLight) {
Transform tfm = _light->get_tfm();
transform_set_column(&tfm, 3, zero_float3()); // Remove translation
TextureCoordinateNode *coordNode = graph->create_node<TextureCoordinateNode>();
coordNode->set_ob_tfm(tfm);
coordNode->set_use_transform(true);
graph->add(coordNode);
textureNode = graph->create_node<EnvironmentTextureNode>();
static_cast<EnvironmentTextureNode *>(textureNode)->set_filename(ustring(filename));
graph->add(textureNode);
graph->connect(coordNode->output("Object"), textureNode->input("Vector"));
hasSpatialVarying = true;
}
else {
GeometryNode *coordNode = graph->create_node<GeometryNode>();
graph->add(coordNode);
textureNode = graph->create_node<ImageTextureNode>();
static_cast<ImageTextureNode *>(textureNode)->set_filename(ustring(filename));
graph->add(textureNode);
graph->connect(coordNode->output("Parametric"), textureNode->input("Vector"));
}
if (hasColorTemperature) {
VectorMathNode *mathNode = graph->create_node<VectorMathNode>();
mathNode->set_math_type(NODE_VECTOR_MATH_MULTIPLY);
graph->add(mathNode);
graph->connect(textureNode->output("Color"), mathNode->input("Vector1"));
ShaderInput *const outputNodeInput = outputNode->input("Color");
graph->connect(outputNodeInput->link, mathNode->input("Vector2"));
graph->disconnect(outputNodeInput);
graph->connect(mathNode->output("Vector"), outputNodeInput);
}
else if (_lightType == HdPrimTypeTokens->domeLight) {
VectorMathNode *mathNode = graph->create_node<VectorMathNode>();
mathNode->set_math_type(NODE_VECTOR_MATH_MULTIPLY);
mathNode->set_vector2(_light->get_strength());
graph->add(mathNode);
graph->connect(textureNode->output("Color"), mathNode->input("Vector1"));
graph->connect(mathNode->output("Vector"), outputNode->input("Color"));
}
else {
graph->connect(textureNode->output("Color"), outputNode->input("Color"));
}
}
}
Shader *const shader = _light->get_shader();
shader->set_graph(graph);
shader->tag_update((Scene *)_light->get_owner());
shader->has_surface_spatial_varying = hasSpatialVarying;
}
void HdCyclesLight::Finalize(HdRenderParam *renderParam)
{
if (!_light) {
return;
}
const SceneLock lock(renderParam);
lock.scene->delete_node(_light);
_light = nullptr;
}
void HdCyclesLight::Initialize(HdRenderParam *renderParam)
{
if (_light) {
return;
}
const SceneLock lock(renderParam);
_light = lock.scene->create_node<Light>();
_light->name = GetId().GetString();
_light->set_random_id(hash_uint2(hash_string(_light->name.c_str()), 0));
if (_lightType == HdPrimTypeTokens->domeLight) {
_light->set_light_type(LIGHT_BACKGROUND);
}
else if (_lightType == HdPrimTypeTokens->distantLight) {
_light->set_light_type(LIGHT_DISTANT);
}
else if (_lightType == HdPrimTypeTokens->diskLight) {
_light->set_light_type(LIGHT_AREA);
_light->set_round(true);
_light->set_size(1.0f);
}
else if (_lightType == HdPrimTypeTokens->rectLight) {
_light->set_light_type(LIGHT_AREA);
_light->set_round(false);
_light->set_size(1.0f);
}
else if (_lightType == HdPrimTypeTokens->sphereLight) {
_light->set_light_type(LIGHT_POINT);
_light->set_size(1.0f);
}
_light->set_use_mis(true);
_light->set_use_camera(false);
Shader *const shader = lock.scene->create_node<Shader>();
_light->set_shader(shader);
// Create default shader graph
PopulateShaderGraph(nullptr);
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,35 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/light.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesLight final : public PXR_NS::HdLight {
public:
HdCyclesLight(const PXR_NS::SdfPath &sprimId, const PXR_NS::TfToken &lightType);
~HdCyclesLight() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits) override;
void Finalize(PXR_NS::HdRenderParam *renderParam) override;
private:
void Initialize(PXR_NS::HdRenderParam *renderParam);
void PopulateShaderGraph(PXR_NS::HdSceneDelegate *sceneDelegate);
CCL_NS::Light *_light = nullptr;
PXR_NS::TfToken _lightType;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,584 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/material.h"
#include "hydra/node_util.h"
#include "hydra/session.h"
#include "scene/scene.h"
#include "scene/shader.h"
#include "scene/shader_graph.h"
#include "scene/shader_nodes.h"
#include <pxr/imaging/hd/sceneDelegate.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(CyclesMaterialTokens,
((cyclesSurface, "cycles:surface"))
((cyclesDisplacement, "cycles:displacement"))
((cyclesVolume, "cycles:volume"))
(UsdPreviewSurface)
(UsdUVTexture)
(UsdPrimvarReader_float)
(UsdPrimvarReader_float2)
(UsdPrimvarReader_float3)
(UsdPrimvarReader_float4)
(UsdPrimvarReader_int)
(UsdTransform2d)
(a)
(rgb)
(r)
(g)
(b)
(result)
(st)
(wrapS)
(wrapT)
(periodic)
);
// clang-format on
// Simple class to handle remapping of USDPreviewSurface nodes and parameters to Cycles equivalents
class UsdToCyclesMapping {
using ParamMap = std::unordered_map<TfToken, ustring, TfToken::HashFunctor>;
public:
UsdToCyclesMapping(const char *nodeType, ParamMap paramMap)
: _nodeType(nodeType), _paramMap(std::move(paramMap))
{
}
ustring nodeType() const
{
return _nodeType;
}
virtual std::string parameterName(const TfToken &name,
const ShaderInput *inputConnection,
VtValue *value = nullptr) const
{
// UsdNode.name -> Node.input
// These all follow a simple pattern that we can just remap
// based on the name or 'Node.input' type
if (inputConnection) {
if (name == CyclesMaterialTokens->a) {
return "alpha";
}
if (name == CyclesMaterialTokens->rgb) {
return "color";
}
// TODO: Is there a better mapping than 'color'?
if (name == CyclesMaterialTokens->r || name == CyclesMaterialTokens->g ||
name == CyclesMaterialTokens->b) {
return "color";
}
if (name == CyclesMaterialTokens->result) {
switch (inputConnection->socket_type.type) {
case SocketType::BOOLEAN:
case SocketType::FLOAT:
case SocketType::INT:
case SocketType::UINT:
return "alpha";
case SocketType::COLOR:
case SocketType::VECTOR:
case SocketType::POINT:
case SocketType::NORMAL:
default:
return "color";
}
}
}
// Simple mapping case
const auto it = _paramMap.find(name);
return it != _paramMap.end() ? it->second.string() : name.GetString();
}
private:
const ustring _nodeType;
ParamMap _paramMap;
};
class UsdToCyclesTexture : public UsdToCyclesMapping {
public:
using UsdToCyclesMapping::UsdToCyclesMapping;
std::string parameterName(const TfToken &name,
const ShaderInput *inputConnection,
VtValue *value) const override
{
if (value) {
// Remap UsdUVTexture.wrapS and UsdUVTexture.wrapT to cycles_image_texture.extension
if (name == CyclesMaterialTokens->wrapS || name == CyclesMaterialTokens->wrapT) {
std::string valueString = VtValue::Cast<std::string>(*value).Get<std::string>();
// A value of 'repeat' in USD is equivalent to 'periodic' in Cycles
if (valueString == "repeat") {
*value = VtValue(CyclesMaterialTokens->periodic);
}
return "extension";
}
}
return UsdToCyclesMapping::parameterName(name, inputConnection, value);
}
};
namespace {
class UsdToCycles {
const UsdToCyclesMapping UsdPreviewSurface = {
"principled_bsdf",
{
{TfToken("diffuseColor"), ustring("base_color")},
{TfToken("emissiveColor"), ustring("emission")},
{TfToken("specularColor"), ustring("specular")},
{TfToken("clearcoatRoughness"), ustring("clearcoat_roughness")},
{TfToken("opacity"), ustring("alpha")},
// opacityThreshold
// occlusion
// displacement
}};
const UsdToCyclesTexture UsdUVTexture = {
"image_texture",
{
{CyclesMaterialTokens->st, ustring("vector")},
{CyclesMaterialTokens->wrapS, ustring("extension")},
{CyclesMaterialTokens->wrapT, ustring("extension")},
{TfToken("file"), ustring("filename")},
{TfToken("sourceColorSpace"), ustring("colorspace")},
}};
const UsdToCyclesMapping UsdPrimvarReader = {"attribute",
{{TfToken("varname"), ustring("attribute")}}};
public:
const UsdToCyclesMapping *findUsd(const TfToken &usdNodeType)
{
if (usdNodeType == CyclesMaterialTokens->UsdPreviewSurface) {
return &UsdPreviewSurface;
}
if (usdNodeType == CyclesMaterialTokens->UsdUVTexture) {
return &UsdUVTexture;
}
if (usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float ||
usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float2 ||
usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float3 ||
usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float4 ||
usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_int) {
return &UsdPrimvarReader;
}
return nullptr;
}
const UsdToCyclesMapping *findCycles(const ustring &cyclesNodeType)
{
return nullptr;
}
};
TfStaticData<UsdToCycles> sUsdToCyles;
} // namespace
HdCyclesMaterial::HdCyclesMaterial(const SdfPath &sprimId) : HdMaterial(sprimId)
{
}
HdCyclesMaterial::~HdCyclesMaterial()
{
}
HdDirtyBits HdCyclesMaterial::GetInitialDirtyBitsMask() const
{
return DirtyBits::DirtyResource | DirtyBits::DirtyParams;
}
void HdCyclesMaterial::Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits)
{
if (*dirtyBits == DirtyBits::Clean) {
return;
}
Initialize(renderParam);
const SceneLock lock(renderParam);
const bool dirtyParams = (*dirtyBits & DirtyBits::DirtyParams);
const bool dirtyResource = (*dirtyBits & DirtyBits::DirtyResource);
VtValue value;
const SdfPath &id = GetId();
if (dirtyResource || dirtyParams) {
value = sceneDelegate->GetMaterialResource(id);
#if 1
const HdMaterialNetwork2 *network = nullptr;
std::unique_ptr<HdMaterialNetwork2> networkConverted;
if (value.IsHolding<HdMaterialNetwork2>()) {
network = &value.UncheckedGet<HdMaterialNetwork2>();
}
else if (value.IsHolding<HdMaterialNetworkMap>()) {
const auto &networkOld = value.UncheckedGet<HdMaterialNetworkMap>();
// In the case of only parameter updates, there is no need to waste time converting to a
// HdMaterialNetwork2, as supporting HdMaterialNetworkMap for parameters only is trivial.
if (!_nodes.empty() && !dirtyResource) {
for (const auto &networkEntry : networkOld.map) {
UpdateParameters(networkEntry.second);
}
_shader->tag_modified();
}
else {
networkConverted = std::make_unique<HdMaterialNetwork2>();
HdMaterialNetwork2ConvertFromHdMaterialNetworkMap(networkOld, networkConverted.get());
network = networkConverted.get();
}
}
else {
TF_RUNTIME_ERROR("Could not get a HdMaterialNetwork2.");
}
if (network) {
if (!_nodes.empty() && !dirtyResource) {
UpdateParameters(*network);
_shader->tag_modified();
}
else {
PopulateShaderGraph(*network);
}
}
#endif
}
if (_shader->is_modified()) {
_shader->tag_update(lock.scene);
}
*dirtyBits = DirtyBits::Clean;
}
void HdCyclesMaterial::UpdateParameters(NodeDesc &nodeDesc,
const std::map<TfToken, VtValue> &parameters,
const SdfPath &nodePath)
{
for (const std::pair<TfToken, VtValue> &param : parameters) {
VtValue value = param.second;
// See if the parameter name is in USDPreviewSurface terms, and needs to be converted
const UsdToCyclesMapping *inputMapping = nodeDesc.mapping;
const std::string inputName = inputMapping ?
inputMapping->parameterName(param.first, nullptr, &value) :
param.first.GetString();
// Find the input to write the parameter value to
const SocketType *input = nullptr;
for (const SocketType &socket : nodeDesc.node->type->inputs) {
if (string_iequals(socket.name.string(), inputName) || socket.ui_name == inputName) {
input = &socket;
break;
}
}
if (!input) {
TF_WARN("Could not find parameter '%s' on node '%s' ('%s')",
param.first.GetText(),
nodePath.GetText(),
nodeDesc.node->name.c_str());
continue;
}
SetNodeValue(nodeDesc.node, *input, value);
}
}
void HdCyclesMaterial::UpdateParameters(const HdMaterialNetwork &network)
{
for (const HdMaterialNode &nodeEntry : network.nodes) {
const SdfPath &nodePath = nodeEntry.path;
const auto nodeIt = _nodes.find(nodePath);
if (nodeIt == _nodes.end()) {
TF_RUNTIME_ERROR("Could not update parameters on missing node '%s'", nodePath.GetText());
continue;
}
UpdateParameters(nodeIt->second, nodeEntry.parameters, nodePath);
}
}
void HdCyclesMaterial::UpdateParameters(const HdMaterialNetwork2 &network)
{
for (const std::pair<SdfPath, HdMaterialNode2> &nodeEntry : network.nodes) {
const SdfPath &nodePath = nodeEntry.first;
const auto nodeIt = _nodes.find(nodePath);
if (nodeIt == _nodes.end()) {
TF_RUNTIME_ERROR("Could not update parameters on missing node '%s'", nodePath.GetText());
continue;
}
UpdateParameters(nodeIt->second, nodeEntry.second.parameters, nodePath);
}
}
void HdCyclesMaterial::UpdateConnections(NodeDesc &nodeDesc,
const HdMaterialNode2 &matNode,
const SdfPath &nodePath,
ShaderGraph *shaderGraph)
{
for (const std::pair<TfToken, std::vector<HdMaterialConnection2>> &connection :
matNode.inputConnections) {
const TfToken &dstSocketName = connection.first;
const UsdToCyclesMapping *inputMapping = nodeDesc.mapping;
const std::string inputName = inputMapping ?
inputMapping->parameterName(dstSocketName, nullptr) :
dstSocketName.GetString();
// Find the input to connect to on the passed in node
ShaderInput *input = nullptr;
for (ShaderInput *in : nodeDesc.node->inputs) {
if (string_iequals(in->socket_type.name.string(), inputName)) {
input = in;
break;
}
}
if (!input) {
TF_WARN("Ignoring connection on '%s.%s', input '%s' was not found",
nodePath.GetText(),
dstSocketName.GetText(),
dstSocketName.GetText());
continue;
}
// Now find the output to connect from
const auto &connectedNodes = connection.second;
if (connectedNodes.empty()) {
continue;
}
// TODO: Hydra allows multiple connections of the same input
// Unsure how to handle this in Cycles, so just use the first
if (connectedNodes.size() > 1) {
TF_WARN(
"Ignoring multiple connections to '%s.%s'", nodePath.GetText(), dstSocketName.GetText());
}
const SdfPath &upstreamNodePath = connectedNodes.front().upstreamNode;
const TfToken &upstreamOutputName = connectedNodes.front().upstreamOutputName;
const auto srcNodeIt = _nodes.find(upstreamNodePath);
if (srcNodeIt == _nodes.end()) {
TF_WARN("Ignoring connection from '%s.%s' to '%s.%s', node '%s' was not found",
upstreamNodePath.GetText(),
upstreamOutputName.GetText(),
nodePath.GetText(),
dstSocketName.GetText(),
upstreamNodePath.GetText());
continue;
}
const UsdToCyclesMapping *outputMapping = srcNodeIt->second.mapping;
const std::string outputName = outputMapping ?
outputMapping->parameterName(upstreamOutputName, input) :
upstreamOutputName.GetString();
ShaderOutput *output = nullptr;
for (ShaderOutput *out : srcNodeIt->second.node->outputs) {
if (string_iequals(out->socket_type.name.string(), outputName)) {
output = out;
break;
}
}
if (!output) {
TF_WARN("Ignoring connection from '%s.%s' to '%s.%s', output '%s' was not found",
upstreamNodePath.GetText(),
upstreamOutputName.GetText(),
nodePath.GetText(),
dstSocketName.GetText(),
upstreamOutputName.GetText());
continue;
}
shaderGraph->connect(output, input);
}
}
void HdCyclesMaterial::PopulateShaderGraph(const HdMaterialNetwork2 &networkMap)
{
_nodes.clear();
auto graph = new ShaderGraph();
// Iterate all the nodes first and build a complete but unconnected graph with parameters set
for (const std::pair<SdfPath, HdMaterialNode2> &nodeEntry : networkMap.nodes) {
NodeDesc nodeDesc = {};
const SdfPath &nodePath = nodeEntry.first;
const auto nodeIt = _nodes.find(nodePath);
// Create new node only if it does not exist yet
if (nodeIt != _nodes.end()) {
nodeDesc = nodeIt->second;
}
else {
// E.g. cycles_principled_bsdf or UsdPreviewSurface
const std::string &nodeTypeId = nodeEntry.second.nodeTypeId.GetString();
ustring cyclesType(nodeTypeId);
// Interpret a node type ID prefixed with cycles_<type> or cycles:<type> as a node of <type>
if (nodeTypeId.rfind("cycles", 0) == 0) {
cyclesType = nodeTypeId.substr(7);
nodeDesc.mapping = sUsdToCyles->findCycles(cyclesType);
}
else {
// Check if any remapping is needed (e.g. for USDPreviewSurface to Cycles nodes)
nodeDesc.mapping = sUsdToCyles->findUsd(nodeEntry.second.nodeTypeId);
if (nodeDesc.mapping) {
cyclesType = nodeDesc.mapping->nodeType();
}
}
// If it's a native Cycles' node-type, just do the lookup now.
if (const NodeType *nodeType = NodeType::find(cyclesType)) {
nodeDesc.node = static_cast<ShaderNode *>(nodeType->create(nodeType));
nodeDesc.node->set_owner(graph);
graph->add(nodeDesc.node);
_nodes.emplace(nodePath, nodeDesc);
}
else {
TF_RUNTIME_ERROR("Could not create node '%s'", nodePath.GetText());
continue;
}
}
UpdateParameters(nodeDesc, nodeEntry.second.parameters, nodePath);
}
// Now that all nodes have been constructed, iterate the network again and build up any
// connections between nodes
for (const std::pair<SdfPath, HdMaterialNode2> &nodeEntry : networkMap.nodes) {
const SdfPath &nodePath = nodeEntry.first;
const auto nodeIt = _nodes.find(nodePath);
if (nodeIt == _nodes.end()) {
TF_RUNTIME_ERROR("Could not find node '%s' to connect", nodePath.GetText());
continue;
}
UpdateConnections(nodeIt->second, nodeEntry.second, nodePath, graph);
}
// Finally connect the terminals to the graph output (Surface, Volume, Displacement)
for (const std::pair<TfToken, HdMaterialConnection2> &terminalEntry : networkMap.terminals) {
const TfToken &terminalName = terminalEntry.first;
const HdMaterialConnection2 &connection = terminalEntry.second;
const auto nodeIt = _nodes.find(connection.upstreamNode);
if (nodeIt == _nodes.end()) {
TF_RUNTIME_ERROR("Could not find terminal node '%s'", connection.upstreamNode.GetText());
continue;
}
ShaderNode *const node = nodeIt->second.node;
const char *inputName = nullptr;
const char *outputName = nullptr;
if (terminalName == HdMaterialTerminalTokens->surface ||
terminalName == CyclesMaterialTokens->cyclesSurface) {
inputName = "Surface";
// Find default output name based on the node if none is provided
if (node->type->name == "add_closure" || node->type->name == "mix_closure") {
outputName = "Closure";
}
else if (node->type->name == "emission") {
outputName = "Emission";
}
else {
outputName = "BSDF";
}
}
else if (terminalName == HdMaterialTerminalTokens->displacement ||
terminalName == CyclesMaterialTokens->cyclesDisplacement) {
inputName = outputName = "Displacement";
}
else if (terminalName == HdMaterialTerminalTokens->volume ||
terminalName == CyclesMaterialTokens->cyclesVolume) {
inputName = outputName = "Volume";
}
if (!connection.upstreamOutputName.IsEmpty()) {
outputName = connection.upstreamOutputName.GetText();
}
ShaderInput *const input = inputName ? graph->output()->input(inputName) : nullptr;
if (!input) {
TF_RUNTIME_ERROR("Could not find terminal input '%s.%s'",
connection.upstreamNode.GetText(),
inputName ? inputName : "<null>");
continue;
}
ShaderOutput *const output = outputName ? node->output(outputName) : nullptr;
if (!output) {
TF_RUNTIME_ERROR("Could not find terminal output '%s.%s'",
connection.upstreamNode.GetText(),
outputName ? outputName : "<null>");
continue;
}
graph->connect(output, input);
}
// Create the instanceId AOV output
{
const ustring instanceId(HdAovTokens->instanceId.GetString());
OutputAOVNode *aovNode = graph->create_node<OutputAOVNode>();
aovNode->set_name(instanceId);
graph->add(aovNode);
AttributeNode *instanceIdNode = graph->create_node<AttributeNode>();
instanceIdNode->set_attribute(instanceId);
graph->add(instanceIdNode);
graph->connect(instanceIdNode->output("Fac"), aovNode->input("Value"));
}
_shader->set_graph(graph);
}
void HdCyclesMaterial::Finalize(HdRenderParam *renderParam)
{
if (!_shader) {
return;
}
const SceneLock lock(renderParam);
_nodes.clear();
lock.scene->delete_node(_shader);
_shader = nullptr;
}
void HdCyclesMaterial::Initialize(HdRenderParam *renderParam)
{
if (_shader) {
return;
}
const SceneLock lock(renderParam);
_shader = lock.scene->create_node<Shader>();
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,63 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/material.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesMaterial final : public PXR_NS::HdMaterial {
public:
HdCyclesMaterial(const PXR_NS::SdfPath &sprimId);
~HdCyclesMaterial() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits) override;
#if PXR_VERSION < 2011
void Reload() override
{
}
#endif
void Finalize(PXR_NS::HdRenderParam *renderParam) override;
CCL_NS::Shader *GetCyclesShader() const
{
return _shader;
}
private:
struct NodeDesc {
CCL_NS::ShaderNode *node;
const class UsdToCyclesMapping *mapping;
};
void Initialize(PXR_NS::HdRenderParam *renderParam);
void UpdateParameters(NodeDesc &nodeDesc,
const std::map<PXR_NS::TfToken, PXR_NS::VtValue> &parameters,
const PXR_NS::SdfPath &nodePath);
void UpdateParameters(const PXR_NS::HdMaterialNetwork &network);
void UpdateParameters(const PXR_NS::HdMaterialNetwork2 &network);
void UpdateConnections(NodeDesc &nodeDesc,
const PXR_NS::HdMaterialNode2 &matNode,
const PXR_NS::SdfPath &nodePath,
CCL_NS::ShaderGraph *shaderGraph);
void PopulateShaderGraph(const PXR_NS::HdMaterialNetwork2 &network);
CCL_NS::Shader *_shader = nullptr;
std::unordered_map<PXR_NS::SdfPath, NodeDesc, PXR_NS::SdfPath::Hash> _nodes;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,524 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/mesh.h"
#include "hydra/geometry.inl"
#include "scene/mesh.h"
#include <pxr/base/gf/vec2f.h>
#include <pxr/imaging/hd/extComputationUtils.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
namespace {
template<typename T>
VtValue ComputeTriangulatedUniformPrimvar(VtValue value, const VtIntArray &primitiveParams)
{
T output;
output.reserve(primitiveParams.size());
const T &input = value.Get<T>();
for (size_t i = 0; i < primitiveParams.size(); ++i) {
const int faceIndex = HdMeshUtil::DecodeFaceIndexFromCoarseFaceParam(primitiveParams[i]);
output.push_back(input[faceIndex]);
}
return VtValue(output);
}
VtValue ComputeTriangulatedUniformPrimvar(VtValue value,
const HdType valueType,
const VtIntArray &primitiveParams)
{
switch (valueType) {
case HdTypeFloat:
return ComputeTriangulatedUniformPrimvar<VtFloatArray>(value, primitiveParams);
case HdTypeFloatVec2:
return ComputeTriangulatedUniformPrimvar<VtVec2fArray>(value, primitiveParams);
case HdTypeFloatVec3:
return ComputeTriangulatedUniformPrimvar<VtVec3fArray>(value, primitiveParams);
case HdTypeFloatVec4:
return ComputeTriangulatedUniformPrimvar<VtVec4fArray>(value, primitiveParams);
default:
TF_RUNTIME_ERROR("Unsupported attribute type %d", static_cast<int>(valueType));
return VtValue();
}
}
VtValue ComputeTriangulatedFaceVaryingPrimvar(VtValue value,
const HdType valueType,
HdMeshUtil &meshUtil)
{
if (meshUtil.ComputeTriangulatedFaceVaryingPrimvar(
HdGetValueData(value), value.GetArraySize(), valueType, &value)) {
return value;
}
return VtValue();
}
} // namespace
Transform convert_transform(const GfMatrix4d &matrix)
{
return make_transform(matrix[0][0],
matrix[1][0],
matrix[2][0],
matrix[3][0],
matrix[0][1],
matrix[1][1],
matrix[2][1],
matrix[3][1],
matrix[0][2],
matrix[1][2],
matrix[2][2],
matrix[3][2]);
}
HdCyclesMesh::HdCyclesMesh(const SdfPath &rprimId
#if PXR_VERSION < 2102
,
const SdfPath &instancerId
#endif
)
: HdCyclesGeometry(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
),
_util(&_topology, rprimId)
{
}
HdCyclesMesh::~HdCyclesMesh()
{
}
HdDirtyBits HdCyclesMesh::GetInitialDirtyBitsMask() const
{
HdDirtyBits bits = HdCyclesGeometry::GetInitialDirtyBitsMask();
bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyNormals |
HdChangeTracker::DirtyPrimvar | HdChangeTracker::DirtyTopology |
HdChangeTracker::DirtyDisplayStyle | HdChangeTracker::DirtySubdivTags;
return bits;
}
HdDirtyBits HdCyclesMesh::_PropagateDirtyBits(HdDirtyBits bits) const
{
if (bits & (HdChangeTracker::DirtyMaterialId)) {
// Update used shaders from geometry subsets if any exist in the topology
bits |= HdChangeTracker::DirtyTopology;
}
if (bits & (HdChangeTracker::DirtyTopology | HdChangeTracker::DirtyDisplayStyle |
HdChangeTracker::DirtySubdivTags)) {
// Do full topology update when display style or subdivision changes
bits |= HdChangeTracker::DirtyTopology | HdChangeTracker::DirtyDisplayStyle |
HdChangeTracker::DirtySubdivTags;
}
if (bits & (HdChangeTracker::DirtyTopology)) {
// Changing topology clears the geometry, so need to populate everything again
bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyNormals |
HdChangeTracker::DirtyPrimvar;
}
return bits;
}
void HdCyclesMesh::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits, bool &rebuild)
{
if (HdChangeTracker::IsTopologyDirty(dirtyBits, GetId())) {
PopulateTopology(sceneDelegate);
}
if (dirtyBits & HdChangeTracker::DirtyPoints) {
PopulatePoints(sceneDelegate);
}
// Must happen after topology update, so that normals attribute size can be calculated
if (dirtyBits & HdChangeTracker::DirtyNormals) {
PopulateNormals(sceneDelegate);
}
// Must happen after topology update, so that appropriate attribute set can be selected
if (dirtyBits & HdChangeTracker::DirtyPrimvar) {
PopulatePrimvars(sceneDelegate);
}
rebuild = (_geom->triangles_is_modified()) || (_geom->subd_start_corner_is_modified()) ||
(_geom->subd_num_corners_is_modified()) || (_geom->subd_shader_is_modified()) ||
(_geom->subd_smooth_is_modified()) || (_geom->subd_ptex_offset_is_modified()) ||
(_geom->subd_face_corners_is_modified());
}
void HdCyclesMesh::PopulatePoints(HdSceneDelegate *sceneDelegate)
{
VtValue value;
for (const HdExtComputationPrimvarDescriptor &desc :
sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) {
if (desc.name == HdTokens->points) {
auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate);
const auto valueStoreIt = valueStore.find(desc.name);
if (valueStoreIt != valueStore.end()) {
value = std::move(valueStoreIt->second);
}
break;
}
}
if (value.IsEmpty()) {
value = GetPoints(sceneDelegate);
}
if (!value.IsHolding<VtVec3fArray>()) {
TF_WARN("Invalid points data for %s", GetId().GetText());
return;
}
const auto &points = value.UncheckedGet<VtVec3fArray>();
TF_VERIFY(points.size() >= static_cast<size_t>(_topology.GetNumPoints()));
array<float3> pointsDataCycles;
pointsDataCycles.reserve(points.size());
for (const GfVec3f &point : points) {
pointsDataCycles.push_back_reserved(make_float3(point[0], point[1], point[2]));
}
_geom->set_verts(pointsDataCycles);
}
void HdCyclesMesh::PopulateNormals(HdSceneDelegate *sceneDelegate)
{
_geom->attributes.remove(ATTR_STD_FACE_NORMAL);
_geom->attributes.remove(ATTR_STD_VERTEX_NORMAL);
// Authored normals should only exist on triangle meshes
if (_geom->get_subdivision_type() != Mesh::SUBDIVISION_NONE) {
return;
}
VtValue value;
HdInterpolation interpolation = HdInterpolationCount;
for (int i = 0; i < HdInterpolationCount && interpolation == HdInterpolationCount; ++i) {
for (const HdExtComputationPrimvarDescriptor &desc :
sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(),
static_cast<HdInterpolation>(i))) {
if (desc.name == HdTokens->normals) {
auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate);
const auto valueStoreIt = valueStore.find(desc.name);
if (valueStoreIt != valueStore.end()) {
value = std::move(valueStoreIt->second);
interpolation = static_cast<HdInterpolation>(i);
}
break;
}
}
}
if (value.IsEmpty()) {
interpolation = GetPrimvarInterpolation(sceneDelegate, HdTokens->normals);
if (interpolation == HdInterpolationCount) {
return; // Ignore missing normals
}
value = GetNormals(sceneDelegate);
}
if (!value.IsHolding<VtVec3fArray>()) {
TF_WARN("Invalid normals data for %s", GetId().GetText());
return;
}
const auto &normals = value.UncheckedGet<VtVec3fArray>();
if (interpolation == HdInterpolationConstant) {
TF_VERIFY(normals.size() == 1);
const GfVec3f constantNormal = normals[0];
float3 *const N = _geom->attributes.add(ATTR_STD_VERTEX_NORMAL)->data_float3();
for (size_t i = 0; i < _geom->get_verts().size(); ++i) {
N[i] = make_float3(constantNormal[0], constantNormal[1], constantNormal[2]);
}
}
else if (interpolation == HdInterpolationUniform) {
TF_VERIFY(normals.size() == static_cast<size_t>(_topology.GetNumFaces()));
float3 *const N = _geom->attributes.add(ATTR_STD_FACE_NORMAL)->data_float3();
for (size_t i = 0; i < _geom->num_triangles(); ++i) {
const int faceIndex = HdMeshUtil::DecodeFaceIndexFromCoarseFaceParam(_primitiveParams[i]);
N[i] = make_float3(normals[faceIndex][0], normals[faceIndex][1], normals[faceIndex][2]);
}
}
else if (interpolation == HdInterpolationVertex || interpolation == HdInterpolationVarying) {
TF_VERIFY(normals.size() == static_cast<size_t>(_topology.GetNumPoints()) &&
static_cast<size_t>(_topology.GetNumPoints()) == _geom->get_verts().size());
float3 *const N = _geom->attributes.add(ATTR_STD_VERTEX_NORMAL)->data_float3();
for (size_t i = 0; i < _geom->get_verts().size(); ++i) {
N[i] = make_float3(normals[i][0], normals[i][1], normals[i][2]);
}
}
else if (interpolation == HdInterpolationFaceVarying) {
TF_VERIFY(normals.size() == static_cast<size_t>(_topology.GetNumFaceVaryings()));
if (!_util.ComputeTriangulatedFaceVaryingPrimvar(
normals.data(), normals.size(), HdTypeFloatVec3, &value)) {
return;
}
const auto &normalsTriangulated = value.UncheckedGet<VtVec3fArray>();
// Cycles has no standard attribute for face-varying normals, so this is a lossy transformation
float3 *const N = _geom->attributes.add(ATTR_STD_FACE_NORMAL)->data_float3();
for (size_t i = 0; i < _geom->num_triangles(); ++i) {
GfVec3f averageNormal = normalsTriangulated[i * 3] + normalsTriangulated[i * 3 + 1] +
normalsTriangulated[i * 3 + 2];
GfNormalize(&averageNormal);
N[i] = make_float3(averageNormal[0], averageNormal[1], averageNormal[2]);
}
}
}
void HdCyclesMesh::PopulatePrimvars(HdSceneDelegate *sceneDelegate)
{
Scene *const scene = (Scene *)_geom->get_owner();
const bool subdivision = _geom->get_subdivision_type() != Mesh::SUBDIVISION_NONE;
AttributeSet &attributes = subdivision ? _geom->subd_attributes : _geom->attributes;
const std::pair<HdInterpolation, AttributeElement> interpolations[] = {
std::make_pair(HdInterpolationFaceVarying, ATTR_ELEMENT_CORNER),
std::make_pair(HdInterpolationUniform, ATTR_ELEMENT_FACE),
std::make_pair(HdInterpolationVertex, ATTR_ELEMENT_VERTEX),
std::make_pair(HdInterpolationVarying, ATTR_ELEMENT_VERTEX),
std::make_pair(HdInterpolationConstant, ATTR_ELEMENT_OBJECT),
};
for (const auto &interpolation : interpolations) {
for (const HdPrimvarDescriptor &desc :
GetPrimvarDescriptors(sceneDelegate, interpolation.first)) {
// Skip special primvars that are handled separately
if (desc.name == HdTokens->points || desc.name == HdTokens->normals) {
continue;
}
VtValue value = GetPrimvar(sceneDelegate, desc.name);
if (value.IsEmpty()) {
continue;
}
const ustring name(desc.name.GetString());
AttributeStandard std = ATTR_STD_NONE;
if (desc.role == HdPrimvarRoleTokens->textureCoordinate) {
std = ATTR_STD_UV;
}
else if (interpolation.first == HdInterpolationVertex) {
if (desc.name == HdTokens->displayColor || desc.role == HdPrimvarRoleTokens->color) {
std = ATTR_STD_VERTEX_COLOR;
}
else if (desc.name == HdTokens->normals) {
std = ATTR_STD_VERTEX_NORMAL;
}
}
else if (desc.name == HdTokens->displayColor &&
interpolation.first == HdInterpolationConstant) {
if (value.IsHolding<VtVec3fArray>() && value.GetArraySize() == 1) {
const GfVec3f color = value.UncheckedGet<VtVec3fArray>()[0];
_instances[0]->set_color(make_float3(color[0], color[1], color[2]));
}
}
// Skip attributes that are not needed
if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) ||
_geom->need_attribute(scene, name)) {
const HdType valueType = HdGetValueTupleType(value).type;
if (!subdivision) {
// Adjust attributes for polygons that were triangulated
if (interpolation.first == HdInterpolationUniform) {
value = ComputeTriangulatedUniformPrimvar(value, valueType, _primitiveParams);
if (value.IsEmpty()) {
continue;
}
}
else if (interpolation.first == HdInterpolationFaceVarying) {
value = ComputeTriangulatedFaceVaryingPrimvar(value, valueType, _util);
if (value.IsEmpty()) {
continue;
}
}
}
ApplyPrimvars(attributes, name, value, interpolation.second, std);
}
}
}
}
void HdCyclesMesh::PopulateTopology(HdSceneDelegate *sceneDelegate)
{
// Clear geometry before populating it again with updated topology
_geom->clear(true);
const HdDisplayStyle displayStyle = GetDisplayStyle(sceneDelegate);
_topology = HdMeshTopology(GetMeshTopology(sceneDelegate), displayStyle.refineLevel);
const TfToken subdivScheme = _topology.GetScheme();
if (subdivScheme == PxOsdOpenSubdivTokens->bilinear && _topology.GetRefineLevel() > 0) {
_geom->set_subdivision_type(Mesh::SUBDIVISION_LINEAR);
}
else if (subdivScheme == PxOsdOpenSubdivTokens->catmullClark && _topology.GetRefineLevel() > 0) {
_geom->set_subdivision_type(Mesh::SUBDIVISION_CATMULL_CLARK);
}
else {
_geom->set_subdivision_type(Mesh::SUBDIVISION_NONE);
}
const bool smooth = !displayStyle.flatShadingEnabled;
const bool subdivision = _geom->get_subdivision_type() != Mesh::SUBDIVISION_NONE;
// Initialize lookup table from polygon face to material shader index
VtIntArray faceShaders(_topology.GetNumFaces(), 0);
HdGeomSubsets const &geomSubsets = _topology.GetGeomSubsets();
if (!geomSubsets.empty()) {
array<Node *> usedShaders = std::move(_geom->get_used_shaders());
// Remove any previous materials except for the material assigned to the prim
usedShaders.resize(1);
std::unordered_map<SdfPath, int, SdfPath::Hash> materials;
for (const HdGeomSubset &geomSubset : geomSubsets) {
TF_VERIFY(geomSubset.type == HdGeomSubset::TypeFaceSet);
int shader = 0;
const auto it = materials.find(geomSubset.materialId);
if (it != materials.end()) {
shader = it->second;
}
else {
const auto material = static_cast<const HdCyclesMaterial *>(
sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material,
geomSubset.materialId));
if (material && material->GetCyclesShader()) {
shader = static_cast<int>(usedShaders.size());
usedShaders.push_back_slow(material->GetCyclesShader());
materials.emplace(geomSubset.materialId, shader);
}
}
for (int face : geomSubset.indices) {
faceShaders[face] = shader;
}
}
_geom->set_used_shaders(usedShaders);
}
const VtIntArray vertIndx = _topology.GetFaceVertexIndices();
const VtIntArray vertCounts = _topology.GetFaceVertexCounts();
if (!subdivision) {
VtVec3iArray triangles;
_util.ComputeTriangleIndices(&triangles, &_primitiveParams);
_geom->reserve_mesh(_topology.GetNumPoints(), triangles.size());
for (size_t i = 0; i < _primitiveParams.size(); ++i) {
const int faceIndex = HdMeshUtil::DecodeFaceIndexFromCoarseFaceParam(_primitiveParams[i]);
const GfVec3i triangle = triangles[i];
_geom->add_triangle(triangle[0], triangle[1], triangle[2], faceShaders[faceIndex], smooth);
}
}
else {
PxOsdSubdivTags subdivTags = GetSubdivTags(sceneDelegate);
_topology.SetSubdivTags(subdivTags);
size_t numNgons = 0;
size_t numCorners = 0;
for (int vertCount : vertCounts) {
numNgons += (vertCount == 4) ? 0 : 1;
numCorners += vertCount;
}
_geom->reserve_subd_faces(_topology.GetNumFaces(), numNgons, numCorners);
// TODO: Handle hole indices
size_t faceIndex = 0;
size_t indexOffset = 0;
for (int vertCount : vertCounts) {
_geom->add_subd_face(&vertIndx[indexOffset], vertCount, faceShaders[faceIndex], smooth);
faceIndex++;
indexOffset += vertCount;
}
const VtIntArray creaseLengths = subdivTags.GetCreaseLengths();
if (!creaseLengths.empty()) {
size_t numCreases = 0;
for (int creaseLength : creaseLengths) {
numCreases += creaseLength - 1;
}
_geom->reserve_subd_creases(numCreases);
const VtIntArray creaseIndices = subdivTags.GetCreaseIndices();
const VtFloatArray creaseWeights = subdivTags.GetCreaseWeights();
indexOffset = 0;
size_t creaseLengthOffset = 0;
size_t createWeightOffset = 0;
for (int creaseLength : creaseLengths) {
for (int j = 0; j < creaseLength - 1; ++j, ++createWeightOffset) {
const int v0 = creaseIndices[indexOffset + j];
const int v1 = creaseIndices[indexOffset + j + 1];
float weight = creaseWeights.size() == creaseLengths.size() ?
creaseWeights[creaseLengthOffset] :
creaseWeights[createWeightOffset];
_geom->add_edge_crease(v0, v1, weight);
}
indexOffset += creaseLength;
creaseLengthOffset++;
}
const VtIntArray cornerIndices = subdivTags.GetCornerIndices();
const VtFloatArray cornerWeights = subdivTags.GetCornerWeights();
for (size_t i = 0; i < cornerIndices.size(); ++i) {
_geom->add_vertex_crease(cornerIndices[i], cornerWeights[i]);
}
}
_geom->set_subd_dicing_rate(1.0f);
_geom->set_subd_max_level(_topology.GetRefineLevel());
_geom->set_subd_objecttoworld(_instances[0]->get_tfm());
}
}
void HdCyclesMesh::Finalize(PXR_NS::HdRenderParam *renderParam)
{
_topology = HdMeshTopology();
_primitiveParams.clear();
HdCyclesGeometry<PXR_NS::HdMesh, Mesh>::Finalize(renderParam);
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,49 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "hydra/geometry.h"
#include <pxr/imaging/hd/mesh.h>
#include <pxr/imaging/hd/meshUtil.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesMesh final : public HdCyclesGeometry<PXR_NS::HdMesh, CCL_NS::Mesh> {
public:
HdCyclesMesh(
const PXR_NS::SdfPath &rprimId
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId = {}
#endif
);
~HdCyclesMesh() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
void Finalize(PXR_NS::HdRenderParam *renderParam) override;
private:
PXR_NS::HdDirtyBits _PropagateDirtyBits(PXR_NS::HdDirtyBits bits) const override;
void Populate(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdDirtyBits dirtyBits,
bool &rebuild) override;
void PopulatePoints(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulateNormals(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulatePrimvars(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulateTopology(PXR_NS::HdSceneDelegate *sceneDelegate);
PXR_NS::HdMeshUtil _util;
PXR_NS::HdMeshTopology _topology;
PXR_NS::VtIntArray _primitiveParams;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,562 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/node_util.h"
#include "util/transform.h"
#include <pxr/base/gf/matrix3d.h>
#include <pxr/base/gf/matrix3f.h>
#include <pxr/base/gf/matrix4d.h>
#include <pxr/base/gf/matrix4f.h>
#include <pxr/base/gf/vec2f.h>
#include <pxr/base/gf/vec3f.h>
#include <pxr/base/vt/array.h>
#include <pxr/usd/sdf/assetPath.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
namespace {
template<typename DstType> DstType convertToCycles(const VtValue &value)
{
if (value.IsHolding<DstType>()) {
return value.UncheckedGet<DstType>();
}
VtValue castedValue = VtValue::Cast<DstType>(value);
if (castedValue.IsHolding<DstType>()) {
return castedValue.UncheckedGet<DstType>();
}
TF_WARN("Could not convert VtValue to Cycles type");
return DstType(0);
}
template<> float2 convertToCycles<float2>(const VtValue &value)
{
const GfVec2f convertedValue = convertToCycles<GfVec2f>(value);
return make_float2(convertedValue[0], convertedValue[1]);
}
template<> float3 convertToCycles<float3>(const VtValue &value)
{
if (value.IsHolding<GfVec3f>()) {
const GfVec3f convertedValue = value.UncheckedGet<GfVec3f>();
return make_float3(convertedValue[0], convertedValue[1], convertedValue[2]);
}
if (value.IsHolding<GfVec4f>()) {
const GfVec4f convertedValue = value.UncheckedGet<GfVec4f>();
return make_float3(convertedValue[0], convertedValue[1], convertedValue[2]);
}
if (value.CanCast<GfVec3f>()) {
const GfVec3f convertedValue = VtValue::Cast<GfVec3f>(value).UncheckedGet<GfVec3f>();
return make_float3(convertedValue[0], convertedValue[1], convertedValue[2]);
}
if (value.CanCast<GfVec4f>()) {
const GfVec4f convertedValue = VtValue::Cast<GfVec4f>(value).UncheckedGet<GfVec4f>();
return make_float3(convertedValue[0], convertedValue[1], convertedValue[2]);
}
TF_WARN("Could not convert VtValue to float3");
return zero_float3();
}
template<> ustring convertToCycles<ustring>(const VtValue &value)
{
if (value.IsHolding<TfToken>()) {
return ustring(value.UncheckedGet<TfToken>().GetString());
}
if (value.IsHolding<std::string>()) {
return ustring(value.UncheckedGet<std::string>());
}
if (value.IsHolding<SdfAssetPath>()) {
const SdfAssetPath &path = value.UncheckedGet<SdfAssetPath>();
return ustring(path.GetResolvedPath());
}
if (value.CanCast<TfToken>()) {
return convertToCycles<ustring>(VtValue::Cast<TfToken>(value));
}
if (value.CanCast<std::string>()) {
return convertToCycles<ustring>(VtValue::Cast<std::string>(value));
}
if (value.CanCast<SdfAssetPath>()) {
return convertToCycles<ustring>(VtValue::Cast<SdfAssetPath>(value));
}
TF_WARN("Could not convert VtValue to ustring");
return ustring();
}
template<typename Matrix>
Transform convertMatrixToCycles(
const typename std::enable_if<Matrix::numRows == 3 && Matrix::numColumns == 3, Matrix>::type
&matrix)
{
return make_transform(matrix[0][0],
matrix[1][0],
matrix[2][0],
0,
matrix[0][1],
matrix[1][1],
matrix[2][1],
0,
matrix[0][2],
matrix[1][2],
matrix[2][2],
0);
}
template<typename Matrix>
Transform convertMatrixToCycles(
const typename std::enable_if<Matrix::numRows == 4 && Matrix::numColumns == 4, Matrix>::type
&matrix)
{
return make_transform(matrix[0][0],
matrix[1][0],
matrix[2][0],
matrix[3][0],
matrix[0][1],
matrix[1][1],
matrix[2][1],
matrix[3][1],
matrix[0][2],
matrix[1][2],
matrix[2][2],
matrix[3][2]);
}
template<> Transform convertToCycles<Transform>(const VtValue &value)
{
if (value.IsHolding<GfMatrix4f>()) {
return convertMatrixToCycles<GfMatrix4f>(value.UncheckedGet<GfMatrix4f>());
}
if (value.IsHolding<GfMatrix3f>()) {
return convertMatrixToCycles<GfMatrix3f>(value.UncheckedGet<GfMatrix3f>());
}
if (value.IsHolding<GfMatrix4d>()) {
return convertMatrixToCycles<GfMatrix4d>(value.UncheckedGet<GfMatrix4d>());
}
if (value.IsHolding<GfMatrix3d>()) {
return convertMatrixToCycles<GfMatrix3d>(value.UncheckedGet<GfMatrix3d>());
}
if (value.CanCast<GfMatrix4f>()) {
return convertToCycles<Transform>(VtValue::Cast<GfMatrix4f>(value));
}
if (value.CanCast<GfMatrix3f>()) {
return convertToCycles<Transform>(VtValue::Cast<GfMatrix3f>(value));
}
if (value.CanCast<GfMatrix4d>()) {
return convertToCycles<Transform>(VtValue::Cast<GfMatrix4d>(value));
}
if (value.CanCast<GfMatrix3d>()) {
return convertToCycles<Transform>(VtValue::Cast<GfMatrix3d>(value));
}
TF_WARN("Could not convert VtValue to Transform");
return transform_identity();
}
template<typename DstType, typename SrcType = DstType>
array<DstType> convertToCyclesArray(const VtValue &value)
{
static_assert(sizeof(DstType) == sizeof(SrcType),
"Size mismatch between VtArray and array base type");
using SrcArray = VtArray<SrcType>;
if (value.IsHolding<SrcArray>()) {
const auto &valueData = value.UncheckedGet<SrcArray>();
array<DstType> cyclesArray;
cyclesArray.resize(valueData.size());
std::memcpy(cyclesArray.data(), valueData.data(), valueData.size() * sizeof(DstType));
return cyclesArray;
}
if (value.CanCast<SrcArray>()) {
VtValue castedValue = VtValue::Cast<SrcArray>(value);
const auto &valueData = castedValue.UncheckedGet<SrcArray>();
array<DstType> cyclesArray;
cyclesArray.resize(valueData.size());
std::memcpy(cyclesArray.data(), valueData.data(), valueData.size() * sizeof(DstType));
return cyclesArray;
}
return array<DstType>();
}
template<> array<float3> convertToCyclesArray<float3, GfVec3f>(const VtValue &value)
{
if (value.IsHolding<VtVec3fArray>()) {
const auto &valueData = value.UncheckedGet<VtVec3fArray>();
array<float3> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const GfVec3f &vec : valueData) {
cyclesArray.push_back_reserved(make_float3(vec[0], vec[1], vec[2]));
}
return cyclesArray;
}
if (value.IsHolding<VtVec4fArray>()) {
const auto &valueData = value.UncheckedGet<VtVec4fArray>();
array<float3> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const GfVec4f &vec : valueData) {
cyclesArray.push_back_reserved(make_float3(vec[0], vec[1], vec[2]));
}
return cyclesArray;
}
if (value.CanCast<VtVec3fArray>()) {
return convertToCyclesArray<float3, GfVec3f>(VtValue::Cast<VtVec3fArray>(value));
}
if (value.CanCast<VtVec4fArray>()) {
return convertToCyclesArray<float3, GfVec3f>(VtValue::Cast<VtVec4fArray>(value));
}
return array<float3>();
}
template<> array<ustring> convertToCyclesArray<ustring, void>(const VtValue &value)
{
using SdfPathArray = VtArray<SdfAssetPath>;
if (value.IsHolding<VtStringArray>()) {
const auto &valueData = value.UncheckedGet<VtStringArray>();
array<ustring> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const auto &element : valueData) {
cyclesArray.push_back_reserved(ustring(element));
}
return cyclesArray;
}
if (value.IsHolding<VtTokenArray>()) {
const auto &valueData = value.UncheckedGet<VtTokenArray>();
array<ustring> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const auto &element : valueData) {
cyclesArray.push_back_reserved(ustring(element.GetString()));
}
return cyclesArray;
}
if (value.IsHolding<SdfPathArray>()) {
const auto &valueData = value.UncheckedGet<SdfPathArray>();
array<ustring> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const auto &element : valueData) {
cyclesArray.push_back_reserved(ustring(element.GetResolvedPath()));
}
return cyclesArray;
}
if (value.CanCast<VtStringArray>()) {
return convertToCyclesArray<ustring, void>(VtValue::Cast<VtStringArray>(value));
}
if (value.CanCast<VtTokenArray>()) {
return convertToCyclesArray<ustring, void>(VtValue::Cast<VtTokenArray>(value));
}
if (value.CanCast<SdfPathArray>()) {
return convertToCyclesArray<ustring, void>(VtValue::Cast<SdfPathArray>(value));
}
TF_WARN("Could not convert VtValue to array<ustring>");
return array<ustring>();
}
template<typename MatrixArray> array<Transform> convertToCyclesTransformArray(const VtValue &value)
{
assert(value.IsHolding<MatrixArray>());
const auto &valueData = value.UncheckedGet<MatrixArray>();
array<Transform> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const auto &element : valueData) {
cyclesArray.push_back_reserved(
convertMatrixToCycles<typename MatrixArray::value_type>(element));
}
return cyclesArray;
}
template<> array<Transform> convertToCyclesArray<Transform, void>(const VtValue &value)
{
if (value.IsHolding<VtMatrix4fArray>()) {
return convertToCyclesTransformArray<VtMatrix4fArray>(value);
}
if (value.IsHolding<VtMatrix3fArray>()) {
return convertToCyclesTransformArray<VtMatrix3fArray>(value);
}
if (value.IsHolding<VtMatrix4dArray>()) {
return convertToCyclesTransformArray<VtMatrix4dArray>(value);
}
if (value.IsHolding<VtMatrix3dArray>()) {
return convertToCyclesTransformArray<VtMatrix3dArray>(value);
}
if (value.CanCast<VtMatrix4fArray>()) {
return convertToCyclesTransformArray<VtMatrix4fArray>(VtValue::Cast<VtMatrix4fArray>(value));
}
if (value.CanCast<VtMatrix3fArray>()) {
return convertToCyclesTransformArray<VtMatrix3fArray>(VtValue::Cast<VtMatrix3fArray>(value));
}
if (value.CanCast<VtMatrix4dArray>()) {
return convertToCyclesTransformArray<VtMatrix4dArray>(VtValue::Cast<VtMatrix4dArray>(value));
}
if (value.CanCast<VtMatrix3dArray>()) {
return convertToCyclesTransformArray<VtMatrix3dArray>(VtValue::Cast<VtMatrix3dArray>(value));
}
TF_WARN("Could not convert VtValue to array<Transform>");
return array<Transform>();
}
template<typename SrcType> VtValue convertFromCycles(const SrcType &value)
{
return VtValue(value);
}
template<> VtValue convertFromCycles<float2>(const float2 &value)
{
const GfVec2f convertedValue(value.x, value.y);
return VtValue(convertedValue);
}
template<> VtValue convertFromCycles<float3>(const float3 &value)
{
const GfVec3f convertedValue(value.x, value.y, value.z);
return VtValue(convertedValue);
}
template<> VtValue convertFromCycles<ustring>(const ustring &value)
{
return VtValue(value.string());
}
GfMatrix4f convertMatrixFromCycles(const Transform &matrix)
{
return GfMatrix4f(matrix[0][0],
matrix[1][0],
matrix[2][0],
0.0f,
matrix[0][1],
matrix[1][1],
matrix[2][1],
0.0f,
matrix[0][2],
matrix[1][2],
matrix[2][2],
0.0f,
0.0f,
0.0f,
0.0f,
1.0f);
}
template<> VtValue convertFromCycles<Transform>(const Transform &value)
{
return VtValue(convertMatrixFromCycles(value));
}
template<typename SrcType, typename DstType = SrcType>
VtValue convertFromCyclesArray(const array<SrcType> &value)
{
static_assert(sizeof(DstType) == sizeof(SrcType),
"Size mismatch between VtArray and array base type");
VtArray<DstType> convertedValue;
convertedValue.resize(value.size());
std::memcpy(convertedValue.data(), value.data(), value.size() * sizeof(SrcType));
return VtValue(convertedValue);
}
template<> VtValue convertFromCyclesArray<float3, GfVec3f>(const array<float3> &value)
{
VtVec3fArray convertedValue;
convertedValue.reserve(value.size());
for (const auto &element : value) {
convertedValue.push_back(GfVec3f(element.x, element.y, element.z));
}
return VtValue(convertedValue);
}
template<> VtValue convertFromCyclesArray<ustring, void>(const array<ustring> &value)
{
VtStringArray convertedValue;
convertedValue.reserve(value.size());
for (const auto &element : value) {
convertedValue.push_back(element.string());
}
return VtValue(convertedValue);
}
template<> VtValue convertFromCyclesArray<Transform, void>(const array<Transform> &value)
{
VtMatrix4fArray convertedValue;
convertedValue.reserve(value.size());
for (const auto &element : value) {
convertedValue.push_back(convertMatrixFromCycles(element));
}
return VtValue(convertedValue);
}
} // namespace
void SetNodeValue(Node *node, const SocketType &socket, const VtValue &value)
{
switch (socket.type) {
default:
case SocketType::UNDEFINED:
TF_RUNTIME_ERROR("Unexpected conversion: SocketType::UNDEFINED");
break;
case SocketType::BOOLEAN:
node->set(socket, convertToCycles<bool>(value));
break;
case SocketType::FLOAT:
node->set(socket, convertToCycles<float>(value));
break;
case SocketType::INT:
node->set(socket, convertToCycles<int>(value));
break;
case SocketType::UINT:
node->set(socket, convertToCycles<unsigned int>(value));
break;
case SocketType::COLOR:
case SocketType::VECTOR:
case SocketType::POINT:
case SocketType::NORMAL:
node->set(socket, convertToCycles<float3>(value));
break;
case SocketType::POINT2:
node->set(socket, convertToCycles<float2>(value));
break;
case SocketType::CLOSURE:
// Handled by node connections
break;
case SocketType::STRING:
node->set(socket, convertToCycles<ustring>(value));
break;
case SocketType::ENUM:
// Enum's can accept a string or an int
if (value.IsHolding<TfToken>() || value.IsHolding<std::string>()) {
node->set(socket, convertToCycles<ustring>(value));
}
else {
node->set(socket, convertToCycles<int>(value));
}
break;
case SocketType::TRANSFORM:
node->set(socket, convertToCycles<Transform>(value));
break;
case SocketType::NODE:
// TODO: renderIndex->GetRprim()->cycles_node ?
TF_WARN("Unimplemented conversion: SocketType::NODE");
break;
case SocketType::BOOLEAN_ARRAY: {
auto cyclesArray = convertToCyclesArray<bool>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::FLOAT_ARRAY: {
auto cyclesArray = convertToCyclesArray<float>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::INT_ARRAY: {
auto cyclesArray = convertToCyclesArray<int>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::COLOR_ARRAY:
case SocketType::VECTOR_ARRAY:
case SocketType::POINT_ARRAY:
case SocketType::NORMAL_ARRAY: {
auto cyclesArray = convertToCyclesArray<float3, GfVec3f>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::POINT2_ARRAY: {
auto cyclesArray = convertToCyclesArray<float2, GfVec2f>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::STRING_ARRAY: {
auto cyclesArray = convertToCyclesArray<ustring, void>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::TRANSFORM_ARRAY: {
auto cyclesArray = convertToCyclesArray<Transform, void>(value);
node->set(socket, cyclesArray);
break;
}
case SocketType::NODE_ARRAY: {
// TODO: renderIndex->GetRprim()->cycles_node ?
TF_WARN("Unimplemented conversion: SocketType::NODE_ARRAY");
break;
}
}
}
VtValue GetNodeValue(const Node *node, const SocketType &socket)
{
switch (socket.type) {
default:
case SocketType::UNDEFINED:
TF_RUNTIME_ERROR("Unexpected conversion: SocketType::UNDEFINED");
return VtValue();
case SocketType::BOOLEAN:
return convertFromCycles(node->get_bool(socket));
case SocketType::FLOAT:
return convertFromCycles(node->get_float(socket));
case SocketType::INT:
return convertFromCycles(node->get_int(socket));
case SocketType::UINT:
return convertFromCycles(node->get_uint(socket));
case SocketType::COLOR:
case SocketType::VECTOR:
case SocketType::POINT:
case SocketType::NORMAL:
return convertFromCycles(node->get_float3(socket));
case SocketType::POINT2:
return convertFromCycles(node->get_float2(socket));
case SocketType::CLOSURE:
return VtValue();
case SocketType::STRING:
return convertFromCycles(node->get_string(socket));
case SocketType::ENUM:
return convertFromCycles(node->get_int(socket));
case SocketType::TRANSFORM:
return convertFromCycles(node->get_transform(socket));
case SocketType::NODE:
TF_WARN("Unimplemented conversion: SocketType::NODE");
return VtValue();
case SocketType::BOOLEAN_ARRAY:
return convertFromCyclesArray(node->get_bool_array(socket));
case SocketType::FLOAT_ARRAY:
return convertFromCyclesArray(node->get_float_array(socket));
case SocketType::INT_ARRAY:
return convertFromCyclesArray(node->get_int_array(socket));
case SocketType::COLOR_ARRAY:
case SocketType::VECTOR_ARRAY:
case SocketType::POINT_ARRAY:
case SocketType::NORMAL_ARRAY:
return convertFromCyclesArray<float3, GfVec3f>(node->get_float3_array(socket));
case SocketType::POINT2_ARRAY:
return convertFromCyclesArray<float2, GfVec2f>(node->get_float2_array(socket));
case SocketType::STRING_ARRAY:
return convertFromCyclesArray<ustring, void>(node->get_string_array(socket));
case SocketType::TRANSFORM_ARRAY:
return convertFromCyclesArray<Transform, void>(node->get_transform_array(socket));
case SocketType::NODE_ARRAY: {
TF_WARN("Unimplemented conversion: SocketType::NODE_ARRAY");
return VtValue();
}
}
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,18 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "graph/node.h"
#include "hydra/config.h"
#include <pxr/base/vt/value.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
void SetNodeValue(CCL_NS::Node *node, const CCL_NS::SocketType &socket, const VtValue &value);
VtValue GetNodeValue(const CCL_NS::Node *node, const CCL_NS::SocketType &socket);
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,78 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/output_driver.h"
#include "hydra/render_buffer.h"
#include "hydra/session.h"
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesOutputDriver::HdCyclesOutputDriver(HdCyclesSession *renderParam)
: _renderParam(renderParam)
{
}
void HdCyclesOutputDriver::write_render_tile(const Tile &tile)
{
update_render_tile(tile);
// Update convergence state of all render buffers
for (const HdRenderPassAovBinding &aovBinding : _renderParam->GetAovBindings()) {
if (const auto renderBuffer = static_cast<HdCyclesRenderBuffer *>(aovBinding.renderBuffer)) {
renderBuffer->SetConverged(true);
}
}
}
bool HdCyclesOutputDriver::update_render_tile(const Tile &tile)
{
std::vector<float> pixels;
for (const HdRenderPassAovBinding &aovBinding : _renderParam->GetAovBindings()) {
if (aovBinding == _renderParam->GetDisplayAovBinding()) {
continue; // Display AOV binding is already updated by Cycles display driver
}
if (const auto renderBuffer = static_cast<HdCyclesRenderBuffer *>(aovBinding.renderBuffer)) {
const HdFormat format = renderBuffer->GetFormat();
if (format == HdFormatInvalid) {
continue; // Skip invalid AOV bindings
}
const size_t channels = HdGetComponentCount(format);
// Avoid extra copy by mapping render buffer directly when dimensions/format match the tile
if (tile.offset.x == 0 && tile.offset.y == 0 && tile.size.x == renderBuffer->GetWidth() &&
tile.size.y == renderBuffer->GetHeight() &&
(format >= HdFormatFloat32 && format <= HdFormatFloat32Vec4)) {
float *const data = static_cast<float *>(renderBuffer->Map());
TF_VERIFY(tile.get_pass_pixels(aovBinding.aovName.GetString(), channels, data));
renderBuffer->Unmap();
}
else {
pixels.resize(channels * tile.size.x * tile.size.y);
if (tile.get_pass_pixels(aovBinding.aovName.GetString(), channels, pixels.data())) {
const bool isId = aovBinding.aovName == HdAovTokens->primId ||
aovBinding.aovName == HdAovTokens->elementId ||
aovBinding.aovName == HdAovTokens->instanceId;
renderBuffer->WritePixels(pixels.data(),
GfVec2i(tile.offset.x, tile.offset.y),
GfVec2i(tile.size.x, tile.size.y),
channels,
isId);
}
else {
// Do not warn on missing elementId, which is a standard AOV but is not implememted
if (aovBinding.aovName != HdAovTokens->elementId) {
TF_RUNTIME_ERROR("Could not find pass for AOV '%s'", aovBinding.aovName.GetText());
}
}
}
}
}
return true;
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,23 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "session/output_driver.h"
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesOutputDriver final : public CCL_NS::OutputDriver {
public:
HdCyclesOutputDriver(HdCyclesSession *renderParam);
private:
void write_render_tile(const Tile &tile) override;
bool update_render_tile(const Tile &tile) override;
HdCyclesSession *const _renderParam;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,3 +0,0 @@
{
"Includes": [ "*/resources/" ]
}

View File

@@ -1,71 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/plugin.h"
#include "hydra/render_delegate.h"
#include "util/log.h"
#include "util/path.h"
#include <pxr/base/arch/fileSystem.h>
#include <pxr/base/plug/plugin.h>
#include <pxr/base/plug/thisPlugin.h>
#include <pxr/base/tf/envSetting.h>
#include <pxr/imaging/hd/rendererPluginRegistry.h>
PXR_NAMESPACE_OPEN_SCOPE
#ifdef WITH_CYCLES_LOGGING
TF_DEFINE_ENV_SETTING(CYCLES_LOGGING, false, "Enable Cycles logging")
TF_DEFINE_ENV_SETTING(CYCLES_LOGGING_SEVERITY, 1, "Cycles logging verbosity")
#endif
HdCyclesPlugin::HdCyclesPlugin()
{
const PlugPluginPtr plugin = PLUG_THIS_PLUGIN;
// Initialize Cycles paths relative to the plugin resource path
std::string rootPath = PXR_NS::ArchAbsPath(plugin->GetResourcePath());
CCL_NS::path_init(std::move(rootPath));
#ifdef WITH_CYCLES_LOGGING
if (TfGetEnvSetting(CYCLES_LOGGING)) {
CCL_NS::util_logging_start();
CCL_NS::util_logging_verbosity_set(TfGetEnvSetting(CYCLES_LOGGING_SEVERITY));
}
#endif
}
HdCyclesPlugin::~HdCyclesPlugin()
{
}
bool HdCyclesPlugin::IsSupported() const
{
return true;
}
HdRenderDelegate *HdCyclesPlugin::CreateRenderDelegate()
{
return CreateRenderDelegate({});
}
HdRenderDelegate *HdCyclesPlugin::CreateRenderDelegate(const HdRenderSettingsMap &settingsMap)
{
return new HD_CYCLES_NS::HdCyclesDelegate(settingsMap);
}
void HdCyclesPlugin::DeleteRenderDelegate(HdRenderDelegate *renderDelegate)
{
delete renderDelegate;
}
// USD's type system accounts for namespace, so we'd have to register our name as
// HdCycles::HdCyclesPlugin in plugInfo.json, which isn't all that bad for JSON,
// but those colons may cause issues for any USD specific tooling. So just put our
// plugin class in the pxr namespace (which USD's type system will elide).
TF_REGISTRY_FUNCTION(TfType)
{
HdRendererPluginRegistry::Define<PXR_NS::HdCyclesPlugin>();
}
PXR_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,25 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/rendererPlugin.h>
PXR_NAMESPACE_OPEN_SCOPE
class HdCyclesPlugin final : public PXR_NS::HdRendererPlugin {
public:
HdCyclesPlugin();
~HdCyclesPlugin() override;
bool IsSupported() const override;
PXR_NS::HdRenderDelegate *CreateRenderDelegate() override;
PXR_NS::HdRenderDelegate *CreateRenderDelegate(const PXR_NS::HdRenderSettingsMap &) override;
void DeleteRenderDelegate(PXR_NS::HdRenderDelegate *) override;
};
PXR_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,199 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/pointcloud.h"
#include "hydra/geometry.inl"
#include "scene/pointcloud.h"
#include <pxr/imaging/hd/extComputationUtils.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesPoints::HdCyclesPoints(const SdfPath &rprimId
#if PXR_VERSION < 2102
,
const SdfPath &instancerId
#endif
)
: HdCyclesGeometry(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
)
{
}
HdCyclesPoints::~HdCyclesPoints()
{
}
HdDirtyBits HdCyclesPoints::GetInitialDirtyBitsMask() const
{
HdDirtyBits bits = HdCyclesGeometry::GetInitialDirtyBitsMask();
bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths |
HdChangeTracker::DirtyPrimvar;
return bits;
}
HdDirtyBits HdCyclesPoints::_PropagateDirtyBits(HdDirtyBits bits) const
{
// Points and widths always have to be updated together
if (bits & (HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths)) {
bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths;
}
return bits;
}
void HdCyclesPoints::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits, bool &rebuild)
{
if (dirtyBits & (HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths)) {
const size_t numPoints = _geom->num_points();
PopulatePoints(sceneDelegate);
PopulateWidths(sceneDelegate);
rebuild = _geom->num_points() != numPoints;
array<int> shaders;
shaders.reserve(_geom->num_points());
for (size_t i = 0; i < _geom->num_points(); ++i) {
shaders.push_back_reserved(0);
}
_geom->set_shader(shaders);
}
if (dirtyBits & HdChangeTracker::DirtyPrimvar) {
PopulatePrimvars(sceneDelegate);
}
}
void HdCyclesPoints::PopulatePoints(HdSceneDelegate *sceneDelegate)
{
VtValue value;
for (const HdExtComputationPrimvarDescriptor &desc :
sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) {
if (desc.name == HdTokens->points) {
auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate);
const auto valueStoreIt = valueStore.find(desc.name);
if (valueStoreIt != valueStore.end()) {
value = std::move(valueStoreIt->second);
}
break;
}
}
if (value.IsEmpty()) {
value = GetPrimvar(sceneDelegate, HdTokens->points);
}
if (!value.IsHolding<VtVec3fArray>()) {
TF_WARN("Invalid points data for %s", GetId().GetText());
return;
}
const auto &points = value.UncheckedGet<VtVec3fArray>();
array<float3> pointsDataCycles;
pointsDataCycles.reserve(points.size());
for (const GfVec3f &point : points) {
pointsDataCycles.push_back_reserved(make_float3(point[0], point[1], point[2]));
}
_geom->set_points(pointsDataCycles);
}
void HdCyclesPoints::PopulateWidths(HdSceneDelegate *sceneDelegate)
{
VtValue value = GetPrimvar(sceneDelegate, HdTokens->widths);
const HdInterpolation interpolation = GetPrimvarInterpolation(sceneDelegate, HdTokens->widths);
if (!value.IsHolding<VtFloatArray>()) {
TF_WARN("Invalid widths data for %s", GetId().GetText());
return;
}
const auto &widths = value.UncheckedGet<VtFloatArray>();
array<float> radiusDataCycles;
radiusDataCycles.reserve(_geom->num_points());
if (interpolation == HdInterpolationConstant) {
TF_VERIFY(widths.size() == 1);
const float constantRadius = widths[0] * 0.5f;
for (size_t i = 0; i < _geom->num_points(); ++i) {
radiusDataCycles.push_back_reserved(constantRadius);
}
}
else if (interpolation == HdInterpolationVertex) {
TF_VERIFY(widths.size() == _geom->num_points());
for (size_t i = 0; i < _geom->num_points(); ++i) {
radiusDataCycles.push_back_reserved(widths[i] * 0.5f);
}
}
_geom->set_radius(radiusDataCycles);
}
void HdCyclesPoints::PopulatePrimvars(HdSceneDelegate *sceneDelegate)
{
Scene *const scene = (Scene *)_geom->get_owner();
const std::pair<HdInterpolation, AttributeElement> interpolations[] = {
std::make_pair(HdInterpolationVertex, ATTR_ELEMENT_VERTEX),
std::make_pair(HdInterpolationConstant, ATTR_ELEMENT_OBJECT),
};
for (const auto &interpolation : interpolations) {
for (const HdPrimvarDescriptor &desc :
GetPrimvarDescriptors(sceneDelegate, interpolation.first)) {
// Skip special primvars that are handled separately
if (desc.name == HdTokens->points || desc.name == HdTokens->widths) {
continue;
}
VtValue value = GetPrimvar(sceneDelegate, desc.name);
if (value.IsEmpty()) {
continue;
}
const ustring name(desc.name.GetString());
AttributeStandard std = ATTR_STD_NONE;
if (desc.role == HdPrimvarRoleTokens->textureCoordinate) {
std = ATTR_STD_UV;
}
else if (interpolation.first == HdInterpolationVertex) {
if (desc.name == HdTokens->displayColor || desc.role == HdPrimvarRoleTokens->color) {
std = ATTR_STD_VERTEX_COLOR;
}
else if (desc.name == HdTokens->normals) {
std = ATTR_STD_VERTEX_NORMAL;
}
}
else if (desc.name == HdTokens->displayColor &&
interpolation.first == HdInterpolationConstant) {
if (value.IsHolding<VtVec3fArray>() && value.GetArraySize() == 1) {
const GfVec3f color = value.UncheckedGet<VtVec3fArray>()[0];
_instances[0]->set_color(make_float3(color[0], color[1], color[2]));
}
}
// Skip attributes that are not needed
if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) ||
_geom->need_attribute(scene, name)) {
ApplyPrimvars(_geom->attributes, name, value, interpolation.second, std);
}
}
}
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,40 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "hydra/geometry.h"
#include <pxr/imaging/hd/points.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesPoints final : public HdCyclesGeometry<PXR_NS::HdPoints, CCL_NS::PointCloud> {
public:
HdCyclesPoints(
const PXR_NS::SdfPath &rprimId
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId = {}
#endif
);
~HdCyclesPoints() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
private:
PXR_NS::HdDirtyBits _PropagateDirtyBits(PXR_NS::HdDirtyBits bits) const override;
void Populate(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdDirtyBits dirtyBits,
bool &rebuild) override;
void PopulatePoints(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulateWidths(PXR_NS::HdSceneDelegate *sceneDelegate);
void PopulatePrimvars(PXR_NS::HdSceneDelegate *sceneDelegate);
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,276 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/render_buffer.h"
#include "hydra/session.h"
#include "util/half.h"
#include <pxr/base/gf/vec3i.h>
#include <pxr/base/gf/vec4f.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesRenderBuffer::HdCyclesRenderBuffer(const SdfPath &bprimId) : HdRenderBuffer(bprimId)
{
}
HdCyclesRenderBuffer::~HdCyclesRenderBuffer()
{
}
void HdCyclesRenderBuffer::Finalize(HdRenderParam *renderParam)
{
// Remove this render buffer from AOV bindings
// This ensures that 'OutputDriver' does not attempt to write to it anymore
static_cast<HdCyclesSession *>(renderParam)->RemoveAovBinding(this);
HdRenderBuffer::Finalize(renderParam);
}
bool HdCyclesRenderBuffer::Allocate(const GfVec3i &dimensions, HdFormat format, bool multiSampled)
{
if (dimensions[2] != 1) {
TF_RUNTIME_ERROR("HdCyclesRenderBuffer::Allocate called with dimensions that are not 2D.");
return false;
}
const size_t oldSize = _data.size();
const size_t newSize = dimensions[0] * dimensions[1] * HdDataSizeOfFormat(format);
if (oldSize == newSize) {
return true;
}
if (IsMapped()) {
TF_RUNTIME_ERROR("HdCyclesRenderBuffer::Allocate called while buffer is mapped.");
return false;
}
_width = dimensions[0];
_height = dimensions[1];
_format = format;
_data.resize(newSize);
return true;
}
void HdCyclesRenderBuffer::_Deallocate()
{
_width = 0u;
_height = 0u;
_format = HdFormatInvalid;
_data.clear();
_data.shrink_to_fit();
_resource = VtValue();
}
void *HdCyclesRenderBuffer::Map()
{
// Mapping is not implemented when a resource is set
if (!_resource.IsEmpty()) {
return nullptr;
}
++_mapped;
return _data.data();
}
void HdCyclesRenderBuffer::Unmap()
{
--_mapped;
}
bool HdCyclesRenderBuffer::IsMapped() const
{
return _mapped != 0;
}
void HdCyclesRenderBuffer::Resolve()
{
}
bool HdCyclesRenderBuffer::IsConverged() const
{
return _converged;
}
void HdCyclesRenderBuffer::SetConverged(bool converged)
{
_converged = converged;
}
VtValue HdCyclesRenderBuffer::GetResource(bool multiSampled) const
{
TF_UNUSED(multiSampled);
return _resource;
}
void HdCyclesRenderBuffer::SetResource(const VtValue &resource)
{
_resource = resource;
}
namespace {
struct SimpleConversion {
static float convert(float value)
{
return value;
}
};
struct IdConversion {
static int32_t convert(float value)
{
return static_cast<int32_t>(value) - 1;
}
};
struct UInt8Conversion {
static uint8_t convert(float value)
{
return static_cast<uint8_t>(value * 255.f);
}
};
struct SInt8Conversion {
static int8_t convert(float value)
{
return static_cast<int8_t>(value * 127.f);
}
};
struct HalfConversion {
static half convert(float value)
{
return float_to_half_image(value);
}
};
template<typename SrcT, typename DstT, typename Convertor = SimpleConversion>
void writePixels(const SrcT *srcPtr,
const GfVec2i &srcSize,
int srcChannelCount,
DstT *dstPtr,
const GfVec2i &dstSize,
int dstChannelCount,
const Convertor &convertor = {})
{
const auto writeSize = GfVec2i(GfMin(srcSize[0], dstSize[0]), GfMin(srcSize[1], dstSize[1]));
const auto writeChannelCount = GfMin(srcChannelCount, dstChannelCount);
for (int y = 0; y < writeSize[1]; ++y) {
for (int x = 0; x < writeSize[0]; ++x) {
for (int c = 0; c < writeChannelCount; ++c) {
dstPtr[x * dstChannelCount + c] = convertor.convert(srcPtr[x * srcChannelCount + c]);
}
}
srcPtr += srcSize[0] * srcChannelCount;
dstPtr += dstSize[0] * dstChannelCount;
}
}
} // namespace
void HdCyclesRenderBuffer::WritePixels(const float *srcPixels,
const PXR_NS::GfVec2i &srcOffset,
const GfVec2i &srcDims,
int srcChannels,
bool isId)
{
uint8_t *dstPixels = _data.data();
const size_t formatSize = HdDataSizeOfFormat(_format);
dstPixels += srcOffset[1] * (formatSize * _width) + srcOffset[0] * formatSize;
switch (_format) {
case HdFormatUNorm8:
case HdFormatUNorm8Vec2:
case HdFormatUNorm8Vec3:
case HdFormatUNorm8Vec4:
writePixels(srcPixels,
srcDims,
srcChannels,
dstPixels,
GfVec2i(_width, _height),
1 + (_format - HdFormatUNorm8),
UInt8Conversion());
break;
case HdFormatSNorm8:
case HdFormatSNorm8Vec2:
case HdFormatSNorm8Vec3:
case HdFormatSNorm8Vec4:
writePixels(srcPixels,
srcDims,
srcChannels,
dstPixels,
GfVec2i(_width, _height),
1 + (_format - HdFormatSNorm8),
SInt8Conversion());
break;
case HdFormatFloat16:
case HdFormatFloat16Vec2:
case HdFormatFloat16Vec3:
case HdFormatFloat16Vec4:
writePixels(srcPixels,
srcDims,
srcChannels,
reinterpret_cast<half *>(dstPixels),
GfVec2i(_width, _height),
1 + (_format - HdFormatFloat16),
HalfConversion());
break;
case HdFormatFloat32:
case HdFormatFloat32Vec2:
case HdFormatFloat32Vec3:
case HdFormatFloat32Vec4:
writePixels(srcPixels,
srcDims,
srcChannels,
reinterpret_cast<float *>(dstPixels),
GfVec2i(_width, _height),
1 + (_format - HdFormatFloat32));
break;
case HdFormatInt32:
// Special case for ID AOVs (see 'HdCyclesMesh::Sync')
if (isId) {
writePixels(srcPixels,
srcDims,
srcChannels,
reinterpret_cast<int *>(dstPixels),
GfVec2i(_width, _height),
1,
IdConversion());
}
else {
writePixels(srcPixels,
srcDims,
srcChannels,
reinterpret_cast<int *>(dstPixels),
GfVec2i(_width, _height),
1);
}
break;
case HdFormatInt32Vec2:
case HdFormatInt32Vec3:
case HdFormatInt32Vec4:
writePixels(srcPixels,
srcDims,
srcChannels,
reinterpret_cast<int *>(dstPixels),
GfVec2i(_width, _height),
1 + (_format - HdFormatInt32));
break;
default:
TF_RUNTIME_ERROR("HdCyclesRenderBuffer::WritePixels called with unsupported format.");
break;
}
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,85 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/renderBuffer.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesRenderBuffer final : public PXR_NS::HdRenderBuffer {
public:
HdCyclesRenderBuffer(const PXR_NS::SdfPath &bprimId);
~HdCyclesRenderBuffer() override;
void Finalize(PXR_NS::HdRenderParam *renderParam) override;
bool Allocate(const PXR_NS::GfVec3i &dimensions,
PXR_NS::HdFormat format,
bool multiSampled) override;
unsigned int GetWidth() const override
{
return _width;
}
unsigned int GetHeight() const override
{
return _height;
}
unsigned int GetDepth() const override
{
return 1u;
}
PXR_NS::HdFormat GetFormat() const override
{
return _format;
}
bool IsMultiSampled() const override
{
return false;
}
void *Map() override;
void Unmap() override;
bool IsMapped() const override;
void Resolve() override;
bool IsConverged() const override;
void SetConverged(bool converged);
PXR_NS::VtValue GetResource(bool multiSampled = false) const override;
void SetResource(const PXR_NS::VtValue &resource);
void WritePixels(const float *pixels,
const PXR_NS::GfVec2i &offset,
const PXR_NS::GfVec2i &dims,
int channels,
bool isId = false);
private:
void _Deallocate() override;
unsigned int _width = 0u;
unsigned int _height = 0u;
PXR_NS::HdFormat _format = PXR_NS::HdFormatInvalid;
std::vector<uint8_t> _data;
PXR_NS::VtValue _resource;
std::atomic_int _mapped = 0;
std::atomic_bool _converged = false;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,515 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/render_delegate.h"
#include "hydra/camera.h"
#include "hydra/curves.h"
#include "hydra/field.h"
#include "hydra/instancer.h"
#include "hydra/light.h"
#include "hydra/material.h"
#include "hydra/mesh.h"
#include "hydra/node_util.h"
#include "hydra/pointcloud.h"
#include "hydra/render_buffer.h"
#include "hydra/render_pass.h"
#include "hydra/session.h"
#include "hydra/volume.h"
#include "scene/integrator.h"
#include "scene/scene.h"
#include "session/session.h"
#include <pxr/base/tf/getenv.h>
#include <pxr/imaging/hd/extComputation.h>
#include <pxr/imaging/hgi/tokens.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(cycles)
(openvdbAsset)
);
TF_DEFINE_PRIVATE_TOKENS(HdCyclesRenderSettingsTokens,
((device, "cycles:device"))
((threads, "cycles:threads"))
((time_limit, "cycles:time_limit"))
((samples, "cycles:samples"))
((sample_offset, "cycles:sample_offset"))
);
// clang-format on
namespace {
const TfTokenVector kSupportedRPrimTypes = {
HdPrimTypeTokens->basisCurves,
HdPrimTypeTokens->mesh,
HdPrimTypeTokens->points,
#ifdef WITH_OPENVDB
HdPrimTypeTokens->volume,
#endif
};
const TfTokenVector kSupportedSPrimTypes = {
HdPrimTypeTokens->camera,
HdPrimTypeTokens->material,
HdPrimTypeTokens->diskLight,
HdPrimTypeTokens->distantLight,
HdPrimTypeTokens->domeLight,
HdPrimTypeTokens->rectLight,
HdPrimTypeTokens->sphereLight,
HdPrimTypeTokens->extComputation,
};
const TfTokenVector kSupportedBPrimTypes = {
HdPrimTypeTokens->renderBuffer,
#ifdef WITH_OPENVDB
_tokens->openvdbAsset,
#endif
};
SessionParams GetSessionParams(const HdRenderSettingsMap &settings)
{
SessionParams params;
params.threads = 0;
params.background = false;
params.use_resolution_divider = false;
HdRenderSettingsMap::const_iterator it;
// Pull all setting that contribute to device creation first
it = settings.find(HdCyclesRenderSettingsTokens->threads);
if (it != settings.end()) {
params.threads = VtValue::Cast<int>(it->second).GetWithDefault(params.threads);
}
// Get the Cycles device from settings or environment, falling back to CPU
std::string deviceType = Device::string_from_type(DEVICE_CPU);
it = settings.find(HdCyclesRenderSettingsTokens->device);
if (it != settings.end()) {
deviceType = VtValue::Cast<std::string>(it->second).GetWithDefault(deviceType);
}
else {
const std::string deviceTypeEnv = TfGetenv("CYCLES_DEVICE");
if (!deviceTypeEnv.empty()) {
deviceType = deviceTypeEnv;
}
}
// Move to all uppercase for Device::type_from_string
std::transform(deviceType.begin(), deviceType.end(), deviceType.begin(), ::toupper);
vector<DeviceInfo> devices = Device::available_devices(
DEVICE_MASK(Device::type_from_string(deviceType.c_str())));
if (devices.empty()) {
devices = Device::available_devices(DEVICE_MASK_CPU);
if (!devices.empty()) {
params.device = devices.front();
}
}
else {
params.device = Device::get_multi_device(devices, params.threads, params.background);
}
return params;
}
} // namespace
HdCyclesDelegate::HdCyclesDelegate(const HdRenderSettingsMap &settingsMap, Session *session_)
: HdRenderDelegate()
{
_renderParam = session_ ? std::make_unique<HdCyclesSession>(session_) :
std::make_unique<HdCyclesSession>(GetSessionParams(settingsMap));
// If the delegate owns the session, pull any remaining settings
if (!session_) {
for (const auto &setting : settingsMap) {
// Skip over the settings known to be used for initialization only
if (setting.first == HdCyclesRenderSettingsTokens->device ||
setting.first == HdCyclesRenderSettingsTokens->threads) {
continue;
}
SetRenderSetting(setting.first, setting.second);
}
}
}
HdCyclesDelegate::~HdCyclesDelegate()
{
}
void HdCyclesDelegate::SetDrivers(const HdDriverVector &drivers)
{
for (HdDriver *hdDriver : drivers) {
if (hdDriver->name == HgiTokens->renderDriver && hdDriver->driver.IsHolding<Hgi *>()) {
_hgi = hdDriver->driver.UncheckedGet<Hgi *>();
break;
}
}
}
bool HdCyclesDelegate::IsDisplaySupported() const
{
#ifdef _WIN32
return _hgi && _hgi->GetAPIName() == HgiTokens->OpenGL;
#else
return false;
#endif
}
const TfTokenVector &HdCyclesDelegate::GetSupportedRprimTypes() const
{
return kSupportedRPrimTypes;
}
const TfTokenVector &HdCyclesDelegate::GetSupportedSprimTypes() const
{
return kSupportedSPrimTypes;
}
const TfTokenVector &HdCyclesDelegate::GetSupportedBprimTypes() const
{
return kSupportedBPrimTypes;
}
HdRenderParam *HdCyclesDelegate::GetRenderParam() const
{
return _renderParam.get();
}
HdResourceRegistrySharedPtr HdCyclesDelegate::GetResourceRegistry() const
{
return HdResourceRegistrySharedPtr();
}
bool HdCyclesDelegate::IsPauseSupported() const
{
return true;
}
bool HdCyclesDelegate::Pause()
{
_renderParam->session->set_pause(true);
return true;
}
bool HdCyclesDelegate::Resume()
{
_renderParam->session->set_pause(false);
return true;
}
HdRenderPassSharedPtr HdCyclesDelegate::CreateRenderPass(HdRenderIndex *index,
const HdRprimCollection &collection)
{
return HdRenderPassSharedPtr(new HdCyclesRenderPass(index, collection, _renderParam.get()));
}
HdInstancer *HdCyclesDelegate::CreateInstancer(HdSceneDelegate *delegate,
const SdfPath &instancerId
#if PXR_VERSION < 2102
,
const SdfPath &parentId
#endif
)
{
return new HdCyclesInstancer(delegate,
instancerId
#if PXR_VERSION < 2102
,
parentId
#endif
);
}
void HdCyclesDelegate::DestroyInstancer(HdInstancer *instancer)
{
delete instancer;
}
HdRprim *HdCyclesDelegate::CreateRprim(const TfToken &typeId,
const SdfPath &rprimId
#if PXR_VERSION < 2102
,
const SdfPath &instancerId
#endif
)
{
if (typeId == HdPrimTypeTokens->mesh) {
return new HdCyclesMesh(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
);
}
if (typeId == HdPrimTypeTokens->basisCurves) {
return new HdCyclesCurves(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
);
}
if (typeId == HdPrimTypeTokens->points) {
return new HdCyclesPoints(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
);
}
#ifdef WITH_OPENVDB
if (typeId == HdPrimTypeTokens->volume) {
return new HdCyclesVolume(rprimId
# if PXR_VERSION < 2102
,
instancerId
# endif
);
}
#endif
TF_CODING_ERROR("Unknown Rprim type %s", typeId.GetText());
return nullptr;
}
void HdCyclesDelegate::DestroyRprim(HdRprim *rPrim)
{
delete rPrim;
}
HdSprim *HdCyclesDelegate::CreateSprim(const TfToken &typeId, const SdfPath &sprimId)
{
if (typeId == HdPrimTypeTokens->camera) {
return new HdCyclesCamera(sprimId);
}
if (typeId == HdPrimTypeTokens->material) {
return new HdCyclesMaterial(sprimId);
}
if (typeId == HdPrimTypeTokens->diskLight || typeId == HdPrimTypeTokens->distantLight ||
typeId == HdPrimTypeTokens->domeLight || typeId == HdPrimTypeTokens->rectLight ||
typeId == HdPrimTypeTokens->sphereLight) {
return new HdCyclesLight(sprimId, typeId);
}
if (typeId == HdPrimTypeTokens->extComputation) {
return new HdExtComputation(sprimId);
}
TF_CODING_ERROR("Unknown Sprim type %s", typeId.GetText());
return nullptr;
}
HdSprim *HdCyclesDelegate::CreateFallbackSprim(const TfToken &typeId)
{
return CreateSprim(typeId, SdfPath::EmptyPath());
}
void HdCyclesDelegate::DestroySprim(HdSprim *sPrim)
{
delete sPrim;
}
HdBprim *HdCyclesDelegate::CreateBprim(const TfToken &typeId, const SdfPath &bprimId)
{
if (typeId == HdPrimTypeTokens->renderBuffer) {
return new HdCyclesRenderBuffer(bprimId);
}
#ifdef WITH_OPENVDB
if (typeId == _tokens->openvdbAsset) {
return new HdCyclesField(bprimId, typeId);
}
#endif
TF_RUNTIME_ERROR("Unknown Bprim type %s", typeId.GetText());
return nullptr;
}
HdBprim *HdCyclesDelegate::CreateFallbackBprim(const TfToken &typeId)
{
return CreateBprim(typeId, SdfPath::EmptyPath());
}
void HdCyclesDelegate::DestroyBprim(HdBprim *bPrim)
{
delete bPrim;
}
void HdCyclesDelegate::CommitResources(HdChangeTracker *tracker)
{
TF_UNUSED(tracker);
const SceneLock lock(_renderParam.get());
_renderParam->UpdateScene();
}
TfToken HdCyclesDelegate::GetMaterialBindingPurpose() const
{
return HdTokens->full;
}
#if HD_API_VERSION < 41
TfToken HdCyclesDelegate::GetMaterialNetworkSelector() const
{
return _tokens->cycles;
}
#else
TfTokenVector HdCyclesDelegate::GetMaterialRenderContexts() const
{
return {_tokens->cycles};
}
#endif
VtDictionary HdCyclesDelegate::GetRenderStats() const
{
const Stats &stats = _renderParam->session->stats;
const Progress &progress = _renderParam->session->progress;
double totalTime, renderTime;
progress.get_time(totalTime, renderTime);
double fractionDone = progress.get_progress();
std::string status, substatus;
progress.get_status(status, substatus);
if (!substatus.empty()) {
status += " | " + substatus;
}
return {{"rendererName", VtValue("Cycles")},
{"rendererVersion", VtValue(GfVec3i(0, 0, 0))},
{"percentDone", VtValue(floor_to_int(fractionDone * 100))},
{"fractionDone", VtValue(fractionDone)},
{"loadClockTime", VtValue(totalTime - renderTime)},
{"peakMemory", VtValue(stats.mem_peak)},
{"totalClockTime", VtValue(totalTime)},
{"totalMemory", VtValue(stats.mem_used)},
{"renderProgressAnnotation", VtValue(status)}};
}
HdAovDescriptor HdCyclesDelegate::GetDefaultAovDescriptor(const TfToken &name) const
{
if (name == HdAovTokens->color) {
HdFormat colorFormat = HdFormatFloat32Vec4;
if (IsDisplaySupported()) {
// Can use Cycles 'DisplayDriver' in OpenGL, but it only supports 'half4' format
colorFormat = HdFormatFloat16Vec4;
}
return HdAovDescriptor(colorFormat, false, VtValue(GfVec4f(0.0f)));
}
if (name == HdAovTokens->depth) {
return HdAovDescriptor(HdFormatFloat32, false, VtValue(1.0f));
}
if (name == HdAovTokens->normal) {
return HdAovDescriptor(HdFormatFloat32Vec3, false, VtValue(GfVec3f(0.0f)));
}
if (name == HdAovTokens->primId || name == HdAovTokens->instanceId ||
name == HdAovTokens->elementId) {
return HdAovDescriptor(HdFormatInt32, false, VtValue(-1));
}
return HdAovDescriptor();
}
HdRenderSettingDescriptorList HdCyclesDelegate::GetRenderSettingDescriptors() const
{
Scene *const scene = _renderParam->session->scene;
HdRenderSettingDescriptorList descriptors;
descriptors.push_back({
"Time Limit",
HdCyclesRenderSettingsTokens->time_limit,
VtValue(0.0),
});
descriptors.push_back({
"Sample Count",
HdCyclesRenderSettingsTokens->samples,
VtValue(1024),
});
descriptors.push_back({
"Sample Offset",
HdCyclesRenderSettingsTokens->sample_offset,
VtValue(0),
});
for (const SocketType &socket : scene->integrator->type->inputs) {
descriptors.push_back({socket.ui_name.string(),
TfToken("cycles:integrator:" + socket.name.string()),
GetNodeValue(scene->integrator, socket)});
}
return descriptors;
}
void HdCyclesDelegate::SetRenderSetting(const PXR_NS::TfToken &key, const PXR_NS::VtValue &value)
{
Scene *const scene = _renderParam->session->scene;
Session *const session = _renderParam->session;
if (key == HdCyclesRenderSettingsTokens->time_limit) {
session->set_time_limit(
VtValue::Cast<double>(value).GetWithDefault(session->params.time_limit));
}
else if (key == HdCyclesRenderSettingsTokens->samples) {
static const int max_samples = Integrator::MAX_SAMPLES;
int samples = VtValue::Cast<int>(value).GetWithDefault(session->params.samples);
samples = std::min(std::max(1, samples), max_samples);
session->set_samples(samples);
}
else if (key == HdCyclesRenderSettingsTokens->sample_offset) {
session->params.sample_offset = VtValue::Cast<int>(value).GetWithDefault(
session->params.sample_offset);
++_settingsVersion;
}
else {
const std::string &keyString = key.GetString();
if (keyString.rfind("cycles:integrator:", 0) == 0) {
ustring socketName(keyString, sizeof("cycles:integrator:") - 1);
if (const SocketType *socket = scene->integrator->type->find_input(socketName)) {
SetNodeValue(scene->integrator, *socket, value);
++_settingsVersion;
}
}
}
}
VtValue HdCyclesDelegate::GetRenderSetting(const TfToken &key) const
{
Scene *const scene = _renderParam->session->scene;
Session *const session = _renderParam->session;
if (key == HdCyclesRenderSettingsTokens->device) {
return VtValue(TfToken(Device::string_from_type(session->params.device.type)));
}
else if (key == HdCyclesRenderSettingsTokens->threads) {
return VtValue(session->params.threads);
}
else if (key == HdCyclesRenderSettingsTokens->time_limit) {
return VtValue(session->params.time_limit);
}
else if (key == HdCyclesRenderSettingsTokens->samples) {
return VtValue(session->params.samples);
}
else if (key == HdCyclesRenderSettingsTokens->sample_offset) {
return VtValue(session->params.sample_offset);
}
else {
const std::string &keyString = key.GetString();
if (keyString.rfind("cycles:integrator:", 0) == 0) {
ustring socketName(keyString, sizeof("cycles:integrator:") - 1);
if (const SocketType *socket = scene->integrator->type->find_input(socketName)) {
return GetNodeValue(scene->integrator, *socket);
}
}
}
return VtValue();
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,98 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/renderDelegate.h>
#include <pxr/imaging/hgi/hgi.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesDelegate final : public PXR_NS::HdRenderDelegate {
public:
HdCyclesDelegate(const PXR_NS::HdRenderSettingsMap &settingsMap,
CCL_NS::Session *session_ = nullptr);
~HdCyclesDelegate() override;
void SetDrivers(const PXR_NS::HdDriverVector &drivers) override;
bool IsDisplaySupported() const;
PXR_NS::Hgi *GetHgi() const
{
return _hgi;
}
const PXR_NS::TfTokenVector &GetSupportedRprimTypes() const override;
const PXR_NS::TfTokenVector &GetSupportedSprimTypes() const override;
const PXR_NS::TfTokenVector &GetSupportedBprimTypes() const override;
PXR_NS::HdRenderParam *GetRenderParam() const override;
PXR_NS::HdResourceRegistrySharedPtr GetResourceRegistry() const override;
PXR_NS::HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override;
bool IsPauseSupported() const override;
bool Pause() override;
bool Resume() override;
PXR_NS::HdRenderPassSharedPtr CreateRenderPass(
PXR_NS::HdRenderIndex *index, const PXR_NS::HdRprimCollection &collection) override;
PXR_NS::HdInstancer *CreateInstancer(PXR_NS::HdSceneDelegate *delegate,
const PXR_NS::SdfPath &id
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId
#endif
) override;
void DestroyInstancer(PXR_NS::HdInstancer *instancer) override;
PXR_NS::HdRprim *CreateRprim(const PXR_NS::TfToken &typeId,
const PXR_NS::SdfPath &rprimId
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId
#endif
) override;
void DestroyRprim(PXR_NS::HdRprim *rPrim) override;
PXR_NS::HdSprim *CreateSprim(const PXR_NS::TfToken &typeId,
const PXR_NS::SdfPath &sprimId) override;
PXR_NS::HdSprim *CreateFallbackSprim(const PXR_NS::TfToken &typeId) override;
void DestroySprim(PXR_NS::HdSprim *sPrim) override;
PXR_NS::HdBprim *CreateBprim(const PXR_NS::TfToken &typeId,
const PXR_NS::SdfPath &bprimId) override;
PXR_NS::HdBprim *CreateFallbackBprim(const PXR_NS::TfToken &typeId) override;
void DestroyBprim(PXR_NS::HdBprim *bPrim) override;
void CommitResources(PXR_NS::HdChangeTracker *tracker) override;
PXR_NS::TfToken GetMaterialBindingPurpose() const override;
#if HD_API_VERSION < 41
PXR_NS::TfToken GetMaterialNetworkSelector() const override;
#else
PXR_NS::TfTokenVector GetMaterialRenderContexts() const override;
#endif
PXR_NS::VtDictionary GetRenderStats() const override;
PXR_NS::HdAovDescriptor GetDefaultAovDescriptor(const PXR_NS::TfToken &name) const override;
void SetRenderSetting(const PXR_NS::TfToken &key, const PXR_NS::VtValue &value) override;
PXR_NS::VtValue GetRenderSetting(const PXR_NS::TfToken &key) const override;
private:
PXR_NS::Hgi *_hgi = nullptr;
std::unique_ptr<HdCyclesSession> _renderParam;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,175 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/render_pass.h"
#include "hydra/camera.h"
#include "hydra/display_driver.h"
#include "hydra/output_driver.h"
#include "hydra/render_buffer.h"
#include "hydra/render_delegate.h"
#include "hydra/session.h"
#include "scene/camera.h"
#include "scene/integrator.h"
#include "scene/scene.h"
#include "session/session.h"
#include <pxr/imaging/hd/renderPassState.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
HdCyclesRenderPass::HdCyclesRenderPass(HdRenderIndex *index,
HdRprimCollection const &collection,
HdCyclesSession *renderParam)
: HdRenderPass(index, collection), _renderParam(renderParam)
{
Session *const session = _renderParam->session;
// Reset cancel state so session thread can continue rendering
session->progress.reset();
session->set_output_driver(make_unique<HdCyclesOutputDriver>(renderParam));
const auto renderDelegate = static_cast<const HdCyclesDelegate *>(
GetRenderIndex()->GetRenderDelegate());
if (renderDelegate->IsDisplaySupported()) {
session->set_display_driver(
make_unique<HdCyclesDisplayDriver>(renderParam, renderDelegate->GetHgi()));
}
}
HdCyclesRenderPass::~HdCyclesRenderPass()
{
Session *const session = _renderParam->session;
session->cancel(true);
}
bool HdCyclesRenderPass::IsConverged() const
{
for (const HdRenderPassAovBinding &aovBinding : _renderParam->GetAovBindings()) {
if (aovBinding.renderBuffer && !aovBinding.renderBuffer->IsConverged()) {
return false;
}
}
return true;
}
void HdCyclesRenderPass::ResetConverged()
{
for (const HdRenderPassAovBinding &aovBinding : _renderParam->GetAovBindings()) {
if (const auto renderBuffer = static_cast<HdCyclesRenderBuffer *>(aovBinding.renderBuffer)) {
renderBuffer->SetConverged(false);
}
}
}
void HdCyclesRenderPass::_Execute(const HdRenderPassStateSharedPtr &renderPassState,
const TfTokenVector &renderTags)
{
Scene *const scene = _renderParam->session->scene;
Session *const session = _renderParam->session;
if (session->progress.get_cancel()) {
return; // Something went wrong and cannot continue without recreating the session
}
if (scene->mutex.try_lock()) {
const auto renderDelegate = static_cast<HdCyclesDelegate *>(
GetRenderIndex()->GetRenderDelegate());
const unsigned int settingsVersion = renderDelegate->GetRenderSettingsVersion();
// Update requested AOV bindings
const HdRenderPassAovBindingVector &aovBindings = renderPassState->GetAovBindings();
if (_renderParam->GetAovBindings() != aovBindings ||
// Need to resync passes when denoising is enabled or disabled to update the pass mode
(settingsVersion != _lastSettingsVersion &&
scene->integrator->use_denoise_is_modified())) {
_renderParam->SyncAovBindings(aovBindings);
if (renderDelegate->IsDisplaySupported()) {
// Update display pass to the first requested color AOV
HdRenderPassAovBinding displayAovBinding = !aovBindings.empty() ? aovBindings.front() :
HdRenderPassAovBinding();
if (displayAovBinding.aovName == HdAovTokens->color && displayAovBinding.renderBuffer) {
_renderParam->SetDisplayAovBinding(displayAovBinding);
}
else {
_renderParam->SetDisplayAovBinding(HdRenderPassAovBinding());
}
}
}
// Update camera dimensions to the viewport size
#if PXR_VERSION >= 2102
CameraUtilFraming framing = renderPassState->GetFraming();
if (!framing.IsValid()) {
const GfVec4f vp = renderPassState->GetViewport();
framing = CameraUtilFraming(GfRect2i(GfVec2i(0), int(vp[2]), int(vp[3])));
}
scene->camera->set_full_width(framing.dataWindow.GetWidth());
scene->camera->set_full_height(framing.dataWindow.GetHeight());
#else
const GfVec4f vp = renderPassState->GetViewport();
scene->camera->set_full_width(int(vp[2]));
scene->camera->set_full_height(int(vp[3]));
#endif
if (const auto camera = static_cast<const HdCyclesCamera *>(renderPassState->GetCamera())) {
camera->ApplyCameraSettings(scene->camera);
}
else {
HdCyclesCamera::ApplyCameraSettings(renderPassState->GetWorldToViewMatrix(),
renderPassState->GetProjectionMatrix(),
renderPassState->GetClipPlanes(),
scene->camera);
}
// Reset session if the session, scene, camera or AOV bindings changed
if (scene->need_reset() || settingsVersion != _lastSettingsVersion) {
_lastSettingsVersion = settingsVersion;
// Reset convergence state of all render buffers
ResetConverged();
BufferParams buffer_params;
#if PXR_VERSION >= 2102
buffer_params.full_x = static_cast<int>(framing.displayWindow.GetMin()[0]);
buffer_params.full_y = static_cast<int>(framing.displayWindow.GetMin()[1]);
buffer_params.full_width = static_cast<int>(framing.displayWindow.GetSize()[0]);
buffer_params.full_height = static_cast<int>(framing.displayWindow.GetSize()[1]);
buffer_params.window_x = framing.dataWindow.GetMinX() - buffer_params.full_x;
buffer_params.window_y = framing.dataWindow.GetMinY() - buffer_params.full_y;
buffer_params.window_width = framing.dataWindow.GetWidth();
buffer_params.window_height = framing.dataWindow.GetHeight();
buffer_params.width = buffer_params.window_width;
buffer_params.height = buffer_params.window_height;
#else
buffer_params.width = static_cast<int>(vp[2]);
buffer_params.height = static_cast<int>(vp[3]);
buffer_params.full_width = buffer_params.width;
buffer_params.full_height = buffer_params.height;
buffer_params.window_width = buffer_params.width;
buffer_params.window_height = buffer_params.height;
#endif
session->reset(session->params, buffer_params);
}
scene->mutex.unlock();
// Start Cycles render thread if not already running
session->start();
}
session->draw();
}
void HdCyclesRenderPass::_MarkCollectionDirty()
{
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,34 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/renderPass.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesRenderPass final : public PXR_NS::HdRenderPass {
public:
HdCyclesRenderPass(PXR_NS::HdRenderIndex *index,
const PXR_NS::HdRprimCollection &collection,
HdCyclesSession *renderParam);
~HdCyclesRenderPass() override;
bool IsConverged() const override;
private:
void ResetConverged();
void _Execute(const PXR_NS::HdRenderPassStateSharedPtr &renderPassState,
const PXR_NS::TfTokenVector &renderTags) override;
void _MarkCollectionDirty() override;
HdCyclesSession *_renderParam;
unsigned int _lastSettingsVersion = 0;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,22 +0,0 @@
{
"Plugins": [
{
"Info": {
"Types": {
"HdCyclesPlugin": {
"bases": [
"HdRendererPlugin"
],
"displayName": "Cycles",
"priority": 0
}
}
},
"LibraryPath": "@PLUG_INFO_LIBRARY_PATH@",
"Name": "hdCycles",
"ResourcePath": "@PLUG_INFO_RESOURCE_PATH@",
"Root": "@PLUG_INFO_ROOT@",
"Type": "library"
}
]
}

View File

@@ -1,170 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/session.h"
#include "scene/shader.h"
// Have to include shader.h before background.h so that 'set_shader' uses the correct 'set'
// overload taking a 'Node *', rather than the one taking a 'bool'
#include "scene/background.h"
#include "scene/light.h"
#include "scene/shader_graph.h"
#include "scene/shader_nodes.h"
#include "session/session.h"
HDCYCLES_NAMESPACE_OPEN_SCOPE
namespace {
const std::unordered_map<TfToken, PassType, TfToken::HashFunctor> kAovToPass = {
{HdAovTokens->color, PASS_COMBINED},
{HdAovTokens->depth, PASS_DEPTH},
{HdAovTokens->normal, PASS_NORMAL},
{HdAovTokens->primId, PASS_OBJECT_ID},
{HdAovTokens->instanceId, PASS_AOV_VALUE},
};
} // namespace
SceneLock::SceneLock(const HdRenderParam *renderParam)
: scene(static_cast<const HdCyclesSession *>(renderParam)->session->scene),
sceneLock(scene->mutex)
{
}
SceneLock::~SceneLock()
{
}
HdCyclesSession::HdCyclesSession(Session *session_) : session(session_), _ownCyclesSession(false)
{
}
HdCyclesSession::HdCyclesSession(const SessionParams &params)
: session(new Session(params, SceneParams())), _ownCyclesSession(true)
{
Scene *const scene = session->scene;
// Create background with ambient light
{
ShaderGraph *graph = new ShaderGraph();
BackgroundNode *bgNode = graph->create_node<BackgroundNode>();
bgNode->set_color(one_float3());
graph->add(bgNode);
graph->connect(bgNode->output("Background"), graph->output()->input("Surface"));
scene->default_background->set_graph(graph);
scene->default_background->tag_update(scene);
}
// Wire up object color in default surface material
{
ShaderGraph *graph = new ShaderGraph();
ObjectInfoNode *objectNode = graph->create_node<ObjectInfoNode>();
graph->add(objectNode);
DiffuseBsdfNode *diffuseNode = graph->create_node<DiffuseBsdfNode>();
graph->add(diffuseNode);
graph->connect(objectNode->output("Color"), diffuseNode->input("Color"));
graph->connect(diffuseNode->output("BSDF"), graph->output()->input("Surface"));
#if 1
// Create the instanceId AOV output
const ustring instanceId(HdAovTokens->instanceId.GetString());
OutputAOVNode *aovNode = graph->create_node<OutputAOVNode>();
aovNode->set_name(instanceId);
graph->add(aovNode);
AttributeNode *instanceIdNode = graph->create_node<AttributeNode>();
instanceIdNode->set_attribute(instanceId);
graph->add(instanceIdNode);
graph->connect(instanceIdNode->output("Fac"), aovNode->input("Value"));
#endif
scene->default_surface->set_graph(graph);
scene->default_surface->tag_update(scene);
}
}
HdCyclesSession::~HdCyclesSession()
{
if (_ownCyclesSession) {
delete session;
}
}
void HdCyclesSession::UpdateScene()
{
Scene *const scene = session->scene;
// Update background depending on presence of a background light
if (scene->light_manager->need_update()) {
Light *background_light = nullptr;
for (Light *light : scene->lights) {
if (light->get_light_type() == LIGHT_BACKGROUND) {
background_light = light;
break;
}
}
if (!background_light) {
scene->background->set_shader(scene->default_background);
scene->background->set_transparent(true);
}
else {
scene->background->set_shader(background_light->get_shader());
scene->background->set_transparent(false);
}
scene->background->tag_update(scene);
}
}
void HdCyclesSession::SyncAovBindings(const HdRenderPassAovBindingVector &aovBindings)
{
Scene *const scene = session->scene;
// Delete all existing passes
scene->delete_nodes(set<Pass *>(scene->passes.begin(), scene->passes.end()));
// Update passes with requested AOV bindings
_aovBindings = aovBindings;
for (const HdRenderPassAovBinding &aovBinding : aovBindings) {
const auto cyclesAov = kAovToPass.find(aovBinding.aovName);
if (cyclesAov == kAovToPass.end()) {
// TODO: Use PASS_AOV_COLOR and PASS_AOV_VALUE for these?
TF_WARN("Unknown pass %s", aovBinding.aovName.GetText());
continue;
}
const PassType type = cyclesAov->second;
const PassMode mode = PassMode::DENOISED;
Pass *pass = scene->create_node<Pass>();
pass->set_type(type);
pass->set_mode(mode);
pass->set_name(ustring(aovBinding.aovName.GetString()));
}
}
void HdCyclesSession::RemoveAovBinding(HdRenderBuffer *renderBuffer)
{
for (HdRenderPassAovBinding &aovBinding : _aovBindings) {
if (renderBuffer == aovBinding.renderBuffer) {
aovBinding.renderBuffer = nullptr;
break;
}
}
if (renderBuffer == _displayAovBinding.renderBuffer) {
_displayAovBinding.renderBuffer = nullptr;
}
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,59 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "util/thread.h"
#include <pxr/imaging/hd/renderDelegate.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
struct SceneLock {
SceneLock(const PXR_NS::HdRenderParam *renderParam);
~SceneLock();
CCL_NS::Scene *scene;
private:
CCL_NS::thread_scoped_lock sceneLock;
};
class HdCyclesSession final : public PXR_NS::HdRenderParam {
public:
HdCyclesSession(CCL_NS::Session *session_);
HdCyclesSession(const CCL_NS::SessionParams &params);
~HdCyclesSession() override;
void UpdateScene();
PXR_NS::HdRenderPassAovBinding GetDisplayAovBinding() const
{
return _displayAovBinding;
}
void SetDisplayAovBinding(const PXR_NS::HdRenderPassAovBinding &aovBinding)
{
_displayAovBinding = aovBinding;
}
const PXR_NS::HdRenderPassAovBindingVector &GetAovBindings() const
{
return _aovBindings;
}
void SyncAovBindings(const PXR_NS::HdRenderPassAovBindingVector &aovBindings);
void RemoveAovBinding(PXR_NS::HdRenderBuffer *renderBuffer);
CCL_NS::Session *session;
private:
const bool _ownCyclesSession;
PXR_NS::HdRenderPassAovBindingVector _aovBindings;
PXR_NS::HdRenderPassAovBinding _displayAovBinding;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,91 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#include "hydra/volume.h"
#include "hydra/field.h"
#include "hydra/geometry.inl"
#include "scene/volume.h"
HDCYCLES_NAMESPACE_OPEN_SCOPE
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(openvdbAsset)
);
// clang-format on
HdCyclesVolume::HdCyclesVolume(const SdfPath &rprimId
#if PXR_VERSION < 2102
,
const SdfPath &instancerId
#endif
)
: HdCyclesGeometry(rprimId
#if PXR_VERSION < 2102
,
instancerId
#endif
)
{
}
HdCyclesVolume::~HdCyclesVolume()
{
}
HdDirtyBits HdCyclesVolume::GetInitialDirtyBitsMask() const
{
HdDirtyBits bits = HdCyclesGeometry::GetInitialDirtyBitsMask();
bits |= HdChangeTracker::DirtyVolumeField;
return bits;
}
void HdCyclesVolume::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits, bool &rebuild)
{
Scene *const scene = (Scene *)_geom->get_owner();
if (dirtyBits & HdChangeTracker::DirtyVolumeField) {
for (const HdVolumeFieldDescriptor &field :
sceneDelegate->GetVolumeFieldDescriptors(GetId())) {
if (const auto openvdbAsset = static_cast<HdCyclesField *>(
sceneDelegate->GetRenderIndex().GetBprim(_tokens->openvdbAsset, field.fieldId))) {
const ustring name(field.fieldName.GetString());
AttributeStandard std = ATTR_STD_NONE;
if (name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) {
std = ATTR_STD_VOLUME_DENSITY;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) {
std = ATTR_STD_VOLUME_COLOR;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME)) {
std = ATTR_STD_VOLUME_FLAME;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
std = ATTR_STD_VOLUME_HEAT;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) {
std = ATTR_STD_VOLUME_TEMPERATURE;
}
else if (name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) {
std = ATTR_STD_VOLUME_VELOCITY;
}
// Skip attributes that are not needed
if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) ||
_geom->need_attribute(scene, name)) {
Attribute *const attr = (std != ATTR_STD_NONE) ?
_geom->attributes.add(std) :
_geom->attributes.add(
name, TypeDesc::TypeFloat, ATTR_ELEMENT_VOXEL);
attr->data_voxel() = openvdbAsset->GetImageHandle();
}
}
}
rebuild = true;
}
}
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -1,33 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2022 NVIDIA Corporation
* Copyright 2022 Blender Foundation */
#pragma once
#include "hydra/config.h"
#include "hydra/geometry.h"
#include <pxr/imaging/hd/volume.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesVolume final : public HdCyclesGeometry<PXR_NS::HdVolume, CCL_NS::Volume> {
public:
HdCyclesVolume(
const PXR_NS::SdfPath &rprimId
#if PXR_VERSION < 2102
,
const PXR_NS::SdfPath &instancerId = {}
#endif
);
~HdCyclesVolume() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
private:
void Populate(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdDirtyBits dirtyBits,
bool &rebuild) override;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE

View File

@@ -18,11 +18,7 @@ CCL_NAMESPACE_BEGIN
*/
PassAccessor::PassAccessInfo::PassAccessInfo(const BufferPass &pass)
: type(pass.type),
mode(pass.mode),
include_albedo(pass.include_albedo),
is_lightgroup(!pass.lightgroup.empty()),
offset(pass.offset)
: type(pass.type), mode(pass.mode), include_albedo(pass.include_albedo), offset(pass.offset)
{
}
@@ -131,8 +127,7 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
const PassType type = pass_access_info_.type;
const PassMode mode = pass_access_info_.mode;
const PassInfo pass_info = Pass::get_info(
type, pass_access_info_.include_albedo, pass_access_info_.is_lightgroup);
const PassInfo pass_info = Pass::get_info(type, pass_access_info_.include_albedo);
int num_written_components = pass_info.num_components;
if (pass_info.num_components == 1) {
@@ -220,8 +215,8 @@ void PassAccessor::init_kernel_film_convert(KernelFilmConvert *kfilm_convert,
const Destination &destination) const
{
const PassMode mode = pass_access_info_.mode;
const PassInfo &pass_info = Pass::get_info(
pass_access_info_.type, pass_access_info_.include_albedo, pass_access_info_.is_lightgroup);
const PassInfo &pass_info = Pass::get_info(pass_access_info_.type,
pass_access_info_.include_albedo);
kfilm_convert->pass_offset = pass_access_info_.offset;
kfilm_convert->pass_stride = buffer_params.pass_stride;
@@ -284,8 +279,8 @@ bool PassAccessor::set_render_tile_pixels(RenderBuffers *render_buffers, const S
return false;
}
const PassInfo pass_info = Pass::get_info(
pass_access_info_.type, pass_access_info_.include_albedo, pass_access_info_.is_lightgroup);
const PassInfo pass_info = Pass::get_info(pass_access_info_.type,
pass_access_info_.include_albedo);
const BufferParams &buffer_params = render_buffers->params;

View File

@@ -28,7 +28,6 @@ class PassAccessor {
PassType type = PASS_NONE;
PassMode mode = PassMode::NOISY;
bool include_albedo = false;
bool is_lightgroup = false;
int offset = -1;
/* For the shadow catcher matte pass: whether to approximate shadow catcher pass into its

View File

@@ -20,7 +20,7 @@ RenderScheduler::RenderScheduler(TileManager &tile_manager, const SessionParams
background_(params.background),
pixel_size_(params.pixel_size),
tile_manager_(tile_manager),
default_start_resolution_divider_(params.use_resolution_divider ? pixel_size_ * 8 : 0)
default_start_resolution_divider_(pixel_size_ * 8)
{
use_progressive_noise_floor_ = !background_;
}
@@ -119,7 +119,7 @@ void RenderScheduler::reset(const BufferParams &buffer_params, int num_samples,
/* In background mode never do lower resolution render preview, as it is not really supported
* by the software. */
if (background_ || start_resolution_divider_ == 0) {
if (background_) {
state_.resolution_divider = 1;
}
else {
@@ -1050,10 +1050,6 @@ bool RenderScheduler::work_need_rebalance()
void RenderScheduler::update_start_resolution_divider()
{
if (default_start_resolution_divider_ == 0) {
return;
}
if (start_resolution_divider_ == 0) {
/* Resolution divider has never been calculated before: use default resolution, so that we have
* somewhat good initial behavior, giving a chance to collect real numbers. */

View File

@@ -223,7 +223,6 @@ set(SRC_KERNEL_INTEGRATOR_HEADERS
integrator/intersect_subsurface.h
integrator/intersect_volume_stack.h
integrator/megakernel.h
integrator/mnee.h
integrator/path_state.h
integrator/shade_background.h
integrator/shade_light.h
@@ -407,11 +406,6 @@ if(WITH_CYCLES_CUDA_BINARIES)
-o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_file}
-Wno-deprecated-gpu-targets)
if(CUDA_HOST_COMPILER)
set(cuda_flags ${cuda_flags}
-ccbin="${CUDA_HOST_COMPILER}")
endif()
if(WITH_NANOVDB)
set(cuda_flags ${cuda_flags}
-D WITH_NANOVDB

View File

@@ -31,17 +31,7 @@ ccl_device_inline float frac(float x, int *ix)
return x - (float)i;
}
template<typename TexT, typename OutT = float4> struct TextureInterpolator {
static ccl_always_inline OutT zero()
{
if constexpr (std::is_same<OutT, float4>::value) {
return zero_float4();
}
else {
return 0.0f;
}
}
template<typename T> struct TextureInterpolator {
static ccl_always_inline float4 read(float4 r)
{
@@ -50,18 +40,21 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
static ccl_always_inline float4 read(uchar4 r)
{
const float f = 1.0f / 255.0f;
float f = 1.0f / 255.0f;
return make_float4(r.x * f, r.y * f, r.z * f, r.w * f);
}
static ccl_always_inline float read(uchar r)
static ccl_always_inline float4 read(uchar r)
{
return r * (1.0f / 255.0f);
float f = r * (1.0f / 255.0f);
return make_float4(f, f, f, 1.0f);
}
static ccl_always_inline float read(float r)
static ccl_always_inline float4 read(float r)
{
return r;
/* TODO(dingto): Optimize this, so interpolation
* happens on float instead of float4 */
return make_float4(r, r, r, 1.0f);
}
static ccl_always_inline float4 read(half4 r)
@@ -69,131 +62,37 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
return half4_to_float4_image(r);
}
static ccl_always_inline float read(half r)
static ccl_always_inline float4 read(half r)
{
return half_to_float_image(r);
float f = half_to_float_image(r);
return make_float4(f, f, f, 1.0f);
}
static ccl_always_inline float read(uint16_t r)
static ccl_always_inline float4 read(uint16_t r)
{
return r * (1.0f / 65535.0f);
float f = r * (1.0f / 65535.0f);
return make_float4(f, f, f, 1.0f);
}
static ccl_always_inline float4 read(ushort4 r)
{
const float f = 1.0f / 65535.0f;
float f = 1.0f / 65535.0f;
return make_float4(r.x * f, r.y * f, r.z * f, r.w * f);
}
/* Read 2D Texture Data
* Does not check if data request is in bounds. */
static ccl_always_inline OutT read(const TexT *data, int x, int y, int width, int height)
static ccl_always_inline float4 read(const T *data, int x, int y, int width, int height)
{
return read(data[y * width + x]);
}
/* Read 2D Texture Data Clip
* Returns transparent black if data request is out of bounds. */
static ccl_always_inline OutT read_clip(const TexT *data, int x, int y, int width, int height)
{
if (x < 0 || x >= width || y < 0 || y >= height) {
return zero();
if (x < 0 || y < 0 || x >= width || y >= height) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
return read(data[y * width + x]);
}
/* Read 3D Texture Data
* Does not check if data request is in bounds. */
static ccl_always_inline OutT
read(const TexT *data, int x, int y, int z, int width, int height, int depth)
{
return read(data[x + y * width + z * width * height]);
}
/* Read 3D Texture Data Clip
* Returns transparent black if data request is out of bounds. */
static ccl_always_inline OutT
read_clip(const TexT *data, int x, int y, int z, int width, int height, int depth)
{
if (x < 0 || x >= width || y < 0 || y >= height || z < 0 || z >= depth) {
return zero();
}
return read(data[x + y * width + z * width * height]);
}
/* Trilinear Interpolation */
static ccl_always_inline OutT
trilinear_lookup(const TexT *data,
float tx,
float ty,
float tz,
int ix,
int iy,
int iz,
int nix,
int niy,
int niz,
int width,
int height,
int depth,
OutT read(const TexT *, int, int, int, int, int, int))
{
OutT r = (1.0f - tz) * (1.0f - ty) * (1.0f - tx) *
read(data, ix, iy, iz, width, height, depth);
r += (1.0f - tz) * (1.0f - ty) * tx * read(data, nix, iy, iz, width, height, depth);
r += (1.0f - tz) * ty * (1.0f - tx) * read(data, ix, niy, iz, width, height, depth);
r += (1.0f - tz) * ty * tx * read(data, nix, niy, iz, width, height, depth);
r += tz * (1.0f - ty) * (1.0f - tx) * read(data, ix, iy, niz, width, height, depth);
r += tz * (1.0f - ty) * tx * read(data, nix, iy, niz, width, height, depth);
r += tz * ty * (1.0f - tx) * read(data, ix, niy, niz, width, height, depth);
r += tz * ty * tx * read(data, nix, niy, niz, width, height, depth);
return r;
}
/** Tricubic Interpolation */
static ccl_always_inline OutT
tricubic_lookup(const TexT *data,
float tx,
float ty,
float tz,
const int xc[4],
const int yc[4],
const int zc[4],
int width,
int height,
int depth,
OutT read(const TexT *, int, int, int, int, int, int))
{
float u[4], v[4], w[4];
/* Some helper macros to keep code size reasonable.
* Lets the compiler inline all the matrix multiplications.
*/
#define DATA(x, y, z) (read(data, xc[x], yc[y], zc[z], width, height, depth))
#define COL_TERM(col, row) \
(v[col] * (u[0] * DATA(0, col, row) + u[1] * DATA(1, col, row) + u[2] * DATA(2, col, row) + \
u[3] * DATA(3, col, row)))
#define ROW_TERM(row) \
(w[row] * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
SET_CUBIC_SPLINE_WEIGHTS(u, tx);
SET_CUBIC_SPLINE_WEIGHTS(v, ty);
SET_CUBIC_SPLINE_WEIGHTS(w, tz);
/* Actual interpolation. */
return ROW_TERM(0) + ROW_TERM(1) + ROW_TERM(2) + ROW_TERM(3);
#undef COL_TERM
#undef ROW_TERM
#undef DATA
}
static ccl_always_inline int wrap_periodic(int x, int width)
{
x %= width;
if (x < 0) {
if (x < 0)
x += width;
}
return x;
}
@@ -204,8 +103,9 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
/* ******** 2D interpolation ******** */
static ccl_always_inline OutT interp_closest(const TextureInfo &info, float x, float y)
static ccl_always_inline float4 interp_closest(const TextureInfo &info, float x, float y)
{
const T *data = (const T *)info.data;
const int width = info.width;
const int height = info.height;
int ix, iy;
@@ -217,134 +117,105 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
iy = wrap_periodic(iy, height);
break;
case EXTENSION_CLIP:
/* No samples are inside the clip region. */
if (ix < 0 || ix >= width || iy < 0 || iy >= height) {
return zero();
if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
break;
ATTR_FALLTHROUGH;
case EXTENSION_EXTEND:
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
break;
default:
kernel_assert(0);
return zero();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
const TexT *data = (const TexT *)info.data;
return read((const TexT *)data, ix, iy, width, height);
return read(data[ix + iy * width]);
}
static ccl_always_inline OutT interp_linear(const TextureInfo &info, float x, float y)
static ccl_always_inline float4 interp_linear(const TextureInfo &info, float x, float y)
{
const T *data = (const T *)info.data;
const int width = info.width;
const int height = info.height;
/* A -0.5 offset is used to center the linear samples around the sample point. */
int ix, iy;
int nix, niy;
int ix, iy, nix, niy;
const float tx = frac(x * (float)width - 0.5f, &ix);
const float ty = frac(y * (float)height - 0.5f, &iy);
switch (info.extension) {
case EXTENSION_REPEAT:
ix = wrap_periodic(ix, width);
nix = wrap_periodic(ix + 1, width);
iy = wrap_periodic(iy, height);
nix = wrap_periodic(ix + 1, width);
niy = wrap_periodic(iy + 1, height);
break;
case EXTENSION_CLIP:
/* No linear samples are inside the clip region. */
if (ix < -1 || ix >= width || iy < -1 || iy >= height) {
return zero();
}
nix = ix + 1;
niy = iy + 1;
break;
case EXTENSION_EXTEND:
nix = wrap_clamp(ix + 1, width);
ix = wrap_clamp(ix, width);
niy = wrap_clamp(iy + 1, height);
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
break;
default:
kernel_assert(0);
return zero();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
const TexT *data = (const TexT *)info.data;
return (1.0f - ty) * (1.0f - tx) * read_clip(data, ix, iy, width, height) +
(1.0f - ty) * tx * read_clip(data, nix, iy, width, height) +
ty * (1.0f - tx) * read_clip(data, ix, niy, width, height) +
ty * tx * read_clip(data, nix, niy, width, height);
return (1.0f - ty) * (1.0f - tx) * read(data, ix, iy, width, height) +
(1.0f - ty) * tx * read(data, nix, iy, width, height) +
ty * (1.0f - tx) * read(data, ix, niy, width, height) +
ty * tx * read(data, nix, niy, width, height);
}
static ccl_always_inline OutT interp_cubic(const TextureInfo &info, float x, float y)
static ccl_always_inline float4 interp_cubic(const TextureInfo &info, float x, float y)
{
const T *data = (const T *)info.data;
const int width = info.width;
const int height = info.height;
/* A -0.5 offset is used to center the cubic samples around the sample point. */
int ix, iy;
int ix, iy, nix, niy;
const float tx = frac(x * (float)width - 0.5f, &ix);
const float ty = frac(y * (float)height - 0.5f, &iy);
int pix, piy;
int nix, niy;
int nnix, nniy;
int pix, piy, nnix, nniy;
switch (info.extension) {
case EXTENSION_REPEAT:
ix = wrap_periodic(ix, width);
pix = wrap_periodic(ix - 1, width);
nix = wrap_periodic(ix + 1, width);
nnix = wrap_periodic(ix + 2, width);
iy = wrap_periodic(iy, height);
pix = wrap_periodic(ix - 1, width);
piy = wrap_periodic(iy - 1, height);
nix = wrap_periodic(ix + 1, width);
niy = wrap_periodic(iy + 1, height);
nnix = wrap_periodic(ix + 2, width);
nniy = wrap_periodic(iy + 2, height);
break;
case EXTENSION_CLIP:
/* No cubic samples are inside the clip region. */
if (ix < -2 || ix > width || iy < -2 || iy > height) {
return zero();
}
pix = ix - 1;
nix = ix + 1;
nnix = ix + 2;
piy = iy - 1;
nix = ix + 1;
niy = iy + 1;
nnix = ix + 2;
nniy = iy + 2;
break;
case EXTENSION_EXTEND:
pix = wrap_clamp(ix - 1, width);
nix = wrap_clamp(ix + 1, width);
nnix = wrap_clamp(ix + 2, width);
ix = wrap_clamp(ix, width);
piy = wrap_clamp(iy - 1, height);
nix = wrap_clamp(ix + 1, width);
niy = wrap_clamp(iy + 1, height);
nnix = wrap_clamp(ix + 2, width);
nniy = wrap_clamp(iy + 2, height);
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
break;
default:
kernel_assert(0);
return zero();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
const TexT *data = (const TexT *)info.data;
const int xc[4] = {pix, ix, nix, nnix};
const int yc[4] = {piy, iy, niy, nniy};
float u[4], v[4];
/* Some helper macros to keep code size reasonable.
* Lets the compiler inline all the matrix multiplications.
/* Some helper macro to keep code reasonable size,
* let compiler to inline all the matrix multiplications.
*/
#define DATA(x, y) (read_clip(data, xc[x], yc[y], width, height))
#define DATA(x, y) (read(data, xc[x], yc[y], width, height))
#define TERM(col) \
(v[col] * \
(u[0] * DATA(0, col) + u[1] * DATA(1, col) + u[2] * DATA(2, col) + u[3] * DATA(3, col)))
@@ -358,8 +229,11 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
#undef DATA
}
static ccl_always_inline OutT interp(const TextureInfo &info, float x, float y)
static ccl_always_inline float4 interp(const TextureInfo &info, float x, float y)
{
if (UNLIKELY(!info.data)) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
switch (info.interpolation) {
case INTERPOLATION_CLOSEST:
return interp_closest(info, x, y);
@@ -372,14 +246,14 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
/* ******** 3D interpolation ******** */
static ccl_always_inline OutT interp_3d_closest(const TextureInfo &info,
float x,
float y,
float z)
static ccl_always_inline float4 interp_3d_closest(const TextureInfo &info,
float x,
float y,
float z)
{
const int width = info.width;
const int height = info.height;
const int depth = info.depth;
int width = info.width;
int height = info.height;
int depth = info.depth;
int ix, iy, iz;
frac(x * (float)width, &ix);
@@ -393,11 +267,10 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
iz = wrap_periodic(iz, depth);
break;
case EXTENSION_CLIP:
/* No samples are inside the clip region. */
if (ix < 0 || ix >= width || iy < 0 || iy >= height || iz < 0 || iz >= depth) {
return zero();
if (x < 0.0f || y < 0.0f || z < 0.0f || x > 1.0f || y > 1.0f || z > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
break;
ATTR_FALLTHROUGH;
case EXTENSION_EXTEND:
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
@@ -405,25 +278,24 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
break;
default:
kernel_assert(0);
return zero();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
const TexT *data = (const TexT *)info.data;
return read(data, ix, iy, iz, width, height, depth);
const T *data = (const T *)info.data;
return read(data[ix + iy * width + iz * width * height]);
}
static ccl_always_inline OutT interp_3d_linear(const TextureInfo &info,
float x,
float y,
float z)
static ccl_always_inline float4 interp_3d_linear(const TextureInfo &info,
float x,
float y,
float z)
{
const int width = info.width;
const int height = info.height;
const int depth = info.depth;
int width = info.width;
int height = info.height;
int depth = info.depth;
int ix, iy, iz;
int nix, niy, niz;
/* A -0.5 offset is used to center the linear samples around the sample point. */
float tx = frac(x * (float)width - 0.5f, &ix);
float ty = frac(y * (float)height - 0.5f, &iy);
float tz = frac(z * (float)depth - 0.5f, &iz);
@@ -431,79 +303,50 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
switch (info.extension) {
case EXTENSION_REPEAT:
ix = wrap_periodic(ix, width);
nix = wrap_periodic(ix + 1, width);
iy = wrap_periodic(iy, height);
niy = wrap_periodic(iy + 1, height);
iz = wrap_periodic(iz, depth);
nix = wrap_periodic(ix + 1, width);
niy = wrap_periodic(iy + 1, height);
niz = wrap_periodic(iz + 1, depth);
break;
case EXTENSION_CLIP:
/* No linear samples are inside the clip region. */
if (ix < -1 || ix >= width || iy < -1 || iy >= height || iz < -1 || iz >= depth) {
return zero();
if (x < 0.0f || y < 0.0f || z < 0.0f || x > 1.0f || y > 1.0f || z > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
nix = ix + 1;
niy = iy + 1;
niz = iz + 1;
/* All linear samples are inside the clip region. */
if (ix >= 0 && nix < width && iy >= 0 && niy < height && iz >= 0 && niz < depth) {
break;
}
/* The linear samples span the clip border.
* #read_clip is used to ensure proper interpolation across the clip border. */
return trilinear_lookup((const TexT *)info.data,
tx,
ty,
tz,
ix,
iy,
iz,
nix,
niy,
niz,
width,
height,
depth,
read_clip);
ATTR_FALLTHROUGH;
case EXTENSION_EXTEND:
nix = wrap_clamp(ix + 1, width);
ix = wrap_clamp(ix, width);
niy = wrap_clamp(iy + 1, height);
iy = wrap_clamp(iy, height);
niz = wrap_clamp(iz + 1, depth);
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
iz = wrap_clamp(iz, depth);
break;
default:
kernel_assert(0);
return zero();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
return trilinear_lookup((const TexT *)info.data,
tx,
ty,
tz,
ix,
iy,
iz,
nix,
niy,
niz,
width,
height,
depth,
read);
const T *data = (const T *)info.data;
float4 r;
r = (1.0f - tz) * (1.0f - ty) * (1.0f - tx) *
read(data[ix + iy * width + iz * width * height]);
r += (1.0f - tz) * (1.0f - ty) * tx * read(data[nix + iy * width + iz * width * height]);
r += (1.0f - tz) * ty * (1.0f - tx) * read(data[ix + niy * width + iz * width * height]);
r += (1.0f - tz) * ty * tx * read(data[nix + niy * width + iz * width * height]);
r += tz * (1.0f - ty) * (1.0f - tx) * read(data[ix + iy * width + niz * width * height]);
r += tz * (1.0f - ty) * tx * read(data[nix + iy * width + niz * width * height]);
r += tz * ty * (1.0f - tx) * read(data[ix + niy * width + niz * width * height]);
r += tz * ty * tx * read(data[nix + niy * width + niz * width * height]);
return r;
}
/* Tricubic b-spline interpolation.
*
* TODO(sergey): For some unspeakable reason both GCC-6 and Clang-3.9 are
/* TODO(sergey): For some unspeakable reason both GCC-6 and Clang-3.9 are
* causing stack overflow issue in this function unless it is inlined.
*
* Only happens for AVX2 kernel and global __KERNEL_SSE__ vectorization
@@ -514,101 +357,100 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
#else
static ccl_never_inline
#endif
OutT
float4
interp_3d_cubic(const TextureInfo &info, float x, float y, float z)
{
int width = info.width;
int height = info.height;
int depth = info.depth;
int ix, iy, iz;
/* A -0.5 offset is used to center the cubic samples around the sample point. */
int nix, niy, niz;
/* Tricubic b-spline interpolation. */
const float tx = frac(x * (float)width - 0.5f, &ix);
const float ty = frac(y * (float)height - 0.5f, &iy);
const float tz = frac(z * (float)depth - 0.5f, &iz);
int pix, piy, piz;
int nix, niy, niz;
int nnix, nniy, nniz;
int pix, piy, piz, nnix, nniy, nniz;
switch (info.extension) {
case EXTENSION_REPEAT:
ix = wrap_periodic(ix, width);
pix = wrap_periodic(ix - 1, width);
nix = wrap_periodic(ix + 1, width);
nnix = wrap_periodic(ix + 2, width);
iy = wrap_periodic(iy, height);
niy = wrap_periodic(iy + 1, height);
piy = wrap_periodic(iy - 1, height);
nniy = wrap_periodic(iy + 2, height);
iz = wrap_periodic(iz, depth);
pix = wrap_periodic(ix - 1, width);
piy = wrap_periodic(iy - 1, height);
piz = wrap_periodic(iz - 1, depth);
nix = wrap_periodic(ix + 1, width);
niy = wrap_periodic(iy + 1, height);
niz = wrap_periodic(iz + 1, depth);
nnix = wrap_periodic(ix + 2, width);
nniy = wrap_periodic(iy + 2, height);
nniz = wrap_periodic(iz + 2, depth);
break;
case EXTENSION_CLIP: {
/* No cubic samples are inside the clip region. */
if (ix < -2 || ix > width || iy < -2 || iy > height || iz < -2 || iz > depth) {
return zero();
case EXTENSION_CLIP:
if (x < 0.0f || y < 0.0f || z < 0.0f || x > 1.0f || y > 1.0f || z > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
pix = ix - 1;
nnix = ix + 2;
nix = ix + 1;
piy = iy - 1;
niy = iy + 1;
nniy = iy + 2;
piz = iz - 1;
niz = iz + 1;
nniz = iz + 2;
/* All cubic samples are inside the clip region. */
if (pix >= 0 && nnix < width && piy >= 0 && nniy < height && piz >= 0 && nniz < depth) {
break;
}
/* The Cubic samples span the clip border.
* read_clip is used to ensure proper interpolation across the clip border. */
const int xc[4] = {pix, ix, nix, nnix};
const int yc[4] = {piy, iy, niy, nniy};
const int zc[4] = {piz, iz, niz, nniz};
return tricubic_lookup(
(const TexT *)info.data, tx, ty, tz, xc, yc, zc, width, height, depth, read_clip);
}
ATTR_FALLTHROUGH;
case EXTENSION_EXTEND:
pix = wrap_clamp(ix - 1, width);
nix = wrap_clamp(ix + 1, width);
nnix = wrap_clamp(ix + 2, width);
ix = wrap_clamp(ix, width);
piy = wrap_clamp(iy - 1, height);
niy = wrap_clamp(iy + 1, height);
nniy = wrap_clamp(iy + 2, height);
iy = wrap_clamp(iy, height);
piz = wrap_clamp(iz - 1, depth);
nix = wrap_clamp(ix + 1, width);
niy = wrap_clamp(iy + 1, height);
niz = wrap_clamp(iz + 1, depth);
nnix = wrap_clamp(ix + 2, width);
nniy = wrap_clamp(iy + 2, height);
nniz = wrap_clamp(iz + 2, depth);
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
iz = wrap_clamp(iz, depth);
break;
default:
kernel_assert(0);
return zero();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
const int xc[4] = {pix, ix, nix, nnix};
const int yc[4] = {piy, iy, niy, nniy};
const int zc[4] = {piz, iz, niz, nniz};
const TexT *data = (const TexT *)info.data;
return tricubic_lookup(data, tx, ty, tz, xc, yc, zc, width, height, depth, read);
const int yc[4] = {width * piy, width * iy, width * niy, width * nniy};
const int zc[4] = {
width * height * piz, width * height * iz, width * height * niz, width * height * nniz};
float u[4], v[4], w[4];
/* Some helper macro to keep code reasonable size,
* let compiler to inline all the matrix multiplications.
*/
#define DATA(x, y, z) (read(data[xc[x] + yc[y] + zc[z]]))
#define COL_TERM(col, row) \
(v[col] * (u[0] * DATA(0, col, row) + u[1] * DATA(1, col, row) + u[2] * DATA(2, col, row) + \
u[3] * DATA(3, col, row)))
#define ROW_TERM(row) \
(w[row] * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
SET_CUBIC_SPLINE_WEIGHTS(u, tx);
SET_CUBIC_SPLINE_WEIGHTS(v, ty);
SET_CUBIC_SPLINE_WEIGHTS(w, tz);
/* Actual interpolation. */
const T *data = (const T *)info.data;
return ROW_TERM(0) + ROW_TERM(1) + ROW_TERM(2) + ROW_TERM(3);
#undef COL_TERM
#undef ROW_TERM
#undef DATA
}
static ccl_always_inline OutT
static ccl_always_inline float4
interp_3d(const TextureInfo &info, float x, float y, float z, InterpolationType interp)
{
if (UNLIKELY(!info.data))
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
switch ((interp == INTERPOLATION_NONE) ? info.interpolation : interp) {
case INTERPOLATION_CLOSEST:
return interp_3d_closest(info, x, y, z);
@@ -621,13 +463,13 @@ template<typename TexT, typename OutT = float4> struct TextureInterpolator {
};
#ifdef WITH_NANOVDB
template<typename TexT, typename OutT = float4> struct NanoVDBInterpolator {
template<typename T> struct NanoVDBInterpolator {
typedef typename nanovdb::NanoGrid<TexT>::AccessorType AccessorType;
typedef typename nanovdb::NanoGrid<T>::AccessorType AccessorType;
static ccl_always_inline float read(float r)
static ccl_always_inline float4 read(float r)
{
return r;
return make_float4(r, r, r, 1.0f);
}
static ccl_always_inline float4 read(nanovdb::Vec3f r)
@@ -635,43 +477,40 @@ template<typename TexT, typename OutT = float4> struct NanoVDBInterpolator {
return make_float4(r[0], r[1], r[2], 1.0f);
}
static ccl_always_inline OutT interp_3d_closest(const AccessorType &acc,
float x,
float y,
float z)
static ccl_always_inline float4 interp_3d_closest(const AccessorType &acc,
float x,
float y,
float z)
{
const nanovdb::Vec3f xyz(x, y, z);
return read(nanovdb::SampleFromVoxels<AccessorType, 0, false>(acc)(xyz));
}
static ccl_always_inline OutT interp_3d_linear(const AccessorType &acc,
float x,
float y,
float z)
static ccl_always_inline float4 interp_3d_linear(const AccessorType &acc,
float x,
float y,
float z)
{
const nanovdb::Vec3f xyz(x - 0.5f, y - 0.5f, z - 0.5f);
return read(nanovdb::SampleFromVoxels<AccessorType, 1, false>(acc)(xyz));
}
/* Tricubic b-spline interpolation. */
# if defined(__GNUC__) || defined(__clang__)
static ccl_always_inline
# else
static ccl_never_inline
# endif
OutT
float4
interp_3d_cubic(const AccessorType &acc, float x, float y, float z)
{
int ix, iy, iz;
int nix, niy, niz;
int pix, piy, piz;
int nnix, nniy, nniz;
/* A -0.5 offset is used to center the cubic samples around the sample point. */
/* Tricubic b-spline interpolation. */
const float tx = frac(x - 0.5f, &ix);
const float ty = frac(y - 0.5f, &iy);
const float tz = frac(z - 0.5f, &iz);
pix = ix - 1;
piy = iy - 1;
piz = iz - 1;
@@ -687,8 +526,8 @@ template<typename TexT, typename OutT = float4> struct NanoVDBInterpolator {
const int zc[4] = {piz, iz, niz, nniz};
float u[4], v[4], w[4];
/* Some helper macros to keep code size reasonable.
* Lets the compiler inline all the matrix multiplications.
/* Some helper macro to keep code reasonable size,
* let compiler to inline all the matrix multiplications.
*/
# define DATA(x, y, z) (read(acc.getValue(nanovdb::Coord(xc[x], yc[y], zc[z]))))
# define COL_TERM(col, row) \
@@ -709,12 +548,12 @@ template<typename TexT, typename OutT = float4> struct NanoVDBInterpolator {
# undef DATA
}
static ccl_always_inline OutT
static ccl_always_inline float4
interp_3d(const TextureInfo &info, float x, float y, float z, InterpolationType interp)
{
using namespace nanovdb;
NanoGrid<TexT> *const grid = (NanoGrid<TexT> *)info.data;
NanoGrid<T> *const grid = (NanoGrid<T> *)info.data;
AccessorType acc = grid->getAccessor();
switch ((interp == INTERPOLATION_NONE) ? info.interpolation : interp) {
@@ -735,27 +574,15 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
if (UNLIKELY(!info.data)) {
return zero_float4();
}
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF: {
const float f = TextureInterpolator<half, float>::interp(info, x, y);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_BYTE: {
const float f = TextureInterpolator<uchar, float>::interp(info, x, y);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_USHORT: {
const float f = TextureInterpolator<uint16_t, float>::interp(info, x, y);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_FLOAT: {
const float f = TextureInterpolator<float, float>::interp(info, x, y);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_HALF:
return TextureInterpolator<half>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE:
return TextureInterpolator<uchar>::interp(info, x, y);
case IMAGE_DATA_TYPE_USHORT:
return TextureInterpolator<uint16_t>::interp(info, x, y);
case IMAGE_DATA_TYPE_FLOAT:
return TextureInterpolator<float>::interp(info, x, y);
case IMAGE_DATA_TYPE_HALF4:
return TextureInterpolator<half4>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE4:
@@ -778,30 +605,19 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
if (UNLIKELY(!info.data)) {
return zero_float4();
}
if (info.use_transform_3d) {
P = transform_point(&info.transform_3d, P);
}
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF: {
const float f = TextureInterpolator<half, float>::interp_3d(info, P.x, P.y, P.z, interp);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_BYTE: {
const float f = TextureInterpolator<uchar, float>::interp_3d(info, P.x, P.y, P.z, interp);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_USHORT: {
const float f = TextureInterpolator<uint16_t, float>::interp_3d(info, P.x, P.y, P.z, interp);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_FLOAT: {
const float f = TextureInterpolator<float, float>::interp_3d(info, P.x, P.y, P.z, interp);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_HALF:
return TextureInterpolator<half>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_BYTE:
return TextureInterpolator<uchar>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_USHORT:
return TextureInterpolator<uint16_t>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_FLOAT:
return TextureInterpolator<float>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_HALF4:
return TextureInterpolator<half4>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_BYTE4:
@@ -811,10 +627,8 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
case IMAGE_DATA_TYPE_FLOAT4:
return TextureInterpolator<float4>::interp_3d(info, P.x, P.y, P.z, interp);
#ifdef WITH_NANOVDB
case IMAGE_DATA_TYPE_NANOVDB_FLOAT: {
const float f = NanoVDBInterpolator<float, float>::interp_3d(info, P.x, P.y, P.z, interp);
return make_float4(f, f, f, 1.0f);
}
case IMAGE_DATA_TYPE_NANOVDB_FLOAT:
return NanoVDBInterpolator<float>::interp_3d(info, P.x, P.y, P.z, interp);
case IMAGE_DATA_TYPE_NANOVDB_FLOAT3:
return NanoVDBInterpolator<nanovdb::Vec3f>::interp_3d(info, P.x, P.y, P.z, interp);
#endif

View File

@@ -76,11 +76,10 @@ typedef unsigned long long uint64_t;
/* GPU texture objects */
typedef unsigned long long CUtexObject;
typedef CUtexObject ccl_gpu_tex_object_2D;
typedef CUtexObject ccl_gpu_tex_object_3D;
typedef CUtexObject ccl_gpu_tex_object;
template<typename T>
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj,
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object texobj,
const float x,
const float y)
{
@@ -88,7 +87,7 @@ ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D
}
template<typename T>
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj,
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object texobj,
const float x,
const float y,
const float z)

View File

@@ -88,7 +88,6 @@
extern "C" __global__ void __launch_bounds__(block_num_threads)
#define ccl_gpu_kernel_signature(name, ...) kernel_gpu_##name(__VA_ARGS__)
#define ccl_gpu_kernel_postfix
#define ccl_gpu_kernel_call(x) x

View File

@@ -56,7 +56,7 @@ ccl_device_noinline T kernel_tex_image_interp_bicubic(ccl_global const TextureIn
float x,
float y)
{
ccl_gpu_tex_object_2D tex = (ccl_gpu_tex_object_2D)info.data;
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
x = (x * info.width) - 0.5f;
y = (y * info.height) - 0.5f;
@@ -85,7 +85,7 @@ template<typename T>
ccl_device_noinline T
kernel_tex_image_interp_tricubic(ccl_global const TextureInfo &info, float x, float y, float z)
{
ccl_gpu_tex_object_3D tex = (ccl_gpu_tex_object_3D)info.data;
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
x = (x * info.width) - 0.5f;
y = (y * info.height) - 0.5f;
@@ -190,7 +190,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
return kernel_tex_image_interp_bicubic<float4>(info, x, y);
}
else {
ccl_gpu_tex_object_2D tex = (ccl_gpu_tex_object_2D)info.data;
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
return ccl_gpu_tex_object_read_2D<float4>(tex, x, y);
}
}
@@ -202,7 +202,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
f = kernel_tex_image_interp_bicubic<float>(info, x, y);
}
else {
ccl_gpu_tex_object_2D tex = (ccl_gpu_tex_object_2D)info.data;
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
f = ccl_gpu_tex_object_read_2D<float>(tex, x, y);
}
@@ -245,7 +245,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
return kernel_tex_image_interp_tricubic<float4>(info, x, y, z);
}
else {
ccl_gpu_tex_object_3D tex = (ccl_gpu_tex_object_3D)info.data;
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
return ccl_gpu_tex_object_read_3D<float4>(tex, x, y, z);
}
}
@@ -256,7 +256,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
f = kernel_tex_image_interp_tricubic<float>(info, x, y, z);
}
else {
ccl_gpu_tex_object_3D tex = (ccl_gpu_tex_object_3D)info.data;
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
f = ccl_gpu_tex_object_read_3D<float>(tex, x, y, z);
}

View File

@@ -58,7 +58,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
INTEGRATOR_STATE_WRITE(state, shadow_path, queued_kernel) = 0;
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_init_from_camera,
@@ -90,7 +89,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(
integrator_init_from_camera(nullptr, state, tile, render_buffer, x, y, sample));
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_init_from_bake,
@@ -122,7 +120,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(
integrator_init_from_bake(nullptr, state, tile, render_buffer, x, y, sample));
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_intersect_closest,
@@ -137,7 +134,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_intersect_closest(NULL, state, render_buffer));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_intersect_shadow,
@@ -151,7 +147,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_intersect_shadow(NULL, state));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_intersect_subsurface,
@@ -165,7 +160,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_intersect_subsurface(NULL, state));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_intersect_volume_stack,
@@ -179,7 +173,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_intersect_volume_stack(NULL, state));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_shade_background,
@@ -194,7 +187,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_shade_background(NULL, state, render_buffer));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_shade_light,
@@ -209,7 +201,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_shade_light(NULL, state, render_buffer));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_shade_shadow,
@@ -224,7 +215,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_shade_shadow(NULL, state, render_buffer));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_shade_surface,
@@ -239,7 +229,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_shade_surface(NULL, state, render_buffer));
}
}
ccl_gpu_kernel_postfix
#ifdef __KERNEL_METAL__
constant int __dummy_constant [[function_constant(0)]];
@@ -267,7 +256,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
#endif
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(integrator_shade_volume,
@@ -282,7 +270,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(integrator_shade_volume(NULL, state, render_buffer));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_queued_paths_array,
@@ -301,7 +288,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_queued_shadow_paths_array,
@@ -320,7 +306,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_active_paths_array,
@@ -336,7 +321,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_terminated_paths_array,
@@ -353,7 +337,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_terminated_shadow_paths_array,
@@ -370,7 +353,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_sorted_paths_array,
@@ -398,7 +380,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE)
key_prefix_sum,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_compact_paths_array,
@@ -418,7 +399,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_compact_states,
@@ -436,7 +416,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_call(integrator_state_move(NULL, to_state, from_state));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_compact_shadow_paths_array,
@@ -456,7 +435,6 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_ACTIVE_INDEX_DEFAULT_BLOCK_SIZE)
num_indices,
ccl_gpu_kernel_lambda_pass);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_signature(integrator_compact_shadow_states,
@@ -474,14 +452,12 @@ ccl_gpu_kernel_threads(GPU_PARALLEL_SORTED_INDEX_DEFAULT_BLOCK_SIZE)
ccl_gpu_kernel_call(integrator_shadow_state_move(NULL, to_state, from_state));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel_threads(GPU_PARALLEL_PREFIX_SUM_DEFAULT_BLOCK_SIZE) ccl_gpu_kernel_signature(
prefix_sum, ccl_global int *counter, ccl_global int *prefix_sum, int num_values)
{
gpu_parallel_prefix_sum(ccl_gpu_global_id_x(), counter, prefix_sum, num_values);
}
ccl_gpu_kernel_postfix
/* --------------------------------------------------------------------
* Adaptive sampling.
@@ -518,7 +494,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
atomic_fetch_and_add_uint32(num_active_pixels, popcount(num_active_pixels_mask));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(adaptive_sampling_filter_x,
@@ -537,7 +512,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
kernel_adaptive_sampling_filter_x(NULL, render_buffer, sy + y, sx, sw, offset, stride));
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(adaptive_sampling_filter_y,
@@ -556,7 +530,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
kernel_adaptive_sampling_filter_y(NULL, render_buffer, sx + x, sy, sh, offset, stride));
}
}
ccl_gpu_kernel_postfix
/* --------------------------------------------------------------------
* Cryptomatte.
@@ -573,7 +546,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(kernel_cryptomatte_post(nullptr, render_buffer, pixel_index));
}
}
ccl_gpu_kernel_postfix
/* --------------------------------------------------------------------
* Film.
@@ -655,7 +627,6 @@ ccl_device_inline void kernel_gpu_film_convert_half_write(ccl_global uchar4 *rgb
\
FILM_GET_PASS_PIXEL_F32(variant, input_channel_count); \
} \
ccl_gpu_kernel_postfix \
\
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) \
ccl_gpu_kernel_signature(film_convert_##variant##_half_rgba, \
@@ -695,8 +666,7 @@ ccl_device_inline void kernel_gpu_film_convert_half_write(ccl_global uchar4 *rgb
const half4 half_pixel = float4_to_half4_display( \
make_float4(pixel[0], pixel[1], pixel[2], pixel[3])); \
kernel_gpu_film_convert_half_write(rgba, rgba_offset, rgba_stride, x, y, half_pixel); \
} \
ccl_gpu_kernel_postfix
}
/* 1 channel inputs */
KERNEL_FILM_CONVERT_VARIANT(depth, 1)
@@ -736,7 +706,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(kernel_displace_evaluate(NULL, input, output, offset + i));
}
}
ccl_gpu_kernel_postfix
/* Background */
@@ -752,7 +721,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_call(kernel_background_evaluate(NULL, input, output, offset + i));
}
}
ccl_gpu_kernel_postfix
/* Curve Shadow Transparency */
@@ -769,7 +737,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
kernel_curve_shadow_transparency_evaluate(NULL, input, output, offset + i));
}
}
ccl_gpu_kernel_postfix
/* --------------------------------------------------------------------
* Denoising.
@@ -803,7 +770,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
color_out[1] = clamp(color_out[1], 0.0f, 10000.0f);
color_out[2] = clamp(color_out[2], 0.0f, 10000.0f);
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(filter_guiding_preprocess,
@@ -883,7 +849,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
flow_out[1] = -motion_in[1] * pixel_scale;
}
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(filter_guiding_set_fake_albedo,
@@ -912,7 +877,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
albedo_out[1] = 0.5f;
albedo_out[2] = 0.5f;
}
ccl_gpu_kernel_postfix
ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
ccl_gpu_kernel_signature(filter_color_postprocess,
@@ -972,7 +936,6 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
denoised_pixel[3] = 0;
}
}
ccl_gpu_kernel_postfix
/* --------------------------------------------------------------------
* Shadow catcher.
@@ -998,4 +961,3 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
atomic_fetch_and_add_uint32(num_possible_splits, popcount(can_split_mask));
}
}
ccl_gpu_kernel_postfix

View File

@@ -73,11 +73,10 @@ typedef unsigned long long uint64_t;
#define ccl_gpu_ballot(predicate) __ballot(predicate)
/* GPU texture objects */
typedef hipTextureObject_t ccl_gpu_tex_object_2D;
typedef hipTextureObject_t ccl_gpu_tex_object_3D;
typedef hipTextureObject_t ccl_gpu_tex_object;
template<typename T>
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj,
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object texobj,
const float x,
const float y)
{
@@ -85,7 +84,7 @@ ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D
}
template<typename T>
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj,
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object texobj,
const float x,
const float y,
const float z)

View File

@@ -31,7 +31,6 @@
extern "C" __global__ void __launch_bounds__(block_num_threads)
#define ccl_gpu_kernel_signature(name, ...) kernel_gpu_##name(__VA_ARGS__)
#define ccl_gpu_kernel_postfix
#define ccl_gpu_kernel_call(x) x

View File

@@ -132,7 +132,6 @@ void kernel_gpu_##name::run(thread MetalKernelContext& context, \
uint simd_group_index, \
uint num_simd_groups) ccl_global const
#define ccl_gpu_kernel_postfix
#define ccl_gpu_kernel_call(x) context.x
/* define a function object where "func" is the lambda body, and additional parameters are used to specify captured state */

View File

@@ -19,18 +19,17 @@ class MetalKernelContext {
{}
/* texture fetch adapter functions */
typedef uint64_t ccl_gpu_tex_object_2D;
typedef uint64_t ccl_gpu_tex_object_3D;
typedef uint64_t ccl_gpu_tex_object;
template<typename T>
inline __attribute__((__always_inline__))
T ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const {
T ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object tex, float x, float y) const {
kernel_assert(0);
return 0;
}
template<typename T>
inline __attribute__((__always_inline__))
T ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const {
T ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object tex, float x, float y, float z) const {
kernel_assert(0);
return 0;
}
@@ -38,14 +37,14 @@ class MetalKernelContext {
// texture2d
template<>
inline __attribute__((__always_inline__))
float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const {
float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object tex, float x, float y) const {
const uint tid(tex);
const uint sid(tex >> 32);
return metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, y));
}
template<>
inline __attribute__((__always_inline__))
float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float y) const {
float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object tex, float x, float y) const {
const uint tid(tex);
const uint sid(tex >> 32);
return metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, y)).x;
@@ -54,14 +53,14 @@ class MetalKernelContext {
// texture3d
template<>
inline __attribute__((__always_inline__))
float4 ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const {
float4 ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object tex, float x, float y, float z) const {
const uint tid(tex);
const uint sid(tex >> 32);
return metal_ancillaries->textures_3d[tid].tex.sample(metal_samplers[sid], float3(x, y, z));
}
template<>
inline __attribute__((__always_inline__))
float ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object_3D tex, float x, float y, float z) const {
float ccl_gpu_tex_object_read_3D(ccl_gpu_tex_object tex, float x, float y, float z) const {
const uint tid(tex);
const uint sid(tex >> 32);
return metal_ancillaries->textures_3d[tid].tex.sample(metal_samplers[sid], float3(x, y, z)).x;

View File

@@ -78,11 +78,10 @@ typedef unsigned long long uint64_t;
/* GPU texture objects */
typedef unsigned long long CUtexObject;
typedef CUtexObject ccl_gpu_tex_object_2D;
typedef CUtexObject ccl_gpu_tex_object_3D;
typedef CUtexObject ccl_gpu_tex_object;
template<typename T>
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj,
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object texobj,
const float x,
const float y)
{
@@ -90,7 +89,7 @@ ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D
}
template<typename T>
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj,
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object texobj,
const float x,
const float y,
const float z)

View File

@@ -320,13 +320,12 @@ ccl_device_inline void kernel_accum_combined_transparent_pass(KernelGlobals kg,
}
/* Write background or emission to appropriate pass. */
ccl_device_inline void kernel_accum_emission_or_background_pass(
KernelGlobals kg,
ConstIntegratorState state,
float3 contribution,
ccl_global float *ccl_restrict buffer,
const int pass,
const int lightgroup = LIGHTGROUP_NONE)
ccl_device_inline void kernel_accum_emission_or_background_pass(KernelGlobals kg,
ConstIntegratorState state,
float3 contribution,
ccl_global float *ccl_restrict
buffer,
const int pass)
{
if (!(kernel_data.film.light_pass_flag & PASS_ANY)) {
return;
@@ -348,22 +347,11 @@ ccl_device_inline void kernel_accum_emission_or_background_pass(
}
# endif /* __DENOISING_FEATURES__ */
if (lightgroup != LIGHTGROUP_NONE && kernel_data.film.pass_lightgroup != PASS_UNUSED) {
kernel_write_pass_float3(buffer + kernel_data.film.pass_lightgroup + 3 * lightgroup,
contribution);
}
if (!(path_flag & PATH_RAY_ANY_PASS)) {
/* Directly visible, write to emission or background pass. */
pass_offset = pass;
}
else if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
/* Don't write any light passes for shadow catcher, for easier
* compositing back together of the combined pass. */
if (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) {
return;
}
if (path_flag & PATH_RAY_SURFACE_PASS) {
/* Indirectly visible through reflection. */
const float3 diffuse_weight = INTEGRATOR_STATE(state, path, pass_diffuse_weight);
@@ -449,19 +437,6 @@ ccl_device_inline void kernel_accum_light(KernelGlobals kg,
if (kernel_data.film.light_pass_flag & PASS_ANY) {
const uint32_t path_flag = INTEGRATOR_STATE(state, shadow_path, flag);
/* Don't write any light passes for shadow catcher, for easier
* compositing back together of the combined pass. */
if (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) {
return;
}
/* Write lightgroup pass. LIGHTGROUP_NONE is ~0 so decode from unsigned to signed */
const int lightgroup = (int)(INTEGRATOR_STATE(state, shadow_path, lightgroup)) - 1;
if (lightgroup != LIGHTGROUP_NONE && kernel_data.film.pass_lightgroup != PASS_UNUSED) {
kernel_write_pass_float3(buffer + kernel_data.film.pass_lightgroup + 3 * lightgroup,
contribution);
}
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
int pass_offset = PASS_UNUSED;
@@ -579,20 +554,15 @@ ccl_device_inline void kernel_accum_background(KernelGlobals kg,
kernel_accum_combined_transparent_pass(
kg, path_flag, sample, contribution, transparent, buffer);
}
kernel_accum_emission_or_background_pass(kg,
state,
contribution,
buffer,
kernel_data.film.pass_background,
kernel_data.background.lightgroup);
kernel_accum_emission_or_background_pass(
kg, state, contribution, buffer, kernel_data.film.pass_background);
}
/* Write emission to render buffer. */
ccl_device_inline void kernel_accum_emission(KernelGlobals kg,
ConstIntegratorState state,
const float3 L,
ccl_global float *ccl_restrict render_buffer,
const int lightgroup = LIGHTGROUP_NONE)
ccl_global float *ccl_restrict render_buffer)
{
float3 contribution = L;
kernel_accum_clamp(kg, &contribution, INTEGRATOR_STATE(state, path, bounce) - 1);
@@ -603,7 +573,7 @@ ccl_device_inline void kernel_accum_emission(KernelGlobals kg,
kernel_accum_combined_pass(kg, path_flag, sample, contribution, buffer);
kernel_accum_emission_or_background_pass(
kg, state, contribution, buffer, kernel_data.film.pass_emission, lightgroup);
kg, state, contribution, buffer, kernel_data.film.pass_emission);
}
CCL_NAMESPACE_END

View File

@@ -451,7 +451,7 @@ ccl_device_inline float4 film_calculate_shadow_catcher_matte_with_shadow(
float scale, scale_exposure;
if (!film_get_scale_and_scale_exposure(kfilm_convert, buffer, &scale, &scale_exposure)) {
return zero_float4();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
ccl_global const float *in_matte = buffer + kfilm_convert->pass_shadow_catcher_matte;

View File

@@ -164,7 +164,7 @@ ccl_device float4 curve_attribute_float4(KernelGlobals kg,
if (dx)
*dx = sd->du.dx * (f1 - f0);
if (dy)
*dy = zero_float4();
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
# endif
return (1.0f - sd->u) * f0 + sd->u * f1;
@@ -172,9 +172,9 @@ ccl_device float4 curve_attribute_float4(KernelGlobals kg,
else {
# ifdef __RAY_DIFFERENTIALS__
if (dx)
*dx = zero_float4();
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
if (dy)
*dy = zero_float4();
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
# endif
if (desc.element & (ATTR_ELEMENT_CURVE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
@@ -183,7 +183,7 @@ ccl_device float4 curve_attribute_float4(KernelGlobals kg,
return kernel_tex_fetch(__attributes_float4, offset);
}
else {
return zero_float4();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
}
}

View File

@@ -283,26 +283,6 @@ ccl_device_inline float object_pass_id(KernelGlobals kg, int object)
return kernel_tex_fetch(__objects, object).pass_id;
}
/* Lightgroup of lamp */
ccl_device_inline int lamp_lightgroup(KernelGlobals kg, int lamp)
{
if (lamp == LAMP_NONE)
return LIGHTGROUP_NONE;
return kernel_tex_fetch(__lights, lamp).lightgroup;
}
/* Lightgroup of object */
ccl_device_inline int object_lightgroup(KernelGlobals kg, int object)
{
if (object == OBJECT_NONE)
return LIGHTGROUP_NONE;
return kernel_tex_fetch(__objects, object).lightgroup;
}
/* Per lamp random number for shader variation */
ccl_device_inline float lamp_random_number(KernelGlobals kg, int lamp)

View File

@@ -391,11 +391,11 @@ ccl_device float4 patch_eval_float4(KernelGlobals kg,
int num_control = patch_eval_control_verts(
kg, sd->object, patch, u, v, channel, indices, weights, weights_du, weights_dv);
float4 val = zero_float4();
float4 val = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
if (du)
*du = zero_float4();
*du = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
if (dv)
*dv = zero_float4();
*dv = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; i < num_control; i++) {
float4 v = kernel_tex_fetch(__attributes_float4, offset + indices[i]);
@@ -428,11 +428,11 @@ ccl_device float4 patch_eval_uchar4(KernelGlobals kg,
int num_control = patch_eval_control_verts(
kg, sd->object, patch, u, v, channel, indices, weights, weights_du, weights_dv);
float4 val = zero_float4();
float4 val = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
if (du)
*du = zero_float4();
*du = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
if (dv)
*dv = zero_float4();
*dv = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; i < num_control; i++) {
float4 v = color_srgb_to_linear_v4(

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