forked from mirror/vulkan-zig
Update readme
This commit is contained in:
26
README.md
26
README.md
@@ -76,14 +76,13 @@ const BaseDispatch = vk.BaseWrapper(.{
|
|||||||
```
|
```
|
||||||
The wrapper struct then provides wrapper functions for each function pointer in the dispatch struct:
|
The wrapper struct then provides wrapper functions for each function pointer in the dispatch struct:
|
||||||
```zig
|
```zig
|
||||||
pub const BaseWrapper(comptime Self: type) type {
|
pub const BaseWrapper(comptime cmds: anytype) type {
|
||||||
...
|
...
|
||||||
|
const Dispatch = CreateDispatchStruct(cmds);
|
||||||
return struct {
|
return struct {
|
||||||
pub fn createInstance(
|
dispatch: Dispatch,
|
||||||
self: Self,
|
|
||||||
create_info: InstanceCreateInfo,
|
pub const CreateInstanceError = error{
|
||||||
p_allocator: ?*const AllocationCallbacks,
|
|
||||||
) error{
|
|
||||||
OutOfHostMemory,
|
OutOfHostMemory,
|
||||||
OutOfDeviceMemory,
|
OutOfDeviceMemory,
|
||||||
InitializationFailed,
|
InitializationFailed,
|
||||||
@@ -91,9 +90,14 @@ pub const BaseWrapper(comptime Self: type) type {
|
|||||||
ExtensionNotPresent,
|
ExtensionNotPresent,
|
||||||
IncompatibleDriver,
|
IncompatibleDriver,
|
||||||
Unknown,
|
Unknown,
|
||||||
}!Instance {
|
};
|
||||||
|
pub fn createInstance(
|
||||||
|
self: Self,
|
||||||
|
create_info: InstanceCreateInfo,
|
||||||
|
p_allocator: ?*const AllocationCallbacks,
|
||||||
|
) CreateInstanceError!Instance {
|
||||||
var instance: Instance = undefined;
|
var instance: Instance = undefined;
|
||||||
const result = self.vkCreateInstance(
|
const result = self.dispatch.vkCreateInstance(
|
||||||
&create_info,
|
&create_info,
|
||||||
p_allocator,
|
p_allocator,
|
||||||
&instance,
|
&instance,
|
||||||
@@ -125,9 +129,9 @@ Wrappers are generated according to the following rules:
|
|||||||
* As of yet, there is no specific handling of enumeration style commands or other commands which accept slices.
|
* As of yet, there is no specific handling of enumeration style commands or other commands which accept slices.
|
||||||
|
|
||||||
Furthermore, each wrapper contains a function to load each function pointer member when passed either `PfnGetInstanceProcAddr` or `PfnGetDeviceProcAddr`, which attempts to load each member as function pointer and casts it to the appropriate type. These functions are loaded literally, and any wrongly named member or member with a wrong function pointer type will result in problems.
|
Furthermore, each wrapper contains a function to load each function pointer member when passed either `PfnGetInstanceProcAddr` or `PfnGetDeviceProcAddr`, which attempts to load each member as function pointer and casts it to the appropriate type. These functions are loaded literally, and any wrongly named member or member with a wrong function pointer type will result in problems.
|
||||||
* For `BaseWrapper`, this function has signature `fn load(loader: PfnGetInstanceProcAddr) !Self`.
|
* For `BaseWrapper`, this function has signature `fn load(loader: anytype) !Self`, where the type of `loader` must resemble `PfnGetInstanceProcAddr` (with optionally having a different calling convention).
|
||||||
* For `InstanceWrapper`, this function has signature `fn load(instance: Instance, loader: PfnGetInstanceProcAddr) !Self`.
|
* For `InstanceWrapper`, this function has signature `fn load(instance: Instance, loader: anytype) !Self`, where the type of `loader` must resemble `PfnGetInstanceProcAddr`.
|
||||||
* For `DeviceWrapper`, this function has signature `fn load(device: Device, loader: PfnGetDeviceProcAddr) !Self`.
|
* For `DeviceWrapper`, this function has signature `fn load(device: Device, loader: anytype) !Self`, where the type of `loader` must resemble `PfnGetDeviceProcAddr`.
|
||||||
|
|
||||||
One can access the underlying unwrapped C functions by doing `wrapper.dispatch.vkFuncYouWant(..)`.
|
One can access the underlying unwrapped C functions by doing `wrapper.dispatch.vkFuncYouWant(..)`.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user