Commit Graph

4726 Commits

Author SHA1 Message Date
Jeroen Bakker
76a1824c52 GPU: Force Workarounds Viewport Layer Array
The OpenGL extension `GL_ARB_shader_viewport_layer_array` wasn't turned
off when starting blender with `--debug-gpu-force-workarounds`. Although
all known supported platforms support this extension and we haven't seen
any failures with it, it was mentioned to be phased out as we consider
it to be a core extension, which it isn't.

This PR will enable the workaround for this extension and remove the
extension from the phase out list.

Pull Request: https://projects.blender.org/blender/blender/pulls/113572
2023-10-12 07:58:33 +02:00
Campbell Barton
b4504c7840 Cleanup: spelling in comments 2023-10-12 16:03:18 +11:00
Campbell Barton
db093a4608 Merge branch 'blender-v4.0-release' 2023-10-12 09:27:43 +11:00
Campbell Barton
b8ad624006 Cleanup: use doxygen doc-strings, spelling in comments 2023-10-12 09:26:53 +11:00
Miguel Pozo
3f72c62be6 GPU: Add GPU_max_storage_buffer_size
Needed for #113509.

Using a `size_t` since some GPUs should support >4GB buffers,
but Vulkan exposes the value as a `uint` and Metal as an `int`.

Pull Request: https://projects.blender.org/blender/blender/pulls/113516
2023-10-11 19:26:40 +02:00
Campbell Barton
91ec9bc5a7 Cleanup: don't use DOXYGEN blocks for inline comments 2023-10-11 10:49:07 +11:00
Jason Fielder
d5139065f1 Metal: Improve input latency management
This patch improves the heuristic used to
determine maximum frames-in-flight at
different input latency levels.

Previous values adjusted to better encapsulate
workloads in the 10-20 FPS range which can
manifest excessive latency. Changes improve
total performance throughput and improve
the interactive user experience.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/113020
2023-10-10 12:27:56 +02:00
Jeroen Bakker
f361cfa361 Vulkan: Bundle Immediate Mode Calls
When using Immediate mode emulation the data is stored in a ring buffer.
As data isn't overwritten it is safe to call multiple draw commands in
a single command buffer.

This improves drawing performance when immediate mode is being used, it
mostly improves the readability of the GPU traces in renderdoc.

Pull Request: https://projects.blender.org/blender/blender/pulls/113482
2023-10-10 09:54:35 +02:00
Jeroen Bakker
d67ec32747 Vulkan: Support for Framebuffer with Missing Attachments
Wireframe mode wasn't working and viewport had flickering artifacts.
Reason was that the render pass creation failed for its framebuffer as
the input data was filled with garbage for attachments that were unused.

Vulkan requires every attachment to be filled upto the highest used attachment
slot. This PR fills missing attachments with a dummy texture.

Pull Request: https://projects.blender.org/blender/blender/pulls/113141
2023-10-10 09:27:07 +02:00
Campbell Barton
137f8dd7bc Cleanup: spelling in comments 2023-10-10 09:44:57 +11:00
Campbell Barton
1bb098bf44 CMake: WITH_OPENGL_BACKEND=OFF excludes EGL/EPOXY includes & libraries
This isn't complete as opensubdiv, hydra & XR still depend on OpenGL.
2023-10-07 18:30:17 +11:00
Campbell Barton
126cf64004 CMake: quiet undefined variable use with MOLTENVK on non-apple systems 2023-10-07 18:25:44 +11:00
Miguel Pozo
026b81ce7c Merge branch 'blender-v4.0-release' 2023-10-06 17:49:15 +02:00
Miguel Pozo
c6194afc41 Fix: Workbench: Missing texture flag
Drawing volumes would trigger an assertion after fe39456ba5.
2023-10-06 17:48:40 +02:00
Jeroen Bakker
4a94e17156 Cleanup: Remove unused attribute in GLShaderInterface 2023-10-06 07:47:08 +02:00
Campbell Barton
71b1712d79 Cleanup: spelling in comments 2023-10-06 12:50:27 +11:00
Brecht Van Lommel
1849e192fa Merge branch 'blender-v4.0-release' into main 2023-10-05 22:03:29 +02:00
coyo_t
b0706a57ac Fix #106760: Cycles OSL boolean socket not working
Pull Request: https://projects.blender.org/blender/blender/pulls/109576
2023-10-05 21:55:10 +02:00
Jason Fielder
57a3ab29cc Metal: EEVEE Next: Optimize Virtual shadow maps for Apple Silicon
Optimization of EEVEE Next's Virtual Shadow Maps for TBDRs.
The core of these optimizations lie in eliminating use of
atomic shadow atlas writes and instead utilise tile memory to
perform depth accumulation as a secondary pass once all
geometry updates for a given shadow view have been updated.

