Unsigned ints in GLSL macros causing UI shader compilation failure/crashes on Intel HD 4000 #106457

Closed
opened 2023-04-02 15:11:09 +02:00 by Avelgest · 5 comments

System Information
Operating system: Windows-10-10.0.19044-SP0
Graphics card: Intel HD Graphics 4000 (10.18.10.5161)

Blender Version
Broken: 3.5.0, 1be25cfff1, release, 2023-03-29
Worked: 3.4.1

I realise that the Intel HD 4000 isn't supported, but I thought I'd better post anyway in case similar issues exist with other GPUs.

There seems to be a bug in the graphics driver that can cause shader compilation to fail when defining and using macros that involve operations on uints in GLSL code. When this happens in the UI shader code this causes Blender to crash with the error EXCEPTION_ACCESS_VIOLATION.

For instance in overlay_motion_path_point_vert.glsl the line if ((flag & MOTIONPATH_VERT_KEY) != 0u) { causes a crash on startup since MOTIONPATH_VERT_KEY is defined in overlay_shader_shared.h with

# define MOTIONPATH_VERT_KEY (1u << 1)

Changing this to # define MOTIONPATH_VERT_KEY 2u fixes the compilation error.

Similar macros defined in draw_common_shader_shared.h result in crashes when entering edit mode and can be fixed in the same way.

These macros in gpu_shader_2D_nodelink_vert.glsl result in crashes when attempting to display links in a node editor.

#  define colStart (colid_doarrow[0] < 3u ? start_color : node_link_data.colors[colid_doarrow[0]])
#  define colEnd (colid_doarrow[1] < 3u ? end_color : node_link_data.colors[colid_doarrow[1]])
#  define colShadow node_link_data.colors[colid_doarrow[2]]
#  define doArrow (colid_doarrow[3] != 0u)
#  define doMuted (domuted[0] != 0u)

Using int instead of uint literals in the above comparisons is a quick fix, though is technically less correct.

Error Messages
N.B. The lines given in the error messages are wrong.
On startup:

ERROR (gpu.shader): overlay_motion_path_point VertShader:
      |
   15 | /* Cubemap support and fallback implementation declarations. */
      |                            ^
      | Error: '&' :  wrong operand types  no operation '&' exists that takes a left-hand operand of type 'attribute uint' and a right operand of type 'const bool' (or there is no acceptable conversion)
      | Error: '{' : syntax error syntax error

Entering edit mode (message below repeated for overlay_edit_mesh_face VertShader):

ERROR (gpu.shader): overlay_edit_mesh_edge VertShader:
      |
   15 | /* Cubemap support and fallback implementation declarations. */
      |      ^
      | Error: '&' :  wrong operand types  no operation '&' exists that takes a left-hand operand of type 'in uint' and a right operand of type 'const bool' (or there is no acceptable conversion)
      | Error: '' : boolean expression expected
      | Error: ';' : syntax error syntax error

Entering the shader editor:

ERROR (gpu.shader): gpu_shader_2D_nodelink_inst VertShader:
      |
   11 | #define gpu_Array(_type) _type[]
      |                                                   ^
      | Error: ';' : syntax error syntax error
**System Information** Operating system: Windows-10-10.0.19044-SP0 Graphics card: Intel HD Graphics 4000 (10.18.10.5161) **Blender Version** Broken: 3.5.0, 1be25cfff18b, release, 2023-03-29 Worked: 3.4.1 I realise that the Intel HD 4000 isn't supported, but I thought I'd better post anyway in case similar issues exist with other GPUs. There seems to be a bug in the graphics driver that can cause shader compilation to fail when defining and using macros that involve operations on uints in GLSL code. When this happens in the UI shader code this causes Blender to crash with the error EXCEPTION_ACCESS_VIOLATION. For instance in [overlay_motion_path_point_vert.glsl](https://projects.blender.org/blender/blender/src/commit/45104ddd14bb208d165b7ecd778bc30f02d3932b/source/blender/draw/engines/overlay/shaders/overlay_motion_path_point_vert.glsl#L27) the line `if ((flag & MOTIONPATH_VERT_KEY) != 0u) {` causes a crash on startup since MOTIONPATH_VERT_KEY is defined in [overlay_shader_shared.h](https://projects.blender.org/blender/blender/src/commit/45104ddd14bb208d165b7ecd778bc30f02d3932b/source/blender/draw/engines/overlay/overlay_shader_shared.h#L77) with `# define MOTIONPATH_VERT_KEY (1u << 1)` Changing this to `# define MOTIONPATH_VERT_KEY 2u` fixes the compilation error. Similar macros defined in [draw_common_shader_shared.h](https://projects.blender.org/blender/blender/src/commit/45104ddd14bb208d165b7ecd778bc30f02d3932b/source/blender/draw/intern/draw_common_shader_shared.h#L251-L267) result in crashes when entering edit mode and can be fixed in the same way. [These macros](https://projects.blender.org/blender/blender/src/commit/45104ddd14bb208d165b7ecd778bc30f02d3932b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl#L19-L23) in gpu_shader_2D_nodelink_vert.glsl result in crashes when attempting to display links in a node editor. ``` # define colStart (colid_doarrow[0] < 3u ? start_color : node_link_data.colors[colid_doarrow[0]]) # define colEnd (colid_doarrow[1] < 3u ? end_color : node_link_data.colors[colid_doarrow[1]]) # define colShadow node_link_data.colors[colid_doarrow[2]] # define doArrow (colid_doarrow[3] != 0u) # define doMuted (domuted[0] != 0u) ``` Using int instead of uint literals in the above comparisons is a quick fix, though is technically less correct. **Error Messages** N.B. The lines given in the error messages are wrong. On startup: ``` ERROR (gpu.shader): overlay_motion_path_point VertShader: | 15 | /* Cubemap support and fallback implementation declarations. */ | ^ | Error: '&' : wrong operand types no operation '&' exists that takes a left-hand operand of type 'attribute uint' and a right operand of type 'const bool' (or there is no acceptable conversion) | Error: '{' : syntax error syntax error ``` Entering edit mode (message below repeated for overlay_edit_mesh_face VertShader): ``` ERROR (gpu.shader): overlay_edit_mesh_edge VertShader: | 15 | /* Cubemap support and fallback implementation declarations. */ | ^ | Error: '&' : wrong operand types no operation '&' exists that takes a left-hand operand of type 'in uint' and a right operand of type 'const bool' (or there is no acceptable conversion) | Error: '' : boolean expression expected | Error: ';' : syntax error syntax error ``` Entering the shader editor: ``` ERROR (gpu.shader): gpu_shader_2D_nodelink_inst VertShader: | 11 | #define gpu_Array(_type) _type[] | ^ | Error: ';' : syntax error syntax error ```
Avelgest added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2023-04-02 15:11:10 +02:00
Member

Actually later we found out it's probably the same problem as stated in this issue #106432.

This should get fixed.

Actually later we found out it's probably the same problem as stated in this issue #106432. This should get fixed.
YimingWu added the
Module
Viewport & EEVEE
label 2023-04-03 11:04:01 +02:00
Author

I think this might be specifically to do with macros, since (at least in the case of MOTIONPATH_VERT_KEY) there are no errors when either manually expanding the macro or defining the macro as just an unsigned literal.

It's probably the same as #106446 though (I probably should have made clear that the MOTIONPATH_VERT_KEY line causes a crash on start-up, the other crashes only occur once that one has been resolved).

I think this might be specifically to do with macros, since (at least in the case of MOTIONPATH_VERT_KEY) there are no errors when either manually expanding the macro or defining the macro as just an unsigned literal. It's probably the same as #106446 though (I probably should have made clear that the MOTIONPATH_VERT_KEY line causes a crash on start-up, the other crashes only occur once that one has been resolved).
Member

@ChengduLittleA : can you confirm this on supported hardware? Or can you confirm it is a duplicate? Then either close as duplicate or confirm it :)

The information is good (thx @Avelgest) but technically, we should not really keep reports open if this only affects unsupported hardware.

Or maybe @fclem can confirm?

@ChengduLittleA : can you confirm this on supported hardware? Or can you confirm it is a duplicate? Then either close as duplicate or confirm it :) The information is good (thx @Avelgest) but technically, we should not really keep reports open if this only affects unsupported hardware. Or maybe @fclem can confirm?
Member

