Commit Graph

5155 Commits

Author SHA1 Message Date
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/121637
2024-05-13 16:07:12 +02:00
Jeroen Bakker
e0da623d33 Vulkan: Don't record drawlist commands for invalid batches
Overlay engine extra layer can record draw list commands with an
empty index buffer. This would not affect any pixels and should be
ignored.

Issue detected when vulkan validation layers are turned on and loading
default scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/121736
2024-05-13 14:09:37 +02:00
Jeroen Bakker
5c369768d7 Vulkan: Revert incorrect fix for begin rendering
Reverting a quick fix which didn't solve the root cause. The root
cause was fixed by #121723.

Pull Request: https://projects.blender.org/blender/blender/pulls/121726
2024-05-13 13:28:05 +02:00
Jeroen Bakker
b998697d4f Vulkan: Fix out of bound access in begin rendering
There is an implementation flaw in the render graph where local pointers
cannot be updated, but the data it refers to can be reallocated to
another location.

The cause of this is that the nodes use an union, which can only contain
simple constructed structs (eg memcpy). this union is stored in a vector
and can relocate the union. Any local pointers can (and will) become
invalid.

This PR is a quick fix by updating the pointers just before sending
them to the command buffer. In future a better fox needs to be done
as part of #121649.

Pull Request: https://projects.blender.org/blender/blender/pulls/121723
2024-05-13 09:35:36 +02:00
Jason Fielder
405be29540 Metal: Fix texture update data sizing for compressed textures
Resolves issue for texture data upload sizing not taking
compressed texture input data size into account.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/121210
2024-05-13 09:35:08 +02:00
Jeroen Bakker
ca40b12240 Vulkan: Remove unneeded device usage in render graph tests
The render graph tests initialized a command buffer wrapper that
requires a working device. The wrapper was not used, but when
destructing it would try to deallocate the command buffer, which
cannot be done as that requires a working device as well.

This PR removes the unneeded command buffer wrappers in the test
cases.
2024-05-13 08:32:58 +02:00
Clément Foucault
e63fef6162 Fix: EEVEE-Legacy: Broken Specular BSDF 2024-05-11 17:08:15 +02:00
Clément Foucault
414854a09f Metal: Change error assert into system backtrace
This matches the behavior of the GL backend debug.
2024-05-11 12:47:23 +02:00
Aras Pranckevicius
3582e52f9c UI: Improved overlay text contrast with new outline text decoration
Overlay texts were previously drawn with two sets of shadows:
- 3px blur,
- 5px blur, slightly offset

But since the shadow color was always set to black, it was still
causing legibility issues when the text itself was dark (set
via theme for example).

This PR adds a new "outline" BLF text decoration, and uses that
for the overlays. And it picks text/outline color depending
on the "background" color of the view.

Details:

- Instead of "shadow level" integer where the only valid options
  are 0, 3 or 5, have a FontShadowType enum.
- Add a new FontShadowType::Outline enum entry, that does a 1px
  outline by doing a 3x3 dilation in the font shader.
- BLF_draw_default_shadowed is changed to do outline, instead of
  drawing the shadow twice.
- In the font shader, instead of encoding shadow type in signs of
  the glyph_size, pass that as a "flags" vertex attribute. Put
  font texture channel count into the same flags, so that the
  vertex size stays the same.
- Well actually, vertex size becomes smaller by 4 bytes, since turns
  out glyph_mode vertex attribute was not used for anything at all.

Images in the PR.

Co-authored-by: Harley Acheson <harley.acheson@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/121383
2024-05-10 21:06:44 +02:00
Jeroen Bakker
b78875c675 Vulkan: Disable failing test
Result isn't consistent on Windows platform due to copying structs with arrays.
This is a quick fix and will be looked at next week. The code isn't used at this moment.

Pull Request: https://projects.blender.org/blender/blender/pulls/121670
2024-05-10 20:29:25 +02:00
Jeroen Bakker
40f2df1a81 Vulkan: Render graph clear attachments
Adds support for clear attachments to the render graph.
Clearing attachments require that the command buffer is
being set for rendering (vkCmdBeginRendering).