This also allows use of fast on-tile depth testing/sorting, reducing
overdraw and redundant fragment operations, while also allowing
for tile indirection calculations to be offloaded into the vertex
shader to increase fragment storage efficiency and throughput.

Authored by Apple: Michael Parkin-White

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/111283
2023-10-05 19:02:39 +02:00
Clément Foucault
9d229aee19 Math: Add from_up_axis matrix creation function
This add the possibility to create a
orthogonal basis around a given unit
vector.

The name was chosen to match the naming
convention already in place and match
the other matrix construction functions.
In other places (ex: renderers), this same
function is commonly named `make_orthonormal`
or `make_basis`.

The function is not given to have a fixed
implementation and might change overtime.
That's why the test only covers the
assumptions and not the raw values.

The implementation is borrowed from
Cycles and adapted to our math API.

Pull Request: https://projects.blender.org/blender/blender/pulls/113218
2023-10-04 14:35:47 +02:00
Campbell Barton
9c018def3e Cleanup: spelling in comments 2023-10-03 11:24:48 +11:00
Clément Foucault
7f7e1ab088 GL: Remove Apple platform specific workarounds
We don't ship with OpenGL anymore on Mac platform.
The build option is not even available anymore.

This removes any reference to Apple or Mac in the
Opengl module.

Note that I left the depth_blitting_workaround
even if it originaly meant for Mac because it
might be still useful for other hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/113126
2023-10-02 10:29:57 +02:00
Sergey Sharybin
732bfba6b8 Cleanup: Strict compiler arning
Unused function argument in the Metal framebuffer.
2023-10-02 09:51:56 +02:00
Clément Foucault
8fe0ffed4e GL: Subpass transition fix with GPU_ATTACHEMENT_IGNORE
GPU_ATTACHEMENT_IGNORE should work on slots that
contain no attachments.
2023-10-01 18:01:15 +02:00
Clément Foucault
8b7bbee14f GL: Add support for loadop
This just do a clear in place for the clear load op.
At least it allows for same result accross backend as
the other op types are only here for performance.
2023-10-01 18:01:15 +02:00
Clément Foucault
9c6e3c80c7 GL: Fix depth clearing with clear_attachment
The depth write mask was no always set to true.
2023-10-01 18:01:15 +02:00
Harley Acheson
f30280a1d1 Cleanup: Make format
Formatting changes resulting from Make Format.
2023-10-01 08:50:28 -07:00
Clément Foucault
4a4b1482cd GL: Add subpass input emulation
This adds basic emulation of the subpass input feature
of vulkan and to a lower extend Raster Order Group on Metal.

This help test paths that might use this feature in the future
(like shadow rendering) on all platform and or simplify higher
level code for supporting older hardware.

This add clear description to the load/store ops and to the
new `GPUAttachementState`.

The OpenGL backend will correctly mask un-writable
attachments and will bind as texture readable attachments.

Even if possible by the vulkan standard, the GPU API prohibit
the read and write to the same attachment inside the same
subpass.

