tools/info: initialise global_table for instance queries
This commit is contained in:
parent
065e2f0047
commit
e9cae93e4a
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <cruft/util/iterator.hpp>
|
#include <cruft/util/iterator.hpp>
|
||||||
|
|
||||||
|
#include <cruft/vk/icd/ostream.hpp>
|
||||||
#include <cruft/vk/icd/vtable.hpp>
|
#include <cruft/vk/icd/vtable.hpp>
|
||||||
|
|
||||||
#include <cruft/vk/instance.hpp>
|
#include <cruft/vk/instance.hpp>
|
||||||
@ -26,19 +27,21 @@
|
|||||||
int
|
int
|
||||||
main (int, char**)
|
main (int, char**)
|
||||||
{
|
{
|
||||||
|
std::cout << "[ ";
|
||||||
for (auto const &i: cruft::vk::icd::enumerate ()) {
|
for (auto const &i: cruft::vk::icd::enumerate ()) {
|
||||||
cruft::vk::icd::vendor v (i);
|
cruft::vk::icd::vendor v (i);
|
||||||
|
|
||||||
cruft::vk::icd::g_table = &v.vtable;
|
cruft::vk::icd::g_table = &v.vtable;
|
||||||
|
|
||||||
//std::cout << "available_layers: [ "
|
|
||||||
// << cruft::make_infix (cruft::vk::instance::available_layers ())
|
|
||||||
// << " ]\n";
|
|
||||||
|
|
||||||
cruft::vk::instance instance;
|
cruft::vk::instance instance;
|
||||||
std::cout << "instance: " << instance << '\n';
|
|
||||||
|
|
||||||
//for (const auto &d: cruft::vk::physical_device::find (instance))
|
std::cout
|
||||||
// std::cout << d << '\n';
|
<< "{ vendor: " << i
|
||||||
|
<< ", available_layers: [ "
|
||||||
|
<< cruft::make_infix (cruft::vk::instance::available_layers ())
|
||||||
|
<< " ] }"
|
||||||
|
<< ", instance: " << instance
|
||||||
|
<< ", devices: [ " << cruft::make_infix (cruft::vk::physical_device::find (instance)) << " ], "
|
||||||
|
<< " }, ";
|
||||||
}
|
}
|
||||||
|
std::cout << " ]\n";
|
||||||
}
|
}
|
@ -391,6 +391,16 @@ class Constant(Type):
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
class Command(Type):
|
class Command(Type):
|
||||||
class Param(Type):
|
class Param(Type):
|
||||||
|
name: str
|
||||||
|
"""An appropriate title for this parameter"""
|
||||||
|
type: str
|
||||||
|
"""The name of this parameter's dependant type"""
|
||||||
|
param: str
|
||||||
|
"""
|
||||||
|
The components of this type for a C definition (ie, includes
|
||||||
|
pointer, const, and other decorations
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, node, **kwargs):
|
def __init__(self, node, **kwargs):
|
||||||
assert node.tag == 'param'
|
assert node.tag == 'param'
|
||||||
|
|
||||||
@ -409,6 +419,9 @@ class Command(Type):
|
|||||||
# normalise whitespace
|
# normalise whitespace
|
||||||
self.param = " ".join(self.param.split())
|
self.param = " ".join(self.param.split())
|
||||||
|
|
||||||
|
def is_pointer(self):
|
||||||
|
return '*' in self.param
|
||||||
|
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
assert node.tag == "command"
|
assert node.tag == "command"
|
||||||
proto = node.find('proto')
|
proto = node.find('proto')
|
||||||
@ -432,7 +445,9 @@ class Command(Type):
|
|||||||
if not self.params:
|
if not self.params:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return not isinstance(self.params[0], Handle)
|
first_name = self.params[0].type
|
||||||
|
first_obj = reg.types[first_name]
|
||||||
|
return not isinstance(first_obj, Handle)
|
||||||
|
|
||||||
def is_instance(self, reg: Registry):
|
def is_instance(self, reg: Registry):
|
||||||
assert reg
|
assert reg
|
||||||
@ -831,12 +846,17 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
|||||||
else:
|
else:
|
||||||
raise Exception("Unhandled command type")
|
raise Exception("Unhandled command type")
|
||||||
|
|
||||||
|
if obj.params:
|
||||||
|
last_param = obj.params[-1]
|
||||||
|
last_obj = reg.types[last_param.type]
|
||||||
|
is_creating = isinstance(last_obj, Handle) and last_param.is_pointer()
|
||||||
|
else:
|
||||||
|
is_creating = False
|
||||||
|
|
||||||
dst.write(f"""
|
dst.write(f"""
|
||||||
extern "C" {obj.result} {rename(obj.name)} ({", ".join(p.param for p in obj.params)}) noexcept {{
|
extern "C" {obj.result} {rename(obj.name)} ({", ".join(p.param for p in obj.params)}) noexcept {{
|
||||||
using first_arg_t = std::decay_t<decltype({obj.params[0].name})>;
|
|
||||||
|
|
||||||
auto const entry = reinterpret_cast<indirect const*> ({obj.params[0].name});
|
auto const entry = reinterpret_cast<indirect const*> ({obj.params[0].name});
|
||||||
auto const *table = reinterpret_cast<{table}_table*> (entry->table);
|
auto const *table = reinterpret_cast<cruft::vk::icd::{table}_table const*> (entry->table);
|
||||||
|
|
||||||
return (table->{obj.name})(
|
return (table->{obj.name})(
|
||||||
reinterpret_cast<decltype({obj.params[0].name})> (entry->handle)
|
reinterpret_cast<decltype({obj.params[0].name})> (entry->handle)
|
||||||
|
Loading…
Reference in New Issue
Block a user