[Bf-blender-cvs] [b11499939c7] master: Python GPU: Replace part of the code that uses 'bgl' with 'gpu'

Germano Cavalcante noreply at git.blender.org
Fri May 14 17:27:04 CEST 2021


Commit: b11499939c7731e369be37c594142fd16e111ca7
Author: Germano Cavalcante
Date:   Fri May 14 11:15:00 2021 -0300
Branches: master
https://developer.blender.org/rBb11499939c7731e369be37c594142fd16e111ca7

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

===================================================================

M	intern/cycles/blender/addon/engine.py
M	release/scripts/modules/bl_ui_utils/bug_report_url.py
M	release/scripts/modules/sys_info.py

===================================================================

diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index dfa696714fb..d8398772a84 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -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
diff --git a/release/scripts/modules/bl_ui_utils/bug_report_url.py b/release/scripts/modules/bl_ui_utils/bug_report_url.py
index 5676e0d6815..3fc57467dac 100644
--- a/release/scripts/modules/bl_ui_utils/bug_report_url.py
+++ b/release/scripts/modules/bl_ui_utils/bug_report_url.py
@@ -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(
diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py
index 5116e0f0088..192fc1a201f 100644
--- a/release/scripts/modules/sys_info.py
+++ b/release/scripts/modules/sys_info.py
@@ -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



More information about the Bf-blender-cvs mailing list