API gpu.state.scissor_test_set(False) not working #113310

Closed
opened 2023-10-05 23:25:11 +02:00 by Y.T-LAW · 6 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 537.34

Blender Version
Broken: version: 4.0.0 Beta, branch: blender-v4.0-release, commit date: 2023-10-04 23:50, hash: 2f71d9f80795
Broken: 3.5, 3.6, 4.0
Worked:

Short description of error
Unable to disable scissor test.

Exact steps for others to reproduce the error
Consider this script works fine in v3.6

import bpy, gpu, blf, bgl
from gpu_extras.batch import batch_for_shader

vertices = (
    (100, 100), (300, 100),
    (100, 200), (300, 200))

indices = (
    (0, 1, 2), (2, 1, 3))

shader = gpu.shader.from_builtin('UNIFORM_COLOR')
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)


def draw():
    bgl.glEnable(bgl.GL_SCISSOR_TEST)
    bgl.glScissor(100, 100, 200, 50)
    shader.uniform_float("color", (0, 0.5, 0.5, 1.0))
    batch.draw(shader)
    bgl.glDisable(bgl.GL_SCISSOR_TEST)
    blf.position(0, 100, 150, 0)
    blf.size(0, 50.0)
    blf.draw(0, "Cut the Box only")

bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')

image

Got unexpected results in v4.0

import bpy, gpu, blf
from gpu_extras.batch import batch_for_shader

vertices = (
    (100, 100), (300, 100),
    (100, 200), (300, 200))

indices = (
    (0, 1, 2), (2, 1, 3))

shader = gpu.shader.from_builtin('UNIFORM_COLOR')
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)


def draw():
    gpu.state.scissor_test_set(True) # <---------------
    gpu.state.scissor_set(100, 100, 200, 50) # <-------
    shader.uniform_float("color", (0, 0.5, 0.5, 1.0))
    batch.draw(shader)
    gpu.state.scissor_test_set(False) # <---------------
    blf.position(0, 100, 150, 0)
    blf.size(0, 50.0)
    blf.draw(0, "Cut the Box only")

bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')

image

**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2080 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 537.34 **Blender Version** Broken: version: 4.0.0 Beta, branch: blender-v4.0-release, commit date: 2023-10-04 23:50, hash: `2f71d9f80795` Broken: 3.5, 3.6, 4.0 Worked: **Short description of error** Unable to disable scissor test. **Exact steps for others to reproduce the error** Consider this script works fine in v3.6 ``` import bpy, gpu, blf, bgl from gpu_extras.batch import batch_for_shader vertices = ( (100, 100), (300, 100), (100, 200), (300, 200)) indices = ( (0, 1, 2), (2, 1, 3)) shader = gpu.shader.from_builtin('UNIFORM_COLOR') batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices) def draw(): bgl.glEnable(bgl.GL_SCISSOR_TEST) bgl.glScissor(100, 100, 200, 50) shader.uniform_float("color", (0, 0.5, 0.5, 1.0)) batch.draw(shader) bgl.glDisable(bgl.GL_SCISSOR_TEST) blf.position(0, 100, 150, 0) blf.size(0, 50.0) blf.draw(0, "Cut the Box only") bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL') ``` ![image](/attachments/fdf8a868-ff9c-4710-ae0e-4dc2de08a3f3) ------------------------------------------------------------------------------------------------------------------------------ **Got unexpected results in v4.0** ``` import bpy, gpu, blf from gpu_extras.batch import batch_for_shader vertices = ( (100, 100), (300, 100), (100, 200), (300, 200)) indices = ( (0, 1, 2), (2, 1, 3)) shader = gpu.shader.from_builtin('UNIFORM_COLOR') batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices) def draw(): gpu.state.scissor_test_set(True) # <--------------- gpu.state.scissor_set(100, 100, 200, 50) # <------- shader.uniform_float("color", (0, 0.5, 0.5, 1.0)) batch.draw(shader) gpu.state.scissor_test_set(False) # <--------------- blf.position(0, 100, 150, 0) blf.size(0, 50.0) blf.draw(0, "Cut the Box only") bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL') ``` ![image](/attachments/f72e83d6-8def-4d55-b91e-9ac88defdc96)
Y.T-LAW added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-10-05 23:25:11 +02:00
Member

Thanks for the report. I can confirm

Thanks for the report. I can confirm
Pratik Borhade added
Module
EEVEE & Viewport
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-10-06 08:29:45 +02:00
Author

Let me know if it's fixed for v4.0/4.1 since I'm catching up a add-on, thanks.

Let me know if it's fixed for v4.0/4.1 since I'm catching up a add-on, thanks.
Member
cc @Jeroen-Bakker
Member

Although the top script gives expected results it is not advices to mingle bgl and gpu calls as it messes up the internal state bgl calls go directly to OpenGL driver and changes the state that blender isn’t aware of. So might be expected, but is asking for problems.

For second script I need to check renderdoc state updates are normally updated during the next drawing command.

Although the top script gives expected results it is not advices to mingle bgl and gpu calls as it messes up the internal state bgl calls go directly to OpenGL driver and changes the state that blender isn’t aware of. So might be expected, but is asking for problems. For second script I need to check renderdoc state updates are normally updated during the next drawing command.
Member

With disabling the scissor test
image

After commenting out scissor_test_set(False)
image

So I confirm that something isn't working as expected.

My idea is that the state is altered to quick and not all events are translated to gl commands. This can be seen as setting the scissor command isn't sent to the driver.

With disabling the scissor test ![image](/attachments/98bb3467-4d04-4a5a-8298-5a5abd534cf4) After commenting out `scissor_test_set(False)` ![image](/attachments/27c1b6e9-759e-474b-b586-4e6cb5048603) So I confirm that something isn't working as expected. My idea is that the state is altered to quick and not all events are translated to gl commands. This can be seen as setting the scissor command isn't sent to the driver.
359 KiB
364 KiB
Member

Found the issue, when setting the scissor enablement, the framebuffer isn't tagged as being dirty.
I will add a patch to 3.3, 3.6 and 4.0

Thanks for reporting!

Found the issue, when setting the scissor enablement, the framebuffer isn't tagged as being dirty. I will add a patch to 3.3, 3.6 and 4.0 Thanks for reporting!
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-10-13 07:44:25 +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
3 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#113310
No description provided.