**What works**

- Clear attachments are working with dynamic rendering and the render graph
- `GPUVulkanTest.framebuffer_clear_color_single_attachment`
- `GPUVulkanTest.framebuffer_clear_color_multiple_attachments`
- `GPUVulkanTest.framebuffer_clear_multiple_color_multiple_attachments`
- `GPUVulkanTest.framebuffer_scissor_test`
- `GPUVulkanTest.framebuffer_clear_depth`

**What still needs to be addressed**

When a command buffer is rendering it cannot do any pipeline
barriers. For clearing attachments this isn't needed, but when
we address drawing we might need to register drawing resource
dependencies to the dependency list of the begin rendering node.
This will be solved when drawing will be implemented. [#121648]

The begin rendering node is large as it has to store data for
framebuffers with 8 color attachments as well. This might
become an overhead and we could solve this by splicing the
data of larger nodes into 2 lists. This will be addressed
after we are able to draw a screen so we can collect data
on this topic. [#121649]

Pull Request: https://projects.blender.org/blender/blender/pulls/121073
2024-05-10 15:39:56 +02:00
Jeroen Bakker
ac005ba20e Vulkan: Add dynamic rendering to command buffer API
This PR adds the dynamic rendering function to the command buffer
API.

Pull Request: https://projects.blender.org/blender/blender/pulls/121645
2024-05-10 10:32:55 +02:00
Jeroen Bakker
2f05a24457 Vulkan: Determine image layout from resource access
Currently the image layout was fixed when creating pipeline barriers.
This PR determined the image layout an image is in based on its access
mask.

This extends the usage of the render graph and its pipeline barrier
generation for render attachments. In future it can be extended to
support other layouts.

Pull Request: https://projects.blender.org/blender/blender/pulls/121646
2024-05-10 10:28:02 +02:00
Jeroen Bakker
6ad541c6b9 Cleanup: Remove debug code
Pull Request: https://projects.blender.org/blender/blender/pulls/121643
2024-05-10 10:23:39 +02:00
Jeroen Bakker
79dfe8d37f Vulkan: Enable device feature dynamic rendering
In the near future the legacy framebuffer/renderpass/pipeline drawing
will be replaced by dynamic rendering. Dynamic rendering provide a
flexible API to reuse pipelines between framebuffers if they share
the same image formats.

Dynamic rendering is provided by `VK_KHR_dynamic_rendering` extension
and is supported by all platforms we support (Intel since HD4000, NVIDIA
since 700, AMD since GCN2 and llvmpipe).

Functions provided by extensions are loaded in a struct inside
`VKDevice`.

Pull Request: https://projects.blender.org/blender/blender/pulls/121642
2024-05-10 10:22:58 +02:00
Miguel Pozo
a7ff3ebad1 Fix: GPU: GPUColorBandBuilder memory leak 2024-05-09 19:38:22 +02:00
Jason Fielder
996014e537 EEVEE Next: Disable TILE_COPY shadow update method
Disabling tile_copy method for shadow update for
stability in scenes with large geometry counts
which may exceed parameter buffer size.

This pass can be re-used in future if the workload
distribution for shadow updates is changed to
better suit this method.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/121623
2024-05-09 15:50:53 +02:00
Clément Foucault
732d0c56df GPU: Add atan_fast 2024-05-09 12:33:13 +02:00
Clément Foucault
94a83bcf04 EEVEE-Next: Make Specular BSDF work
This removes the ambient occlusion socket as this
have no use in EEVEE-Next.

Add correct material flags for noiseless clear coat
and fix transparency.
2024-05-09 11:59:27 +02:00
Jeroen Bakker
c50a0f6478 Cleanup: Framebuffer tests expect parameter order
Framebuffer tests use incorrect order of parameters, which lead to messages
misinforming the developer.

Pull Request: https://projects.blender.org/blender/blender/pulls/121481
2024-05-06 16:19:52 +02:00
Jeroen Bakker
d2d1311023 OpenGL: Disable multi texture binding on Windows with Intel GPUs
Multiple generations of Intel GPU have the same issue where multi
texture binding results in invalid operations where the driver
reports that the internal texture format isn't supported.

Previously this was only enabled for UHD devices, but this PR
enables it for any Intel GPU. It was detected to be faulty on
UHD600 and Iris.

Pull Request: https://projects.blender.org/blender/blender/pulls/121479
2024-05-06 14:57:25 +02:00
Campbell Barton
ab6e00bd7d Cleanup: sort cmake file lists 2024-05-06 09:20:57 +10:00
Campbell Barton
4f5f0040c0 Cleanup: back-tick quote file extensions in code-comments 2024-05-04 15:06:46 +10:00
Clément Foucault
b00c6d7d13 GPU: Fix shader builder stubs 2024-05-03 12:24:33 +02:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Bastien Montagne
ec350a6115 BKE ID copy: Pass new owner ID when possible.
Advanced ID copying code can now take a `new_owner_id` ID pointer parameter,
and use it to set the relevant 'loopback' pointer to its owner ID by the
copy code itself.

Besides avoiding the need for all code copying embedded IDs to set the
loopback pointer themselves, this also means that `lib_id` copying code
itself does not need to use `IDWALK_IGNORE_MISSING_OWNER_ID` anymore.

This change is not expected to have any effect in current codebase.
2024-05-02 17:17:04 +02:00
Lukas Stockner
17f2cdd104 Cycles: Add thin film iridescence to Principled BSDF
This is an implementation of thin film iridescence in the Principled BSDF based on "A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence".

There are still several open topics that are left for future work:
- Currently, the thin film only affects dielectric Fresnel, not metallic. Properly specifying thin films on metals requires a proper conductive Fresnel term with complex IOR inputs, any attempt of trying to hack it into the F82 model we currently use for the Principled BSDF is fundamentally flawed. In the future, we'll add a node for proper conductive Fresnel, including thin films.
- The F0/F90 control is not very elegantly implemented right now. It fundamentally works, but enabling thin film while using a Specular Tint causes a jump in appearance since the models integrate it differently. Then again, thin film interference is a physical effect, so of course a non-physical tweak doesn't play nicely with it.
- The white point handling is currently quite crude. In short: The code computes XYZ values of the reflectance spectrum, but we'd need the XYZ values of the product of the reflectance spectrum and the neutral illuminant of the working color space. Currently, this is addressed by just dividing by the XYZ values of the illuminant, but it would be better to do a proper chromatic adaptation transform or to use the proper reference curves for the working space instead of the XYZ curves from the paper.

Pull Request: https://projects.blender.org/blender/blender/pulls/118477
2024-05-02 14:28:44 +02:00
Miguel Pozo
a8f8745dcb Draw: Add default material fallback detection
Detect passes that are functionally equivalent to the default Material
ones to skip their compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/121137
2024-04-30 19:44:06 +02:00
Clément Foucault
e581ba077d Fix: EEVEE-Next: Principled BSDF transmission color applied twice
This was caused by the 2 transmission event approximation we
do for object with non-null thickness. This follows cycles
by using the square root of the color.
2024-04-30 19:32:52 +02:00
Jason Fielder
7114c44c9b Fix #121020: Fix curve index buffer generation with Triangle prim
Resolves offset error when building index buffers on device for
cuves/hair strips using Triangles instead of TriangleStrips.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/121218
2024-04-30 10:49:09 +02:00
Jeroen Bakker
3d3dfb6518 Fix #120273: GPU: UHD630 on Windows reports buggy extension
On windows the OpenGL backend of the UHD630 driver (but could also be other
GPUs that use the same driver) reports of supporting `GL_ARB_multi_bind`.
But when enabling it can result in incorrect bindings and report errors
about unsupported internal texture formats. These are internal driver issues.

Might also fix #107642 as it shows the same error message. EEVEE-Next
relies more on using the same binding slot for the same texture in order
to reduce actual bindings which makes this more prominent.

Pull Request: https://projects.blender.org/blender/blender/pulls/121062
2024-04-30 10:38:07 +02:00
David Murmann
ee51f643b0 Cycles: Ray Portal BSDF
Transport rays that enter to another location in the scene, with
specified ray position and normal. This may be used to render portals
for visual effects, and other production rendering tricks.

This acts much like a Transparent BSDF. Render passes are passed
through, and this is affected by light path max transparent bounces.

Pull Request: https://projects.blender.org/blender/blender/pulls/114386
2024-04-29 12:37:51 +02:00
Alaska
f8c0050a25 Shaders: Add Roughness to Subsurface Scattering Node
Matching the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/114499
2024-04-29 10:54:29 +02:00
Alaska
afa66fc628 Shader: Clamp invalid inputs of various BSDF nodes
Clamp some of the inputs of the Glossy BSDF, Glass BSDF, Sheen BSDF,
and Subsurface Scattering nodes to improve consistency between render
engines and to avoid unexpected results.

* Clamp roughness to 0..1
* Clamp subsurface radius to 0..inf
* Clamp colors to 0..inf

Pull Request: https://projects.blender.org/blender/blender/pulls/120390
2024-04-26 17:39:39 +02:00
Jeroen Bakker
7e3aa5a7a9 Vulkan: Add to_string functions for dynamic rendering
The plan is to use dynamic rendering. This PR adds to_string functions
for enums, structs related to dynamic rendering.
2024-04-26 14:55:50 +02:00
Jeroen Bakker
54d879fd24 Cleanup: Use GTest macros
Vulkan render graph test cases used BLI asserts. These
are now replaced with GTEST macros
2024-04-26 14:55:50 +02:00
Clément Foucault
bc1c35e201 EEVEE-Next: Change lights object matrix for more readability and compactness
This adds a new `Transform` type similar to cycles that reduces
the amount of data passed for a typical affine 3D transform.

This then applies this type to the light data and cleanup
all usage of the former `object_mat`. This also changes the axes
macros into utility accessor functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/121089
2024-04-26 12:54:08 +02:00
Jeroen Bakker
c8ccf77564 Vulkan: Render graph dispatch indirect
Add dispatch indirect node. Also refactored the dispatch (direct) node
so more logic could be reused. The context only stores a `VKResourceAccessInfo`
struct which is reused by both the dispatch and dispatch indirect node.

Pull Request: https://projects.blender.org/blender/blender/pulls/120993
2024-04-24 21:28:45 +02:00
Clément Foucault
6d347dd5ca Fix: EEVEE-Next: Point cloud macro coliding with voronoi texture
Was caused by macro declaration. Remove the macro
and add another `#if` case for EEVEE-next instead.

Fix #115438
2024-04-24 09:38:32 +02:00
Campbell Barton
019d3ef939 Cleanup: spelling in comments 2024-04-24 10:48:45 +10:00
Clément Foucault
ce768d43a1 MTL: Increase log level to errors for missing texture binds
This avoid missing them as they are true user level errors.
2024-04-23 23:08:19 +02:00
Jeroen Bakker
164fb68386 Vulkan: Render graph direct compute
This PR adds support for compute shaders to render graph. Only direct dispatch
is supported. indirect dispatch will be added in a future PR.

This change enables the next test cases to be supported when using render graphs

- `GPUVulkanTest.push_constants*`
- `GPUVulkanTest.shader_compute_*`
- `GPUVulkanTest.buffer_texture`
- `GPUVulkanTest.specialization_constants_compute`
- `GPUVulkanTest.compute_direct`

```
[==========] 95 tests from 2 test suites ran. (24059 ms total)
[  PASSED  ] 95 tests.
```

Specialization constants are supported when using the render graph. This should conclude
the conversion the prototype of the render graph.

Pull Request: https://projects.blender.org/blender/blender/pulls/120963
2024-04-23 15:43:32 +02:00
Jeroen Bakker
2a1b4bf219 Vulkan: Move push constants to VKShader
VKPipeline class is deprecated and will be phased out in the near future.
This PR moves the push constants to VKShader as it was wrongly placed in the
pipeline.

Pull Request: https://projects.blender.org/blender/blender/pulls/120980
2024-04-23 14:49:41 +02:00
Jeroen Bakker
9fa6ac6976 GPU: Fix out of bound write when logging system paths
Blender expects that only the filename is provided which is true
for internal shader sources.

Metal shaders can error and return a full path to a system shader.
This doesn't fit inside the reserved memory that Blender reserved
for logging filename and line number.

This out of bound write can be triggered when using `min`
where the parameters aren't of the same kind.
`uint min(uint, int)` for example.

This PR reserves more space to store the filename.

Pull Request: https://projects.blender.org/blender/blender/pulls/120967
2024-04-23 12:50:50 +02:00
Jeroen Bakker
17c84451b9 Vulkan: Pipeline pool
In Vulkan, a Blender shader is organized in multiple
objects. A VkPipeline is the highest level concept and represents
somewhat we call a shader. A pipeline is an device/platform optimized
version of the shader that is uploaded and executed in the GPU device.
A key difference with shaders is that its usage is also compiled
in. When using the same shader with a different blending, a new pipeline
needs to be created.

In the current implementation of the Vulkan backend the pipeline is
re-created when any pipeline parameter changes. This triggers many
pipeline compilations. Especially when common shaders are used in
different parts of the drawing code.

A requirement of our render graph implementation is that changes
of the pipeline can be detected based on the VkPipeline handle.
We only want to rebind the pipeline handle when the handle actually
changes. This improves performance (especially on NVIDIA) devices
where pipeline binds are known to be costly.

The solution of this PR is to add a pipeline pool. This holds all
pipelines and can find an already created pipeline based on pipeline
infos. Only compute pipelines support has been added.

# Future enhancements
- Recent drivers replace `VkShaderModule` with pipeline libraries.
  It improves sharing pipeline stages and reduce pipeline creation times.
- GPUMaterials should be removed from the pipeline pool when they are
  destroyed. Details on this will be more clear when EEVEE support is
  added.

Pull Request: https://projects.blender.org/blender/blender/pulls/120899
2024-04-23 12:39:41 +02:00
Jeroen Bakker
191b4fea5b GPU: Better hash for specialization constants
Due to an error in the hash function the specialization constants hash
wasn't optimal. This PR fixes the hash function implementation by replacing
the addition with an xor.

Pull Request: https://projects.blender.org/blender/blender/pulls/120964
2024-04-23 09:44:08 +02:00
Jeroen Bakker
07dd09aa55 Vulkan: Add reset method to resource access info.
Resource access info contains lists in a future setup the resource access info
will be kept in the VKContext and reused. This requires a reset function to
cleanup the instance for reuse.

Pull Request: https://projects.blender.org/blender/blender/pulls/120962
2024-04-23 08:23:12 +02:00
Jeroen Bakker
3f6e2ea915 Vulkan: Shader interface access mask
When building the resource access used when adding dispatch/draw commands
to the render graph, the access mask is required. This PR stores the
access mask in the shader interface. When binding the resources referenced
by the state manager, the resource access info struct is populated with
the access flags.

In the near future the resource access info will be passed when adding
a dispatch/draw node to the render graph to generate the links.

Pull Request: https://projects.blender.org/blender/blender/pulls/120908
2024-04-22 20:47:30 +02:00
Jacques Lucke
ed111e1907 Fix: assert when opening debug build with OpenGL backend
Can't use `GPU_type_matches` there, because it requires `GPG.init` to be called beforehand.

Pull Request: https://projects.blender.org/blender/blender/pulls/120928
2024-04-22 13:57:18 +02:00
Jeroen Bakker
0c2085a316 GPU: Remove GPU_compute_shader_support
Compute shaders are required since 4.0. There was one occasion where
an older AMD driver failed and support was turned off. This driver
is now marked unsupported.

This PR includes:
- removing the check in viewport compositing
- remove properties from system info
- always construct draw manager.
- remove unused pass logic in draw hair/curves
- add deprecation warning when accessed from python

Pull Request: https://projects.blender.org/blender/blender/pulls/120909
2024-04-22 13:28:10 +02:00