OpenGL Invalid Enum #95592

Closed
opened 2022-02-07 22:57:29 +01:00 by jon denning · 15 comments
Member

System Information
Operating system: macOS-12.1-arm64-arm-64bit 64 Bits
Graphics card: Apple M1 Apple 4.1 Metal - 76.3

Blender Version
Broken: version: 3.1.0 Beta, branch: master, commit date: 2022-02-06 19:53, hash: 1d59a7aa77
Worked: 2.93.6, 3.0.1, 3.2.0 Alpha

Short description of error
Something in the Blender startup is causing an Invalid Enum OpenGL to occur.

Exact steps for others to reproduce the error

Run the following in the Python Console after starting Blender with default scene and factory loaded settings.

import bgl ; bgl.glGetError()  # reports 1280, which is bgl.GL_INVALID_ENUM
**System Information** Operating system: macOS-12.1-arm64-arm-64bit 64 Bits Graphics card: Apple M1 Apple 4.1 Metal - 76.3 **Blender Version** Broken: version: 3.1.0 Beta, branch: master, commit date: 2022-02-06 19:53, hash: `1d59a7aa77` Worked: 2.93.6, 3.0.1, 3.2.0 Alpha **Short description of error** Something in the Blender startup is causing an `Invalid Enum` OpenGL to occur. **Exact steps for others to reproduce the error** Run the following in the Python Console after starting Blender with default scene and factory loaded settings. ``` import bgl ; bgl.glGetError() # reports 1280, which is bgl.GL_INVALID_ENUM ```
Author
Member

Added subscriber: @gfxcoder

Added subscriber: @gfxcoder

Added subscriber: @dodo-2

Added subscriber: @dodo-2

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Verified, i can reproduce the error.

Verified, i can reproduce the error.

Added subscriber: @JacobMerrill-1

Added subscriber: @JacobMerrill-1

apple does not have openGL

I think the gpu module needs to be used here (to use metal?)

apple does not have openGL I think the gpu module needs to be used here (to use metal?)
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

apple does not have openGL

Yeah.... no... apple doeshave opengl and we use it, there is a metal backend for cycles, but everything else is good'ol openGL

@gfxcoder can you try starting blender with the --factory-startup --debug-gpu --log gpu.* --log-level -1 flags and attaching the log?

> apple does not have openGL Yeah.... no... apple *does*have opengl and we use it, there is a metal backend for cycles, but everything else is good'ol openGL @gfxcoder can you try starting blender with the ` --factory-startup --debug-gpu --log gpu.* --log-level -1` flags and attaching the log?
Author
Member

@LazyDodo, see attached.

log

@LazyDodo, see attached. [log](https://archive.blender.org/developer/F12854437/log)

Added subscribers: @fclem, @michael64

Added subscribers: @fclem, @michael64

Thank you @gfxcoder for reporting this issue. There are a few things going here.
Let's start with the symptom of the 1280 error code.
Blender uses the the function check_gl_error in gl_debug.cc to check and report OpenGL errors.
Since 8be20fcc61 check_gl_error does not even call glGetError() if blender is not run with --debug-gpu.
So if you'd run run blender with --debug-gpu you should get error code 0 again because it was read by check_gl_error.
But there actually was an error 1280 that was not reported by check_gl_error.
I think this missing error report is due to 0d1f65e516 where the logic if an error should be reported was always incorrectly inverted.
The standard logging level for gpu.debug is CLG_SEVERITY_WARN(=1) and the error that wasn't reported had CLG_SEVERITY_ERROR(=2) so more severe.

In the debug_callback which is used by check_gl_error we have the line:
```
if (((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level >= clog_severity))) {

I think comparison `>=` actually needs to be `<=` so the same log level severity and more severe levels are reported.
Actually compiling and running a build with  `<=` promptly reveals an OpenGL error on Mac and Windows as well that has been silently ignored.
@fclem, could you have a look at this?
Thank you @gfxcoder for reporting this issue. There are a few things going here. Let's start with the symptom of the 1280 error code. Blender uses the the function `check_gl_error` in `gl_debug.cc` to check and report OpenGL errors. Since 8be20fcc61 `check_gl_error` does not even call `glGetError()` if blender is not run with `--debug-gpu`. So if you'd run run blender with `--debug-gpu` you should get error code 0 again because it was read by `check_gl_error`. But there actually was an error 1280 that was not reported by `check_gl_error`. I think this missing error report is due to 0d1f65e516 where the logic if an error should be reported was always incorrectly inverted. The standard logging level for `gpu.debug` is `CLG_SEVERITY_WARN`(=1) and the error that wasn't reported had `CLG_SEVERITY_ERROR`(=2) so more severe. In the `debug_callback` which is used by `check_gl_error` we have the line: ``` if (((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level >= clog_severity))) { ``` I think comparison `>=` actually needs to be `<=` so the same log level severity and more severe levels are reported. Actually compiling and running a build with `<=` promptly reveals an OpenGL error on Mac and Windows as well that has been silently ignored. @fclem, could you have a look at this?

I think comparison >= actually needs to be <= so the same log level severity and more severe levels are reported.

I actually ran into the same issue and just forgot to push the fix.

I guess the error comes from the glGetIntegerv we do to get the capabilities and limits of the context. But it is not obvious which one is not available on all systems. I'll see if I can reproduce on my intel Mac.

>I think comparison >= actually needs to be <= so the same log level severity and more severe levels are reported. I actually ran into the same issue and just forgot to push the fix. I guess the error comes from the `glGetIntegerv` we do to get the capabilities and limits of the context. But it is not obvious which one is not available on all systems. I'll see if I can reproduce on my intel Mac.
Author
Member

probably unrelated, but i'll post here as an update: when I tried building with DEBUG and running blender in lldb, it stop with an invalid enum error when creating shaders at startup (workbench_taa, workbench_composite_matcap, others?). I traced this issue to the default value for the final parameter of sampler function in gpu_shader_create_info.hh. when I changed the default value from -1 (which is not a value in eGPUSamplerState) to GPU_SAMPLER_DEFAULT (see below), lldb no longer stops when creating shaders. however, the Invalid Enum error is still getting set, so this solution does not solve the original problem.

  Self &sampler(int slot,
                ImageType type,
                StringRefNull name,
                Frequency freq = Frequency::PASS,
                eGPUSamplerState sampler = (eGPUSamplerState)GPU_SAMPLER_DEFAULT) // was -1
  {
probably unrelated, but i'll post here as an update: when I tried building with DEBUG and running blender in lldb, it stop with an invalid enum error when creating shaders at startup (`workbench_taa`, `workbench_composite_matcap`, others?). I traced this issue to the default value for the final parameter of `sampler` function in `gpu_shader_create_info.hh`. when I changed the default value from `-1` (which is not a value in `eGPUSamplerState`) to `GPU_SAMPLER_DEFAULT` (see below), lldb no longer stops when creating shaders. however, the Invalid Enum error is still getting set, so this solution does not solve the original problem. ``` Self &sampler(int slot, ImageType type, StringRefNull name, Frequency freq = Frequency::PASS, eGPUSamplerState sampler = (eGPUSamplerState)GPU_SAMPLER_DEFAULT) // was -1 { ```

This issue was referenced by 883326040e

This issue was referenced by 883326040ec20a8289e619446147792f62e6aa32

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Clément Foucault self-assigned this 2022-03-30 15:54:42 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
7 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#95592
No description provided.