In the GL backend, this is implemented using `glTextureBarrier`
and `texelFetch` as it is described in the ARB_texture_barrier
extension.
https://registry.khronos.org/OpenGL/extensions/ARB/ARB_texture_barrier.txt

Pull Request: https://projects.blender.org/blender/blender/pulls/112051
2023-10-01 15:27:21 +02:00
Clément Foucault
ad50ded7b5 Metal: Fix texture atomic wrapper
GLSL imageAtomic operations operate on single components.
2023-09-30 21:37:44 +02:00
Jeroen Bakker
f97a56eedd Vulkan: Fix Blitting Extents
During Blitting it is not allowed to read/write outside
the texture bounds. This patch ensures that the bounds
(called extents in Vulkan) are inside the expected range.

Pull Request: https://projects.blender.org/blender/blender/pulls/113050
2023-09-29 11:44:50 +02:00
Julian Eisel
b5599fed3d Merge branch 'blender-v4.0-release' 2023-09-28 19:30:23 +02:00
Jason Fielder
06f27b564c Fix: DRW: Flickering and sync in Metal
Flickering caused by in-flight SSBO data
overwrites has been resolved by ensuring
data updates go into a new buffer while
existing data is in flight.

GPU_finish has also been removed from
SSBO read due to its frequent mid-frame use
limiting performance.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/113019
2023-09-28 18:42:49 +02:00
Julian Eisel
8d556733b3 Merge branch 'blender-v4.0-release' 2023-09-28 16:20:11 +02:00
Brecht Van Lommel
66056fead0 Fix #112632: crash batch generating previews with Cycles
Don't assume existence of GPU backend in (background) preview rendering.

Also add null pointer checks and rely on assert instead to detect
invalid usage of GPU_render_begin/end, so that potential future mistakes
don't cause crashes.

Pull Request: https://projects.blender.org/blender/blender/pulls/112971
2023-09-28 16:13:09 +02:00
Jason Fielder
e64db67fa5 GPU: Add platform parameter for GPU architecture
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/112566
2023-09-28 12:49:55 +02:00
Jeroen Bakker
ad93324580 Vulkan: Add support for Framebuffer Depth Blit
This PR adds support for `GPU_framebuffer_blit` When used with `GPU_DEPTH_BIT`.
The challenge with is that not all GPUs support using a depth texture as a blit destination.

An AMD GPU doesn't support a depth buffer with stencil buffer as blit destination.
![image](/attachments/130e7e38-2dbc-4653-950c-2234bd5bad52)
> NOTE: AMD GPUs don't support 24 bit unsigned normalized depth textures at all.

In all cases when we use depth blitting we are blitting the whole texture
and in stead we can use a texture copy.

A negative effect is that we need to unbind the framebuffer when copying
depth textures, but a positive effect is that we can use a data transfer function what should
theoretically be faster.

This should be revisited when we are investigating in areas to improve the
performance of the Vulkan backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/112674
2023-09-28 10:00:24 +02:00
Jeroen Bakker
e5a33b3b2c Vulkan: Rework Initializing/Allocating Textures
When initialy adding textures it wasn't possible to allocate during
initialization as its usage wasn't known. Bot Metal and Vulkan would do
a delayed allocation adding more checks when using textures.

Recently the behavior of setting texture usage was changed and now is
known when initializing textures. This PR makes advantage of this to
give correct feedback to the calling code if the texture can be created
and remove all the delayed allocating of textures.

Pull Request: https://projects.blender.org/blender/blender/pulls/112997
2023-09-28 09:38:52 +02:00
Clément Foucault
3a4fc2c94e EEVEE-Next: Shadow Map Tracing Initial Implementation
Shadow Map Ray Tracing is a technique that ray cast against the shadow
depth buffer. The technique is described in "Soft Shadows by
Ray Tracing Multilayer Transparent Shadow Maps".
Note that we only implement the single layer approach since storing
multiple depth is prohibitively expensive.

