Python GPU: Replace part of the code that uses 'bgl' with 'gpu'

This is part of the process described in T80730.

The aim is to deprecate the bgl module.

Reviewed By: fclem, brecht, campbellbarton

Revision: D11147
This commit is contained in:
Germano Cavalcante 2021-05-14 11:15:00 -03:00 committed by Germano Cavalcante
parent 48fa029dd1
commit b11499939c
3 changed files with 23 additions and 40 deletions

View File

@ -19,16 +19,16 @@ from __future__ import annotations
def _is_using_buggy_driver():
import bgl
import gpu
# We need to be conservative here because in multi-GPU systems display card
# might be quite old, but others one might be just good.
#
# So We shouldn't disable possible good dedicated cards just because display
# card seems weak. And instead we only blacklist configurations which are
# proven to cause problems.
if bgl.glGetString(bgl.GL_VENDOR) == "ATI Technologies Inc.":
if gpu.platform.vendor_get() == "ATI Technologies Inc.":
import re
version = bgl.glGetString(bgl.GL_VERSION)
version = gpu.platform.version_get()
if version.endswith("Compatibility Profile Context"):
# Old HD 4xxx and 5xxx series drivers did not have driver version
# in the version string, but those cards do not quite work and

View File

@ -21,7 +21,7 @@
def url_prefill_from_blender(addon_info=None):
import bpy
import bgl
import gpu
import struct
import platform
import urllib.parse
@ -38,9 +38,9 @@ def url_prefill_from_blender(addon_info=None):
)
fh.write(
"Graphics card: %s %s %s\n" % (
bgl.glGetString(bgl.GL_RENDERER),
bgl.glGetString(bgl.GL_VENDOR),
bgl.glGetString(bgl.GL_VERSION),
gpu.platform.renderer_get(),
gpu.platform.vendor_get(),
gpu.platform.version_get(),
)
)
fh.write(

View File

@ -28,7 +28,7 @@ def write_sysinfo(filepath):
import subprocess
import bpy
import bgl
import gpu
# pretty repr
def prepr(v):
@ -190,46 +190,29 @@ def write_sysinfo(filepath):
if bpy.app.background:
output.write("\nOpenGL: missing, background mode\n")
else:
output.write(title("OpenGL"))
version = bgl.glGetString(bgl.GL_RENDERER)
output.write("renderer:\t%r\n" % version)
output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
output.write(title("GPU"))
output.write("renderer:\t%r\n" % gpu.platform.renderer_get())
output.write("vendor:\t\t%r\n" % gpu.platform.vendor_get())
output.write("version:\t%r\n" % gpu.platform.version_get())
output.write("extensions:\n")
limit = bgl.Buffer(bgl.GL_INT, 1)
bgl.glGetIntegerv(bgl.GL_NUM_EXTENSIONS, limit)
glext = []
for i in range(limit[0]):
glext.append(bgl.glGetStringi(bgl.GL_EXTENSIONS, i))
glext = sorted(glext)
glext = sorted(gpu.capabilities.extensions_get())
for l in glext:
output.write("\t%s\n" % l)
output.write(title("Implementation Dependent OpenGL Limits"))
bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_VERTICES, limit)
output.write("Maximum DrawElements Vertices:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_INDICES, limit)
output.write("Maximum DrawElements Indices:\t%d\n" % limit[0])
output.write(title("Implementation Dependent GPU Limits"))
output.write("Maximum Batch Vertices:\t%d\n" % gpu.capabilities.max_batch_vertices_get())
output.write("Maximum Batch Indices:\t%d\n" % gpu.capabilities.max_batch_indices_get())
output.write("\nGLSL:\n")
bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
output.write("Maximum Varying Floats:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])
output.write("Maximum Varying Floats:\t%d\n" % gpu.capabilities.max_varying_floats_get())
output.write("Maximum Vertex Attributes:\t%d\n" % gpu.capabilities.max_vertex_attribs_get())
output.write("Maximum Vertex Uniform Components:\t%d\n" % gpu.capabilities.max_uniforms_vert_get())
output.write("Maximum Fragment Uniform Components:\t%d\n" % gpu.capabilities.max_uniforms_frag_get())
output.write("Maximum Vertex Image Units:\t%d\n" % gpu.capabilities.max_textures_vert_get())
output.write("Maximum Fragment Image Units:\t%d\n" % gpu.capabilities.max_textures_frag_get())
output.write("Maximum Pipeline Image Units:\t%d\n" % gpu.capabilities.max_textures_get())
if bpy.app.build_options.cycles:
import cycles