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
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
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
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
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.
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
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
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
The workaround for shader draw parameters isn't working for OpenGL. The
reason is that it isn't looking for the correct attribute to attach the
buffer to.
This fixes the issue that all objects where drawn using the unit matrix when
starting blender with `--debug-gpu-force-workarounds`.

Fixes#112641
Pull Request: https://projects.blender.org/blender/blender/pulls/112668
Blender 4.0 requires OpenGL 4.3 which always support SSBO's.
Platforms that don't support enough SSBO bind points will be marked
as unsupported.
Users who start Blender on those platforms will be informed via a
dialog. This PR also updates the `--debug-gpu-force-workarounds`
to match our minimum requirements. Note that some bugs are still
there that should be solved in other PRs:
* Workbench only renders the object using a unit matrix this is because
there is a bug in the workaround for shader_draw_parameters
* Navigating with middle mouse button is not working. Unsure what the
cause is, but might be a missing feature check in the OpenGL backend.
Related to #112224
Pull Request: https://projects.blender.org/blender/blender/pulls/112572
Blender has the option to disable SSBO support. This was accessible
as a command line option `--debug-gpu-disable-ssbo`.
Blender 4.0 has a hard requirement for OpenGL 4.3 which includes
SSBO support by default.
This PR removes the command line option as it makes no sense to
have it anymore.
Related to #112224
Pull Request: https://projects.blender.org/blender/blender/pulls/112571
In Vulkan the grid overlay wasn't rendering correctly. The reason was
a mis alignment in the std430 layout. This PR fixes the std430 layout
so the grid overlay (and perhaps also other sections) would work.
Root cause is that the reserve size if an nVec3 is different when used
as an array versus a single attribute. This was not taken into account
where the overlay flag was read from uninitialized memory.
Pull Request: https://projects.blender.org/blender/blender/pulls/112564
Array textures stores the array length inside the size of the image. In
vulkan the size mustn't contain the array length, but it should be set
as a separate parameter. This logic wasn't implemented when updating
the mipmap chain.
Patch also includes some smaller fixes where textures would not yet be
allocated on the device, but was expected to be.
Pull Request: https://projects.blender.org/blender/blender/pulls/112518
Uniform buffers can have data provided during construction, or as
attached data. Attached data should be uploaded during bind.
This PR implements `GPU_uniformbuf_create_from_list`.
Pull Request: https://projects.blender.org/blender/blender/pulls/112517
Resources can still be in use inside the vulkan command queue, when
they are destroyed. Especially as Vulkan doesn't allow resetting
bindings to nothing.
This PR will collect the resources that needs to be destroyed inside
the VKDevice and actually destroy the resources when on frame end.
The resources currently include:
* VkBuffer
* VkImage
* VkImageView
* VkFramebuffer
* VkRenderPass
Pull Request: https://projects.blender.org/blender/blender/pulls/112514
Previous implemetation had some limitations that were not working
for complex shaders. This limitations included:
* All bindings should be bound to a location < 16.
* Collision could happen when image locations where read that
overlapped with the texture locations.
This PR replaces the fixed binding locations with a dynamic vector.
When allocating locations for images the image offset is determined
that it is always clear if the requested locations is already
offsetted or not. This is done by ensuring the offset to larger than
the max slot of samplers, but also of image slots.
When using Eevee-next materials the slot numbers can be very high
as the location of the first material texture is set to
`GPU_max_textures_frag()` On current NVIDIA drivers this number is
set to 1K. Images are stored after the textures slots upwards.
In the future driver could set this to MAX_INT which will not work
with the new implementation. This isn't the case at this moment
and perhaps also not realistic. We don't check for this situation yet.
Pull Request: https://projects.blender.org/blender/blender/pulls/112511
The NDEBUG is a toggle define, and in debug builds it is not defined.
This change solves the warning
mtl_context.mm:2282:5: warning: 'NDEBUG' is not defined, evaluates to 0 [-Wundef]
Pull Request: https://projects.blender.org/blender/blender/pulls/112504
because it contains reflectance and transmittance, so BSDF would be a
morep proper name.
Also rename BSDF to BRDF at places where only reflectance is returned.
Previously, the Principled BSDF used the Subsurface input to scale the radius.
When it was zero, it used a diffuse closure, otherwise a subsurface closure.
This sort of scaling input makes sense, but it should be specified in distance
units, rather than a 0..1 factor, so this commit changes the unit and renames
the input to Subsurface Scale.
Additionally, it adds support for mixing diffuse and subsurface components.
This is part of e.g. the OpenPBR spec, and the logic behind it is to support
modeling e.g. dirt or paint on top of skin. Before, materials would be either
fully diffuse (radius=0) or fully subsurface.
For typical materials, this mixing factor will be either zero or one
(just like metallic or transmission), but supporting fractional inputs makes
sense for e.g. smooth transitions at boundaries.
Another change is that there is no separate Subsurface Color anymore - before,
this was mixed with the Base Color using the Subsurface input as the factor,
but this was not really useful since that input was generally very small.
And finally, the handling of how the path enters the material for random walk
subsurface scattering is changed. Before, this always used lambertian (diffuse)
transmission, but this caused some problems, like overly white edges.
Instead, two different methods are now used, depending on the selected mode.
In Fixed Radius mode, the code assumes a simple medium boundary, and performs
refraction into the material using the main Roughness and IOR inputs.
Meanwhile, when not using Fixed Radius, the code assumes a more complex
boundary (as typically found on organic materials, e.g. skin), so the entry
bounce has a 50/50 chance of being either diffuse transmission or refraction
using the separate Subsurface IOR input and a fixed roughness of 1.
Credit for this method goes to Christophe Hery.
Pull Request: https://projects.blender.org/blender/blender/pulls/110989
- Adds tint control, which simulates volumetric absorption inside the coating.
This results in angle-dependent saturation and affects all underlying layers
(diffuse, subsurface, metallic, transmission). It provides a physically-based
alternative to ad-hoc effects such as tinted specular highlights.
- Renames the component from "Clearcoat" to "Coat", since it's no longer
necessarily clear now. This matches naming in e.g. other renderers or OpenPBR.
- Adds an explicit Coat IOR input, in preparation for future smarter IOR logic
around the interaction between Coat and main IOR. This used to be hardcoded
to 1.5.
- Removes hardcoded 0.25 weight multiplier, and adds versioning code to update
existing files accordingly. OBJ import/export still applies the factor.
- Replaces the GTR1 microfacet component with regular GGX. This removes a corner
case in the Microfacet code, solves #53038, and makes us more consistent with
other standard surface shaders. The original Disney BSDF used GTR1, but it
doesn't appear that it caught on in the industry.
Co-authored-by: Weizhen Huang <weizhen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/110993
5cf7089e43 added the `BuiltinBits::LAYER` to shaders with a geometry
stage. This causes compilation errors when
`GLContext::layered_rendering_support` is false (otherwise the flag
does nothing).
This PR moves the `LAYER` flags to the `no_geom` shader versions and
adds a check to `ShaderCreateInfo::finalize()` to ensure the `LAYER` flag
is not used in shaders with a geometry stage.
Pull Request: https://projects.blender.org/blender/blender/pulls/112245
Component swizzling is part of an image view and localized in the code.
With component swizzling a different channel (or 0 or 1) can be read
when the component is accessed.
Pull Request: https://projects.blender.org/blender/blender/pulls/112273
Adding support for Texture View in Vulkan backend.
When a VKTexture is a texture view many options become
irrelevant, but isn't actually clear via its API. Added
asserts to make sure that the usage is supported.
This patch allows rendering simple workbench-next scenes
without any validation errors.
Pull Request: https://projects.blender.org/blender/blender/pulls/110887
When `COMP_U*` is used together with a `GPU_FETCH_INT` the backend
tried to convert them to floats. What is of course not what should
happen.
Issue was that these cases were never correctly tested. With this
change the `data` attribute of the `overlay_edit_mesh` shaders are
transferred correctly and can draw some pixels as intended.
Pull Request: https://projects.blender.org/blender/blender/pulls/112270
Shader draw parameter support is needed for Workbench-next. (Almost) All
devices that we support also supports shader draw parameters. This PR
doesn't include a workaround for devices that don't have support.
For end-users this PR will allow workbench-next to render the object on
the correct location. Before this patch they were always drawn on the origin.
The catch is that OpenGL uses gl_InstanceID which always starts counting at 0.
Vulkan has gl_InstanceIndex which holds the correct instance number. By
subtracting the gl_InstanceIndex from gl_BaseInstance will get the correct
gl_InstanceID.
This patch also activates some device extensions to perform in shader printf
statements inside a shader. Documentation for this will be added to the dev
docs how to use them.
Pull Request: https://projects.blender.org/blender/blender/pulls/111461