Page MenuHome

Setting Masking->Stencil Mask->Stencil Image crashes Blender. Includes fix
Closed, ResolvedPublic

Description

System Information
Operating system: Linux-5.4.0-100-generic-x86_64-with-glibc2.31 64 Bits
Graphics card: NVIDIA GeForce GTX 750 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.103.01

Blender Version
Broken: version: 3.2.0 Alpha, branch: master, commit date: 2022-02-23 01:31, hash: rBc6df7266c718
Worked: 3.0.1 (Think the issue started sometime in the 3.1.0 Alpha cycle)

Caused by rB9d3f35a0bf1b: Revert "Revert "GPUShaderCreateInfo for interface abstraction"" look at that :)

Short description of error
Setting Stencil Mask->Stencil Image either by creating a new image or selecting an existing image will immediate crash Blender.
Bug affects both linux and windows and is 100% reproducible on my system.

Exact steps for others to reproduce the error

  1. Load the attached .blend file (Optional:switch to the mask tool)
  1. In the 3D view, scroll the tool tab down to Masking->Stencil Mask->Stencil Image
  1. Click the 'New' button then click 'Ok' to accept the defaults
  1. crash straight to the desktop

I've also attached the error message that you'll receive after the crash if you start blender via a terminal or cmd prompt.

It explains the problem: the smoothstep function is now interpreting "0" as an integer, rather than assuming it's a float.

The Fix

Edit: blender-git/blender/source/blender/draw/engines/overlay/shaders/paint_texture_frag.glsl

simply change line 18 from:
float mask_step = smoothstep(0, 3.0, mask.r + mask.g + mask.b);
to:
float mask_step = smoothstep(0.0, 3.0, mask.r + mask.g + mask.b);

I've tested this by locally compiling a version of Blender with this change and it creates a binary that works as expected and does not crash when setting the stencil mask.

Event Timeline

Doesn't crash on latest master 165b030b19718694eaf33d6602034ed88fdd31a1
Perhaps crash is specific for NVIDIA GPU?

System Information
Operating system : Windows-10-10.0.18362-SP0 64 Bits
Graphics card : AMD Radeon(TM) 535 ATI Technologies .
Graphics card: Intel(R) UHD Graphics 620 Intel 4.5.0 - Build 26.20.100.7323
Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Feb 23 2022, 8:32 AM
Philipp Oeser (lichtwerk) triaged this task as High priority.

Can confirm. Will check.

Even if the implicit conversion is guaranteed by the specification, this seems like an easy fix.
@Jeff Dierstein (elkmug) If you are interested in submitting your fix as patch, check https://wiki.blender.org/wiki/Process/Contributing_Code.

Not able to reproduce, but it is known that some drivers don't handle implicit conversions that well. Will apply the fix. Thanks!
Interesting that this was already there for 2 years...