@lichtwerk From the graphics information, it's just 1 generation behind Haswell (which is the official requirement), maybe through some driver magic it might still work with that shader if #106432 is fixed. These two issues do look similar but not exactly the same, but they both involve the & with integer and booleans.

@lichtwerk From the graphics information, it's just 1 generation behind Haswell (which is the official requirement), maybe through some driver magic it might still work with that shader if #106432 is fixed. These two issues do look similar but not exactly the same, but they both involve the `&` with integer and booleans.

I've seen this issue with this GPU before and it appears to be different than #106432.

While #106432 appears to be about unsigned vs signed type conflicts, here the Intel driver simply ignores the parentheses [( and )] within the macro.

As far as I can tell, this is a problem specific to Intel HD Graphics 4000.

We could change the line # define MOTIONPATH_VERT_KEY (1u << 1) to # define MOTIONPATH_VERT_KEY 2u /*(1u << 1)*/ but that would be a blind fix, as this GPU is no longer maintained by any developer in Blender.

Therefore, please provide a Pull Request if you want this issue addressed: https://wiki.blender.org/wiki/Process/Contributing_Code

I am closing this report as this GPU is below the minimum requirements for Blender.

I've seen this issue with this GPU before and it appears to be different than #106432. While #106432 appears to be about unsigned vs signed type conflicts, here the Intel driver simply ignores the parentheses [`(` and `)`] within the macro. As far as I can tell, this is a problem specific to `Intel HD Graphics 4000`. We could change the line `# define MOTIONPATH_VERT_KEY (1u << 1)` to `# define MOTIONPATH_VERT_KEY 2u /*(1u << 1)*/` but that would be a blind fix, as this GPU is no longer maintained by any developer in Blender. Therefore, please provide a Pull Request if you want this issue addressed: https://wiki.blender.org/wiki/Process/Contributing_Code I am closing this report as this GPU is below the minimum requirements for Blender.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-04-03 21:59:36 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106457
No description provided.