[Mesa-dev] New "state tracker": Pylladium

Corbin Simpson mostawesomedude at gmail.com
Sun May 2 09:34:09 PDT 2010


So I got bored a few days ago and broke ground on a little bit of code
I've had in mind for a while. This is a new state tracker, Pylladium,
that acts to expose the core Gallium objects of a driver in a clean,
Pythonic fashion, without being overly low-level or abstracted away.

So why make another tracker when there's already a great one maintained by Jose?

1) SWIG. The current tracker must be compiled against a pipe driver
library, and can't dynamically switch between drivers. Additionally,
it can't be run on any Python besides CPython, which is mostly a
personal annoyance but something some people honestly have to work
with.
2) The interface, being SWIG'd, is a straight copy of the interface
defined in the Gallium headers, which isn't very Python-friendly. In
particular, there's no encapsulation. Zack indicated this was a
feature, not a bug, and frankly, I agree. It was designed to replicate
the Gallium interface in Python, and it does it well. No need to
change it.
3) I could not pass up the pun. Seriously, I've been sitting on it for
months, and I finally got fed up and acted on it.

You can take a look at the general direction I've taken at
http://cgit.freedesktop.org/~csimpson/pylladium . It acts on raw
Gallium drivers, something not present yet in master. My raw-targets
branch of Mesa (http://cgit.freedesktop.org/~csimpson/mesa/log/?h=raw-targets)
has a r300g target already and I have an i915g target that I'll push
when I get home later. These drivers make drm_api_create being
publicly accessible. (I needed to do this because one cannot dlopen()
DRI or EGL drivers in the general case.) A softpipe variant using
null_sw_winsys should be fairly trivial, but I haven't done it yet.

One thing that I feel is important: This isn't meant to be performant.
At all. Buffers are going to be displayed through a variety of fairly
slow methods, most of them likely involving PIL. ctypes is the binding
I'm using, and it incurs a fair overhead on anything besides PyPy.
This is meant to be a clear demonstration of how the objects in
Gallium interact and work, more than anything else.

Oh, and a brief demonstration, culled from my main.py:

da = drm.DrmApi(raw)

print "Loaded drm_api object, name %s" % da.name

s = da.create_screen(raw.drmOpen(da.name, None))

print "Created screen, name %s vendor %s" % (s.name, s.vendor)
if s.params["GLSL"]:
    print "Whoo, GLSL!"
else:
    print "No GLSL..."

b = screen.Bindings()
b.RENDER_TARGET = True
b.SAMPLER_VIEW = True

g = screen.Geom()

for name, number in formats.by_name.iteritems():
    if s.is_format_supported(number, 2, b, g):
        print "%s is an acceptable FBO colorbuf" % name

Comments, criticisms, flames, etc. welcome.

~ C.

(Just watch, Phoronix; next time, it'll be a tracker for Flash
rendering. I'll call it, "Galoshes!")

-- 
When the facts change, I change my mind. What do you do, sir? ~ Keynes

Corbin Simpson
<MostAwesomeDude at gmail.com>


More information about the mesa-dev mailing list