-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge develop to bring in EGL, format handler and test-suite fixes
* 3e9791f Bump release to 3.1.5 * d06c1ac NUMPY Register intc and uintc as handled scalar types * 38edb04 WIN FIX GL entry points are NULL on windows initially * 57b7706 TESTS Run accelerate tests from base tox as well * 60aec44 BUILD Update cython source with current release * c26398b TESTS Switch to pytest.mark for skipping numpy handler when not available * 6ec398d TESTS Switch to assertRaises * 581d240 TESTS Don't print glget calls, compressed image api call revert * 8cf737d API More support for using short-string types for convenience * 1b7c3c3 API In ctypes arrays allow for numpy style short-string type specifiers * eb9a6b4 FIX Work around weird numpy scalar behaviour (0-dimension arrays) * d625f8b TESTS reason cannot be passed as a keyword argument in pytest.skip * f12403b WGL FIX Set the resstyle for getCurrentDC in the wrapper * 143ecbc GITHUB #7 Use b-strings instead of as_8_bit * 44a89fe GITIGNORE Ignore .pyd files for Windows develop builds * a52215f TESTS Fix usage of glCompressedTexImage2D in test_core * 2f401a0 EGL Allow eglGetDeviceQueryString without display, use to display drm name * c4cd5d0 BUILD Back out adding python3.8 to the build matrix * 447fbfa BUILD Continue trying to get sdl to compile * bdb957b BUILD Add libsdl1.2-dev to get the sld-config utility * dccbbb6 BUILD Revert attempts to use arm64 (pygame doesn't build) but add python 3.8 * 907ec4a BUILD Experiment with testing on arm64 (loosely related to GH #29) * 637caf4 TESTS Remove flaky test in favour of more robust one below it * 144ce85 EGL DEMO Further refactoring of os_egl setup * a07c956 EGL DEMO Allow for null values in EGL debug table formatting * 9f115ff EGL Explicitly export EGLError from the EGL namespace * c58c9c4 EGL Move code to debug, rely on EGLError for display, debug configs * 93d6f66 EGL DEMO PPM writing and tabular format of configs in EGL debug module * 9640630 FIX Fix latebind __bool__ definition as __nonzero__ isn't available * 8628ce1 EGL Allow ErrorCheckers to specify GLError sub-classes, use for EGLError * 1f1cda4 FORMAT Black formatting for os_egl demo/test script * 0ed754b FIX for #27 to work on machines where libOpenGL is not present * 589d3ca EGL Make `eglGetPlatformDisplay` an alternate with `eglGetPlatformDisplayEXT` * e04bee4 FIX Add on for the fix to #6 to make force_extension functions bool() work * 2487c21 EGL DEMO Try to create script to query the egl device enumerations * 41e6f57 EGL DEMO Explicitly delete the DISPLAY environment variable to force offline operation * 4a40d2b TESTS Ignore the output of osmesa and egl tests * 3c81386 EGL DEMO Attempt to get an offscreen (pbuffer) render wrapper working * 8f8d3e8 FIX #27 Load libOpenGL instead of libGL for egl platform * 4f9cb46 DOCS Add pyrender as a sample source * d401885 FIX GH #12 Include pxd files in the source-code release * ca2cbbe DEMO Attempt to recreate github #33 without success * ce8c5d5 DOCS Update comment to note that we're next to the main checkout now * f85d8ce DOCS Update tartley projects to github urls, provide first-line links on gh and bb * e81584a DOCS Skip generation of .xhtml redirect stubs * 5f206da DEMO provide a running version of code in bug report in #34 * bf3fe7c FIX Explicitly add nonzero methods for base latebind classes
- Loading branch information
Showing
55 changed files
with
3,681 additions
and
1,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
"""Debug utilities for EGL operations""" | ||
from OpenGL.EGL import * | ||
import itertools | ||
|
||
|
||
def eglErrorName(value): | ||
"""Returns error constant if known, otherwise returns value""" | ||
return KNOWN_ERRORS.get(value, value) | ||
|
||
|
||
KNOWN_ERRORS = { | ||
EGL_SUCCESS: EGL_SUCCESS, | ||
EGL_NOT_INITIALIZED: EGL_NOT_INITIALIZED, | ||
EGL_BAD_ACCESS: EGL_BAD_ACCESS, | ||
EGL_BAD_ALLOC: EGL_BAD_ALLOC, | ||
EGL_BAD_ATTRIBUTE: EGL_BAD_ATTRIBUTE, | ||
EGL_BAD_CONTEXT: EGL_BAD_CONTEXT, | ||
EGL_BAD_CONFIG: EGL_BAD_CONFIG, | ||
EGL_BAD_CURRENT_SURFACE: EGL_BAD_CURRENT_SURFACE, | ||
EGL_BAD_DISPLAY: EGL_BAD_DISPLAY, | ||
EGL_BAD_SURFACE: EGL_BAD_SURFACE, | ||
EGL_BAD_MATCH: EGL_BAD_MATCH, | ||
EGL_BAD_PARAMETER: EGL_BAD_PARAMETER, | ||
EGL_BAD_NATIVE_PIXMAP: EGL_BAD_NATIVE_PIXMAP, | ||
EGL_BAD_NATIVE_WINDOW: EGL_BAD_NATIVE_WINDOW, | ||
EGL_CONTEXT_LOST: EGL_CONTEXT_LOST, | ||
} | ||
|
||
|
||
def write_ppm(buf, filename): | ||
"""Write height * width * 3-component buffer as ppm to filename | ||
This lets us write a simple image format without | ||
using any libraries that can be viewed on most | ||
linux workstations. | ||
""" | ||
with open(filename, "w") as f: | ||
h, w, c = buf.shape | ||
print("P3", file=f) | ||
print("# ascii ppm file created by pyopengl", file=f) | ||
print("%i %i" % (w, h), file=f) | ||
print("255", file=f) | ||
for y in range(h - 1, -1, -1): | ||
for x in range(w): | ||
pixel = buf[y, x] | ||
l = " %3d %3d %3d" % (pixel[0], pixel[1], pixel[2]) | ||
f.write(l) | ||
f.write("\n") | ||
|
||
|
||
def debug_config(display, config): | ||
"""Get debug display for the given configuration""" | ||
result = {} | ||
value = EGLint() | ||
for attr in CONFIG_ATTRS: | ||
if not eglGetConfigAttrib(display, config, attr, value): | ||
log.warning("Failed to get attribute %s from config", attr) | ||
continue | ||
if attr in BITMASK_FIELDS: | ||
attr_value = {} | ||
for subattr in BITMASK_FIELDS[attr]: | ||
if value.value & subattr: | ||
attr_value[subattr.name] = True | ||
else: | ||
attr_value = value.value | ||
result[attr.name] = attr_value | ||
return result | ||
|
||
|
||
def debug_configs(display, configs=None, max_count=256): | ||
"""Present a formatted list of configs for the display""" | ||
if configs is None: | ||
configs = (EGLConfig * max_count)() | ||
num_configs = EGLint() | ||
eglGetConfigs(display, configs, max_count, num_configs) | ||
if not num_configs.value: | ||
return [] | ||
configs = configs[: num_configs.value] | ||
debug_configs = [debug_config(display, cfg) for cfg in configs] | ||
return debug_configs | ||
|
||
|
||
SURFACE_TYPE_BITS = [ | ||
EGL_MULTISAMPLE_RESOLVE_BOX_BIT, | ||
EGL_PBUFFER_BIT, | ||
EGL_PIXMAP_BIT, | ||
EGL_SWAP_BEHAVIOR_PRESERVED_BIT, | ||
EGL_VG_ALPHA_FORMAT_PRE_BIT, | ||
EGL_VG_COLORSPACE_LINEAR_BIT, | ||
EGL_WINDOW_BIT, | ||
] | ||
RENDERABLE_TYPE_BITS = [ | ||
EGL_OPENGL_BIT, | ||
EGL_OPENGL_ES_BIT, | ||
EGL_OPENGL_ES2_BIT, | ||
EGL_OPENGL_ES3_BIT, | ||
EGL_OPENVG_BIT, | ||
] | ||
CAVEAT_BITS = [ | ||
EGL_NONE, | ||
EGL_SLOW_CONFIG, | ||
EGL_NON_CONFORMANT_CONFIG, | ||
] | ||
TRANSPARENT_BITS = [ | ||
EGL_NONE, | ||
EGL_TRANSPARENT_RGB, | ||
] | ||
|
||
CONFIG_ATTRS = [ | ||
EGL_CONFIG_ID, | ||
EGL_RED_SIZE, | ||
EGL_GREEN_SIZE, | ||
EGL_BLUE_SIZE, | ||
EGL_DEPTH_SIZE, | ||
EGL_ALPHA_SIZE, | ||
EGL_ALPHA_MASK_SIZE, | ||
EGL_BUFFER_SIZE, | ||
EGL_STENCIL_SIZE, | ||
EGL_BIND_TO_TEXTURE_RGB, | ||
EGL_BIND_TO_TEXTURE_RGBA, | ||
EGL_COLOR_BUFFER_TYPE, | ||
EGL_CONFIG_CAVEAT, | ||
EGL_CONFORMANT, | ||
EGL_LEVEL, | ||
EGL_LUMINANCE_SIZE, | ||
EGL_MAX_PBUFFER_WIDTH, | ||
EGL_MAX_PBUFFER_HEIGHT, | ||
EGL_MAX_PBUFFER_PIXELS, | ||
EGL_MIN_SWAP_INTERVAL, | ||
EGL_MAX_SWAP_INTERVAL, | ||
EGL_NATIVE_RENDERABLE, | ||
EGL_NATIVE_VISUAL_ID, | ||
EGL_NATIVE_VISUAL_TYPE, | ||
EGL_RENDERABLE_TYPE, | ||
EGL_SAMPLE_BUFFERS, | ||
EGL_SAMPLES, | ||
EGL_SURFACE_TYPE, | ||
EGL_TRANSPARENT_TYPE, | ||
EGL_TRANSPARENT_RED_VALUE, | ||
EGL_TRANSPARENT_GREEN_VALUE, | ||
EGL_TRANSPARENT_BLUE_VALUE, | ||
] | ||
|
||
BITMASK_FIELDS = dict( | ||
[ | ||
(EGL_SURFACE_TYPE, SURFACE_TYPE_BITS), | ||
(EGL_RENDERABLE_TYPE, RENDERABLE_TYPE_BITS), | ||
(EGL_CONFORMANT, RENDERABLE_TYPE_BITS), | ||
(EGL_CONFIG_CAVEAT, CAVEAT_BITS), | ||
(EGL_TRANSPARENT_TYPE, TRANSPARENT_BITS), | ||
] | ||
) | ||
|
||
|
||
def bit_renderer(bit): | ||
def render(value): | ||
if bit.name in value: | ||
return " Y" | ||
else: | ||
return " ." | ||
|
||
return render | ||
|
||
|
||
CONFIG_FORMAT = [ | ||
(EGL_CONFIG_ID, "0x%x", "id", "cfg"), | ||
(EGL_BUFFER_SIZE, "%i", "sz", "bf"), | ||
(EGL_LEVEL, "%i", "l", "lv"), | ||
(EGL_RED_SIZE, "%i", "r", "cbuf"), | ||
(EGL_GREEN_SIZE, "%i", "g", "cbuf"), | ||
(EGL_BLUE_SIZE, "%i", "b", "cbuf"), | ||
(EGL_ALPHA_SIZE, "%i", "a", "cbuf"), | ||
(EGL_DEPTH_SIZE, "%i", "th", "dp"), | ||
(EGL_STENCIL_SIZE, "%i", "t", "s"), | ||
(EGL_SAMPLES, "%i", "ns", "mult"), | ||
(EGL_SAMPLE_BUFFERS, "%i", "bu", "mult"), | ||
(EGL_NATIVE_VISUAL_ID, "0x%x", "id", "visual"), | ||
(EGL_RENDERABLE_TYPE, bit_renderer(EGL_OPENGL_BIT), "gl", "render"), | ||
(EGL_RENDERABLE_TYPE, bit_renderer(EGL_OPENGL_ES_BIT), "es", "render"), | ||
(EGL_RENDERABLE_TYPE, bit_renderer(EGL_OPENGL_ES2_BIT), "e2", "render"), | ||
(EGL_RENDERABLE_TYPE, bit_renderer(EGL_OPENGL_ES3_BIT), "e3", "render"), | ||
(EGL_RENDERABLE_TYPE, bit_renderer(EGL_OPENVG_BIT), "vg", "render"), | ||
(EGL_SURFACE_TYPE, bit_renderer(EGL_WINDOW_BIT), "wn", "surface"), | ||
(EGL_SURFACE_TYPE, bit_renderer(EGL_PBUFFER_BIT), "pb", "surface"), | ||
(EGL_SURFACE_TYPE, bit_renderer(EGL_PIXMAP_BIT), "px", "surface"), | ||
] | ||
|
||
|
||
def format_debug_configs(debug_configs, formats=CONFIG_FORMAT): | ||
"""Format config for compact debugging display | ||
Produces a config summary display for a set of | ||
debug_configs as a text-mode table. | ||
Uses `formats` (default `CONFIG_FORMAT`) to determine | ||
which fields are extracted and how they are formatted | ||
along with the column/subcolum set to be rendered in | ||
the overall header. | ||
returns formatted ASCII table for display in debug | ||
logs or utilities | ||
""" | ||
columns = [] | ||
for (key, format, subcol, col) in formats: | ||
column = [] | ||
max_width = 0 | ||
for row in debug_configs: | ||
if isinstance(row, EGLConfig): | ||
raise TypeError(row, "Call debug_config(display,config)") | ||
try: | ||
value = row[key.name] | ||
except KeyError: | ||
formatted = "_" | ||
else: | ||
if isinstance(format, str): | ||
formatted = format % (value) | ||
else: | ||
formatted = format(value) | ||
max_width = max((len(formatted), max_width)) | ||
column.append(formatted) | ||
columns.append( | ||
{ | ||
"rows": column, | ||
"key": key, | ||
"format": format, | ||
"subcol": subcol, | ||
"col": col, | ||
"width": max_width, | ||
} | ||
) | ||
headers = [] | ||
subheaders = [] | ||
rows = [headers, subheaders] | ||
last_column = None | ||
last_column_width = 0 | ||
for header, subcols in itertools.groupby(columns, lambda x: x["col"]): | ||
subcols = list(subcols) | ||
width = sum([col["width"] for col in subcols]) + (len(subcols) - 1) | ||
headers.append(header.center(width, ".")[:width]) | ||
for column in columns: | ||
subheaders.append(column["subcol"].rjust(column["width"])[: column["width"]]) | ||
rows.extend( | ||
zip(*[[v.rjust(col["width"], " ") for v in col["rows"]] for col in columns]) | ||
) | ||
return "\n".join([" ".join(row) for row in rows]) |
Oops, something went wrong.