Pull Request: https://projects.blender.org/blender/blender/pulls/111809
2023-09-26 23:42:40 +02:00
Jeroen Bakker
7dbe689b63 Vulkan: Use Point Shaders When Drawing Points
In Vulkan (and Metal) it is not possible to use a global as point
size. It needs to be set for each vertex when drawing points. Blender
has specialized shaders for that, but not all code respect those
shaders.

This PR will add an assert inside the vulkan backend when incorrect
usage of shaders are detected.

Pull Request: https://projects.blender.org/blender/blender/pulls/112906
2023-09-26 16:04:08 +02:00
Clément Foucault
788506d7fc GPU: add pragma once to GPU_shader_shared.h
Otherwise there are compilation issues
when the file happens to be included twice.
2023-09-26 15:19:51 +02:00
Campbell Barton
077832e063 Cleanup: spelling in comments 2023-09-26 19:50:48 +10:00
Clément Foucault
a5741e0561 EEVEE: Change do_multiscatter to a bool internally
This avoid confusion outside of the shader node GLSL code.
The issue also is that Metal allow float to cast to bool
implicitly but this create a compilation error on
OpenGL.
2023-09-26 11:48:51 +02:00
Clément Foucault
0a4fa62f51 EEVEE: Add support for metallic F82 tint
This adds a new entry to the split sum LUT to isolate
the effect of the F82 tint.

The application of the tint part is similar to cycles
and uses the same way for precomputing the `b` factor.

Results matches almost perfectly to the extent of the
split sum approximation.

Note that this removes the unused LTC MAG LUT for
EEVEE next to make space for the new table. It can still
be added back if needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/112881
2023-09-26 10:16:39 +02:00
Jason Fielder
ee03bb38cb Metal: Add support for atomic image operations
Texture Atomics have been added in Metal 3.1
and enable the original implementations of
shadow update and irradiance cache baking.

However, a fallback solution will be
required for versions under macOS 14.0 utilising
buffer-backed textures instead.

This patch also includes a stub implementation if
building/running on older macOS versions which
provides locally-synchronized texture access in
place of atomics. This enables some effects to be
partially tested, and ensures non-guarded use
of imageAtomic functions does not result
in compilation failure.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/112866
2023-09-25 21:56:46 +02:00
Brecht Van Lommel
3d38b51435 Shaders: add "Weight" to Transmission/Subsurface/Coat/Sheen socket names
Ref #99447
Ref #112848
2023-09-25 19:51:27 +02:00
Brecht Van Lommel
1d265eed5d Shaders: rename Specular to Specular IOR Level in Principled BSDF
To clarify that this is no longer the primary control, but rather
and adjustment on IOR.

Ref #99447
Ref #112552
2023-09-25 19:51:22 +02:00
Brecht Van Lommel
239edb27ad EEVEE: optimize principled BSDF by skipping unused components
Ref #99447
Ref #112848
2023-09-25 19:51:17 +02:00
Alaska
a03ee1af81 Shaders: clamp various shader inputs for Principled BSDF
Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112774
2023-09-25 19:51:12 +02:00
Lukas Stockner
6e2f29b421 Shader: change Specular input on Principled BSDF to affect IOR
This keeps the behavior similar to the Disney BRDF, where 0.5
is neutral and lower/higher values respectively decrease/increase
the dielectric specular. But it's more correct in that it's not
an arbitrary scale on Fresnel, but rather adjusting the IOR.

Ref #99447
Ref #112848

Pull Request: https://projects.blender.org/blender/blender/pulls/112552
2023-09-25 19:51:02 +02:00
Brecht Van Lommel
3d986b81c5 Shaders: move subsurface scale input below radius in Principled BSDF
To help clarify that this is a scale on the radius.

Ref #99447
Ref #112848
2023-09-25 19:50:56 +02:00