diff options
author | Corbin Simpson <MostAwesomeDude@gmail.com> | 2010-05-01 21:04:25 -0700 |
---|---|---|
committer | Corbin Simpson <MostAwesomeDude@gmail.com> | 2010-05-01 21:18:53 -0700 |
commit | c3243e8c00673ed1357420ed59b7e43de47fb367 (patch) | |
tree | 28690144a39ac2f2bd58ce8408e1160ceb662353 | |
parent | 37f321364f3f46bec04a341eaf2d76ea5fe79a8c (diff) |
Add is_format_supported.
-rw-r--r-- | screen.py | 49 |
1 files changed, 47 insertions, 2 deletions
@@ -1,5 +1,40 @@ from ctypes import * +class bind_bitfield(Structure): + _fields_ = [ + ("DEPTH_STENCIL", c_uint, 1), + ("RENDER_TARGET", c_uint, 1), + ("SAMPLER_VIEW", c_uint, 1), + ("VERTEX_BUFFER", c_uint, 1), + ("INDEX_BUFFER", c_uint, 1), + ("CONSTANT_BUFFER", c_uint, 1), + ("BLIT_SOURCE", c_uint, 1), + ("BLIT_DESTINATION", c_uint, 1), + ("DISPLAY_TARGET", c_uint, 1), + ("TRANSFER_WRITE", c_uint, 1), + ("TRANSFER_READ", c_uint, 1), + ] + +class Bindings(Union): + _anonymous_ = ("bitfield",) + _fields_ = [ + ("bitfield", bind_bitfield), + ("value", c_uint), + ] + +class geom_bitfield(Structure): + _fields_ = [ + ("NON_SQUARE", c_uint, 1), + ("NON_POWER_OF_TWO", c_uint, 1), + ] + +class Geom(Union): + _anonymous_ = ("bitfield",) + _fields_ = [ + ("bitfield", geom_bitfield), + ("value", c_uint), + ] + class pipe_screen(Structure): pass @@ -16,8 +51,8 @@ pipe_screen._fields_ = [ POINTER(pipe_screen), c_int, c_int, - c_uint, - c_uint)), + bind_bitfield, + geom_bitfield)), ("resource_create", CFUNCTYPE(c_void_p, POINTER(pipe_screen), c_void_p)), ("resource_from_handle", CFUNCTYPE(c_void_p, POINTER(pipe_screen), c_void_p, c_void_p)), @@ -98,6 +133,7 @@ class Screen(object): def __init__(self, s): self.pipe_screen = s self.init_params() + self.format_supported_dict = {} def __del__(self): self.destroy() @@ -122,3 +158,12 @@ class Screen(object): def vendor(self): return self.pipe_screen[0].get_vendor(self.pipe_screen) + def is_format_supported(self, format, target, bindings, geom_flags): + t = format, target, bindings, geom_flags + if t not in self.format_supported_dict: + self.format_supported_dict[t] = bool( + self.pipe_screen[0].is_format_supported( + self.pipe_screen, format, target, + bindings, geom_flags)) + return self.format_supported_dict[t] + |