Page MenuHome

gpu.types.GPUOffscreen crashes Blender
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: Radeon RX 580 Series ATI Technologies Inc. 4.5.13587 Core Profile Context 20.4.2 26.20.15029.27017

Blender Version
Broken: version: 2.83 release and 2.90
Worked: 2.82 and some previous 2.83

Short description of error
If using gpu.types.GPUOffscreen with samples parameter, it will crash Blender with error:

GPUFrameBuffer: framebuffer status GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE

See docs: https://docs.blender.org/api/blender2.8/gpu.types.html?highlight=gpuoffscreen#gpu.types.GPUOffScreen

Exact steps for others to reproduce the error

  • Open the .blend in 2.83 release or 2.90 alpha (or copy provided code)
  • Run the script in Blender
  • Move cursor over 3d viewport
  • Blender crashes

FILE

CODE (based on an example of the official documentation)

import bgl
import bpy
import gpu
from gpu_extras.presets import draw_texture_2d

WIDTH = 512
HEIGHT = 256
SAMPLES = 4

offscreen = gpu.types.GPUOffScreen(WIDTH, HEIGHT, samples=SAMPLES)


def draw():
    context = bpy.context
    scene = context.scene

    view_matrix = scene.camera.matrix_world.inverted()

    projection_matrix = scene.camera.calc_matrix_camera(
        context.evaluated_depsgraph_get(), x=WIDTH, y=HEIGHT)

    offscreen.draw_view3d(
        scene,
        context.view_layer,
        context.space_data,
        context.region,
        view_matrix,
        projection_matrix)

    bgl.glDisable(bgl.GL_DEPTH_TEST)
    draw_texture_2d(offscreen.color_texture, (10, 10), WIDTH, HEIGHT)


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

Event Timeline

Juanfran Matheu (jfmatheu) renamed this task from gpy.types.GPUOffscreen crashes Blender to gpu.types.GPUOffscreen crashes Blender.Sat, Jun 13, 5:21 PM
Juanfran Matheu (jfmatheu) created this task.
Juanfran Matheu (jfmatheu) updated the task description. (Show Details)
Juanfran Matheu (jfmatheu) updated the task description. (Show Details)
Campbell Barton (campbellbarton) changed the task status from Needs Triage to Confirmed.Tue, Jun 16, 9:24 AM
Campbell Barton (campbellbarton) changed the subtype of this task from "Report" to "Bug".

The workbench rendering engine assumes the buffer isn't multi-sample.

While I didn't look into it in detail, it seems like support could be added.

Setting SAMPLES to 0 resolves the issue.

Multisample buffers are not compatible with how we draw things in the DRW manager now.

So I will remove the argument from the python function as well.