zig build lib
This commit is contained in:
parent
b2495bcff7
commit
fc6b0a154a
|
|
@ -1,8 +1,9 @@
|
|||
.{
|
||||
.name = "objLoader",
|
||||
.name = .objLoader,
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
.fingerprint = 0xd1e6b855824386ac,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
.{
|
||||
.name = "vulkan",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
}
|
||||
.{
|
||||
.name = .ozz,
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
.fingerprint = 0xd9ca5c512e8ed6a7,
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ test "concurrent queue multiple producer single consumer" {
|
|||
threads[i].join();
|
||||
}
|
||||
|
||||
try utils.assertf(poppedCount == pushedCountResults.load(.acquire), "mismatched, we popped {d} records while the workers pushed {d}", .{ poppedCount, pushedCountResults.load(.acquire) });
|
||||
try utils.assertf(poppedCount == pushedCountResults.load(.seq_cst), "mismatched, we popped {d} records while the workers pushed {d}", .{ poppedCount, pushedCountResults.load(.seq_cst) });
|
||||
}
|
||||
|
||||
fn test_getTime() f64 {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
.{
|
||||
.name = "packer",
|
||||
.name = .packer,
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{ .p2 = .{ .path = "../p2" } },
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
.fingerprint = 0xd52201412e16f8a6,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,17 +138,9 @@ pub const PackerFS = struct {
|
|||
try self.pakMountings.append(self.allocator, .{ .filePath = try self.stringAlloc().dupe(u8, filePath) });
|
||||
|
||||
while (try iterator.next(reader)) |headerEntry| {
|
||||
const HeaderName = Name.Make(headerEntry.getFileName());
|
||||
var HeaderName = Name.Make(headerEntry.getFileName());
|
||||
|
||||
if (self.fileHandlesByName.get(HeaderName.handle())) |oldFileHeaderIndex| {
|
||||
// const oldFileHeaderSource = self.filePakSources.items[oldFileHeaderIndex];
|
||||
|
||||
// std.debug.print(
|
||||
// // todo; how should I deal with eviction?
|
||||
// "file {s} is already discovered, previously from {s}, this previous reference will be overwritten.\n",
|
||||
// .{ headerEntry.getFileName(), getDisplayNameForFileSource(oldFileHeaderSource, self) },
|
||||
// );
|
||||
|
||||
self.fileHeaders.items[oldFileHeaderIndex] = headerEntry;
|
||||
self.filePakSources.items[oldFileHeaderIndex] = pakMountingIndex;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
# libraries go here.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
.{
|
||||
.name = "SpirvReflect",
|
||||
.name = .SpirvReflect,
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{
|
||||
.glslTypes = .{ .path = "glslTypes" },
|
||||
|
|
@ -7,4 +7,5 @@
|
|||
.paths = .{
|
||||
"",
|
||||
},
|
||||
.fingerprint = 0x8bdf68352d7dc5fa,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
|
|||
spng_c.addIncludePath(b.path("spng"));
|
||||
spng_c.addIncludePath(b.path("./"));
|
||||
|
||||
spng_c.defineCMacro("SPNG_USE_MINIZ", "1");
|
||||
spng_c.root_module.addCMacro("SPNG_USE_MINIZ", "1");
|
||||
|
||||
const mod = b.addModule("spng", .{
|
||||
.target = target,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
.{
|
||||
.name = "spng",
|
||||
.name = .spng,
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
.fingerprint = 0x24970aec860b3476,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
.{
|
||||
.name = "tracy",
|
||||
.name = .tracy,
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
.fingerprint = 0x255a89ee0c7e7cb3,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
# See https://git-scm.com/docs/gitattributes
|
||||
# See https://help.github.com/articles/dealing-with-line-endings/
|
||||
|
||||
# Default behavior, if core.autocrlf is unset.
|
||||
* text=auto
|
||||
|
||||
# Files to be converted to native line endings on checkout.
|
||||
*.cpp text
|
||||
*.h text
|
||||
|
||||
# Text files to always have CRLF (dos) line endings on checkout.
|
||||
*.bat text eol=crlf
|
||||
|
||||
# Text files to always have LF (unix) line endings on checkout.
|
||||
*.sh text eol=lf
|
||||
*.zig text eol=lf
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
zig-cache/
|
||||
zig-out/
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
===================== VulkanMemoryAllocator =======================
|
||||
|
||||
Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
======================= Zig-VMA ===============================
|
||||
|
||||
Copyright (c) 2020 Martin Wickham.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
# Zig-VMA
|
||||
|
||||
This project provides Zig bindings for the Vulkan Memory Allocator library.
|
||||
|
||||
## Using this project
|
||||
|
||||
To use this library, first vendor this repository into your project (or use a git submodule).
|
||||
|
||||
In your build.zig, use this to link vma to your executable:
|
||||
```zig
|
||||
const vma_build = @import("path/to/vma/vma_build.zig");
|
||||
vma_build.link(exe, "path/to/vk.zig", mode, target);
|
||||
```
|
||||
|
||||
If you are linking vma to a package, use `pkg` to obtain a package for use in dependencies:
|
||||
```zig
|
||||
vma_build.pkg(exe.builder, "path/to/vk.zig")
|
||||
```
|
||||
If you aren't using `link` to enable the vma package on your root, you will still need to link the C sources with the executable, using this:
|
||||
```zig
|
||||
vma_build.linkWithoutModule(exe, mode, target);
|
||||
```
|
||||
|
||||
`vma_config.zig` contains build flags which will be used to configure the project. It has separate configurations for debug and release builds. These flags can be modified to tune the library.
|
||||
|
||||
Check out [this repository](https://github.com/SpexGuy/sdltest) for an example of the library in use.
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
const std = @import("std");
|
||||
const vma_build = @import("vma_build.zig");
|
||||
const vma_config = @import("vma_config.zig");
|
||||
|
||||
fn getConfigArgs(comptime config: vma_config.Config) []const []const u8 {
|
||||
comptime {
|
||||
@setEvalBranchQuota(100000);
|
||||
var args: []const []const u8 = &[_][]const u8{
|
||||
std.fmt.comptimePrint("-DVMA_VULKAN_VERSION={}", .{config.vulkanVersion}),
|
||||
std.fmt.comptimePrint("-DVMA_DEDICATED_ALLOCATION={}", .{@intFromBool(config.dedicatedAllocation)}),
|
||||
std.fmt.comptimePrint("-DVMA_BIND_MEMORY2={}", .{@intFromBool(config.bindMemory2)}),
|
||||
std.fmt.comptimePrint("-DVMA_MEMORY_BUDGET={}", .{@intFromBool(config.memoryBudget)}),
|
||||
std.fmt.comptimePrint("-DVMA_STATIC_VULKAN_FUNCTIONS={}", .{@intFromBool(config.staticVulkanFunctions)}),
|
||||
std.fmt.comptimePrint("-DVMA_STATS_STRING_ENABLED={}", .{@intFromBool(config.statsStringEnabled)}),
|
||||
};
|
||||
if (config.debugInitializeAllocations) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_INITIALIZE_ALLOCATIONS={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.debugMargin) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_MARGIN={}",
|
||||
.{value},
|
||||
)};
|
||||
}
|
||||
if (config.debugDetectCorruption) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_DETECT_CORRUPTION={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.recordingEnabled) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_RECORDING_ENABLED={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.debugMinBufferImageGranularity) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY={}",
|
||||
.{value},
|
||||
)};
|
||||
}
|
||||
if (config.debugGlobalMutex) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_GLOBAL_MUTEX={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.useStlContainers) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_USE_STL_CONTAINERS={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.useStlSharedMutex) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_USE_STL_SHARED_MUTEX={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const commonArgs = &[_][]const u8{ "-std=c++14", "-DVMA_IMPLEMENTATION" };
|
||||
const releaseArgs = &[_][]const u8{} ++ commonArgs ++ comptime getConfigArgs(vma_config.releaseConfig);
|
||||
const debugArgs = &[_][]const u8{} ++ commonArgs ++ comptime getConfigArgs(vma_config.debugConfig);
|
||||
const args = if (optimize == .Debug) debugArgs else releaseArgs;
|
||||
|
||||
const macos_vulkan_sdk = b.graph.env_map.hash_map.get("VULKAN_SDK");
|
||||
|
||||
const vulkan_dep = b.dependency("vulkan", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const vulkan = vulkan_dep.module("vulkan");
|
||||
|
||||
const mod = b.addModule("vma", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("vma.zig"),
|
||||
.link_libc = true,
|
||||
.link_libcpp = target.result.abi != .msvc,
|
||||
});
|
||||
|
||||
if (target.result.os.tag == .macos) {
|
||||
mod.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib/" });
|
||||
mod.addLibraryPath(.{ .cwd_relative = b.fmt("{s}/1.3.250.1/macOS/lib/", .{macos_vulkan_sdk.?}) });
|
||||
mod.linkSystemLibrary("vulkan", .{});
|
||||
}
|
||||
|
||||
mod.addIncludePath(b.path("vulkan"));
|
||||
mod.addCSourceFile(.{ .file = b.path("vk_mem_alloc.cpp"), .flags = args });
|
||||
|
||||
mod.addImport("vulkan", vulkan);
|
||||
|
||||
// ========== tests =============
|
||||
const test_step = b.step("test", "run unit tests for vma");
|
||||
const tests = b.addTest(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("vma_test.zig"),
|
||||
});
|
||||
tests.root_module.addImport("vma", mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
.{
|
||||
.name = "vma",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{
|
||||
.vulkan = .{ .path = "../vulkan" },
|
||||
},
|
||||
.paths = .{
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
const vk = @import("vk");
|
||||
const vma = @import("vma");
|
||||
const std = @import("std");
|
||||
|
||||
test "vma" {
|
||||
const instance = try vk.CreateInstance(.{}, null);
|
||||
defer vk.DestroyInstance(instance, null);
|
||||
|
||||
var physDevice: vk.PhysicalDevice = .Null;
|
||||
_ = try vk.EnumeratePhysicalDevices(instance, @as(*[1]vk.PhysicalDevice, &physDevice));
|
||||
if (physDevice == .Null) return error.NoDevicesAvailable;
|
||||
|
||||
const device = try vk.CreateDevice(physDevice, .{
|
||||
.queueCreateInfoCount = 1,
|
||||
.pQueueCreateInfos = &[_]vk.DeviceQueueCreateInfo{ .{
|
||||
.queueFamilyIndex = 0,
|
||||
.queueCount = 1,
|
||||
.pQueuePriorities = &[_]f32{ 1.0 },
|
||||
} },
|
||||
}, null);
|
||||
defer vk.DestroyDevice(device, null);
|
||||
|
||||
const functions = vma.VulkanFunctions.init(instance, device, vk.vkGetInstanceProcAddr);
|
||||
|
||||
const allocator = try vma.Allocator.create(.{
|
||||
.instance = instance,
|
||||
.physicalDevice = physDevice,
|
||||
.device = device,
|
||||
.frameInUseCount = 3,
|
||||
.pVulkanFunctions = &functions,
|
||||
});
|
||||
defer allocator.destroy();
|
||||
}
|
||||
|
||||
test "Compile everything" {
|
||||
@setEvalBranchQuota(10000);
|
||||
compileEverything(vma);
|
||||
}
|
||||
|
||||
fn compileEverything(comptime Outer: type) void {
|
||||
inline for (comptime std.meta.declarations(Outer)) |decl| {
|
||||
if (decl.is_pub) {
|
||||
const T = @TypeOf(@field(Outer, decl.name));
|
||||
if (T == type) {
|
||||
switch (@typeInfo(@field(Outer, decl.name))) {
|
||||
.Struct,
|
||||
.Enum,
|
||||
.Union,
|
||||
.Opaque,
|
||||
=> compileEverything(@field(Outer, decl.name)),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
<Type Name="VmaRawList<*>">
|
||||
<DisplayString>{{ Count={m_Count} }}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[Count]">m_Count</Item>
|
||||
<LinkedListItems>
|
||||
<Size>m_Count</Size>
|
||||
<HeadPointer>m_pFront</HeadPointer>
|
||||
<NextPointer>pNext</NextPointer>
|
||||
<ValueNode>Value</ValueNode>
|
||||
</LinkedListItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="VmaList<*>">
|
||||
<DisplayString>{{ Count={m_RawList.m_Count} }}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[Count]">m_RawList.m_Count</Item>
|
||||
<LinkedListItems>
|
||||
<Size>m_RawList.m_Count</Size>
|
||||
<HeadPointer>m_RawList.m_pFront</HeadPointer>
|
||||
<NextPointer>pNext</NextPointer>
|
||||
<ValueNode>Value</ValueNode>
|
||||
</LinkedListItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="VmaVector<*>">
|
||||
<DisplayString>{{ Count={m_Count} }}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[Count]">m_Count</Item>
|
||||
<Item Name="[Capacity]">m_Capacity</Item>
|
||||
<ArrayItems>
|
||||
<Size>m_Count</Size>
|
||||
<ValuePointer>m_pArray</ValuePointer>
|
||||
</ArrayItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
</AutoVisualizer>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,130 +0,0 @@
|
|||
const std = @import("std");
|
||||
const Builder = std.Build;
|
||||
const LibExeObjStep = std.Build.Step;
|
||||
const Module = std.Build.Module;
|
||||
const vma_config = @import("vma_config.zig");
|
||||
const version: std.SemanticVersion = @import("builtin").zig_version;
|
||||
|
||||
// @src() is only allowed inside of a function, so we need this wrapper
|
||||
fn srcFile() []const u8 {
|
||||
return @src().file;
|
||||
}
|
||||
const sep = std.fs.path.sep_str;
|
||||
|
||||
const zig_vma_path = std.fs.path.dirname(srcFile()).?;
|
||||
const zig_vma_file = zig_vma_path ++ sep ++ "vma.zig";
|
||||
|
||||
pub fn pkg(b: *Builder, vk_root_file: []const u8) *Module {
|
||||
const allocator = b.allocator;
|
||||
_ = allocator;
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = zig_vma_file },
|
||||
.dependencies = &[_]std.Build.ModuleDependency{
|
||||
.{
|
||||
.name = "vk",
|
||||
.module = b.createModule(
|
||||
.{ .source_file = .{ .path = vk_root_file } },
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
pub fn pkg2(b: *std.Build, vk_package: anytype) *Module {
|
||||
const allocator = b.allocator;
|
||||
_ = allocator;
|
||||
return b.createModule(.{
|
||||
.root_source_file = .{ .path = zig_vma_file },
|
||||
.imports = &[_]std.Build.Module.Import{
|
||||
.{
|
||||
.name = "vk",
|
||||
.module = vk_package,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
fn getConfigArgs(comptime config: vma_config.Config) []const []const u8 {
|
||||
comptime {
|
||||
@setEvalBranchQuota(100000);
|
||||
var args: []const []const u8 = &[_][]const u8{
|
||||
std.fmt.comptimePrint("-DVMA_VULKAN_VERSION={}", .{config.vulkanVersion}),
|
||||
std.fmt.comptimePrint("-DVMA_DEDICATED_ALLOCATION={}", .{@intFromBool(config.dedicatedAllocation)}),
|
||||
std.fmt.comptimePrint("-DVMA_BIND_MEMORY2={}", .{@intFromBool(config.bindMemory2)}),
|
||||
std.fmt.comptimePrint("-DVMA_MEMORY_BUDGET={}", .{@intFromBool(config.memoryBudget)}),
|
||||
std.fmt.comptimePrint("-DVMA_STATIC_VULKAN_FUNCTIONS={}", .{@intFromBool(config.staticVulkanFunctions)}),
|
||||
std.fmt.comptimePrint("-DVMA_STATS_STRING_ENABLED={}", .{@intFromBool(config.statsStringEnabled)}),
|
||||
};
|
||||
if (config.debugInitializeAllocations) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_INITIALIZE_ALLOCATIONS={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.debugMargin) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_MARGIN={}",
|
||||
.{value},
|
||||
)};
|
||||
}
|
||||
if (config.debugDetectCorruption) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_DETECT_CORRUPTION={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.recordingEnabled) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_RECORDING_ENABLED={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.debugMinBufferImageGranularity) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY={}",
|
||||
.{value},
|
||||
)};
|
||||
}
|
||||
if (config.debugGlobalMutex) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_DEBUG_GLOBAL_MUTEX={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.useStlContainers) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_USE_STL_CONTAINERS={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
if (config.useStlSharedMutex) |value| {
|
||||
args = args ++ &[_][]const u8{std.fmt.comptimePrint(
|
||||
"-DVMA_USE_STL_SHARED_MUTEX={}",
|
||||
.{@intFromBool(value)},
|
||||
)};
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn link(object: *std.Build.Step.Compile, vk_package: anytype, mode: std.builtin.Mode, target: std.Build.ResolvedTarget, builder: *Builder) void {
|
||||
const package = pkg2(builder, vk_package);
|
||||
linkWithoutModule(object, mode, target);
|
||||
object.root_module.addImport("vma", package);
|
||||
}
|
||||
|
||||
pub fn linkWithoutModule(object: *std.Build.Step.Compile, mode: std.builtin.Mode, target: std.Build.ResolvedTarget) void {
|
||||
const commonArgs = &[_][]const u8{ "-std=c++14", "-DVMA_IMPLEMENTATION" };
|
||||
const releaseArgs = &[_][]const u8{} ++ commonArgs ++ comptime getConfigArgs(vma_config.releaseConfig);
|
||||
const debugArgs = &[_][]const u8{} ++ commonArgs ++ comptime getConfigArgs(vma_config.debugConfig);
|
||||
const args = if (mode == .Debug) debugArgs else releaseArgs;
|
||||
|
||||
object.addCSourceFile(.{ .file = .{ .path = zig_vma_path ++ sep ++ "vk_mem_alloc.cpp" }, .flags = args });
|
||||
object.linkLibC();
|
||||
if (target.result.abi != .msvc) {
|
||||
// MSVC can't link libc++, it causes duplicate symbol errors.
|
||||
// But it's needed for other targets.
|
||||
object.linkLibCpp();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
// This file stores comptime-known configuration variables.
|
||||
// These would be defines specified before including vk_mem_alloc.h.
|
||||
// This file is read by both the `zig build` in this repo and the
|
||||
// zig header.
|
||||
|
||||
pub const debugConfig = Config{
|
||||
// Override values here for your build
|
||||
.vulkanVersion = 1001000, // Vulkan 1.1
|
||||
//.recordingEnabled = true,
|
||||
//.statsStringEnabled = false,
|
||||
//.debugMargin = 64,
|
||||
//.debugDetectCorruption = true,
|
||||
//.debugInitializeAllocations = true,
|
||||
//.debugGlobalMutex = true,
|
||||
//.debugMinBufferImageGranularity = 256,
|
||||
};
|
||||
|
||||
pub const releaseConfig = Config{
|
||||
// Override values here for your build
|
||||
.vulkanVersion = 1001000, // Vulkan 1.1
|
||||
//.statsStringEnabled = false,
|
||||
};
|
||||
|
||||
// Default values here, please do not change
|
||||
// Null in any of these values means that no
|
||||
// define will be passed to the build and the
|
||||
// default value will be used.
|
||||
pub const Config = struct {
|
||||
/// The current version of vulkan
|
||||
vulkanVersion: u32 = 1000000, // Vulkan 1.0
|
||||
|
||||
/// Whether to use the KHR Dedicated Allocation extension
|
||||
dedicatedAllocation: bool = false, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Whether to use the KHR Bind Memory 2 extension
|
||||
bindMemory2: bool = false, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Whether to use the KHR Memory Budget extension
|
||||
memoryBudget: bool = false, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// If you experience a bug with incorrect and nondeterministic data in your program and you suspect uninitialized memory to be used,
|
||||
/// you can enable automatic memory initialization to verify this.
|
||||
/// To do it, set debugInitializeAllocations to true.
|
||||
///
|
||||
/// It makes memory of all new allocations initialized to bit pattern `0xDCDCDCDC`.
|
||||
/// Before an allocation is destroyed, its memory is filled with bit pattern `0xEFEFEFEF`.
|
||||
/// Memory is automatically mapped and unmapped if necessary.
|
||||
///
|
||||
/// If you find these values while debugging your program, good chances are that you incorrectly
|
||||
/// read Vulkan memory that is allocated but not initialized, or already freed, respectively.
|
||||
///
|
||||
/// Memory initialization works only with memory types that are `HOST_VISIBLE`.
|
||||
/// It works also with dedicated allocations.
|
||||
/// It doesn't work with allocations created with #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag,
|
||||
/// as they cannot be mapped.
|
||||
debugInitializeAllocations: ?bool = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// By default, allocations are laid out in memory blocks next to each other if possible
|
||||
/// (considering required alignment, `bufferImageGranularity`, and `nonCoherentAtomSize`).
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// Define debugMargin to some non-zero value (e.g. 16) to enforce specified
|
||||
/// number of bytes as a margin before and after every allocation.
|
||||
/// If your bug goes away after enabling margins, it means it may be caused by memory
|
||||
/// being overwritten outside of allocation boundaries. It is not 100% certain though.
|
||||
/// Change in application behavior may also be caused by different order and distribution
|
||||
/// of allocations across memory blocks after margins are applied.
|
||||
///
|
||||
/// The margin is applied also before first and after last allocation in a block.
|
||||
/// It may occur only once between two adjacent allocations.
|
||||
///
|
||||
/// Margins work with all types of memory.
|
||||
///
|
||||
/// Margin is applied only to allocations made out of memory blocks and not to dedicated
|
||||
/// allocations, which have their own memory block of specific size.
|
||||
/// It is thus not applied to allocations made using #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT flag
|
||||
/// or those automatically decided to put into dedicated allocations, e.g. due to its
|
||||
/// large size or recommended by VK_KHR_dedicated_allocation extension.
|
||||
/// Margins are also not active in custom pools created with #VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT flag.
|
||||
///
|
||||
/// Margins appear in [JSON dump](@ref statistics_json_dump) as part of free space.
|
||||
///
|
||||
/// Note that enabling margins increases memory usage and fragmentation.
|
||||
debugMargin: ?usize = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// You can additionally set debugDetectCorruption to enable validation
|
||||
/// of contents of the margins.
|
||||
///
|
||||
/// When this feature is enabled, number of bytes specified as `VMA_DEBUG_MARGIN`
|
||||
/// (it must be multiply of 4) before and after every allocation is filled with a magic number.
|
||||
/// This idea is also know as "canary".
|
||||
/// Memory is automatically mapped and unmapped if necessary.
|
||||
///
|
||||
/// This number is validated automatically when the allocation is destroyed.
|
||||
/// If it's not equal to the expected value, `VMA_ASSERT()` is executed.
|
||||
/// It clearly means that either CPU or GPU overwritten the memory outside of boundaries of the allocation,
|
||||
/// which indicates a serious bug.
|
||||
///
|
||||
/// You can also explicitly request checking margins of all allocations in all memory blocks
|
||||
/// that belong to specified memory types by using function vmaCheckCorruption(),
|
||||
/// or in memory blocks that belong to specified custom pool, by using function
|
||||
/// vmaCheckPoolCorruption().
|
||||
///
|
||||
/// Margin validation (corruption detection) works only for memory types that are
|
||||
/// `HOST_VISIBLE` and `HOST_COHERENT`.
|
||||
debugDetectCorruption: ?bool = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Recording functionality is disabled by default.
|
||||
/// To enable it, set recordingEnabled to true.
|
||||
///
|
||||
/// <b>To record sequence of calls to a file:</b> Fill in
|
||||
/// VmaAllocatorCreateInfo::pRecordSettings member while creating #VmaAllocator
|
||||
/// object. File is opened and written during whole lifetime of the allocator.
|
||||
///
|
||||
/// <b>To replay file:</b> Use VmaReplay - standalone command-line program.
|
||||
/// Precompiled binary can be found in "bin" directory.
|
||||
/// Its source can be found in "src/VmaReplay" directory.
|
||||
/// Its project is generated by Premake.
|
||||
/// Command line syntax is printed when the program is launched without parameters.
|
||||
/// Basic usage:
|
||||
///
|
||||
/// VmaReplay.exe MyRecording.csv
|
||||
///
|
||||
/// <b>Documentation of file format</b> can be found in file: "docs/Recording file format.md".
|
||||
/// It's a human-readable, text file in CSV format (Comma Separated Values).
|
||||
///
|
||||
/// \section record_and_replay_additional_considerations Additional considerations
|
||||
///
|
||||
/// - Replaying file that was recorded on a different GPU (with different parameters
|
||||
/// like `bufferImageGranularity`, `nonCoherentAtomSize`, and especially different
|
||||
/// set of memory heaps and types) may give different performance and memory usage
|
||||
/// results, as well as issue some warnings and errors.
|
||||
/// - Current implementation of recording in VMA, as well as VmaReplay application, is
|
||||
/// coded and tested only on Windows. Inclusion of recording code is driven by
|
||||
/// `VMA_RECORDING_ENABLED` macro. Support for other platforms should be easy to
|
||||
/// add. Contributions are welcomed.
|
||||
recordingEnabled: ?bool = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Minimum value for VkPhysicalDeviceLimits::bufferImageGranularity.
|
||||
/// Set to more than 1 for debugging purposes only. Must be power of two.
|
||||
debugMinBufferImageGranularity: ?usize = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Set this to 1 for debugging purposes only, to enable single mutex protecting all
|
||||
/// entry calls to the library. Can be useful for debugging multithreading issues.
|
||||
debugGlobalMutex: ?bool = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Whether to use C++ STL containers for VMA internal data
|
||||
useStlContainers: ?bool = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Set to true to always use STL mutex, false otherwise.
|
||||
/// If null, the library will choose based on whether
|
||||
/// the compiler supports C++17.
|
||||
useStlSharedMutex: ?bool = null, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
// Set this to true to enable functions: vmaBuildStatsString, vmaFreeStatsString.
|
||||
statsStringEnabled: bool = true, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
|
||||
/// Set this value to true to make the library fetch pointers to Vulkan functions
|
||||
/// internally, like:
|
||||
///
|
||||
/// vulkanFunctions.vkAllocateMemory = &vkAllocateMemory;
|
||||
///
|
||||
/// Set to false if you are going to provide you own pointers to Vulkan functions via
|
||||
/// AllocatorCreateInfo::pVulkanFunctions.
|
||||
staticVulkanFunctions: bool = true, // NOTE: Please modify values in the instance at the top of this file, not here.
|
||||
};
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
const std = @import("std");
|
||||
const vma = @import("vma");
|
||||
|
||||
test "vma integration" {
|
||||
std.debug.print("vulkanVersion = {any}", .{vma.config.vulkanVersion});
|
||||
}
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
//
|
||||
// File: vk_icd.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2016 Valve Corporation
|
||||
* Copyright (c) 2015-2016 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef VKICD_H
|
||||
#define VKICD_H
|
||||
|
||||
#include "vulkan.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
// Loader-ICD version negotiation API. Versions add the following features:
|
||||
// Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr
|
||||
// or vk_icdNegotiateLoaderICDInterfaceVersion.
|
||||
// Version 1 - Add support for vk_icdGetInstanceProcAddr.
|
||||
// Version 2 - Add Loader/ICD Interface version negotiation
|
||||
// via vk_icdNegotiateLoaderICDInterfaceVersion.
|
||||
// Version 3 - Add ICD creation/destruction of KHR_surface objects.
|
||||
// Version 4 - Add unknown physical device extension qyering via
|
||||
// vk_icdGetPhysicalDeviceProcAddr.
|
||||
// Version 5 - Tells ICDs that the loader is now paying attention to the
|
||||
// application version of Vulkan passed into the ApplicationInfo
|
||||
// structure during vkCreateInstance. This will tell the ICD
|
||||
// that if the loader is older, it should automatically fail a
|
||||
// call for any API version > 1.0. Otherwise, the loader will
|
||||
// manually determine if it can support the expected version.
|
||||
#define CURRENT_LOADER_ICD_INTERFACE_VERSION 5
|
||||
#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
|
||||
#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
|
||||
typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
|
||||
|
||||
// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
|
||||
// file directly, it won't be found.
|
||||
#ifndef PFN_GetPhysicalDeviceProcAddr
|
||||
typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ICD must reserve space for a pointer for the loader's dispatch
|
||||
* table, at the start of <each object>.
|
||||
* The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
|
||||
*/
|
||||
|
||||
#define ICD_LOADER_MAGIC 0x01CDC0DE
|
||||
|
||||
typedef union {
|
||||
uintptr_t loaderMagic;
|
||||
void *loaderData;
|
||||
} VK_LOADER_DATA;
|
||||
|
||||
static inline void set_loader_magic_value(void *pNewObject) {
|
||||
VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
|
||||
loader_info->loaderMagic = ICD_LOADER_MAGIC;
|
||||
}
|
||||
|
||||
static inline bool valid_loader_magic_value(void *pNewObject) {
|
||||
const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
|
||||
return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
|
||||
* contains the platform-specific connection and surface information.
|
||||
*/
|
||||
typedef enum {
|
||||
VK_ICD_WSI_PLATFORM_MIR,
|
||||
VK_ICD_WSI_PLATFORM_WAYLAND,
|
||||
VK_ICD_WSI_PLATFORM_WIN32,
|
||||
VK_ICD_WSI_PLATFORM_XCB,
|
||||
VK_ICD_WSI_PLATFORM_XLIB,
|
||||
VK_ICD_WSI_PLATFORM_ANDROID,
|
||||
VK_ICD_WSI_PLATFORM_MACOS,
|
||||
VK_ICD_WSI_PLATFORM_IOS,
|
||||
VK_ICD_WSI_PLATFORM_DISPLAY,
|
||||
VK_ICD_WSI_PLATFORM_HEADLESS,
|
||||
VK_ICD_WSI_PLATFORM_METAL,
|
||||
} VkIcdWsiPlatform;
|
||||
|
||||
typedef struct {
|
||||
VkIcdWsiPlatform platform;
|
||||
} VkIcdSurfaceBase;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MIR_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
MirConnection *connection;
|
||||
MirSurface *mirSurface;
|
||||
} VkIcdSurfaceMir;
|
||||
#endif // VK_USE_PLATFORM_MIR_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
struct wl_display *display;
|
||||
struct wl_surface *surface;
|
||||
} VkIcdSurfaceWayland;
|
||||
#endif // VK_USE_PLATFORM_WAYLAND_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
HINSTANCE hinstance;
|
||||
HWND hwnd;
|
||||
} VkIcdSurfaceWin32;
|
||||
#endif // VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
xcb_connection_t *connection;
|
||||
xcb_window_t window;
|
||||
} VkIcdSurfaceXcb;
|
||||
#endif // VK_USE_PLATFORM_XCB_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
Display *dpy;
|
||||
Window window;
|
||||
} VkIcdSurfaceXlib;
|
||||
#endif // VK_USE_PLATFORM_XLIB_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
struct ANativeWindow *window;
|
||||
} VkIcdSurfaceAndroid;
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MACOS_MVK
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const void *pView;
|
||||
} VkIcdSurfaceMacOS;
|
||||
#endif // VK_USE_PLATFORM_MACOS_MVK
|
||||
|
||||
#ifdef VK_USE_PLATFORM_IOS_MVK
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const void *pView;
|
||||
} VkIcdSurfaceIOS;
|
||||
#endif // VK_USE_PLATFORM_IOS_MVK
|
||||
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
VkDisplayModeKHR displayMode;
|
||||
uint32_t planeIndex;
|
||||
uint32_t planeStackIndex;
|
||||
VkSurfaceTransformFlagBitsKHR transform;
|
||||
float globalAlpha;
|
||||
VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
|
||||
VkExtent2D imageExtent;
|
||||
} VkIcdSurfaceDisplay;
|
||||
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
} VkIcdSurfaceHeadless;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const CAMetalLayer *pLayer;
|
||||
} VkIcdSurfaceMetal;
|
||||
#endif // VK_USE_PLATFORM_METAL_EXT
|
||||
|
||||
#endif // VKICD_H
|
||||
|
|
@ -1,202 +0,0 @@
|
|||
//
|
||||
// File: vk_layer.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2017 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2017 Valve Corporation
|
||||
* Copyright (c) 2015-2017 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Need to define dispatch table
|
||||
* Core struct can then have ptr to dispatch table at the top
|
||||
* Along with object ptrs for current and next OBJ
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "vulkan.h"
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define VK_LAYER_EXPORT __attribute__((visibility("default")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||
#define VK_LAYER_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define VK_LAYER_EXPORT
|
||||
#endif
|
||||
|
||||
#define MAX_NUM_UNKNOWN_EXTS 250
|
||||
|
||||
// Loader-Layer version negotiation API. Versions add the following features:
|
||||
// Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr
|
||||
// or vk_icdNegotiateLoaderLayerInterfaceVersion.
|
||||
// Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and
|
||||
// vk_icdNegotiateLoaderLayerInterfaceVersion.
|
||||
#define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2
|
||||
#define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1
|
||||
|
||||
#define VK_CURRENT_CHAIN_VERSION 1
|
||||
|
||||
// Typedef for use in the interfaces below
|
||||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
|
||||
|
||||
// Version negotiation values
|
||||
typedef enum VkNegotiateLayerStructType {
|
||||
LAYER_NEGOTIATE_UNINTIALIZED = 0,
|
||||
LAYER_NEGOTIATE_INTERFACE_STRUCT = 1,
|
||||
} VkNegotiateLayerStructType;
|
||||
|
||||
// Version negotiation structures
|
||||
typedef struct VkNegotiateLayerInterface {
|
||||
VkNegotiateLayerStructType sType;
|
||||
void *pNext;
|
||||
uint32_t loaderLayerInterfaceVersion;
|
||||
PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr;
|
||||
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr;
|
||||
PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr;
|
||||
} VkNegotiateLayerInterface;
|
||||
|
||||
// Version negotiation functions
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct);
|
||||
|
||||
// Function prototype for unknown physical device extension command
|
||||
typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// CreateInstance and CreateDevice support structures
|
||||
|
||||
/* Sub type of structure for instance and device loader ext of CreateInfo.
|
||||
* When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
|
||||
* or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
|
||||
* then VkLayerFunction indicates struct type pointed to by pNext
|
||||
*/
|
||||
typedef enum VkLayerFunction_ {
|
||||
VK_LAYER_LINK_INFO = 0,
|
||||
VK_LOADER_DATA_CALLBACK = 1,
|
||||
VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2
|
||||
} VkLayerFunction;
|
||||
|
||||
typedef struct VkLayerInstanceLink_ {
|
||||
struct VkLayerInstanceLink_ *pNext;
|
||||
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
|
||||
PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr;
|
||||
} VkLayerInstanceLink;
|
||||
|
||||
/*
|
||||
* When creating the device chain the loader needs to pass
|
||||
* down information about it's device structure needed at
|
||||
* the end of the chain. Passing the data via the
|
||||
* VkLayerDeviceInfo avoids issues with finding the
|
||||
* exact instance being used.
|
||||
*/
|
||||
typedef struct VkLayerDeviceInfo_ {
|
||||
void *device_info;
|
||||
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
|
||||
} VkLayerDeviceInfo;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
|
||||
void *object);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
|
||||
void *object);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
|
||||
typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction);
|
||||
typedef struct {
|
||||
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
|
||||
const void *pNext;
|
||||
VkLayerFunction function;
|
||||
union {
|
||||
VkLayerInstanceLink *pLayerInfo;
|
||||
PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData;
|
||||
struct {
|
||||
PFN_vkLayerCreateDevice pfnLayerCreateDevice;
|
||||
PFN_vkLayerDestroyDevice pfnLayerDestroyDevice;
|
||||
} layerDevice;
|
||||
} u;
|
||||
} VkLayerInstanceCreateInfo;
|
||||
|
||||
typedef struct VkLayerDeviceLink_ {
|
||||
struct VkLayerDeviceLink_ *pNext;
|
||||
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
|
||||
PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr;
|
||||
} VkLayerDeviceLink;
|
||||
|
||||
typedef struct {
|
||||
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
|
||||
const void *pNext;
|
||||
VkLayerFunction function;
|
||||
union {
|
||||
VkLayerDeviceLink *pLayerInfo;
|
||||
PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData;
|
||||
} u;
|
||||
} VkLayerDeviceCreateInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct);
|
||||
|
||||
typedef enum VkChainType {
|
||||
VK_CHAIN_TYPE_UNKNOWN = 0,
|
||||
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1,
|
||||
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2,
|
||||
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3,
|
||||
} VkChainType;
|
||||
|
||||
typedef struct VkChainHeader {
|
||||
VkChainType type;
|
||||
uint32_t version;
|
||||
uint32_t size;
|
||||
} VkChainHeader;
|
||||
|
||||
typedef struct VkEnumerateInstanceExtensionPropertiesChain {
|
||||
VkChainHeader header;
|
||||
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *,
|
||||
VkExtensionProperties *);
|
||||
const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const {
|
||||
return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties);
|
||||
}
|
||||
#endif
|
||||
} VkEnumerateInstanceExtensionPropertiesChain;
|
||||
|
||||
typedef struct VkEnumerateInstanceLayerPropertiesChain {
|
||||
VkChainHeader header;
|
||||
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *);
|
||||
const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const {
|
||||
return pfnNextLayer(pNextLink, pPropertyCount, pProperties);
|
||||
}
|
||||
#endif
|
||||
} VkEnumerateInstanceLayerPropertiesChain;
|
||||
|
||||
typedef struct VkEnumerateInstanceVersionChain {
|
||||
VkChainHeader header;
|
||||
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *);
|
||||
const struct VkEnumerateInstanceVersionChain *pNextLink;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline VkResult CallDown(uint32_t *pApiVersion) const {
|
||||
return pfnNextLayer(pNextLink, pApiVersion);
|
||||
}
|
||||
#endif
|
||||
} VkEnumerateInstanceVersionChain;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
//
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Platform-specific directives and type declarations
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
||||
* with the same calling conventions that the Vulkan implementation expects.
|
||||
*
|
||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
// On Windows, Vulkan commands use the stdcall convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL __stdcall
|
||||
#define VKAPI_PTR VKAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
||||
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
||||
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
|
||||
// calling convention, i.e. float parameters are passed in registers. This
|
||||
// is true even if the rest of the application passes floats on the stack,
|
||||
// as it does by default when compiling for the armeabi-v7a NDK ABI.
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR VKAPI_ATTR
|
||||
#else
|
||||
// On other platforms, use the default calling convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif // !defined(VK_NO_STDINT_H)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
//
|
||||
// File: vk_sdk_platform.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2016 Valve Corporation
|
||||
* Copyright (c) 2015-2016 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef VK_SDK_PLATFORM_H
|
||||
#define VK_SDK_PLATFORM_H
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define NOMINMAX
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#define inline __inline
|
||||
#endif // __cplusplus
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
|
||||
// C99:
|
||||
// Microsoft didn't implement C99 in Visual Studio; but started adding it with
|
||||
// VS2013. However, VS2013 still didn't have snprintf(). The following is a
|
||||
// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the
|
||||
// "CMakeLists.txt" file).
|
||||
// NOTE: This is fixed in Visual Studio 2015.
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define strdup _strdup
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
// Check for noexcept support using clang, with fallback to Windows or GCC version numbers
|
||||
#ifndef NOEXCEPT
|
||||
#if defined(__clang__)
|
||||
#if __has_feature(cxx_noexcept)
|
||||
#define HAS_NOEXCEPT
|
||||
#endif
|
||||
#else
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46
|
||||
#define HAS_NOEXCEPT
|
||||
#else
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS
|
||||
#define HAS_NOEXCEPT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAS_NOEXCEPT
|
||||
#define NOEXCEPT noexcept
|
||||
#else
|
||||
#define NOEXCEPT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // VK_SDK_PLATFORM_H
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
#ifndef VULKAN_H_
|
||||
#define VULKAN_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
#include "vk_platform.h"
|
||||
#include "vulkan_core.h"
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include "vulkan_android.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
#include <zircon/types.h>
|
||||
#include "vulkan_fuchsia.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_IOS_MVK
|
||||
#include "vulkan_ios.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MACOS_MVK
|
||||
#include "vulkan_macos.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
#include "vulkan_metal.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_VI_NN
|
||||
#include "vulkan_vi.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#include <wayland-client.h>
|
||||
#include "vulkan_wayland.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
#include <windows.h>
|
||||
#include "vulkan_win32.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
#include <xcb/xcb.h>
|
||||
#include "vulkan_xcb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
#include <X11/Xlib.h>
|
||||
#include "vulkan_xlib.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include "vulkan_xlib_xrandr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_GGP
|
||||
#include <ggp_c/vulkan_types.h>
|
||||
#include "vulkan_ggp.h"
|
||||
#endif
|
||||
|
||||
#endif // VULKAN_H_
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,122 +0,0 @@
|
|||
#ifndef VULKAN_ANDROID_H_
|
||||
#define VULKAN_ANDROID_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_android_surface 1
|
||||
struct ANativeWindow;
|
||||
#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
|
||||
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
|
||||
typedef struct VkAndroidSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAndroidSurfaceCreateFlagsKHR flags;
|
||||
struct ANativeWindow* window;
|
||||
} VkAndroidSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_ANDROID_external_memory_android_hardware_buffer 1
|
||||
struct AHardwareBuffer;
|
||||
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 3
|
||||
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer"
|
||||
typedef struct VkAndroidHardwareBufferUsageANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint64_t androidHardwareBufferUsage;
|
||||
} VkAndroidHardwareBufferUsageANDROID;
|
||||
|
||||
typedef struct VkAndroidHardwareBufferPropertiesANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkDeviceSize allocationSize;
|
||||
uint32_t memoryTypeBits;
|
||||
} VkAndroidHardwareBufferPropertiesANDROID;
|
||||
|
||||
typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFormat format;
|
||||
uint64_t externalFormat;
|
||||
VkFormatFeatureFlags formatFeatures;
|
||||
VkComponentMapping samplerYcbcrConversionComponents;
|
||||
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
|
||||
VkSamplerYcbcrRange suggestedYcbcrRange;
|
||||
VkChromaLocation suggestedXChromaOffset;
|
||||
VkChromaLocation suggestedYChromaOffset;
|
||||
} VkAndroidHardwareBufferFormatPropertiesANDROID;
|
||||
|
||||
typedef struct VkImportAndroidHardwareBufferInfoANDROID {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
struct AHardwareBuffer* buffer;
|
||||
} VkImportAndroidHardwareBufferInfoANDROID;
|
||||
|
||||
typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceMemory memory;
|
||||
} VkMemoryGetAndroidHardwareBufferInfoANDROID;
|
||||
|
||||
typedef struct VkExternalFormatANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint64_t externalFormat;
|
||||
} VkExternalFormatANDROID;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(
|
||||
VkDevice device,
|
||||
const struct AHardwareBuffer* buffer,
|
||||
VkAndroidHardwareBufferPropertiesANDROID* pProperties);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(
|
||||
VkDevice device,
|
||||
const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo,
|
||||
struct AHardwareBuffer** pBuffer);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,57 +0,0 @@
|
|||
#ifndef VULKAN_FUCHSIA_H_
|
||||
#define VULKAN_FUCHSIA_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_FUCHSIA_imagepipe_surface 1
|
||||
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1
|
||||
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface"
|
||||
typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA;
|
||||
typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkImagePipeSurfaceCreateFlagsFUCHSIA flags;
|
||||
zx_handle_t imagePipeHandle;
|
||||
} VkImagePipeSurfaceCreateInfoFUCHSIA;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA(
|
||||
VkInstance instance,
|
||||
const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
#ifndef VULKAN_GGP_H_
|
||||
#define VULKAN_GGP_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_GGP_stream_descriptor_surface 1
|
||||
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1
|
||||
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface"
|
||||
typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP;
|
||||
typedef struct VkStreamDescriptorSurfaceCreateInfoGGP {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkStreamDescriptorSurfaceCreateFlagsGGP flags;
|
||||
GgpStreamDescriptor streamDescriptor;
|
||||
} VkStreamDescriptorSurfaceCreateInfoGGP;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP(
|
||||
VkInstance instance,
|
||||
const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_GGP_frame_token 1
|
||||
#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1
|
||||
#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token"
|
||||
typedef struct VkPresentFrameTokenGGP {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
GgpFrameToken frameToken;
|
||||
} VkPresentFrameTokenGGP;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#ifndef VULKAN_IOS_H_
|
||||
#define VULKAN_IOS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_MVK_ios_surface 1
|
||||
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2
|
||||
#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface"
|
||||
typedef VkFlags VkIOSSurfaceCreateFlagsMVK;
|
||||
typedef struct VkIOSSurfaceCreateInfoMVK {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkIOSSurfaceCreateFlagsMVK flags;
|
||||
const void* pView;
|
||||
} VkIOSSurfaceCreateInfoMVK;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK(
|
||||
VkInstance instance,
|
||||
const VkIOSSurfaceCreateInfoMVK* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#ifndef VULKAN_MACOS_H_
|
||||
#define VULKAN_MACOS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_MVK_macos_surface 1
|
||||
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2
|
||||
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
|
||||
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
||||
typedef struct VkMacOSSurfaceCreateInfoMVK {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkMacOSSurfaceCreateFlagsMVK flags;
|
||||
const void* pView;
|
||||
} VkMacOSSurfaceCreateInfoMVK;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(
|
||||
VkInstance instance,
|
||||
const VkMacOSSurfaceCreateInfoMVK* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#ifndef VULKAN_METAL_H_
|
||||
#define VULKAN_METAL_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_metal_surface 1
|
||||
|
||||
#ifdef __OBJC__
|
||||
@class CAMetalLayer;
|
||||
#else
|
||||
typedef void CAMetalLayer;
|
||||
#endif
|
||||
|
||||
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
|
||||
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
|
||||
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
|
||||
typedef struct VkMetalSurfaceCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkMetalSurfaceCreateFlagsEXT flags;
|
||||
const CAMetalLayer* pLayer;
|
||||
} VkMetalSurfaceCreateInfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(
|
||||
VkInstance instance,
|
||||
const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#ifndef VULKAN_VI_H_
|
||||
#define VULKAN_VI_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_NN_vi_surface 1
|
||||
#define VK_NN_VI_SURFACE_SPEC_VERSION 1
|
||||
#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface"
|
||||
typedef VkFlags VkViSurfaceCreateFlagsNN;
|
||||
typedef struct VkViSurfaceCreateInfoNN {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkViSurfaceCreateFlagsNN flags;
|
||||
void* window;
|
||||
} VkViSurfaceCreateInfoNN;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN(
|
||||
VkInstance instance,
|
||||
const VkViSurfaceCreateInfoNN* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#ifndef VULKAN_WAYLAND_H_
|
||||
#define VULKAN_WAYLAND_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_wayland_surface 1
|
||||
#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface"
|
||||
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
||||
typedef struct VkWaylandSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkWaylandSurfaceCreateFlagsKHR flags;
|
||||
struct wl_display* display;
|
||||
struct wl_surface* surface;
|
||||
} VkWaylandSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
struct wl_display* display);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,328 +0,0 @@
|
|||
#ifndef VULKAN_WIN32_H_
|
||||
#define VULKAN_WIN32_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_win32_surface 1
|
||||
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
|
||||
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
|
||||
typedef struct VkWin32SurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkWin32SurfaceCreateFlagsKHR flags;
|
||||
HINSTANCE hinstance;
|
||||
HWND hwnd;
|
||||
} VkWin32SurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_external_memory_win32 1
|
||||
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
|
||||
typedef struct VkImportMemoryWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
HANDLE handle;
|
||||
LPCWSTR name;
|
||||
} VkImportMemoryWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkExportMemoryWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
LPCWSTR name;
|
||||
} VkExportMemoryWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkMemoryWin32HandlePropertiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t memoryTypeBits;
|
||||
} VkMemoryWin32HandlePropertiesKHR;
|
||||
|
||||
typedef struct VkMemoryGetWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceMemory memory;
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
} VkMemoryGetWin32HandleInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo,
|
||||
HANDLE* pHandle);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
|
||||
VkDevice device,
|
||||
VkExternalMemoryHandleTypeFlagBits handleType,
|
||||
HANDLE handle,
|
||||
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_win32_keyed_mutex 1
|
||||
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
|
||||
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
|
||||
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t acquireCount;
|
||||
const VkDeviceMemory* pAcquireSyncs;
|
||||
const uint64_t* pAcquireKeys;
|
||||
const uint32_t* pAcquireTimeouts;
|
||||
uint32_t releaseCount;
|
||||
const VkDeviceMemory* pReleaseSyncs;
|
||||
const uint64_t* pReleaseKeys;
|
||||
} VkWin32KeyedMutexAcquireReleaseInfoKHR;
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_external_semaphore_win32 1
|
||||
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
|
||||
typedef struct VkImportSemaphoreWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkSemaphore semaphore;
|
||||
VkSemaphoreImportFlags flags;
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
HANDLE handle;
|
||||
LPCWSTR name;
|
||||
} VkImportSemaphoreWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkExportSemaphoreWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
LPCWSTR name;
|
||||
} VkExportSemaphoreWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkD3D12FenceSubmitInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t waitSemaphoreValuesCount;
|
||||
const uint64_t* pWaitSemaphoreValues;
|
||||
uint32_t signalSemaphoreValuesCount;
|
||||
const uint64_t* pSignalSemaphoreValues;
|
||||
} VkD3D12FenceSubmitInfoKHR;
|
||||
|
||||
typedef struct VkSemaphoreGetWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkSemaphore semaphore;
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
} VkSemaphoreGetWin32HandleInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_external_fence_win32 1
|
||||
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
|
||||
typedef struct VkImportFenceWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkFence fence;
|
||||
VkFenceImportFlags flags;
|
||||
VkExternalFenceHandleTypeFlagBits handleType;
|
||||
HANDLE handle;
|
||||
LPCWSTR name;
|
||||
} VkImportFenceWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkExportFenceWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
LPCWSTR name;
|
||||
} VkExportFenceWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkFenceGetWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkFence fence;
|
||||
VkExternalFenceHandleTypeFlagBits handleType;
|
||||
} VkFenceGetWin32HandleInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo,
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_NV_external_memory_win32 1
|
||||
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
|
||||
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
|
||||
typedef struct VkImportMemoryWin32HandleInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkExternalMemoryHandleTypeFlagsNV handleType;
|
||||
HANDLE handle;
|
||||
} VkImportMemoryWin32HandleInfoNV;
|
||||
|
||||
typedef struct VkExportMemoryWin32HandleInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
} VkExportMemoryWin32HandleInfoNV;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
|
||||
VkDevice device,
|
||||
VkDeviceMemory memory,
|
||||
VkExternalMemoryHandleTypeFlagsNV handleType,
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_NV_win32_keyed_mutex 1
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
|
||||
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t acquireCount;
|
||||
const VkDeviceMemory* pAcquireSyncs;
|
||||
const uint64_t* pAcquireKeys;
|
||||
const uint32_t* pAcquireTimeoutMilliseconds;
|
||||
uint32_t releaseCount;
|
||||
const VkDeviceMemory* pReleaseSyncs;
|
||||
const uint64_t* pReleaseKeys;
|
||||
} VkWin32KeyedMutexAcquireReleaseInfoNV;
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_full_screen_exclusive 1
|
||||
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4
|
||||
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive"
|
||||
|
||||
typedef enum VkFullScreenExclusiveEXT {
|
||||
VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_BEGIN_RANGE_EXT = VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_END_RANGE_EXT = VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_RANGE_SIZE_EXT = (VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT - VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT + 1),
|
||||
VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkFullScreenExclusiveEXT;
|
||||
typedef struct VkSurfaceFullScreenExclusiveInfoEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFullScreenExclusiveEXT fullScreenExclusive;
|
||||
} VkSurfaceFullScreenExclusiveInfoEXT;
|
||||
|
||||
typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 fullScreenExclusiveSupported;
|
||||
} VkSurfaceCapabilitiesFullScreenExclusiveEXT;
|
||||
|
||||
typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
HMONITOR hmonitor;
|
||||
} VkSurfaceFullScreenExclusiveWin32InfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
|
||||
uint32_t* pPresentModeCount,
|
||||
VkPresentModeKHR* pPresentModes);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT(
|
||||
VkDevice device,
|
||||
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
|
||||
VkDeviceGroupPresentModeFlagsKHR* pModes);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
#ifndef VULKAN_XCB_H_
|
||||
#define VULKAN_XCB_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_xcb_surface 1
|
||||
#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
|
||||
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
|
||||
typedef struct VkXcbSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkXcbSurfaceCreateFlagsKHR flags;
|
||||
xcb_connection_t* connection;
|
||||
xcb_window_t window;
|
||||
} VkXcbSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
xcb_connection_t* connection,
|
||||
xcb_visualid_t visual_id);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
#ifndef VULKAN_XLIB_H_
|
||||
#define VULKAN_XLIB_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_xlib_surface 1
|
||||
#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface"
|
||||
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
|
||||
typedef struct VkXlibSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkXlibSurfaceCreateFlagsKHR flags;
|
||||
Display* dpy;
|
||||
Window window;
|
||||
} VkXlibSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
Display* dpy,
|
||||
VisualID visualID);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef VULKAN_XLIB_XRANDR_H_
|
||||
#define VULKAN_XLIB_XRANDR_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2015-2020 The Khronos Group Inc.
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_acquire_xlib_display 1
|
||||
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1
|
||||
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display"
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
Display* dpy,
|
||||
VkDisplayKHR display);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
Display* dpy,
|
||||
RROutput rrOutput,
|
||||
VkDisplayKHR* pDisplay);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
zig-cache/
|
||||
zig-out/
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
Copyright © 2020-2022 Robin Voetter
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -1,279 +0,0 @@
|
|||
# vulkan-zig
|
||||
|
||||
NOTE: This is a vendored fork of snektron/vulkan-zig intended for use with the Neonwood game engine
|
||||
|
||||
A Vulkan binding generator for Zig.
|
||||
|
||||
[](https://github.com/Snektron/vulkan-zig/actions)
|
||||
|
||||
## Overview
|
||||
|
||||
vulkan-zig attempts to provide a better experience to programming Vulkan applications in Zig, by providing features such as integration of vulkan errors with Zig's error system, function pointer loading, renaming fields to standard Zig style, better bitfield handling, turning out parameters into return values and more.
|
||||
|
||||
vulkan-zig is automatically tested daily against the latest vk.xml and zig, and supports vk.xml from version 1.x.163.
|
||||
|
||||
### Zig versions
|
||||
|
||||
vulkan-zig aims to be always compatible with the ever-changing Zig master branch (however, development may lag a few days behind). Sometimes, the Zig master branch breaks a bunch of functionality however, which may make the latest version vulkan-zig incompatible with older releases of Zig. This repository aims to have a version compatible for both the latest Zig master, and the latest Zig release. The `master` branch is compatible with the `master` branch of Zig, and versions for older versions of Zig are maintained in the `zig-<version>-compat` branch.
|
||||
|
||||
## Features
|
||||
### CLI-interface
|
||||
A CLI-interface is provided to generate vk.zig from the [Vulkan XML registry](https://github.com/KhronosGroup/Vulkan-Docs/blob/main/xml), which is built by default when invoking `zig build` in the project root. To generate vk.zig, simply invoke the program as follows:
|
||||
```
|
||||
$ zig-cache/bin/vulkan-zig-generator path/to/vk.xml output/path/to/vk.zig
|
||||
```
|
||||
This reads the xml file, parses its contents, renders the Vulkan bindings, and formats file, before writing the result to the output path. While the intended usage of vulkan-zig is through direct generation from build.zig (see below), the CLI-interface can be used for one-off generation and vendoring the result.
|
||||
|
||||
### Generation from build.zig
|
||||
Vulkan bindings can be generated from the Vulkan XML registry at compile time with build.zig, by using the provided Vulkan generation step:
|
||||
```zig
|
||||
const vkgen = @import("vulkan-zig/generator/index.zig");
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
...
|
||||
const exe = b.addExecutable("my-executable", "src/main.zig");
|
||||
|
||||
// Create a step that generates vk.zig (stored in zig-cache) from the provided vulkan registry.
|
||||
const gen = vkgen.VkGenerateStep.init(b, "path/to/vk.xml", "vk.zig");
|
||||
|
||||
// Add the generated file as package to the final executable
|
||||
exe.addModule(gen.package);
|
||||
}
|
||||
```
|
||||
This reads vk.xml, parses its contents, and renders the Vulkan bindings to "vk.zig", which is then formatted and placed in `zig-cache`. The resulting file can then be added to an executable by using `addModule`, after which the bindings will be made available to the executable under the name `vulkan`.
|
||||
|
||||
### Function & field renaming
|
||||
Functions and fields are renamed to be more or less in line with [Zig's standard library style](https://ziglang.org/documentation/master/#Style-Guide):
|
||||
* The vk prefix is removed everywhere
|
||||
* Structs like `VkInstanceCreateInfo` are renamed to `InstanceCreateInfo`.
|
||||
* Handles like `VkSwapchainKHR` are renamed to `SwapchainKHR` (note that the tag is retained in caps).
|
||||
* Functions like `vkCreateInstance` are generated as `createInstance` as wrapper and as `PfnCreateInstance` as function pointer.
|
||||
* API constants like `VK_WHOLE_SIZE` retain screaming snake case, and are generates as `WHOLE_SIZE`.
|
||||
* The type name is stripped from enumeration fields and bitflags, and they are generated in (lower) snake case. For example, `VK_IMAGE_LAYOUT_GENERAL` is generated as just `general`. Note that author tags are also generated to lower case: `VK_SURFACE_TRANSFORM_FLAGS_IDENTITY_BIT_KHR` is translated to `identity_bit_khr`.
|
||||
* Container fields and function parameter names are generated in (lower) snake case in a similar manner: `ppEnabledLayerNames` becomes `pp_enabled_layer_names`.
|
||||
* Any name which is either an illegal Zig name or a reserved identifier is rendered using `@"name"` syntax. For example, `VK_IMAGE_TYPE_2D` is translated to `@"2d"`.
|
||||
|
||||
### Function pointers & Wrappers
|
||||
vulkan-zig provides no integration for statically linking libvulkan, and these symbols are not generated at all. Instead, vulkan functions are to be loaded dynamically. For each Vulkan function, a function pointer type is generated using the exact parameters and return types as defined by the Vulkan specification:
|
||||
```zig
|
||||
pub const PfnCreateInstance = fn (
|
||||
p_create_info: *const InstanceCreateInfo,
|
||||
p_allocator: ?*const AllocationCallbacks,
|
||||
p_instance: *Instance,
|
||||
) callconv(vulkan_call_conv) Result;
|
||||
```
|
||||
|
||||
For each function, a wrapper is generated into one of three structs:
|
||||
* BaseWrapper. This contains wrappers for functions which are loaded by `vkGetInstanceProcAddr` without an instance, such as `vkCreateInstance`, `vkEnumerateInstanceVersion`, etc.
|
||||
* InstanceWrapper. This contains wrappers for functions which are otherwise loaded by `vkGetInstanceProcAddr`.
|
||||
* DeviceWrapper. This contains wrappers for functions which are loaded by `vkGetDeviceProcAddr`.
|
||||
|
||||
Each wrapper struct can be called with an array of the appropriate enums:
|
||||
```zig
|
||||
const vk = @import("vulkan");
|
||||
const BaseDispatch = vk.BaseWrapper(.{
|
||||
.createInstance = true,
|
||||
});
|
||||
```
|
||||
The wrapper struct then provides wrapper functions for each function pointer in the dispatch struct:
|
||||
```zig
|
||||
pub const BaseWrapper(comptime cmds: anytype) type {
|
||||
...
|
||||
const Dispatch = CreateDispatchStruct(cmds);
|
||||
return struct {
|
||||
dispatch: Dispatch,
|
||||
|
||||
pub const CreateInstanceError = error{
|
||||
OutOfHostMemory,
|
||||
OutOfDeviceMemory,
|
||||
InitializationFailed,
|
||||
LayerNotPresent,
|
||||
ExtensionNotPresent,
|
||||
IncompatibleDriver,
|
||||
Unknown,
|
||||
};
|
||||
pub fn createInstance(
|
||||
self: Self,
|
||||
create_info: InstanceCreateInfo,
|
||||
p_allocator: ?*const AllocationCallbacks,
|
||||
) CreateInstanceError!Instance {
|
||||
var instance: Instance = undefined;
|
||||
const result = self.dispatch.vkCreateInstance(
|
||||
&create_info,
|
||||
p_allocator,
|
||||
&instance,
|
||||
);
|
||||
switch (result) {
|
||||
.success => {},
|
||||
.error_out_of_host_memory => return error.OutOfHostMemory,
|
||||
.error_out_of_device_memory => return error.OutOfDeviceMemory,
|
||||
.error_initialization_failed => return error.InitializationFailed,
|
||||
.error_layer_not_present => return error.LayerNotPresent,
|
||||
.error_extension_not_present => return error.ExtensionNotPresent,
|
||||
.error_incompatible_driver => return error.IncompatibleDriver,
|
||||
else => return error.Unknown,
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
Wrappers are generated according to the following rules:
|
||||
* The return type is determined from the original return type and the parameters.
|
||||
* Any non-const, non-optional single-item pointer is interpreted as an out parameter.
|
||||
* If a command returns a non-error `VkResult` other than `VK_SUCCESS` it is also returned.
|
||||
* If there are multiple return values selected, an additional struct is generated. The original call's return value is called `return_value`, `VkResult` is named `result`, and the out parameters are called the same except `p_` is removed. They are generated in this order.
|
||||
* Any const non-optional single-item pointer is interpreted as an in-parameter. For these, one level of indirection is removed so that create info structure pointers can now be passed as values, enabling the ability to use struct literals for these parameters.
|
||||
* Error codes are translated into Zig errors.
|
||||
* 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.
|
||||
* For `BaseWrapper`, this function has signature `fn load(loader: anytype) error{CommandFailure}!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: anytype) error{CommandFailure}!Self`, where the type of `loader` must resemble `PfnGetInstanceProcAddr`.
|
||||
* For `DeviceWrapper`, this function has signature `fn load(device: Device, loader: anytype) error{CommandFailure}!Self`, where the type of `loader` must resemble `PfnGetDeviceProcAddr`.
|
||||
|
||||
Note that these functions accepts a loader with the signature of `anytype` instead of `PfnGetInstanceProcAddr`. This is because it is valid for `vkGetInstanceProcAddr` to load itself, in which case the returned function is to be called with the vulkan calling convention. This calling convention is not required for loading vulkan-zig itself, though, and a loader to be called with any calling convention with the target architecture may be passed in. This is particularly useful when interacting with C libraries that provide `vkGetInstanceProcAddr`.
|
||||
|
||||
```zig
|
||||
// vkGetInstanceProcAddr as provided by GLFW.
|
||||
// Note that vk.Instance and vk.PfnVoidFunction are ABI compatible with VkInstance,
|
||||
// and that `extern` implies the C calling convention.
|
||||
pub extern fn glfwGetInstanceProcAddress(instance: vk.Instance, procname: [*:0]const u8) vk.PfnVoidFunction;
|
||||
|
||||
// Or provide a custom implementation.
|
||||
// This function is called with the unspecified Zig-internal calling convention.
|
||||
fn customGetInstanceProcAddress(instance: vk.Instance, procname: [*:0]const u8) vk.PfnVoidFunction {
|
||||
...
|
||||
}
|
||||
|
||||
// Both calls are valid, even
|
||||
const vkb = try BaseDispatch.load(glfwGetInstanceProcAddress);
|
||||
const vkb = try BaseDispatch.load(customGetInstanceProcAddress);
|
||||
```
|
||||
|
||||
By default, wrapper `load` functions return `error.CommandLoadFailure` if a call to the loader resulted in `null`. If this behaviour is not desired, one can use `loadNoFail`. This function accepts the same parameters as `load`, but does not return an error any function pointer fails to load and sets its value to `undefined` instead. It is at the programmer's discretion not to invoke invalid functions, which can be tested for by checking whether the required core and extension versions the function requires are supported.
|
||||
|
||||
One can access the underlying unwrapped C functions by doing `wrapper.dispatch.vkFuncYouWant(..)`.
|
||||
|
||||
### Bitflags
|
||||
Packed structs of bools are used for bit flags in vulkan-zig, instead of both a `FlagBits` and `Flags` variant. Places where either of these variants are used are both replaced by this packed struct instead. This means that even in places where just one flag would normally be accepted, the packed struct is accepted. The programmer is responsible for only enabling a single bit.
|
||||
|
||||
Each bit is defaulted to `false`, and the first `bool` is aligned to guarantee the overal alignment
|
||||
of each Flags type to guarantee ABI compatibility when passing bitfields through structs:
|
||||
```zig
|
||||
pub const QueueFlags = packed struct {
|
||||
graphics_bit: bool align(@alignOf(Flags)) = false,
|
||||
compute_bit: bool = false,
|
||||
transfer_bit: bool = false,
|
||||
sparse_binding_bit: bool = false,
|
||||
protected_bit: bool = false,
|
||||
_reserved_bit_5: bool = false,
|
||||
_reserved_bit_6: bool = false,
|
||||
...
|
||||
}
|
||||
```
|
||||
Note that on function call ABI boundaries, this alignment trick is not sufficient. Instead, the flags
|
||||
are reinterpreted as an integer which is passed instead. Each flags type is augmented by a mixin which provides `IntType`, an integer which represents the flags on function ABI boundaries. This mixin also provides some common set operation on bitflags:
|
||||
```zig
|
||||
pub fn FlagsMixin(comptime FlagsType: type) type {
|
||||
return struct {
|
||||
pub const IntType = Flags;
|
||||
|
||||
// Return the integer representation of these flags
|
||||
pub fn toInt(self: FlagsType) IntType {...}
|
||||
|
||||
// Turn an integer representation back into a flags type
|
||||
pub fn fromInt(flags: IntType) FlagsType { ... }
|
||||
|
||||
// Return the set-union of `lhs` and `rhs.
|
||||
pub fn merge(lhs: FlagsType, rhs: FlagsType) FlagsType { ... }
|
||||
|
||||
// Return the set-intersection of `lhs` and `rhs`.
|
||||
pub fn intersect(lhs: FlagsType, rhs: FlagsType) FlagsType { ... }
|
||||
|
||||
// Return the set-complement of `lhs` and `rhs`. Note: this also inverses reserved bits.
|
||||
pub fn complement(self: FlagsType) FlagsType { ... }
|
||||
|
||||
// Return the set-subtraction of `lhs` and `rhs`: All fields set in `rhs` are cleared in `lhs`.
|
||||
pub fn subtract(lhs: FlagsType, rhs: FlagsType) FlagsType { ... }
|
||||
|
||||
// Returns whether all bits set in `rhs` are also set in `lhs`.
|
||||
pub fn contains(lhs: FlagsType, rhs: FlagsType) bool { ... }
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Handles
|
||||
Handles are generated to a non-exhaustive enum, backed by a `u64` for non-dispatchable handles and `usize` for dispatchable ones:
|
||||
```zig
|
||||
const Instance = extern enum(usize) { null_handle = 0, _ };
|
||||
```
|
||||
This means that handles are type-safe even when compiling for a 32-bit target.
|
||||
|
||||
### Struct defaults
|
||||
Defaults are generated for certain fields of structs:
|
||||
* sType is defaulted to the appropriate value.
|
||||
* pNext is defaulted to `null`.
|
||||
* No other fields have default values.
|
||||
```zig
|
||||
pub const InstanceCreateInfo = extern struct {
|
||||
s_type: StructureType = .instance_create_info,
|
||||
p_next: ?*const anyopaque = null,
|
||||
flags: InstanceCreateFlags,
|
||||
...
|
||||
};
|
||||
```
|
||||
|
||||
### Pointer types
|
||||
Pointer types in both commands (wrapped and function pointers) and struct fields are augmented with the following information, where available in the registry:
|
||||
* Pointer optional-ness.
|
||||
* Pointer const-ness.
|
||||
* Pointer size: Either single-item, null-terminated or many-items.
|
||||
|
||||
Note that this information is not everywhere as useful in the registry, leading to places where optional-ness is not correct. Most notably, CreateInfo type structures which take a slice often have the item count marked as optional, but the pointer itself not. As of yet, this is not fixed in vulkan-zig. If drivers properly follow the Vulkan specification, these can be initialized to `undefined`, however, [that is not always the case](https://zeux.io/2019/07/17/serializing-pipeline-cache/).
|
||||
|
||||
### Platform types
|
||||
Defaults with the same ABI layout are generated for most platform-defined types. These can either by bitcasted to, or overridden by defining them in the project root:
|
||||
```zig
|
||||
pub const xcb_connection_t = if (@hasDecl(root, "xcb_connection_t")) root.xcb_connection_t else @Type(.Opaque);
|
||||
```
|
||||
For some times (such as those from Google Games Platform) no default is known. Usage of these without providing a concrete type in the project root generates a compile error.
|
||||
|
||||
### Shader compilation
|
||||
vulkan-zig provides functionality to help compiling shaders using glslc. It can be used from build.zig as follows:
|
||||
|
||||
```zig
|
||||
const vkgen = @import("vulkan-zig/generator/index.zig");
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
...
|
||||
const exe = b.addExecutable("my-executable", "src/main.zig");
|
||||
|
||||
const gen = vkgen.VkGenerateStep(b, "path/to/vk.xml", "vk.zig");
|
||||
exe.addModule(gen.package);
|
||||
|
||||
const shader_comp = vkgen.ShaderCompileStep.init(
|
||||
builder,
|
||||
&[_][]const u8{"glslc", "--target-env=vulkan1.2"}, // Path to glslc and additional parameters
|
||||
);
|
||||
exe.step.dependOn(&shader_comp.step);
|
||||
const spv_path = shader_comp.addShader("path/to/shader.frag");
|
||||
}
|
||||
```
|
||||
Upon compilation, glslc is then invoked to compile each shader, and the result is placed within `zig-cache`. `addShader` returns the full path to the compiled shader code. This file can then be included in the project, as is done in [build.zig for the example](build.zig) by generating an additional file which uses `@embedFile`.
|
||||
|
||||
## Limitations
|
||||
* Currently, the self-hosted version of Zig's cache-hash API is not yet ready for usage, which means that the bindings are regenerated every time an executable is built.
|
||||
|
||||
* vulkan-zig has as of yet no functionality for selecting feature levels and extensions when generating bindings. This is because when an extension is promoted to Vulkan core, its fields and commands are renamed to lose the extensions author tag (for example, VkSemaphoreWaitFlagsKHR was renamed to VkSemaphoreWaitFlags when it was promoted from an extension to Vulkan 1.2 core). This leads to inconsistencies when only items from up to a certain feature level is included, as these promoted items then need to re-gain a tag.
|
||||
|
||||
## Example
|
||||
A partial implementation of https://vulkan-tutorial.org is implemented in [examples/triangle.zig](examples/triangle.zig). This example can be ran by executing `zig build run-triangle` in vulkan-zig's root.
|
||||
|
||||
## See also
|
||||
* Implementation of https://vulkan-tutorial.org using `@cImport`'ed bindings: https://github.com/andrewrk/zig-vulkan-triangle.
|
||||
* Alternative binding generator: https://github.com/SpexGuy/Zig-Vulkan-Headers
|
||||
* Zig bindings for GLFW: https://github.com/hexops/mach-glfw
|
||||
* With vulkan-zig integration example: https://github.com/hexops/mach-glfw-vulkan-example
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
const std = @import("std");
|
||||
const vkgen = @import("generator/index.zig");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const macos_vulkan_sdk = b.graph.env_map.hash_map.get("VULKAN_SDK");
|
||||
|
||||
const gen = vkgen.VkGenerateStep.init(b, "vk.xml", "vk.zig");
|
||||
|
||||
const mod = gen.package;
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
mod.addObjectFile(b.path("objs/vulkan-1.lib"));
|
||||
} else if (target.result.os.tag == .macos) {
|
||||
mod.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib/" });
|
||||
mod.addLibraryPath(.{ .cwd_relative = b.fmt("{s}/1.3.250.1/macOS/lib/", .{macos_vulkan_sdk.?}) });
|
||||
} else {
|
||||
mod.linkSystemLibrary("vulkan", .{});
|
||||
}
|
||||
|
||||
const test_step = b.step("test", "");
|
||||
const tests = b.addTest(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("test_integration.zig"),
|
||||
.link_libc = true,
|
||||
});
|
||||
|
||||
tests.root_module.addImport("vulkan", mod);
|
||||
const runArtifact = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&runArtifact.step);
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
export VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_monitor:VK_LAYER_KHRONOS_validation"
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
const std = @import("std");
|
||||
const path = std.fs.path;
|
||||
const Builder = std.Build;
|
||||
const Step = std.build.Step;
|
||||
|
||||
/// Utility functionality to help with compiling shaders from build.zig.
|
||||
/// Invokes glslc (or another shader compiler passed to `init`) for each shader
|
||||
/// added via `addShader`.
|
||||
pub const ShaderCompileStep = struct {
|
||||
/// Structure representing a shader to be compiled.
|
||||
const Shader = struct {
|
||||
/// The path to the shader, relative to the current build root.
|
||||
source_path: []const u8,
|
||||
|
||||
/// The full output path where the compiled shader binary is placed.
|
||||
full_out_path: []const u8,
|
||||
|
||||
reflected_path: []const u8,
|
||||
};
|
||||
|
||||
step: Step,
|
||||
builder: *Builder,
|
||||
|
||||
/// The command and optional arguments used to invoke the shader compiler.
|
||||
glslc_cmd: []const []const u8,
|
||||
|
||||
/// The directory within `zig-cache/` that the compiled shaders are placed in.
|
||||
output_dir: []const u8,
|
||||
|
||||
/// List of shaders that are to be compiled.
|
||||
shaders: std.ArrayList(Shader),
|
||||
|
||||
/// Create a ShaderCompilerStep for `builder`. When this step is invoked by the build
|
||||
/// system, `<glcl_cmd...> <shader_source> -o <dst_addr>` is invoked for each shader.
|
||||
pub fn init(builder: *Builder, glslc_cmd: []const []const u8, output_dir: []const u8) *ShaderCompileStep {
|
||||
const self = builder.allocator.create(ShaderCompileStep) catch unreachable;
|
||||
self.* = .{
|
||||
.step = Step.init(.{
|
||||
.id = .custom,
|
||||
.name = "shader-compile",
|
||||
.makeFn = make,
|
||||
.owner = builder,
|
||||
}),
|
||||
.builder = builder,
|
||||
.output_dir = output_dir,
|
||||
.glslc_cmd = builder.dupeStrings(glslc_cmd),
|
||||
.shaders = std.ArrayList(Shader).init(builder.allocator),
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
/// Add a shader to be compiled. `src` is shader source path, relative to the project root.
|
||||
/// Returns the full path where the compiled binary will be stored upon successful compilation.
|
||||
/// This path can then be used to include the binary into an executable, for example by passing it
|
||||
/// to @embedFile via an additional generated file.
|
||||
pub fn add(self: *ShaderCompileStep, src: []const u8) []const u8 {
|
||||
const output_filename = std.fmt.allocPrint(self.builder.allocator, "{s}.spv", .{src}) catch unreachable;
|
||||
const full_out_path = path.join(self.builder.allocator, &[_][]const u8{
|
||||
// self.builder.build_root.path.?,
|
||||
self.builder.cache_root.path.?,
|
||||
//self.output_dir,
|
||||
output_filename,
|
||||
}) catch unreachable;
|
||||
self.shaders.append(.{
|
||||
.source_path = src,
|
||||
.full_out_path = full_out_path,
|
||||
.reflected_path = std.fmt.allocPrint(self.builder.allocator, "{s}.json", .{full_out_path}) catch unreachable,
|
||||
}) catch unreachable;
|
||||
return full_out_path;
|
||||
}
|
||||
|
||||
/// Internal build function.
|
||||
fn make(step: *Step, progress: *std.Progress.Node) !void {
|
||||
_ = progress;
|
||||
const self: *ShaderCompileStep = @fieldParentPtr("step", step);
|
||||
const cwd = std.fs.cwd();
|
||||
|
||||
const cmd = try self.builder.allocator.alloc([]const u8, self.glslc_cmd.len + 3);
|
||||
for (self.glslc_cmd, 0..) |part, i| {
|
||||
cmd[i] = part;
|
||||
}
|
||||
cmd[cmd.len - 2] = "-o";
|
||||
|
||||
var allocator = self.builder.allocator;
|
||||
|
||||
for (self.shaders.items) |shader| {
|
||||
const dir = path.dirname(shader.full_out_path).?;
|
||||
try cwd.makePath(dir);
|
||||
cmd[cmd.len - 3] = shader.source_path;
|
||||
cmd[cmd.len - 1] = shader.full_out_path;
|
||||
try step.evalChildProcess(cmd);
|
||||
// run spirv-cross to generate an output json file with meta information
|
||||
var spirvCrossCmdFull = try allocator.alloc([]const u8, 5);
|
||||
defer allocator.free(spirvCrossCmdFull);
|
||||
spirvCrossCmdFull[0] = try std.fmt.allocPrint(allocator, "spirv-cross", .{});
|
||||
spirvCrossCmdFull[1] = try std.fmt.allocPrint(allocator, "{s}", .{shader.full_out_path});
|
||||
spirvCrossCmdFull[2] = try std.fmt.allocPrint(allocator, "--reflect", .{});
|
||||
spirvCrossCmdFull[3] = try std.fmt.allocPrint(allocator, "--output", .{});
|
||||
spirvCrossCmdFull[4] = try std.fmt.allocPrint(allocator, "{s}.json", .{shader.full_out_path});
|
||||
|
||||
try step.evalChildProcess(spirvCrossCmdFull);
|
||||
|
||||
for (spirvCrossCmdFull) |inner| {
|
||||
allocator.free(inner);
|
||||
}
|
||||
|
||||
// Create the associated gpu_structs.zig file
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const Allocator = mem.Allocator;
|
||||
|
||||
pub fn isZigPrimitiveType(name: []const u8) bool {
|
||||
if (name.len > 1 and (name[0] == 'u' or name[0] == 'i')) {
|
||||
for (name[1..]) |c| {
|
||||
switch (c) {
|
||||
'0'...'9' => {},
|
||||
else => break,
|
||||
}
|
||||
} else return true;
|
||||
}
|
||||
|
||||
const primitives = [_][]const u8{
|
||||
"void",
|
||||
"comptime_float",
|
||||
"comptime_int",
|
||||
"bool",
|
||||
"isize",
|
||||
"usize",
|
||||
"f16",
|
||||
"f32",
|
||||
"f64",
|
||||
"f128",
|
||||
"c_longdouble",
|
||||
"noreturn",
|
||||
"type",
|
||||
"anyerror",
|
||||
"c_short",
|
||||
"c_ushort",
|
||||
"c_int",
|
||||
"c_uint",
|
||||
"c_long",
|
||||
"c_ulong",
|
||||
"c_longlong",
|
||||
"c_ulonglong",
|
||||
// Removed in stage 2 in https://github.com/ziglang/zig/commit/05cf44933d753f7a5a53ab289ea60fd43761de57,
|
||||
// but these are still invalid identifiers in stage 1.
|
||||
"undefined",
|
||||
"true",
|
||||
"false",
|
||||
"null",
|
||||
};
|
||||
|
||||
for (primitives) |reserved| {
|
||||
if (mem.eql(u8, reserved, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn writeIdentifier(out: anytype, id: []const u8) !void {
|
||||
// https://github.com/ziglang/zig/issues/2897
|
||||
if (isZigPrimitiveType(id)) {
|
||||
try out.print("@\"{}\"", .{std.zig.fmtEscapes(id)});
|
||||
} else {
|
||||
try out.print("{}", .{std.zig.fmtId(id)});
|
||||
}
|
||||
}
|
||||
|
||||
pub const CaseStyle = enum {
|
||||
snake,
|
||||
screaming_snake,
|
||||
title,
|
||||
camel,
|
||||
};
|
||||
|
||||
pub const SegmentIterator = struct {
|
||||
text: []const u8,
|
||||
offset: usize,
|
||||
|
||||
pub fn init(text: []const u8) SegmentIterator {
|
||||
return .{
|
||||
.text = text,
|
||||
.offset = 0,
|
||||
};
|
||||
}
|
||||
|
||||
fn nextBoundary(self: SegmentIterator) usize {
|
||||
var i = self.offset + 1;
|
||||
|
||||
while (true) {
|
||||
if (i == self.text.len or self.text[i] == '_') {
|
||||
return i;
|
||||
}
|
||||
|
||||
const prev_lower = std.ascii.isLower(self.text[i - 1]);
|
||||
const next_lower = std.ascii.isLower(self.text[i]);
|
||||
|
||||
if (prev_lower and !next_lower) {
|
||||
return i;
|
||||
} else if (i != self.offset + 1 and !prev_lower and next_lower) {
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next(self: *SegmentIterator) ?[]const u8 {
|
||||
while (self.offset < self.text.len and self.text[self.offset] == '_') {
|
||||
self.offset += 1;
|
||||
}
|
||||
|
||||
if (self.offset == self.text.len) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const end = self.nextBoundary();
|
||||
const word = self.text[self.offset..end];
|
||||
self.offset = end;
|
||||
return word;
|
||||
}
|
||||
|
||||
pub fn rest(self: SegmentIterator) []const u8 {
|
||||
if (self.offset >= self.text.len) {
|
||||
return &[_]u8{};
|
||||
} else {
|
||||
return self.text[self.offset..];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const IdRenderer = struct {
|
||||
tags: []const []const u8,
|
||||
text_cache: std.ArrayList(u8),
|
||||
|
||||
pub fn init(allocator: Allocator, tags: []const []const u8) IdRenderer {
|
||||
return .{
|
||||
.tags = tags,
|
||||
.text_cache = std.ArrayList(u8).init(allocator),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: IdRenderer) void {
|
||||
self.text_cache.deinit();
|
||||
}
|
||||
|
||||
fn renderSnake(self: *IdRenderer, comptime screaming: bool, id: []const u8, tag: ?[]const u8) !void {
|
||||
var it = SegmentIterator.init(id);
|
||||
var first = true;
|
||||
const transform = if (screaming) std.ascii.toUpper else std.ascii.toLower;
|
||||
|
||||
while (it.next()) |segment| {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
try self.text_cache.append('_');
|
||||
}
|
||||
|
||||
for (segment) |c| {
|
||||
try self.text_cache.append(transform(c));
|
||||
}
|
||||
}
|
||||
|
||||
if (tag) |name| {
|
||||
try self.text_cache.append('_');
|
||||
|
||||
for (name) |c| {
|
||||
try self.text_cache.append(transform(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn renderCamel(self: *IdRenderer, title: bool, id: []const u8, tag: ?[]const u8) !void {
|
||||
var it = SegmentIterator.init(id);
|
||||
var lower_first = !title;
|
||||
|
||||
while (it.next()) |segment| {
|
||||
var i: usize = 0;
|
||||
while (i < segment.len and std.ascii.isDigit(segment[i])) {
|
||||
try self.text_cache.append(segment[i]);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
if (i == segment.len) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == 0 and lower_first) {
|
||||
try self.text_cache.append(std.ascii.toLower(segment[i]));
|
||||
} else {
|
||||
try self.text_cache.append(std.ascii.toUpper(segment[i]));
|
||||
}
|
||||
lower_first = false;
|
||||
|
||||
for (segment[i + 1 ..]) |c| {
|
||||
try self.text_cache.append(std.ascii.toLower(c));
|
||||
}
|
||||
}
|
||||
|
||||
if (tag) |name| {
|
||||
try self.text_cache.appendSlice(name);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn renderFmt(self: *IdRenderer, out: anytype, comptime fmt: []const u8, args: anytype) !void {
|
||||
self.text_cache.items.len = 0;
|
||||
try std.fmt.format(self.text_cache.writer(), fmt, args);
|
||||
try writeIdentifier(out, self.text_cache.items);
|
||||
}
|
||||
|
||||
pub fn renderWithCase(self: *IdRenderer, out: anytype, case_style: CaseStyle, id: []const u8) !void {
|
||||
const tag = self.getAuthorTag(id);
|
||||
// The trailing underscore doesn't need to be removed here as its removed by the SegmentIterator.
|
||||
const adjusted_id = if (tag) |name| id[0 .. id.len - name.len] else id;
|
||||
|
||||
self.text_cache.items.len = 0;
|
||||
|
||||
switch (case_style) {
|
||||
.snake => try self.renderSnake(false, adjusted_id, tag),
|
||||
.screaming_snake => try self.renderSnake(true, adjusted_id, tag),
|
||||
.title => try self.renderCamel(true, adjusted_id, tag),
|
||||
.camel => try self.renderCamel(false, adjusted_id, tag),
|
||||
}
|
||||
|
||||
try writeIdentifier(out, self.text_cache.items);
|
||||
}
|
||||
|
||||
pub fn getAuthorTag(self: IdRenderer, id: []const u8) ?[]const u8 {
|
||||
for (self.tags) |tag| {
|
||||
if (mem.endsWith(u8, id, tag)) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn stripAuthorTag(self: IdRenderer, id: []const u8) []const u8 {
|
||||
if (self.getAuthorTag(id)) |tag| {
|
||||
return mem.trimRight(u8, id[0 .. id.len - tag.len], "_");
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
};
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
pub const generateVk = @import("vulkan/generator.zig").generate;
|
||||
pub const VkGenerateStep = @import("vulkan/build_integration.zig").GenerateStep;
|
||||
pub const ShaderCompileStep = @import("build_integration.zig").ShaderCompileStep;
|
||||
|
||||
test "main" {
|
||||
_ = @import("xml.zig");
|
||||
_ = @import("vulkan/c_parse.zig");
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
const std = @import("std");
|
||||
const generate = @import("vulkan/generator.zig").generate;
|
||||
|
||||
const usage = "Usage: {s} [-h|--help] <spec xml path> <output zig source>\n";
|
||||
|
||||
pub fn main() !void {
|
||||
const stderr = std.io.getStdErr();
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
var args = try std.process.argsWithAllocator(allocator);
|
||||
const prog_name = args.next() orelse return error.ExecutableNameMissing;
|
||||
|
||||
var maybe_xml_path: ?[]const u8 = null;
|
||||
var maybe_out_path: ?[]const u8 = null;
|
||||
|
||||
while (args.next()) |arg| {
|
||||
if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) {
|
||||
@setEvalBranchQuota(2000);
|
||||
try stderr.writer().print(
|
||||
\\Utility to generate a Zig binding from the Vulkan XML API registry.
|
||||
\\
|
||||
\\The most recent Vulkan XML API registry can be obtained from
|
||||
\\https://github.com/KhronosGroup/Vulkan-Docs/blob/master/xml/vk.xml,
|
||||
\\and the most recent LunarG Vulkan SDK version can be found at
|
||||
\\$VULKAN_SDK/x86_64/share/vulkan/registry/vk.xml.
|
||||
\\
|
||||
\\
|
||||
++ usage,
|
||||
.{prog_name},
|
||||
);
|
||||
return;
|
||||
} else if (maybe_xml_path == null) {
|
||||
maybe_xml_path = arg;
|
||||
} else if (maybe_out_path == null) {
|
||||
maybe_out_path = arg;
|
||||
} else {
|
||||
try stderr.writer().print("Error: Superficial argument '{s}'\n", .{arg});
|
||||
}
|
||||
}
|
||||
|
||||
const xml_path = maybe_xml_path orelse {
|
||||
try stderr.writer().print("Error: Missing required argument <spec xml path>\n" ++ usage, .{prog_name});
|
||||
return;
|
||||
};
|
||||
|
||||
const out_path = maybe_out_path orelse {
|
||||
try stderr.writer().print("Error: Missing required argument <output zig source>\n" ++ usage, .{prog_name});
|
||||
return;
|
||||
};
|
||||
|
||||
const cwd = std.fs.cwd();
|
||||
const xml_src = cwd.readFileAlloc(allocator, xml_path, std.math.maxInt(usize)) catch |err| {
|
||||
try stderr.writer().print("Error: Failed to open input file '{s}' ({s})\n", .{ xml_path, @errorName(err) });
|
||||
return;
|
||||
};
|
||||
|
||||
var out_buffer = std.ArrayList(u8).init(allocator);
|
||||
try generate(allocator, xml_src, out_buffer.writer());
|
||||
try out_buffer.append(0);
|
||||
|
||||
const src = out_buffer.items[0 .. out_buffer.items.len - 1 :0];
|
||||
const tree = try std.zig.parse(allocator, src);
|
||||
const formatted = try tree.render(allocator);
|
||||
defer allocator.free(formatted);
|
||||
|
||||
if (std.fs.path.dirname(out_path)) |dir| {
|
||||
cwd.makePath(dir) catch |err| {
|
||||
try stderr.writer().print("Error: Failed to create output directory '{s}' ({s})\n", .{ dir, @errorName(err) });
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
cwd.writeFile(out_path, formatted) catch |err| {
|
||||
try stderr.writer().print("Error: Failed to write to output file '{s}' ({s})\n", .{ out_path, @errorName(err) });
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
const std = @import("std");
|
||||
const generate = @import("generator.zig").generate;
|
||||
const path = std.fs.path;
|
||||
const Step = std.Build.Step;
|
||||
|
||||
pub const GenerateStep = struct {
|
||||
step: Step,
|
||||
builder: *std.Build,
|
||||
|
||||
/// The path to vk.xml
|
||||
spec_path: []const u8,
|
||||
|
||||
package: *std.Build.Module,
|
||||
|
||||
output_file: std.Build.GeneratedFile,
|
||||
|
||||
pub fn init(builder: *std.Build, spec_path: []const u8, out_path: []const u8) *GenerateStep {
|
||||
const self = builder.allocator.create(GenerateStep) catch unreachable;
|
||||
const full_out_path = path.join(builder.allocator, &[_][]const u8{
|
||||
// builder.build_root.path.?,
|
||||
builder.cache_root.path.?,
|
||||
out_path,
|
||||
}) catch unreachable;
|
||||
|
||||
self.* = .{
|
||||
.step = Step.init(.{ .id = .custom, .name = "vulkan-generate", .makeFn = make, .owner = builder }),
|
||||
.builder = builder,
|
||||
.spec_path = spec_path,
|
||||
.package = undefined,
|
||||
.output_file = .{
|
||||
.step = &self.step,
|
||||
.path = full_out_path,
|
||||
},
|
||||
};
|
||||
|
||||
self.package = builder.addModule("vulkan", .{
|
||||
.root_source_file = .{ .generated = .{ .file = &self.output_file } },
|
||||
});
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/// Initialize a Vulkan generation step for `builder`, by extracting vk.xml from the LunarG installation
|
||||
/// root. Typically, the location of the LunarG SDK root can be retrieved by querying for the VULKAN_SDK
|
||||
/// environment variable, set by activating the environment setup script located in the SDK root.
|
||||
/// `builder` and `out_path` are used in the same manner as `init`.
|
||||
pub fn initFromSdk(builder: *std.Build, sdk_path: []const u8, out_path: []const u8) *GenerateStep {
|
||||
const spec_path = std.fs.path.join(
|
||||
builder.allocator,
|
||||
&[_][]const u8{ sdk_path, "share/vulkan/registry/vk.xml" },
|
||||
) catch unreachable;
|
||||
|
||||
return init(builder, spec_path, out_path);
|
||||
}
|
||||
|
||||
/// Internal build function. This reads `vk.xml`, and passes it to `generate`, which then generates
|
||||
/// the final bindings. The resulting generated bindings are not formatted, which is why an ArrayList
|
||||
/// writer is passed instead of a file writer. This is then formatted into standard formatting
|
||||
/// by parsing it and rendering with `std.zig.parse` and `std.zig.render` respectively.
|
||||
fn make(step: *Step, progress: std.Progress.Node) !void {
|
||||
_ = progress;
|
||||
const self: *GenerateStep = @fieldParentPtr("step", step);
|
||||
const cwd = std.fs.cwd();
|
||||
|
||||
const spec = try cwd.readFileAlloc(self.builder.allocator, self.builder.path(self.spec_path).getPath(self.builder), std.math.maxInt(usize));
|
||||
|
||||
var out_buffer = std.ArrayList(u8).init(self.builder.allocator);
|
||||
try generate(self.builder.allocator, spec, out_buffer.writer());
|
||||
try out_buffer.append(0);
|
||||
|
||||
const src = out_buffer.items[0 .. out_buffer.items.len - 1 :0];
|
||||
const tree = try std.zig.Ast.parse(self.builder.allocator, src, .zig);
|
||||
std.debug.assert(tree.errors.len == 0); // If this triggers, vulkan-zig produced invalid code.
|
||||
|
||||
const formatted = try tree.render(self.builder.allocator);
|
||||
|
||||
const dir = path.dirname(self.output_file.path.?).?;
|
||||
try cwd.makePath(dir);
|
||||
try cwd.writeFile(.{
|
||||
.sub_path = self.output_file.path.?,
|
||||
.data = formatted,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -1,617 +0,0 @@
|
|||
const std = @import("std");
|
||||
const registry = @import("registry.zig");
|
||||
const xml = @import("../xml.zig");
|
||||
const mem = std.mem;
|
||||
const Allocator = mem.Allocator;
|
||||
const testing = std.testing;
|
||||
const ArraySize = registry.Array.ArraySize;
|
||||
const TypeInfo = registry.TypeInfo;
|
||||
|
||||
pub const Token = struct {
|
||||
kind: Kind,
|
||||
text: []const u8,
|
||||
|
||||
const Kind = enum {
|
||||
id, // Any id thats not a keyword
|
||||
name, // Vulkan <name>...</name>
|
||||
type_name, // Vulkan <type>...</type>
|
||||
enum_name, // Vulkan <enum>...</enum>
|
||||
int,
|
||||
star,
|
||||
comma,
|
||||
semicolon,
|
||||
colon,
|
||||
minus,
|
||||
tilde,
|
||||
dot,
|
||||
hash,
|
||||
lparen,
|
||||
rparen,
|
||||
lbracket,
|
||||
rbracket,
|
||||
kw_typedef,
|
||||
kw_const,
|
||||
kw_vkapi_ptr,
|
||||
kw_struct,
|
||||
};
|
||||
};
|
||||
|
||||
pub const CTokenizer = struct {
|
||||
source: []const u8,
|
||||
offset: usize = 0,
|
||||
in_comment: bool = false,
|
||||
|
||||
fn peek(self: CTokenizer) ?u8 {
|
||||
return if (self.offset < self.source.len) self.source[self.offset] else null;
|
||||
}
|
||||
|
||||
fn consumeNoEof(self: *CTokenizer) u8 {
|
||||
const c = self.peek().?;
|
||||
self.offset += 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
fn consume(self: *CTokenizer) !u8 {
|
||||
return if (self.offset < self.source.len)
|
||||
return self.consumeNoEof()
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
fn keyword(self: *CTokenizer) Token {
|
||||
const start = self.offset;
|
||||
_ = self.consumeNoEof();
|
||||
|
||||
while (true) {
|
||||
const c = self.peek() orelse break;
|
||||
switch (c) {
|
||||
'A'...'Z', 'a'...'z', '_', '0'...'9' => _ = self.consumeNoEof(),
|
||||
else => break,
|
||||
}
|
||||
}
|
||||
|
||||
const token_text = self.source[start..self.offset];
|
||||
|
||||
const kind = if (mem.eql(u8, token_text, "typedef"))
|
||||
Token.Kind.kw_typedef
|
||||
else if (mem.eql(u8, token_text, "const"))
|
||||
Token.Kind.kw_const
|
||||
else if (mem.eql(u8, token_text, "VKAPI_PTR"))
|
||||
Token.Kind.kw_vkapi_ptr
|
||||
else if (mem.eql(u8, token_text, "struct"))
|
||||
Token.Kind.kw_struct
|
||||
else
|
||||
Token.Kind.id;
|
||||
|
||||
return .{ .kind = kind, .text = token_text };
|
||||
}
|
||||
|
||||
fn int(self: *CTokenizer) Token {
|
||||
const start = self.offset;
|
||||
_ = self.consumeNoEof();
|
||||
|
||||
while (true) {
|
||||
const c = self.peek() orelse break;
|
||||
switch (c) {
|
||||
'0'...'9' => _ = self.consumeNoEof(),
|
||||
else => break,
|
||||
}
|
||||
}
|
||||
|
||||
return .{
|
||||
.kind = .int,
|
||||
.text = self.source[start..self.offset],
|
||||
};
|
||||
}
|
||||
|
||||
fn skipws(self: *CTokenizer) void {
|
||||
while (true) {
|
||||
switch (self.peek() orelse break) {
|
||||
' ', '\t', '\n', '\r' => _ = self.consumeNoEof(),
|
||||
else => break,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next(self: *CTokenizer) !?Token {
|
||||
self.skipws();
|
||||
if (mem.startsWith(u8, self.source[self.offset..], "//") or self.in_comment) {
|
||||
const end = mem.indexOfScalarPos(u8, self.source, self.offset, '\n') orelse {
|
||||
self.offset = self.source.len;
|
||||
self.in_comment = true;
|
||||
return null;
|
||||
};
|
||||
self.in_comment = false;
|
||||
self.offset = end + 1;
|
||||
}
|
||||
self.skipws();
|
||||
|
||||
const c = self.peek() orelse return null;
|
||||
var kind: Token.Kind = undefined;
|
||||
switch (c) {
|
||||
'A'...'Z', 'a'...'z', '_' => return self.keyword(),
|
||||
'0'...'9' => return self.int(),
|
||||
'*' => kind = .star,
|
||||
',' => kind = .comma,
|
||||
';' => kind = .semicolon,
|
||||
':' => kind = .colon,
|
||||
'-' => kind = .minus,
|
||||
'~' => kind = .tilde,
|
||||
'.' => kind = .dot,
|
||||
'#' => kind = .hash,
|
||||
'[' => kind = .lbracket,
|
||||
']' => kind = .rbracket,
|
||||
'(' => kind = .lparen,
|
||||
')' => kind = .rparen,
|
||||
else => return error.UnexpectedCharacter,
|
||||
}
|
||||
|
||||
const start = self.offset;
|
||||
_ = self.consumeNoEof();
|
||||
return Token{ .kind = kind, .text = self.source[start..self.offset] };
|
||||
}
|
||||
};
|
||||
|
||||
pub const XmlCTokenizer = struct {
|
||||
it: xml.Element.ChildIterator,
|
||||
ctok: ?CTokenizer = null,
|
||||
current: ?Token = null,
|
||||
|
||||
pub fn init(elem: *xml.Element) XmlCTokenizer {
|
||||
return .{
|
||||
.it = elem.iterator(),
|
||||
};
|
||||
}
|
||||
|
||||
fn elemToToken(elem: *xml.Element) !?Token {
|
||||
if (elem.children.items.len != 1 or elem.children.items[0] != .CharData) {
|
||||
return error.InvalidXml;
|
||||
}
|
||||
|
||||
const text = elem.children.items[0].CharData;
|
||||
if (mem.eql(u8, elem.tag, "type")) {
|
||||
return Token{ .kind = .type_name, .text = text };
|
||||
} else if (mem.eql(u8, elem.tag, "enum")) {
|
||||
return Token{ .kind = .enum_name, .text = text };
|
||||
} else if (mem.eql(u8, elem.tag, "name")) {
|
||||
return Token{ .kind = .name, .text = text };
|
||||
} else if (mem.eql(u8, elem.tag, "comment")) {
|
||||
return null;
|
||||
} else {
|
||||
return error.InvalidTag;
|
||||
}
|
||||
}
|
||||
|
||||
fn next(self: *XmlCTokenizer) !?Token {
|
||||
if (self.current) |current| {
|
||||
const token = current;
|
||||
self.current = null;
|
||||
return token;
|
||||
}
|
||||
|
||||
var in_comment: bool = false;
|
||||
|
||||
while (true) {
|
||||
if (self.ctok) |*ctok| {
|
||||
if (try ctok.next()) |tok| {
|
||||
return tok;
|
||||
}
|
||||
in_comment = ctok.in_comment;
|
||||
}
|
||||
|
||||
self.ctok = null;
|
||||
|
||||
if (self.it.next()) |child| {
|
||||
switch (child.*) {
|
||||
.CharData => |cdata| self.ctok = CTokenizer{ .source = cdata, .in_comment = in_comment },
|
||||
.Comment => {}, // xml comment
|
||||
.Element => |elem| if (!in_comment) if (try elemToToken(elem)) |tok| return tok,
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn nextNoEof(self: *XmlCTokenizer) !Token {
|
||||
return (try self.next()) orelse return error.UnexpectedEof;
|
||||
}
|
||||
|
||||
fn peek(self: *XmlCTokenizer) !?Token {
|
||||
if (self.current) |current| {
|
||||
return current;
|
||||
}
|
||||
|
||||
self.current = try self.next();
|
||||
return self.current;
|
||||
}
|
||||
|
||||
fn peekNoEof(self: *XmlCTokenizer) !Token {
|
||||
return (try self.peek()) orelse return error.UnexpectedEof;
|
||||
}
|
||||
|
||||
fn expect(self: *XmlCTokenizer, kind: Token.Kind) !Token {
|
||||
const tok = (try self.next()) orelse return error.UnexpectedEof;
|
||||
if (tok.kind != kind) {
|
||||
return error.UnexpectedToken;
|
||||
}
|
||||
|
||||
return tok;
|
||||
}
|
||||
};
|
||||
|
||||
// TYPEDEF = kw_typedef DECLARATION ';'
|
||||
pub fn parseTypedef(allocator: Allocator, xctok: *XmlCTokenizer, ptrs_optional: bool) !registry.Declaration {
|
||||
_ = try xctok.expect(.kw_typedef);
|
||||
const decl = try parseDeclaration(allocator, xctok, ptrs_optional);
|
||||
_ = try xctok.expect(.semicolon);
|
||||
if (try xctok.peek()) |_| {
|
||||
return error.InvalidSyntax;
|
||||
}
|
||||
|
||||
return registry.Declaration{
|
||||
.name = decl.name orelse return error.MissingTypeIdentifier,
|
||||
.decl_type = .{ .typedef = decl.decl_type },
|
||||
};
|
||||
}
|
||||
|
||||
// MEMBER = DECLARATION (':' int)?
|
||||
pub fn parseMember(allocator: Allocator, xctok: *XmlCTokenizer, ptrs_optional: bool) !registry.Container.Field {
|
||||
const decl = try parseDeclaration(allocator, xctok, ptrs_optional);
|
||||
var field = registry.Container.Field{
|
||||
.name = decl.name orelse return error.MissingTypeIdentifier,
|
||||
.field_type = decl.decl_type,
|
||||
.bits = null,
|
||||
.is_buffer_len = false,
|
||||
};
|
||||
|
||||
if (try xctok.peek()) |tok| {
|
||||
if (tok.kind != .colon) {
|
||||
return error.InvalidSyntax;
|
||||
}
|
||||
|
||||
_ = try xctok.nextNoEof();
|
||||
const bits = try xctok.expect(.int);
|
||||
field.bits = try std.fmt.parseInt(usize, bits.text, 10);
|
||||
|
||||
// Assume for now that there won't be any invalid C types like `char char* x : 4`.
|
||||
|
||||
if (try xctok.peek()) |_| {
|
||||
return error.InvalidSyntax;
|
||||
}
|
||||
}
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
pub fn parseParamOrProto(allocator: Allocator, xctok: *XmlCTokenizer, ptrs_optional: bool) !registry.Declaration {
|
||||
const decl = try parseDeclaration(allocator, xctok, ptrs_optional);
|
||||
if (try xctok.peek()) |_| {
|
||||
return error.InvalidSyntax;
|
||||
}
|
||||
return registry.Declaration{
|
||||
.name = decl.name orelse return error.MissingTypeIdentifier,
|
||||
.decl_type = .{ .typedef = decl.decl_type },
|
||||
};
|
||||
}
|
||||
|
||||
pub const Declaration = struct {
|
||||
name: ?[]const u8, // Parameter names may be optional, especially in case of func(void)
|
||||
decl_type: TypeInfo,
|
||||
};
|
||||
|
||||
pub const ParseError = error{
|
||||
OutOfMemory,
|
||||
InvalidSyntax,
|
||||
InvalidTag,
|
||||
InvalidXml,
|
||||
Overflow,
|
||||
UnexpectedEof,
|
||||
UnexpectedCharacter,
|
||||
UnexpectedToken,
|
||||
MissingTypeIdentifier,
|
||||
};
|
||||
|
||||
// DECLARATION = kw_const? type_name DECLARATOR
|
||||
// DECLARATOR = POINTERS (id | name)? ('[' ARRAY_DECLARATOR ']')*
|
||||
// | POINTERS '(' FNPTRSUFFIX
|
||||
fn parseDeclaration(allocator: Allocator, xctok: *XmlCTokenizer, ptrs_optional: bool) ParseError!Declaration {
|
||||
// Parse declaration constness
|
||||
var tok = try xctok.nextNoEof();
|
||||
const inner_is_const = tok.kind == .kw_const;
|
||||
if (inner_is_const) {
|
||||
tok = try xctok.nextNoEof();
|
||||
}
|
||||
|
||||
if (tok.kind == .kw_struct) {
|
||||
tok = try xctok.nextNoEof();
|
||||
}
|
||||
// Parse type name
|
||||
if (tok.kind != .type_name and tok.kind != .id) return error.InvalidSyntax;
|
||||
const type_name = tok.text;
|
||||
|
||||
var type_info = TypeInfo{ .name = type_name };
|
||||
|
||||
// Parse pointers
|
||||
type_info = try parsePointers(allocator, xctok, inner_is_const, type_info, ptrs_optional);
|
||||
|
||||
// Parse name / fn ptr
|
||||
|
||||
if (try parseFnPtrSuffix(allocator, xctok, type_info, ptrs_optional)) |decl| {
|
||||
return decl;
|
||||
}
|
||||
|
||||
const name = blk: {
|
||||
const name_tok = (try xctok.peek()) orelse break :blk null;
|
||||
if (name_tok.kind == .id or name_tok.kind == .name) {
|
||||
_ = try xctok.nextNoEof();
|
||||
break :blk name_tok.text;
|
||||
} else {
|
||||
break :blk null;
|
||||
}
|
||||
};
|
||||
|
||||
var inner_type = &type_info;
|
||||
while (try parseArrayDeclarator(xctok)) |array_size| {
|
||||
// Move the current inner type to a new node on the heap
|
||||
const child = try allocator.create(TypeInfo);
|
||||
child.* = inner_type.*;
|
||||
|
||||
// Re-assign the previous inner type for the array type info node
|
||||
inner_type.* = .{
|
||||
.array = .{
|
||||
.size = array_size,
|
||||
.child = child,
|
||||
},
|
||||
};
|
||||
|
||||
// update the inner_type pointer so it points to the proper
|
||||
// inner type again
|
||||
inner_type = child;
|
||||
}
|
||||
|
||||
return Declaration{
|
||||
.name = name,
|
||||
.decl_type = type_info,
|
||||
};
|
||||
}
|
||||
|
||||
// FNPTRSUFFIX = kw_vkapi_ptr '*' name' ')' '(' ('void' | (DECLARATION (',' DECLARATION)*)?) ')'
|
||||
fn parseFnPtrSuffix(allocator: Allocator, xctok: *XmlCTokenizer, return_type: TypeInfo, ptrs_optional: bool) !?Declaration {
|
||||
const lparen = try xctok.peek();
|
||||
if (lparen == null or lparen.?.kind != .lparen) {
|
||||
return null;
|
||||
}
|
||||
_ = try xctok.nextNoEof();
|
||||
_ = try xctok.expect(.kw_vkapi_ptr);
|
||||
_ = try xctok.expect(.star);
|
||||
const name = try xctok.expect(.name);
|
||||
_ = try xctok.expect(.rparen);
|
||||
_ = try xctok.expect(.lparen);
|
||||
|
||||
const return_type_heap = try allocator.create(TypeInfo);
|
||||
return_type_heap.* = return_type;
|
||||
|
||||
var command_ptr = Declaration{
|
||||
.name = name.text,
|
||||
.decl_type = .{
|
||||
.command_ptr = .{
|
||||
.params = &[_]registry.Command.Param{},
|
||||
.return_type = return_type_heap,
|
||||
.success_codes = &[_][]const u8{},
|
||||
.error_codes = &[_][]const u8{},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const first_param = try parseDeclaration(allocator, xctok, ptrs_optional);
|
||||
if (first_param.name == null) {
|
||||
if (first_param.decl_type != .name or !mem.eql(u8, first_param.decl_type.name, "void")) {
|
||||
return error.InvalidSyntax;
|
||||
}
|
||||
|
||||
_ = try xctok.expect(.rparen);
|
||||
return command_ptr;
|
||||
}
|
||||
|
||||
// There is no good way to estimate the number of parameters beforehand.
|
||||
// Fortunately, there are usually a relatively low number of parameters to a function pointer,
|
||||
// so an ArrayList backed by an arena allocator is good enough.
|
||||
var params = std.ArrayList(registry.Command.Param).init(allocator);
|
||||
try params.append(.{
|
||||
.name = first_param.name.?,
|
||||
.param_type = first_param.decl_type,
|
||||
.is_buffer_len = false,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
switch ((try xctok.peekNoEof()).kind) {
|
||||
.rparen => break,
|
||||
.comma => _ = try xctok.nextNoEof(),
|
||||
else => return error.InvalidSyntax,
|
||||
}
|
||||
|
||||
const decl = try parseDeclaration(allocator, xctok, ptrs_optional);
|
||||
try params.append(.{
|
||||
.name = decl.name orelse return error.MissingTypeIdentifier,
|
||||
.param_type = decl.decl_type,
|
||||
.is_buffer_len = false,
|
||||
});
|
||||
}
|
||||
|
||||
_ = try xctok.nextNoEof();
|
||||
command_ptr.decl_type.command_ptr.params = try params.toOwnedSlice();
|
||||
return command_ptr;
|
||||
}
|
||||
|
||||
// POINTERS = (kw_const? '*')*
|
||||
fn parsePointers(allocator: Allocator, xctok: *XmlCTokenizer, inner_const: bool, inner: TypeInfo, ptrs_optional: bool) !TypeInfo {
|
||||
var type_info = inner;
|
||||
var first_const = inner_const;
|
||||
|
||||
while (true) {
|
||||
var tok = (try xctok.peek()) orelse return type_info;
|
||||
var is_const = first_const;
|
||||
first_const = false;
|
||||
|
||||
if (tok.kind == .kw_const) {
|
||||
is_const = true;
|
||||
_ = try xctok.nextNoEof();
|
||||
tok = (try xctok.peek()) orelse return type_info;
|
||||
}
|
||||
|
||||
if (tok.kind != .star) {
|
||||
// if `is_const` is true at this point, there was a trailing const,
|
||||
// and the declaration itself is const.
|
||||
return type_info;
|
||||
}
|
||||
|
||||
_ = try xctok.nextNoEof();
|
||||
|
||||
const child = try allocator.create(TypeInfo);
|
||||
child.* = type_info;
|
||||
|
||||
type_info = .{
|
||||
.pointer = .{
|
||||
.is_const = is_const or first_const,
|
||||
.is_optional = ptrs_optional, // set elsewhere
|
||||
.size = .one, // set elsewhere
|
||||
.child = child,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ARRAY_DECLARATOR = '[' (int | enum_name) ']'
|
||||
fn parseArrayDeclarator(xctok: *XmlCTokenizer) !?ArraySize {
|
||||
const lbracket = try xctok.peek();
|
||||
if (lbracket == null or lbracket.?.kind != .lbracket) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_ = try xctok.nextNoEof();
|
||||
|
||||
const size_tok = try xctok.nextNoEof();
|
||||
const size: ArraySize = switch (size_tok.kind) {
|
||||
.int => .{
|
||||
.int = std.fmt.parseInt(usize, size_tok.text, 10) catch |err| switch (err) {
|
||||
error.Overflow => return error.Overflow,
|
||||
error.InvalidCharacter => unreachable,
|
||||
},
|
||||
},
|
||||
.enum_name => .{ .alias = size_tok.text },
|
||||
else => return error.InvalidSyntax,
|
||||
};
|
||||
|
||||
_ = try xctok.expect(.rbracket);
|
||||
return size;
|
||||
}
|
||||
|
||||
pub fn parseVersion(xctok: *XmlCTokenizer) ![4][]const u8 {
|
||||
_ = try xctok.expect(.hash);
|
||||
const define = try xctok.expect(.id);
|
||||
if (!mem.eql(u8, define.text, "define")) {
|
||||
return error.InvalidVersion;
|
||||
}
|
||||
|
||||
_ = try xctok.expect(.name);
|
||||
const vk_make_version = try xctok.expect(.type_name);
|
||||
if (!mem.eql(u8, vk_make_version.text, "VK_MAKE_API_VERSION")) {
|
||||
return error.NotVersion;
|
||||
}
|
||||
|
||||
_ = try xctok.expect(.lparen);
|
||||
var version: [4][]const u8 = undefined;
|
||||
for (&version, 0..) |*part, i| {
|
||||
if (i != 0) {
|
||||
_ = try xctok.expect(.comma);
|
||||
}
|
||||
|
||||
const tok = try xctok.nextNoEof();
|
||||
switch (tok.kind) {
|
||||
.id, .int => part.* = tok.text,
|
||||
else => return error.UnexpectedToken,
|
||||
}
|
||||
}
|
||||
_ = try xctok.expect(.rparen);
|
||||
return version;
|
||||
}
|
||||
|
||||
fn testTokenizer(tokenizer: anytype, expected_tokens: []const Token) !void {
|
||||
for (expected_tokens) |expected| {
|
||||
const tok = (tokenizer.next() catch unreachable).?;
|
||||
try testing.expectEqual(expected.kind, tok.kind);
|
||||
try testing.expectEqualSlices(u8, expected.text, tok.text);
|
||||
}
|
||||
|
||||
if (tokenizer.next() catch unreachable) |_| unreachable;
|
||||
}
|
||||
|
||||
test "CTokenizer" {
|
||||
var ctok = CTokenizer{ .source = "typedef ([const)]** VKAPI_PTR 123,;aaaa" };
|
||||
|
||||
try testTokenizer(&ctok, &[_]Token{
|
||||
.{ .kind = .kw_typedef, .text = "typedef" },
|
||||
.{ .kind = .lparen, .text = "(" },
|
||||
.{ .kind = .lbracket, .text = "[" },
|
||||
.{ .kind = .kw_const, .text = "const" },
|
||||
.{ .kind = .rparen, .text = ")" },
|
||||
.{ .kind = .rbracket, .text = "]" },
|
||||
.{ .kind = .star, .text = "*" },
|
||||
.{ .kind = .star, .text = "*" },
|
||||
.{ .kind = .kw_vkapi_ptr, .text = "VKAPI_PTR" },
|
||||
.{ .kind = .int, .text = "123" },
|
||||
.{ .kind = .comma, .text = "," },
|
||||
.{ .kind = .semicolon, .text = ";" },
|
||||
.{ .kind = .id, .text = "aaaa" },
|
||||
});
|
||||
}
|
||||
|
||||
test "XmlCTokenizer" {
|
||||
const document = try xml.parse(testing.allocator,
|
||||
\\<root>// comment <name>commented name</name> <type>commented type</type> trailing
|
||||
\\ typedef void (VKAPI_PTR *<name>PFN_vkVoidFunction</name>)(void);
|
||||
\\</root>
|
||||
);
|
||||
defer document.deinit();
|
||||
|
||||
var xctok = XmlCTokenizer.init(document.root);
|
||||
|
||||
try testTokenizer(&xctok, &[_]Token{
|
||||
.{ .kind = .kw_typedef, .text = "typedef" },
|
||||
.{ .kind = .id, .text = "void" },
|
||||
.{ .kind = .lparen, .text = "(" },
|
||||
.{ .kind = .kw_vkapi_ptr, .text = "VKAPI_PTR" },
|
||||
.{ .kind = .star, .text = "*" },
|
||||
.{ .kind = .name, .text = "PFN_vkVoidFunction" },
|
||||
.{ .kind = .rparen, .text = ")" },
|
||||
.{ .kind = .lparen, .text = "(" },
|
||||
.{ .kind = .id, .text = "void" },
|
||||
.{ .kind = .rparen, .text = ")" },
|
||||
.{ .kind = .semicolon, .text = ";" },
|
||||
});
|
||||
}
|
||||
|
||||
test "parseTypedef" {
|
||||
const document = try xml.parse(testing.allocator,
|
||||
\\<root> // comment <name>commented name</name> trailing
|
||||
\\ typedef const struct <type>Python</type>* pythons[4];
|
||||
\\ // more comments
|
||||
\\</root>
|
||||
\\
|
||||
);
|
||||
defer document.deinit();
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
var xctok = XmlCTokenizer.init(document.root);
|
||||
const decl = try parseTypedef(arena.allocator(), &xctok, false);
|
||||
|
||||
try testing.expectEqualSlices(u8, "pythons", decl.name);
|
||||
const array = decl.decl_type.typedef.array;
|
||||
try testing.expectEqual(ArraySize{ .int = 4 }, array.size);
|
||||
const ptr = array.child.pointer;
|
||||
try testing.expectEqual(true, ptr.is_const);
|
||||
try testing.expectEqualSlices(u8, "Python", ptr.child.name);
|
||||
}
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
const std = @import("std");
|
||||
const reg = @import("registry.zig");
|
||||
const xml = @import("../xml.zig");
|
||||
const renderRegistry = @import("render.zig").render;
|
||||
const parseXml = @import("parse.zig").parseXml;
|
||||
const IdRenderer = @import("../id_render.zig").IdRenderer;
|
||||
const mem = std.mem;
|
||||
const Allocator = mem.Allocator;
|
||||
const FeatureLevel = reg.FeatureLevel;
|
||||
|
||||
const EnumFieldMerger = struct {
|
||||
const EnumExtensionMap = std.StringArrayHashMapUnmanaged(std.ArrayListUnmanaged(reg.Enum.Field));
|
||||
const FieldSet = std.StringArrayHashMapUnmanaged(void);
|
||||
|
||||
arena: Allocator,
|
||||
registry: *reg.Registry,
|
||||
enum_extensions: EnumExtensionMap,
|
||||
field_set: FieldSet,
|
||||
|
||||
fn init(arena: Allocator, registry: *reg.Registry) EnumFieldMerger {
|
||||
return .{
|
||||
.arena = arena,
|
||||
.registry = registry,
|
||||
.enum_extensions = .{},
|
||||
.field_set = .{},
|
||||
};
|
||||
}
|
||||
|
||||
fn putEnumExtension(self: *EnumFieldMerger, enum_name: []const u8, field: reg.Enum.Field) !void {
|
||||
const res = try self.enum_extensions.getOrPut(self.arena, enum_name);
|
||||
if (!res.found_existing) {
|
||||
res.value_ptr.* = std.ArrayListUnmanaged(reg.Enum.Field){};
|
||||
}
|
||||
|
||||
try res.value_ptr.append(self.arena, field);
|
||||
}
|
||||
|
||||
fn addRequires(self: *EnumFieldMerger, reqs: []const reg.Require) !void {
|
||||
for (reqs) |req| {
|
||||
for (req.extends) |enum_ext| {
|
||||
try self.putEnumExtension(enum_ext.extends, enum_ext.field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn mergeEnumFields(self: *EnumFieldMerger, name: []const u8, base_enum: *reg.Enum) !void {
|
||||
// If there are no extensions for this enum, assume its valid.
|
||||
const extensions = self.enum_extensions.get(name) orelse return;
|
||||
|
||||
self.field_set.clearRetainingCapacity();
|
||||
|
||||
const n_fields_upper_bound = base_enum.fields.len + extensions.items.len;
|
||||
const new_fields = try self.arena.alloc(reg.Enum.Field, n_fields_upper_bound);
|
||||
var i: usize = 0;
|
||||
|
||||
for (base_enum.fields) |field| {
|
||||
const res = try self.field_set.getOrPut(self.arena, field.name);
|
||||
if (!res.found_existing) {
|
||||
new_fields[i] = field;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Assume that if a field name clobbers, the value is the same
|
||||
for (extensions.items) |field| {
|
||||
const res = try self.field_set.getOrPut(self.arena, field.name);
|
||||
if (!res.found_existing) {
|
||||
new_fields[i] = field;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Existing base_enum.fields was allocated by `self.arena`, so
|
||||
// it gets cleaned up whenever that is deinited.
|
||||
base_enum.fields = try self.arena.realloc(new_fields, i);
|
||||
}
|
||||
|
||||
fn merge(self: *EnumFieldMerger) !void {
|
||||
for (self.registry.features) |feature| {
|
||||
try self.addRequires(feature.requires);
|
||||
}
|
||||
|
||||
for (self.registry.extensions) |ext| {
|
||||
try self.addRequires(ext.requires);
|
||||
}
|
||||
|
||||
// Merge all the enum fields.
|
||||
// Assume that all keys of enum_extensions appear in `self.registry.decls`
|
||||
for (self.registry.decls) |*decl| {
|
||||
if (decl.decl_type == .enumeration) {
|
||||
try self.mergeEnumFields(decl.name, &decl.decl_type.enumeration);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const Generator = struct {
|
||||
arena: std.heap.ArenaAllocator,
|
||||
registry: reg.Registry,
|
||||
id_renderer: IdRenderer,
|
||||
|
||||
fn init(allocator: Allocator, spec: *xml.Element) !Generator {
|
||||
const result = try parseXml(allocator, spec);
|
||||
|
||||
const tags = try allocator.alloc([]const u8, result.registry.tags.len);
|
||||
for (tags, 0..) |*tag, i| tag.* = result.registry.tags[i].name;
|
||||
|
||||
return Generator{
|
||||
.arena = result.arena,
|
||||
.registry = result.registry,
|
||||
.id_renderer = IdRenderer.init(allocator, tags),
|
||||
};
|
||||
}
|
||||
|
||||
fn deinit(self: Generator) void {
|
||||
self.arena.deinit();
|
||||
}
|
||||
|
||||
fn stripFlagBits(self: Generator, name: []const u8) []const u8 {
|
||||
const tagless = self.id_renderer.stripAuthorTag(name);
|
||||
return tagless[0 .. tagless.len - "FlagBits".len];
|
||||
}
|
||||
|
||||
fn stripFlags(self: Generator, name: []const u8) []const u8 {
|
||||
const tagless = self.id_renderer.stripAuthorTag(name);
|
||||
return tagless[0 .. tagless.len - "Flags".len];
|
||||
}
|
||||
|
||||
// Solve `registry.declarations` according to `registry.extensions` and `registry.features`.
|
||||
fn mergeEnumFields(self: *Generator) !void {
|
||||
var merger = EnumFieldMerger.init(self.arena.allocator(), &self.registry);
|
||||
try merger.merge();
|
||||
}
|
||||
|
||||
// https://github.com/KhronosGroup/Vulkan-Docs/pull/1556
|
||||
fn fixupBitFlags(self: *Generator) !void {
|
||||
var seen_bits = std.StringArrayHashMap(void).init(self.arena.allocator());
|
||||
defer seen_bits.deinit();
|
||||
|
||||
for (self.registry.decls) |decl| {
|
||||
const bitmask = switch (decl.decl_type) {
|
||||
.bitmask => |bm| bm,
|
||||
else => continue,
|
||||
};
|
||||
|
||||
if (bitmask.bits_enum) |bits_enum| {
|
||||
try seen_bits.put(bits_enum, {});
|
||||
}
|
||||
}
|
||||
|
||||
var i: usize = 0;
|
||||
|
||||
for (self.registry.decls) |decl| {
|
||||
switch (decl.decl_type) {
|
||||
.enumeration => |e| {
|
||||
if (e.is_bitmask and seen_bits.get(decl.name) == null)
|
||||
continue;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
self.registry.decls[i] = decl;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
self.registry.decls.len = i;
|
||||
}
|
||||
|
||||
fn render(self: *Generator, writer: anytype) !void {
|
||||
try renderRegistry(writer, self.arena.allocator(), &self.registry, &self.id_renderer);
|
||||
}
|
||||
};
|
||||
|
||||
/// Main function for generating the Vulkan bindings. vk.xml is to be provided via `spec_xml`,
|
||||
/// and the resulting binding is written to `writer`. `allocator` will be used to allocate temporary
|
||||
/// internal datastructures - mostly via an ArenaAllocator, but sometimes a hashmap uses this allocator
|
||||
/// directly.
|
||||
pub fn generate(allocator: Allocator, spec_xml: []const u8, writer: anytype) !void {
|
||||
const spec = try xml.parse(allocator, spec_xml);
|
||||
defer spec.deinit();
|
||||
|
||||
var gen = try Generator.init(allocator, spec.root);
|
||||
defer gen.deinit();
|
||||
|
||||
try gen.mergeEnumFields();
|
||||
try gen.fixupBitFlags();
|
||||
try gen.render(writer);
|
||||
}
|
||||
|
|
@ -1,860 +0,0 @@
|
|||
const std = @import("std");
|
||||
const registry = @import("registry.zig");
|
||||
const xml = @import("../xml.zig");
|
||||
const cparse = @import("c_parse.zig");
|
||||
const mem = std.mem;
|
||||
const Allocator = mem.Allocator;
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
|
||||
const api_constants_name = "API Constants";
|
||||
|
||||
pub const ParseResult = struct {
|
||||
arena: ArenaAllocator,
|
||||
registry: registry.Registry,
|
||||
|
||||
pub fn deinit(self: ParseResult) void {
|
||||
self.arena.deinit();
|
||||
}
|
||||
};
|
||||
|
||||
pub fn parseXml(backing_allocator: Allocator, root: *xml.Element) !ParseResult {
|
||||
var arena = ArenaAllocator.init(backing_allocator);
|
||||
errdefer arena.deinit();
|
||||
|
||||
const allocator = arena.allocator();
|
||||
|
||||
const reg = registry.Registry{
|
||||
.copyright = root.getCharData("comment") orelse return error.InvalidRegistry,
|
||||
.decls = try parseDeclarations(allocator, root),
|
||||
.api_constants = try parseApiConstants(allocator, root),
|
||||
.tags = try parseTags(allocator, root),
|
||||
.features = try parseFeatures(allocator, root),
|
||||
.extensions = try parseExtensions(allocator, root),
|
||||
};
|
||||
|
||||
return ParseResult{
|
||||
.arena = arena,
|
||||
.registry = reg,
|
||||
};
|
||||
}
|
||||
|
||||
fn parseDeclarations(allocator: Allocator, root: *xml.Element) ![]registry.Declaration {
|
||||
const types_elem = root.findChildByTag("types") orelse return error.InvalidRegistry;
|
||||
const commands_elem = root.findChildByTag("commands") orelse return error.InvalidRegistry;
|
||||
|
||||
const decl_upper_bound = types_elem.children.items.len + commands_elem.children.items.len;
|
||||
const decls = try allocator.alloc(registry.Declaration, decl_upper_bound);
|
||||
|
||||
var count: usize = 0;
|
||||
count += try parseTypes(allocator, decls, types_elem);
|
||||
count += try parseEnums(allocator, decls[count..], root);
|
||||
count += try parseCommands(allocator, decls[count..], commands_elem);
|
||||
return try allocator.realloc(decls, count);
|
||||
}
|
||||
|
||||
fn parseTypes(allocator: Allocator, out: []registry.Declaration, types_elem: *xml.Element) !usize {
|
||||
var i: usize = 0;
|
||||
var it = types_elem.findChildrenByTag("type");
|
||||
while (it.next()) |ty| {
|
||||
out[i] = blk: {
|
||||
const category = ty.getAttribute("category") orelse {
|
||||
break :blk try parseForeigntype(ty);
|
||||
};
|
||||
|
||||
if (mem.eql(u8, category, "bitmask")) {
|
||||
break :blk try parseBitmaskType(ty);
|
||||
} else if (mem.eql(u8, category, "handle")) {
|
||||
break :blk try parseHandleType(ty);
|
||||
} else if (mem.eql(u8, category, "basetype")) {
|
||||
break :blk try parseBaseType(allocator, ty);
|
||||
} else if (mem.eql(u8, category, "struct")) {
|
||||
break :blk try parseContainer(allocator, ty, false);
|
||||
} else if (mem.eql(u8, category, "union")) {
|
||||
break :blk try parseContainer(allocator, ty, true);
|
||||
} else if (mem.eql(u8, category, "funcpointer")) {
|
||||
break :blk try parseFuncPointer(allocator, ty);
|
||||
} else if (mem.eql(u8, category, "enum")) {
|
||||
break :blk (try parseEnumAlias(ty)) orelse continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
};
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
fn parseForeigntype(ty: *xml.Element) !registry.Declaration {
|
||||
const name = ty.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
const depends = ty.getAttribute("requires") orelse if (mem.eql(u8, name, "int"))
|
||||
"vk_platform" // for some reason, int doesn't depend on vk_platform (but the other c types do)
|
||||
else
|
||||
return error.InvalidRegistry;
|
||||
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{ .foreign = .{ .depends = depends } },
|
||||
};
|
||||
}
|
||||
|
||||
fn parseBitmaskType(ty: *xml.Element) !registry.Declaration {
|
||||
if (ty.getAttribute("name")) |name| {
|
||||
const alias = ty.getAttribute("alias") orelse return error.InvalidRegistry;
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{ .alias = .{ .name = alias, .target = .other_type } },
|
||||
};
|
||||
} else {
|
||||
const flags_type = ty.getCharData("type") orelse return error.InvalidRegistry;
|
||||
|
||||
const bitwidth: u8 = if (mem.eql(u8, flags_type, "VkFlags"))
|
||||
32
|
||||
else if (mem.eql(u8, flags_type, "VkFlags64"))
|
||||
64
|
||||
else
|
||||
return error.InvalidRegistry;
|
||||
|
||||
return registry.Declaration{
|
||||
.name = ty.getCharData("name") orelse return error.InvalidRegistry,
|
||||
.decl_type = .{
|
||||
.bitmask = .{
|
||||
// Who knows why these are different fields
|
||||
.bits_enum = ty.getAttribute("requires") orelse ty.getAttribute("bitvalues"),
|
||||
.bitwidth = bitwidth,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn parseHandleType(ty: *xml.Element) !registry.Declaration {
|
||||
// Parent is not handled in case of an alias
|
||||
if (ty.getAttribute("name")) |name| {
|
||||
const alias = ty.getAttribute("alias") orelse return error.InvalidRegistry;
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{
|
||||
.alias = .{ .name = alias, .target = .other_type },
|
||||
},
|
||||
};
|
||||
} else {
|
||||
const name = ty.getCharData("name") orelse return error.InvalidRegistry;
|
||||
const handle_type = ty.getCharData("type") orelse return error.InvalidRegistry;
|
||||
const dispatchable = mem.eql(u8, handle_type, "VK_DEFINE_HANDLE");
|
||||
if (!dispatchable and !mem.eql(u8, handle_type, "VK_DEFINE_NON_DISPATCHABLE_HANDLE")) {
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{
|
||||
.handle = .{
|
||||
.parent = ty.getAttribute("parent"),
|
||||
.is_dispatchable = dispatchable,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn parseBaseType(allocator: Allocator, ty: *xml.Element) !registry.Declaration {
|
||||
const name = ty.getCharData("name") orelse return error.InvalidRegistry;
|
||||
if (ty.getCharData("type")) |_| {
|
||||
var tok = cparse.XmlCTokenizer.init(ty);
|
||||
return try cparse.parseTypedef(allocator, &tok, false);
|
||||
} else {
|
||||
// Either ANativeWindow, AHardwareBuffer or CAMetalLayer. The latter has a lot of
|
||||
// macros, which is why this part is not built into the xml/c parser.
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{ .external = {} },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn parseContainer(allocator: Allocator, ty: *xml.Element, is_union: bool) !registry.Declaration {
|
||||
const name = ty.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
|
||||
if (ty.getAttribute("alias")) |alias| {
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{
|
||||
.alias = .{ .name = alias, .target = .other_type },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
var members = try allocator.alloc(registry.Container.Field, ty.children.items.len);
|
||||
|
||||
var i: usize = 0;
|
||||
var it = ty.findChildrenByTag("member");
|
||||
var maybe_stype: ?[]const u8 = null;
|
||||
while (it.next()) |member| {
|
||||
var xctok = cparse.XmlCTokenizer.init(member);
|
||||
members[i] = try cparse.parseMember(allocator, &xctok, false);
|
||||
if (mem.eql(u8, members[i].name, "sType")) {
|
||||
if (member.getAttribute("values")) |stype| {
|
||||
maybe_stype = stype;
|
||||
}
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
members = try allocator.realloc(members, i);
|
||||
|
||||
var maybe_extends: ?[][]const u8 = null;
|
||||
if (ty.getAttribute("structextends")) |extends| {
|
||||
const n_structs = std.mem.count(u8, extends, ",") + 1;
|
||||
maybe_extends = try allocator.alloc([]const u8, n_structs);
|
||||
var struct_extends = std.mem.split(u8, extends, ",");
|
||||
var j: usize = 0;
|
||||
while (struct_extends.next()) |struct_extend| {
|
||||
maybe_extends.?[j] = struct_extend;
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
|
||||
it = ty.findChildrenByTag("member");
|
||||
for (members) |*member| {
|
||||
const member_elem = it.next().?;
|
||||
try parsePointerMeta(.{ .container = members }, &member.field_type, member_elem);
|
||||
}
|
||||
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{
|
||||
.container = .{
|
||||
.stype = maybe_stype,
|
||||
.fields = members,
|
||||
.is_union = is_union,
|
||||
.extends = maybe_extends,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
fn parseFuncPointer(allocator: Allocator, ty: *xml.Element) !registry.Declaration {
|
||||
var xctok = cparse.XmlCTokenizer.init(ty);
|
||||
return try cparse.parseTypedef(allocator, &xctok, true);
|
||||
}
|
||||
|
||||
// For some reason, the DeclarationType cannot be passed to lenToPointerSize, as
|
||||
// that causes the Zig compiler to generate invalid code for the function. Using a
|
||||
// dedicated enum fixes the issue...
|
||||
const Fields = union(enum) {
|
||||
command: []registry.Command.Param,
|
||||
container: []registry.Container.Field,
|
||||
};
|
||||
|
||||
fn lenToPointerSize(fields: Fields, len: []const u8) registry.Pointer.PointerSize {
|
||||
switch (fields) {
|
||||
.command => |params| {
|
||||
for (params) |*param| {
|
||||
if (mem.eql(u8, param.name, len)) {
|
||||
param.is_buffer_len = true;
|
||||
return .{ .other_field = param.name };
|
||||
}
|
||||
}
|
||||
},
|
||||
.container => |members| {
|
||||
for (members) |*member| {
|
||||
if (mem.eql(u8, member.name, len)) {
|
||||
member.is_buffer_len = true;
|
||||
return .{ .other_field = member.name };
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
if (mem.eql(u8, len, "null-terminated")) {
|
||||
return .zero_terminated;
|
||||
} else {
|
||||
return .many;
|
||||
}
|
||||
}
|
||||
|
||||
fn parsePointerMeta(fields: Fields, type_info: *registry.TypeInfo, elem: *xml.Element) !void {
|
||||
if (elem.getAttribute("len")) |lens| {
|
||||
var it = mem.split(u8, lens, ",");
|
||||
var current_type_info = type_info;
|
||||
while (current_type_info.* == .pointer) {
|
||||
// TODO: Check altlen
|
||||
const size = if (it.next()) |len_str| lenToPointerSize(fields, len_str) else .one;
|
||||
current_type_info.pointer.size = size;
|
||||
current_type_info = current_type_info.pointer.child;
|
||||
}
|
||||
|
||||
if (it.next()) |_| {
|
||||
// There are more elements in the `len` attribute than there are pointers
|
||||
// Something probably went wrong
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
if (elem.getAttribute("optional")) |optionals| {
|
||||
var it = mem.split(u8, optionals, ",");
|
||||
var current_type_info = type_info;
|
||||
while (current_type_info.* == .pointer) {
|
||||
if (it.next()) |current_optional| {
|
||||
current_type_info.pointer.is_optional = mem.eql(u8, current_optional, "true");
|
||||
} else {
|
||||
// There is no information for this pointer, probably incorrect.
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
|
||||
current_type_info = current_type_info.pointer.child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parseEnumAlias(elem: *xml.Element) !?registry.Declaration {
|
||||
if (elem.getAttribute("alias")) |alias| {
|
||||
const name = elem.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{
|
||||
.alias = .{ .name = alias, .target = .other_type },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
fn parseEnums(allocator: Allocator, out: []registry.Declaration, root: *xml.Element) !usize {
|
||||
var i: usize = 0;
|
||||
var it = root.findChildrenByTag("enums");
|
||||
while (it.next()) |enums| {
|
||||
const name = enums.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
if (mem.eql(u8, name, api_constants_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
out[i] = .{
|
||||
.name = name,
|
||||
.decl_type = .{ .enumeration = try parseEnumFields(allocator, enums) },
|
||||
};
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
fn parseEnumFields(allocator: Allocator, elem: *xml.Element) !registry.Enum {
|
||||
// TODO: `type` was added recently, fall back to checking endswith FlagBits for older versions?
|
||||
const enum_type = elem.getAttribute("type") orelse return error.InvalidRegistry;
|
||||
const is_bitmask = mem.eql(u8, enum_type, "bitmask");
|
||||
if (!is_bitmask and !mem.eql(u8, enum_type, "enum")) {
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
|
||||
const bitwidth = if (elem.getAttribute("bitwidth")) |bitwidth|
|
||||
try std.fmt.parseInt(u8, bitwidth, 10)
|
||||
else
|
||||
32;
|
||||
|
||||
const fields = try allocator.alloc(registry.Enum.Field, elem.children.items.len);
|
||||
|
||||
var i: usize = 0;
|
||||
var it = elem.findChildrenByTag("enum");
|
||||
while (it.next()) |field| {
|
||||
fields[i] = try parseEnumField(field);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return registry.Enum{
|
||||
.fields = try allocator.realloc(fields, i),
|
||||
.bitwidth = bitwidth,
|
||||
.is_bitmask = is_bitmask,
|
||||
};
|
||||
}
|
||||
|
||||
fn parseEnumField(field: *xml.Element) !registry.Enum.Field {
|
||||
const is_compat_alias = if (field.getAttribute("comment")) |comment|
|
||||
mem.eql(u8, comment, "Backwards-compatible alias containing a typo") or
|
||||
mem.eql(u8, comment, "Deprecated name for backwards compatibility")
|
||||
else
|
||||
false;
|
||||
|
||||
const name = field.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
const value: registry.Enum.Value = blk: {
|
||||
// An enum variant's value could be defined by any of the following attributes:
|
||||
// - value: Straight up value of the enum variant, in either base 10 or 16 (prefixed with 0x).
|
||||
// - bitpos: Used for bitmasks, and can also be set in extensions.
|
||||
// - alias: The field is an alias of another variant within the same enum.
|
||||
// - offset: Used with features and extensions, where a non-bitpos value is added to an enum.
|
||||
// The value is given by `1e9 + (extr_nr - 1) * 1e3 + offset`, where `ext_nr` is either
|
||||
// given by the `extnumber` field (in the case of a feature), or given in the parent <extension>
|
||||
// tag. In the latter case its passed via the `ext_nr` parameter.
|
||||
if (field.getAttribute("value")) |value| {
|
||||
if (mem.startsWith(u8, value, "0x")) {
|
||||
break :blk .{ .bit_vector = try std.fmt.parseInt(i32, value[2..], 16) };
|
||||
} else {
|
||||
break :blk .{ .int = try std.fmt.parseInt(i32, value, 10) };
|
||||
}
|
||||
} else if (field.getAttribute("bitpos")) |bitpos| {
|
||||
break :blk .{ .bitpos = try std.fmt.parseInt(u6, bitpos, 10) };
|
||||
} else if (field.getAttribute("alias")) |alias| {
|
||||
break :blk .{ .alias = .{ .name = alias, .is_compat_alias = is_compat_alias } };
|
||||
} else {
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
};
|
||||
|
||||
return registry.Enum.Field{
|
||||
.name = name,
|
||||
.value = value,
|
||||
};
|
||||
}
|
||||
|
||||
fn parseCommands(allocator: Allocator, out: []registry.Declaration, commands_elem: *xml.Element) !usize {
|
||||
var i: usize = 0;
|
||||
var it = commands_elem.findChildrenByTag("command");
|
||||
while (it.next()) |elem| {
|
||||
out[i] = try parseCommand(allocator, elem);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
fn splitCommaAlloc(allocator: Allocator, text: []const u8) ![][]const u8 {
|
||||
var n_codes: usize = 1;
|
||||
for (text) |c| {
|
||||
if (c == ',') n_codes += 1;
|
||||
}
|
||||
|
||||
const codes = try allocator.alloc([]const u8, n_codes);
|
||||
var it = mem.split(u8, text, ",");
|
||||
for (codes) |*code| {
|
||||
code.* = it.next().?;
|
||||
}
|
||||
|
||||
return codes;
|
||||
}
|
||||
|
||||
fn parseCommand(allocator: Allocator, elem: *xml.Element) !registry.Declaration {
|
||||
if (elem.getAttribute("alias")) |alias| {
|
||||
const name = elem.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
return registry.Declaration{
|
||||
.name = name,
|
||||
.decl_type = .{
|
||||
.alias = .{ .name = alias, .target = .other_command },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const proto = elem.findChildByTag("proto") orelse return error.InvalidRegistry;
|
||||
var proto_xctok = cparse.XmlCTokenizer.init(proto);
|
||||
const command_decl = try cparse.parseParamOrProto(allocator, &proto_xctok, false);
|
||||
|
||||
var params = try allocator.alloc(registry.Command.Param, elem.children.items.len);
|
||||
|
||||
var i: usize = 0;
|
||||
var it = elem.findChildrenByTag("param");
|
||||
while (it.next()) |param| {
|
||||
var xctok = cparse.XmlCTokenizer.init(param);
|
||||
const decl = try cparse.parseParamOrProto(allocator, &xctok, false);
|
||||
params[i] = .{
|
||||
.name = decl.name,
|
||||
.param_type = decl.decl_type.typedef,
|
||||
.is_buffer_len = false,
|
||||
};
|
||||
i += 1;
|
||||
}
|
||||
|
||||
const return_type = try allocator.create(registry.TypeInfo);
|
||||
return_type.* = command_decl.decl_type.typedef;
|
||||
|
||||
const success_codes: [][]const u8 = if (elem.getAttribute("successcodes")) |codes|
|
||||
try splitCommaAlloc(allocator, codes)
|
||||
else
|
||||
&[_][]const u8{};
|
||||
|
||||
const error_codes: [][]const u8 = if (elem.getAttribute("errorcodes")) |codes|
|
||||
try splitCommaAlloc(allocator, codes)
|
||||
else
|
||||
&[_][]const u8{};
|
||||
|
||||
params = try allocator.realloc(params, i);
|
||||
|
||||
it = elem.findChildrenByTag("param");
|
||||
for (params) |*param| {
|
||||
const param_elem = it.next().?;
|
||||
try parsePointerMeta(.{ .command = params }, ¶m.param_type, param_elem);
|
||||
}
|
||||
|
||||
return registry.Declaration{
|
||||
.name = command_decl.name,
|
||||
.decl_type = .{
|
||||
.command = .{
|
||||
.params = params,
|
||||
.return_type = return_type,
|
||||
.success_codes = success_codes,
|
||||
.error_codes = error_codes,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
fn parseApiConstants(allocator: Allocator, root: *xml.Element) ![]registry.ApiConstant {
|
||||
var enums = blk: {
|
||||
var it = root.findChildrenByTag("enums");
|
||||
while (it.next()) |child| {
|
||||
const name = child.getAttribute("name") orelse continue;
|
||||
if (mem.eql(u8, name, api_constants_name)) {
|
||||
break :blk child;
|
||||
}
|
||||
}
|
||||
|
||||
return error.InvalidRegistry;
|
||||
};
|
||||
|
||||
var types = root.findChildByTag("types") orelse return error.InvalidRegistry;
|
||||
const n_defines = blk: {
|
||||
var n_defines: usize = 0;
|
||||
var it = types.findChildrenByTag("type");
|
||||
while (it.next()) |ty| {
|
||||
if (ty.getAttribute("category")) |category| {
|
||||
if (mem.eql(u8, category, "define")) {
|
||||
n_defines += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break :blk n_defines;
|
||||
};
|
||||
|
||||
const constants = try allocator.alloc(registry.ApiConstant, enums.children.items.len + n_defines);
|
||||
|
||||
var i: usize = 0;
|
||||
var it = enums.findChildrenByTag("enum");
|
||||
while (it.next()) |constant| {
|
||||
const expr = if (constant.getAttribute("value")) |expr|
|
||||
expr
|
||||
else if (constant.getAttribute("alias")) |alias|
|
||||
alias
|
||||
else
|
||||
return error.InvalidRegistry;
|
||||
|
||||
constants[i] = .{
|
||||
.name = constant.getAttribute("name") orelse return error.InvalidRegistry,
|
||||
.value = .{ .expr = expr },
|
||||
};
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
i += try parseDefines(types, constants[i..]);
|
||||
return try allocator.realloc(constants, i);
|
||||
}
|
||||
|
||||
fn parseDefines(types: *xml.Element, out: []registry.ApiConstant) !usize {
|
||||
var i: usize = 0;
|
||||
var it = types.findChildrenByTag("type");
|
||||
while (it.next()) |ty| {
|
||||
const category = ty.getAttribute("category") orelse continue;
|
||||
if (!mem.eql(u8, category, "define")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const name = ty.getCharData("name") orelse continue;
|
||||
if (mem.eql(u8, name, "VK_HEADER_VERSION")) {
|
||||
out[i] = .{
|
||||
.name = name,
|
||||
.value = .{ .expr = mem.trim(u8, ty.children.items[2].CharData, " ") },
|
||||
};
|
||||
} else {
|
||||
var xctok = cparse.XmlCTokenizer.init(ty);
|
||||
out[i] = .{
|
||||
.name = name,
|
||||
.value = .{ .version = cparse.parseVersion(&xctok) catch continue },
|
||||
};
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
fn parseTags(allocator: Allocator, root: *xml.Element) ![]registry.Tag {
|
||||
var tags_elem = root.findChildByTag("tags") orelse return error.InvalidRegistry;
|
||||
const tags = try allocator.alloc(registry.Tag, tags_elem.children.items.len);
|
||||
|
||||
var i: usize = 0;
|
||||
var it = tags_elem.findChildrenByTag("tag");
|
||||
while (it.next()) |tag| {
|
||||
tags[i] = .{
|
||||
.name = tag.getAttribute("name") orelse return error.InvalidRegistry,
|
||||
.author = tag.getAttribute("author") orelse return error.InvalidRegistry,
|
||||
};
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return try allocator.realloc(tags, i);
|
||||
}
|
||||
|
||||
fn parseFeatures(allocator: Allocator, root: *xml.Element) ![]registry.Feature {
|
||||
var it = root.findChildrenByTag("feature");
|
||||
var count: usize = 0;
|
||||
while (it.next()) |_| count += 1;
|
||||
|
||||
const features = try allocator.alloc(registry.Feature, count);
|
||||
var i: usize = 0;
|
||||
it = root.findChildrenByTag("feature");
|
||||
while (it.next()) |feature| {
|
||||
features[i] = try parseFeature(allocator, feature);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
fn parseFeature(allocator: Allocator, feature: *xml.Element) !registry.Feature {
|
||||
const name = feature.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
const feature_level = blk: {
|
||||
const number = feature.getAttribute("number") orelse return error.InvalidRegistry;
|
||||
break :blk try splitFeatureLevel(number, ".");
|
||||
};
|
||||
|
||||
var requires = try allocator.alloc(registry.Require, feature.children.items.len);
|
||||
var i: usize = 0;
|
||||
var it = feature.findChildrenByTag("require");
|
||||
while (it.next()) |require| {
|
||||
requires[i] = try parseRequire(allocator, require, null);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return registry.Feature{
|
||||
.name = name,
|
||||
.level = feature_level,
|
||||
.requires = try allocator.realloc(requires, i),
|
||||
};
|
||||
}
|
||||
|
||||
fn parseEnumExtension(elem: *xml.Element, parent_extnumber: ?u31) !?registry.Require.EnumExtension {
|
||||
// check for either _SPEC_VERSION or _EXTENSION_NAME
|
||||
const extends = elem.getAttribute("extends") orelse return null;
|
||||
|
||||
if (elem.getAttribute("offset")) |offset_str| {
|
||||
const offset = try std.fmt.parseInt(u31, offset_str, 10);
|
||||
const name = elem.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
const extnumber = if (elem.getAttribute("extnumber")) |num|
|
||||
try std.fmt.parseInt(u31, num, 10)
|
||||
else
|
||||
null;
|
||||
|
||||
const actual_extnumber = extnumber orelse parent_extnumber orelse return error.InvalidRegistry;
|
||||
const value = blk: {
|
||||
const abs_value = enumExtOffsetToValue(actual_extnumber, offset);
|
||||
if (elem.getAttribute("dir")) |dir| {
|
||||
if (mem.eql(u8, dir, "-")) {
|
||||
break :blk -@as(i32, abs_value);
|
||||
} else {
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
break :blk @as(i32, abs_value);
|
||||
};
|
||||
|
||||
return registry.Require.EnumExtension{
|
||||
.extends = extends,
|
||||
.extnumber = actual_extnumber,
|
||||
.field = .{
|
||||
.name = name,
|
||||
.value = .{ .int = value },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return registry.Require.EnumExtension{
|
||||
.extends = extends,
|
||||
.extnumber = parent_extnumber,
|
||||
.field = try parseEnumField(elem),
|
||||
};
|
||||
}
|
||||
|
||||
fn enumExtOffsetToValue(extnumber: u31, offset: u31) u31 {
|
||||
const extension_value_base = 1000000000;
|
||||
const extension_block = 1000;
|
||||
return extension_value_base + (extnumber - 1) * extension_block + offset;
|
||||
}
|
||||
|
||||
fn parseRequire(allocator: Allocator, require: *xml.Element, extnumber: ?u31) !registry.Require {
|
||||
var n_extends: usize = 0;
|
||||
var n_types: usize = 0;
|
||||
var n_commands: usize = 0;
|
||||
|
||||
var it = require.elements();
|
||||
while (it.next()) |elem| {
|
||||
if (mem.eql(u8, elem.tag, "enum")) {
|
||||
n_extends += 1;
|
||||
} else if (mem.eql(u8, elem.tag, "type")) {
|
||||
n_types += 1;
|
||||
} else if (mem.eql(u8, elem.tag, "command")) {
|
||||
n_commands += 1;
|
||||
}
|
||||
}
|
||||
|
||||
const extends = try allocator.alloc(registry.Require.EnumExtension, n_extends);
|
||||
const types = try allocator.alloc([]const u8, n_types);
|
||||
const commands = try allocator.alloc([]const u8, n_commands);
|
||||
|
||||
var i_extends: usize = 0;
|
||||
var i_types: usize = 0;
|
||||
var i_commands: usize = 0;
|
||||
|
||||
it = require.elements();
|
||||
while (it.next()) |elem| {
|
||||
if (mem.eql(u8, elem.tag, "enum")) {
|
||||
if (try parseEnumExtension(elem, extnumber)) |ext| {
|
||||
extends[i_extends] = ext;
|
||||
i_extends += 1;
|
||||
}
|
||||
} else if (mem.eql(u8, elem.tag, "type")) {
|
||||
types[i_types] = elem.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
i_types += 1;
|
||||
} else if (mem.eql(u8, elem.tag, "command")) {
|
||||
commands[i_commands] = elem.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
i_commands += 1;
|
||||
}
|
||||
}
|
||||
|
||||
const required_feature_level = blk: {
|
||||
const feature_level = require.getAttribute("feature") orelse break :blk null;
|
||||
if (!mem.startsWith(u8, feature_level, "VK_VERSION_")) {
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
|
||||
break :blk try splitFeatureLevel(feature_level["VK_VERSION_".len..], "_");
|
||||
};
|
||||
|
||||
return registry.Require{
|
||||
.extends = try allocator.realloc(extends, i_extends),
|
||||
.types = types,
|
||||
.commands = commands,
|
||||
.required_feature_level = required_feature_level,
|
||||
.required_extension = require.getAttribute("extension"),
|
||||
};
|
||||
}
|
||||
|
||||
fn parseExtensions(allocator: Allocator, root: *xml.Element) ![]registry.Extension {
|
||||
const extensions_elem = root.findChildByTag("extensions") orelse return error.InvalidRegistry;
|
||||
|
||||
const extensions = try allocator.alloc(registry.Extension, extensions_elem.children.items.len);
|
||||
var i: usize = 0;
|
||||
var it = extensions_elem.findChildrenByTag("extension");
|
||||
while (it.next()) |extension| {
|
||||
// Some extensions (in particular 94) are disabled, so just skip them
|
||||
if (extension.getAttribute("supported")) |supported| {
|
||||
if (mem.eql(u8, supported, "disabled")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
extensions[i] = try parseExtension(allocator, extension);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return try allocator.realloc(extensions, i);
|
||||
}
|
||||
|
||||
fn findExtVersion(extension: *xml.Element) !u32 {
|
||||
var req_it = extension.findChildrenByTag("require");
|
||||
while (req_it.next()) |req| {
|
||||
var enum_it = req.findChildrenByTag("enum");
|
||||
while (enum_it.next()) |e| {
|
||||
const name = e.getAttribute("name") orelse continue;
|
||||
const value = e.getAttribute("value") orelse continue;
|
||||
if (mem.endsWith(u8, name, "_SPEC_VERSION")) {
|
||||
return try std.fmt.parseInt(u32, value, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
|
||||
fn parseExtension(allocator: Allocator, extension: *xml.Element) !registry.Extension {
|
||||
const name = extension.getAttribute("name") orelse return error.InvalidRegistry;
|
||||
const platform = extension.getAttribute("platform");
|
||||
const version = try findExtVersion(extension);
|
||||
|
||||
// For some reason there are two ways for an extension to state its required
|
||||
// feature level: both seperately in each <require> tag, or using
|
||||
// the requiresCore attribute.
|
||||
const requires_core = if (extension.getAttribute("requiresCore")) |feature_level|
|
||||
try splitFeatureLevel(feature_level, ".")
|
||||
else
|
||||
null;
|
||||
|
||||
const promoted_to: registry.Extension.Promotion = blk: {
|
||||
const promotedto = extension.getAttribute("promotedto") orelse break :blk .none;
|
||||
if (mem.startsWith(u8, promotedto, "VK_VERSION_")) {
|
||||
const feature_level = try splitFeatureLevel(promotedto["VK_VERSION_".len..], "_");
|
||||
break :blk .{ .feature = feature_level };
|
||||
}
|
||||
|
||||
break :blk .{ .extension = promotedto };
|
||||
};
|
||||
|
||||
const number = blk: {
|
||||
const number_str = extension.getAttribute("number") orelse return error.InvalidRegistry;
|
||||
break :blk try std.fmt.parseInt(u31, number_str, 10);
|
||||
};
|
||||
|
||||
const ext_type: ?registry.Extension.ExtensionType = blk: {
|
||||
const ext_type_str = extension.getAttribute("type") orelse break :blk null;
|
||||
if (mem.eql(u8, ext_type_str, "instance")) {
|
||||
break :blk .instance;
|
||||
} else if (mem.eql(u8, ext_type_str, "device")) {
|
||||
break :blk .device;
|
||||
} else {
|
||||
return error.InvalidRegistry;
|
||||
}
|
||||
};
|
||||
|
||||
const depends = blk: {
|
||||
const requires_str = extension.getAttribute("requires") orelse break :blk &[_][]const u8{};
|
||||
break :blk try splitCommaAlloc(allocator, requires_str);
|
||||
};
|
||||
|
||||
var requires = try allocator.alloc(registry.Require, extension.children.items.len);
|
||||
var i: usize = 0;
|
||||
var it = extension.findChildrenByTag("require");
|
||||
while (it.next()) |require| {
|
||||
requires[i] = try parseRequire(allocator, require, number);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return registry.Extension{
|
||||
.name = name,
|
||||
.number = number,
|
||||
.version = version,
|
||||
.extension_type = ext_type,
|
||||
.depends = depends,
|
||||
.promoted_to = promoted_to,
|
||||
.platform = platform,
|
||||
.required_feature_level = requires_core,
|
||||
.requires = try allocator.realloc(requires, i),
|
||||
};
|
||||
}
|
||||
|
||||
fn splitFeatureLevel(ver: []const u8, split: []const u8) !registry.FeatureLevel {
|
||||
var it = mem.split(u8, ver, split);
|
||||
|
||||
const major = it.next() orelse return error.InvalidFeatureLevel;
|
||||
const minor = it.next() orelse return error.InvalidFeatureLevel;
|
||||
if (it.next() != null) {
|
||||
return error.InvalidFeatureLevel;
|
||||
}
|
||||
|
||||
return registry.FeatureLevel{
|
||||
.major = try std.fmt.parseInt(u32, major, 10),
|
||||
.minor = try std.fmt.parseInt(u32, minor, 10),
|
||||
};
|
||||
}
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
pub const Registry = struct {
|
||||
copyright: []const u8,
|
||||
decls: []Declaration,
|
||||
api_constants: []ApiConstant,
|
||||
tags: []Tag,
|
||||
features: []Feature,
|
||||
extensions: []Extension,
|
||||
};
|
||||
|
||||
pub const Declaration = struct {
|
||||
name: []const u8,
|
||||
decl_type: DeclarationType,
|
||||
};
|
||||
|
||||
pub const DeclarationType = union(enum) {
|
||||
container: Container,
|
||||
enumeration: Enum,
|
||||
bitmask: Bitmask,
|
||||
handle: Handle,
|
||||
command: Command,
|
||||
alias: Alias,
|
||||
foreign: Foreign,
|
||||
typedef: TypeInfo,
|
||||
external,
|
||||
};
|
||||
|
||||
pub const Alias = struct {
|
||||
pub const Target = enum {
|
||||
other_command,
|
||||
other_type,
|
||||
};
|
||||
|
||||
name: []const u8,
|
||||
target: Target,
|
||||
};
|
||||
|
||||
pub const ApiConstant = struct {
|
||||
pub const Value = union(enum) {
|
||||
expr: []const u8,
|
||||
version: [4][]const u8,
|
||||
};
|
||||
|
||||
name: []const u8,
|
||||
value: Value,
|
||||
};
|
||||
|
||||
pub const Tag = struct {
|
||||
name: []const u8,
|
||||
author: []const u8,
|
||||
};
|
||||
|
||||
pub const TypeInfo = union(enum) {
|
||||
name: []const u8,
|
||||
command_ptr: Command,
|
||||
pointer: Pointer,
|
||||
array: Array,
|
||||
};
|
||||
|
||||
pub const Container = struct {
|
||||
pub const Field = struct {
|
||||
name: []const u8,
|
||||
field_type: TypeInfo,
|
||||
bits: ?usize,
|
||||
is_buffer_len: bool,
|
||||
};
|
||||
|
||||
stype: ?[]const u8,
|
||||
extends: ?[]const []const u8,
|
||||
fields: []Field,
|
||||
is_union: bool,
|
||||
};
|
||||
|
||||
pub const Enum = struct {
|
||||
pub const Value = union(enum) {
|
||||
bitpos: u6, // 1 << bitpos
|
||||
bit_vector: i32, // Combined flags & some vendor IDs
|
||||
int: i32,
|
||||
alias: struct {
|
||||
name: []const u8,
|
||||
is_compat_alias: bool,
|
||||
},
|
||||
};
|
||||
|
||||
pub const Field = struct {
|
||||
name: []const u8,
|
||||
value: Value,
|
||||
};
|
||||
|
||||
fields: []Field,
|
||||
bitwidth: u8,
|
||||
is_bitmask: bool,
|
||||
};
|
||||
|
||||
pub const Bitmask = struct {
|
||||
bits_enum: ?[]const u8,
|
||||
bitwidth: u8,
|
||||
};
|
||||
|
||||
pub const Handle = struct {
|
||||
parent: ?[]const u8, // VkInstance has no parent
|
||||
is_dispatchable: bool,
|
||||
};
|
||||
|
||||
pub const Command = struct {
|
||||
pub const Param = struct {
|
||||
name: []const u8,
|
||||
param_type: TypeInfo,
|
||||
is_buffer_len: bool,
|
||||
};
|
||||
|
||||
params: []Param,
|
||||
return_type: *TypeInfo,
|
||||
success_codes: [][]const u8,
|
||||
error_codes: [][]const u8,
|
||||
};
|
||||
|
||||
pub const Pointer = struct {
|
||||
pub const PointerSize = union(enum) {
|
||||
one,
|
||||
many, // The length is given by some complex expression, possibly involving another field
|
||||
other_field: []const u8, // The length is given by some other field or parameter
|
||||
zero_terminated,
|
||||
};
|
||||
|
||||
is_const: bool,
|
||||
is_optional: bool,
|
||||
size: PointerSize,
|
||||
child: *TypeInfo,
|
||||
};
|
||||
|
||||
pub const Array = struct {
|
||||
pub const ArraySize = union(enum) {
|
||||
int: usize,
|
||||
alias: []const u8, // Field size is given by an api constant
|
||||
};
|
||||
|
||||
size: ArraySize,
|
||||
child: *TypeInfo,
|
||||
};
|
||||
|
||||
pub const Foreign = struct {
|
||||
depends: []const u8, // Either a header or vk_platform
|
||||
};
|
||||
|
||||
pub const Feature = struct {
|
||||
name: []const u8,
|
||||
level: FeatureLevel, // from 'number'
|
||||
requires: []Require,
|
||||
};
|
||||
|
||||
pub const Extension = struct {
|
||||
pub const ExtensionType = enum {
|
||||
instance,
|
||||
device,
|
||||
};
|
||||
|
||||
pub const Promotion = union(enum) {
|
||||
none,
|
||||
feature: FeatureLevel,
|
||||
extension: []const u8,
|
||||
};
|
||||
|
||||
name: []const u8,
|
||||
number: u31,
|
||||
version: u32,
|
||||
extension_type: ?ExtensionType,
|
||||
depends: []const []const u8, // Other extensions
|
||||
promoted_to: Promotion,
|
||||
platform: ?[]const u8,
|
||||
required_feature_level: ?FeatureLevel,
|
||||
requires: []Require,
|
||||
};
|
||||
|
||||
pub const Require = struct {
|
||||
pub const EnumExtension = struct {
|
||||
extends: []const u8,
|
||||
extnumber: ?u31,
|
||||
field: Enum.Field,
|
||||
};
|
||||
|
||||
extends: []EnumExtension,
|
||||
types: []const []const u8,
|
||||
commands: []const []const u8,
|
||||
required_feature_level: ?FeatureLevel,
|
||||
required_extension: ?[]const u8,
|
||||
};
|
||||
|
||||
pub const FeatureLevel = struct {
|
||||
major: u32,
|
||||
minor: u32,
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,667 +0,0 @@
|
|||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const testing = std.testing;
|
||||
const Allocator = mem.Allocator;
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
const ArrayList = std.ArrayList;
|
||||
|
||||
pub const Attribute = struct {
|
||||
name: []const u8,
|
||||
value: []const u8,
|
||||
};
|
||||
|
||||
pub const Content = union(enum) {
|
||||
CharData: []const u8,
|
||||
Comment: []const u8,
|
||||
Element: *Element,
|
||||
};
|
||||
|
||||
pub const Element = struct {
|
||||
pub const AttributeList = ArrayList(*Attribute);
|
||||
pub const ContentList = ArrayList(Content);
|
||||
|
||||
tag: []const u8,
|
||||
attributes: AttributeList,
|
||||
children: ContentList,
|
||||
|
||||
fn init(tag: []const u8, alloc: Allocator) Element {
|
||||
return .{
|
||||
.tag = tag,
|
||||
.attributes = AttributeList.init(alloc),
|
||||
.children = ContentList.init(alloc),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getAttribute(self: *Element, attrib_name: []const u8) ?[]const u8 {
|
||||
for (self.attributes.items) |child| {
|
||||
if (mem.eql(u8, child.name, attrib_name)) {
|
||||
return child.value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn getCharData(self: *Element, child_tag: []const u8) ?[]const u8 {
|
||||
const child = self.findChildByTag(child_tag) orelse return null;
|
||||
if (child.children.items.len != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return switch (child.children.items[0]) {
|
||||
.CharData => |char_data| char_data,
|
||||
else => null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn iterator(self: *Element) ChildIterator {
|
||||
return .{
|
||||
.items = self.children.items,
|
||||
.i = 0,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn elements(self: *Element) ChildElementIterator {
|
||||
return .{
|
||||
.inner = self.iterator(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn findChildByTag(self: *Element, tag: []const u8) ?*Element {
|
||||
var childIterator = self.findChildrenByTag(tag);
|
||||
return childIterator.next();
|
||||
}
|
||||
|
||||
pub fn findChildrenByTag(self: *Element, tag: []const u8) FindChildrenByTagIterator {
|
||||
return .{
|
||||
.inner = self.elements(),
|
||||
.tag = tag,
|
||||
};
|
||||
}
|
||||
|
||||
pub const ChildIterator = struct {
|
||||
items: []Content,
|
||||
i: usize,
|
||||
|
||||
pub fn next(self: *ChildIterator) ?*Content {
|
||||
if (self.i < self.items.len) {
|
||||
self.i += 1;
|
||||
return &self.items[self.i - 1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
pub const ChildElementIterator = struct {
|
||||
inner: ChildIterator,
|
||||
|
||||
pub fn next(self: *ChildElementIterator) ?*Element {
|
||||
while (self.inner.next()) |child| {
|
||||
if (child.* != .Element) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return child.*.Element;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
pub const FindChildrenByTagIterator = struct {
|
||||
inner: ChildElementIterator,
|
||||
tag: []const u8,
|
||||
|
||||
pub fn next(self: *FindChildrenByTagIterator) ?*Element {
|
||||
while (self.inner.next()) |child| {
|
||||
if (!mem.eql(u8, child.tag, self.tag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
pub const XmlDecl = struct {
|
||||
version: []const u8,
|
||||
encoding: ?[]const u8,
|
||||
standalone: ?bool,
|
||||
};
|
||||
|
||||
pub const Document = struct {
|
||||
arena: ArenaAllocator,
|
||||
xml_decl: ?*XmlDecl,
|
||||
root: *Element,
|
||||
|
||||
pub fn deinit(self: Document) void {
|
||||
var arena = self.arena; // Copy to stack so self can be taken by value.
|
||||
arena.deinit();
|
||||
}
|
||||
};
|
||||
|
||||
const ParseContext = struct {
|
||||
source: []const u8,
|
||||
offset: usize,
|
||||
line: usize,
|
||||
column: usize,
|
||||
|
||||
fn init(source: []const u8) ParseContext {
|
||||
return .{
|
||||
.source = source,
|
||||
.offset = 0,
|
||||
.line = 0,
|
||||
.column = 0,
|
||||
};
|
||||
}
|
||||
|
||||
fn peek(self: *ParseContext) ?u8 {
|
||||
return if (self.offset < self.source.len) self.source[self.offset] else null;
|
||||
}
|
||||
|
||||
fn consume(self: *ParseContext) !u8 {
|
||||
if (self.offset < self.source.len) {
|
||||
return self.consumeNoEof();
|
||||
}
|
||||
|
||||
return error.UnexpectedEof;
|
||||
}
|
||||
|
||||
fn consumeNoEof(self: *ParseContext) u8 {
|
||||
std.debug.assert(self.offset < self.source.len);
|
||||
const c = self.source[self.offset];
|
||||
self.offset += 1;
|
||||
|
||||
if (c == '\n') {
|
||||
self.line += 1;
|
||||
self.column = 0;
|
||||
} else {
|
||||
self.column += 1;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
fn eat(self: *ParseContext, char: u8) bool {
|
||||
self.expect(char) catch return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
fn expect(self: *ParseContext, expected: u8) !void {
|
||||
if (self.peek()) |actual| {
|
||||
if (expected != actual) {
|
||||
return error.UnexpectedCharacter;
|
||||
}
|
||||
|
||||
_ = self.consumeNoEof();
|
||||
return;
|
||||
}
|
||||
|
||||
return error.UnexpectedEof;
|
||||
}
|
||||
|
||||
fn eatStr(self: *ParseContext, text: []const u8) bool {
|
||||
self.expectStr(text) catch return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
fn expectStr(self: *ParseContext, text: []const u8) !void {
|
||||
if (self.source.len < self.offset + text.len) {
|
||||
return error.UnexpectedEof;
|
||||
} else if (std.mem.startsWith(u8, self.source[self.offset..], text)) {
|
||||
var i: usize = 0;
|
||||
while (i < text.len) : (i += 1) {
|
||||
_ = self.consumeNoEof();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return error.UnexpectedCharacter;
|
||||
}
|
||||
|
||||
fn eatWs(self: *ParseContext) bool {
|
||||
var ws = false;
|
||||
|
||||
while (self.peek()) |ch| {
|
||||
switch (ch) {
|
||||
' ', '\t', '\n', '\r' => {
|
||||
ws = true;
|
||||
_ = self.consumeNoEof();
|
||||
},
|
||||
else => break,
|
||||
}
|
||||
}
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
||||
fn expectWs(self: *ParseContext) !void {
|
||||
if (!self.eatWs()) return error.UnexpectedCharacter;
|
||||
}
|
||||
|
||||
fn currentLine(self: ParseContext) []const u8 {
|
||||
var begin: usize = 0;
|
||||
if (mem.lastIndexOfScalar(u8, self.source[0..self.offset], '\n')) |prev_nl| {
|
||||
begin = prev_nl + 1;
|
||||
}
|
||||
|
||||
const end = mem.indexOfScalarPos(u8, self.source, self.offset, '\n') orelse self.source.len;
|
||||
return self.source[begin..end];
|
||||
}
|
||||
};
|
||||
|
||||
test "ParseContext" {
|
||||
{
|
||||
var ctx = ParseContext.init("I like pythons");
|
||||
try testing.expectEqual(@as(?u8, 'I'), ctx.peek());
|
||||
try testing.expectEqual(@as(u8, 'I'), ctx.consumeNoEof());
|
||||
try testing.expectEqual(@as(?u8, ' '), ctx.peek());
|
||||
try testing.expectEqual(@as(u8, ' '), try ctx.consume());
|
||||
|
||||
try testing.expect(ctx.eat('l'));
|
||||
try testing.expectEqual(@as(?u8, 'i'), ctx.peek());
|
||||
try testing.expectEqual(false, ctx.eat('a'));
|
||||
try testing.expectEqual(@as(?u8, 'i'), ctx.peek());
|
||||
|
||||
try ctx.expect('i');
|
||||
try testing.expectEqual(@as(?u8, 'k'), ctx.peek());
|
||||
try testing.expectError(error.UnexpectedCharacter, ctx.expect('a'));
|
||||
try testing.expectEqual(@as(?u8, 'k'), ctx.peek());
|
||||
|
||||
try testing.expect(ctx.eatStr("ke"));
|
||||
try testing.expectEqual(@as(?u8, ' '), ctx.peek());
|
||||
|
||||
try testing.expect(ctx.eatWs());
|
||||
try testing.expectEqual(@as(?u8, 'p'), ctx.peek());
|
||||
try testing.expectEqual(false, ctx.eatWs());
|
||||
try testing.expectEqual(@as(?u8, 'p'), ctx.peek());
|
||||
|
||||
try testing.expectEqual(false, ctx.eatStr("aaaaaaaaa"));
|
||||
try testing.expectEqual(@as(?u8, 'p'), ctx.peek());
|
||||
|
||||
try testing.expectError(error.UnexpectedEof, ctx.expectStr("aaaaaaaaa"));
|
||||
try testing.expectEqual(@as(?u8, 'p'), ctx.peek());
|
||||
try testing.expectError(error.UnexpectedCharacter, ctx.expectStr("pytn"));
|
||||
try testing.expectEqual(@as(?u8, 'p'), ctx.peek());
|
||||
try ctx.expectStr("python");
|
||||
try testing.expectEqual(@as(?u8, 's'), ctx.peek());
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("");
|
||||
try testing.expectEqual(ctx.peek(), null);
|
||||
try testing.expectError(error.UnexpectedEof, ctx.consume());
|
||||
try testing.expectEqual(ctx.eat('p'), false);
|
||||
try testing.expectError(error.UnexpectedEof, ctx.expect('p'));
|
||||
}
|
||||
}
|
||||
|
||||
pub const ParseError = error{
|
||||
IllegalCharacter,
|
||||
UnexpectedEof,
|
||||
UnexpectedCharacter,
|
||||
UnclosedValue,
|
||||
UnclosedComment,
|
||||
InvalidName,
|
||||
InvalidEntity,
|
||||
InvalidStandaloneValue,
|
||||
NonMatchingClosingTag,
|
||||
InvalidDocument,
|
||||
OutOfMemory,
|
||||
};
|
||||
|
||||
pub fn parse(backing_allocator: Allocator, source: []const u8) !Document {
|
||||
var ctx = ParseContext.init(source);
|
||||
return try parseDocument(&ctx, backing_allocator);
|
||||
}
|
||||
|
||||
fn parseDocument(ctx: *ParseContext, backing_allocator: Allocator) !Document {
|
||||
var doc = Document{
|
||||
.arena = ArenaAllocator.init(backing_allocator),
|
||||
.xml_decl = null,
|
||||
.root = undefined,
|
||||
};
|
||||
|
||||
errdefer doc.deinit();
|
||||
|
||||
const allocator = doc.arena.allocator();
|
||||
|
||||
try trySkipComments(ctx, allocator);
|
||||
|
||||
doc.xml_decl = try tryParseProlog(ctx, allocator);
|
||||
_ = ctx.eatWs();
|
||||
try trySkipComments(ctx, allocator);
|
||||
|
||||
doc.root = (try tryParseElement(ctx, allocator)) orelse return error.InvalidDocument;
|
||||
_ = ctx.eatWs();
|
||||
try trySkipComments(ctx, allocator);
|
||||
|
||||
if (ctx.peek() != null) return error.InvalidDocument;
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
fn parseAttrValue(ctx: *ParseContext, alloc: Allocator) ![]const u8 {
|
||||
const quote = try ctx.consume();
|
||||
if (quote != '"' and quote != '\'') return error.UnexpectedCharacter;
|
||||
|
||||
const begin = ctx.offset;
|
||||
|
||||
while (true) {
|
||||
const c = ctx.consume() catch return error.UnclosedValue;
|
||||
if (c == quote) break;
|
||||
}
|
||||
|
||||
const end = ctx.offset - 1;
|
||||
|
||||
return try dupeAndUnescape(alloc, ctx.source[begin..end]);
|
||||
}
|
||||
|
||||
fn parseEqAttrValue(ctx: *ParseContext, alloc: Allocator) ![]const u8 {
|
||||
_ = ctx.eatWs();
|
||||
try ctx.expect('=');
|
||||
_ = ctx.eatWs();
|
||||
|
||||
return try parseAttrValue(ctx, alloc);
|
||||
}
|
||||
|
||||
fn parseNameNoDupe(ctx: *ParseContext) ![]const u8 {
|
||||
// XML's spec on names is very long, so to make this easier
|
||||
// we just take any character that is not special and not whitespace
|
||||
const begin = ctx.offset;
|
||||
|
||||
while (ctx.peek()) |ch| {
|
||||
switch (ch) {
|
||||
' ', '\t', '\n', '\r' => break,
|
||||
'&', '"', '\'', '<', '>', '?', '=', '/' => break,
|
||||
else => _ = ctx.consumeNoEof(),
|
||||
}
|
||||
}
|
||||
|
||||
const end = ctx.offset;
|
||||
if (begin == end) return error.InvalidName;
|
||||
|
||||
return ctx.source[begin..end];
|
||||
}
|
||||
|
||||
fn tryParseCharData(ctx: *ParseContext, alloc: Allocator) !?[]const u8 {
|
||||
const begin = ctx.offset;
|
||||
|
||||
while (ctx.peek()) |ch| {
|
||||
switch (ch) {
|
||||
'<' => break,
|
||||
else => _ = ctx.consumeNoEof(),
|
||||
}
|
||||
}
|
||||
|
||||
const end = ctx.offset;
|
||||
if (begin == end) return null;
|
||||
|
||||
return try dupeAndUnescape(alloc, ctx.source[begin..end]);
|
||||
}
|
||||
|
||||
fn parseContent(ctx: *ParseContext, alloc: Allocator) ParseError!Content {
|
||||
if (try tryParseCharData(ctx, alloc)) |cd| {
|
||||
return Content{ .CharData = cd };
|
||||
} else if (try tryParseComment(ctx, alloc)) |comment| {
|
||||
return Content{ .Comment = comment };
|
||||
} else if (try tryParseElement(ctx, alloc)) |elem| {
|
||||
return Content{ .Element = elem };
|
||||
} else {
|
||||
return error.UnexpectedCharacter;
|
||||
}
|
||||
}
|
||||
|
||||
fn tryParseAttr(ctx: *ParseContext, alloc: Allocator) !?*Attribute {
|
||||
const name = parseNameNoDupe(ctx) catch return null;
|
||||
_ = ctx.eatWs();
|
||||
try ctx.expect('=');
|
||||
_ = ctx.eatWs();
|
||||
const value = try parseAttrValue(ctx, alloc);
|
||||
|
||||
const attr = try alloc.create(Attribute);
|
||||
attr.name = try alloc.dupe(u8, name);
|
||||
attr.value = value;
|
||||
return attr;
|
||||
}
|
||||
|
||||
fn tryParseElement(ctx: *ParseContext, alloc: Allocator) !?*Element {
|
||||
const start = ctx.offset;
|
||||
if (!ctx.eat('<')) return null;
|
||||
const tag = parseNameNoDupe(ctx) catch {
|
||||
ctx.offset = start;
|
||||
return null;
|
||||
};
|
||||
|
||||
const element = try alloc.create(Element);
|
||||
element.* = Element.init(try alloc.dupe(u8, tag), alloc);
|
||||
|
||||
while (ctx.eatWs()) {
|
||||
const attr = (try tryParseAttr(ctx, alloc)) orelse break;
|
||||
try element.attributes.append(attr);
|
||||
}
|
||||
|
||||
if (ctx.eatStr("/>")) {
|
||||
return element;
|
||||
}
|
||||
|
||||
try ctx.expect('>');
|
||||
|
||||
while (true) {
|
||||
if (ctx.peek() == null) {
|
||||
return error.UnexpectedEof;
|
||||
} else if (ctx.eatStr("</")) {
|
||||
break;
|
||||
}
|
||||
|
||||
const content = try parseContent(ctx, alloc);
|
||||
try element.children.append(content);
|
||||
}
|
||||
|
||||
const closing_tag = try parseNameNoDupe(ctx);
|
||||
if (!std.mem.eql(u8, tag, closing_tag)) {
|
||||
return error.NonMatchingClosingTag;
|
||||
}
|
||||
|
||||
_ = ctx.eatWs();
|
||||
try ctx.expect('>');
|
||||
return element;
|
||||
}
|
||||
|
||||
test "tryParseElement" {
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<= a='b'/>");
|
||||
try testing.expectEqual(@as(?*Element, null), try tryParseElement(&ctx, alloc));
|
||||
try testing.expectEqual(@as(?u8, '<'), ctx.peek());
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<python size='15' color = \"green\"/>");
|
||||
const elem = try tryParseElement(&ctx, alloc);
|
||||
try testing.expectEqualSlices(u8, elem.?.tag, "python");
|
||||
|
||||
const size_attr = elem.?.attributes.items[0];
|
||||
try testing.expectEqualSlices(u8, size_attr.name, "size");
|
||||
try testing.expectEqualSlices(u8, size_attr.value, "15");
|
||||
|
||||
const color_attr = elem.?.attributes.items[1];
|
||||
try testing.expectEqualSlices(u8, color_attr.name, "color");
|
||||
try testing.expectEqualSlices(u8, color_attr.value, "green");
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<python>test</python>");
|
||||
const elem = try tryParseElement(&ctx, alloc);
|
||||
try testing.expectEqualSlices(u8, elem.?.tag, "python");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[0].CharData, "test");
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<a>b<c/>d<e/>f<!--g--></a>");
|
||||
const elem = try tryParseElement(&ctx, alloc);
|
||||
try testing.expectEqualSlices(u8, elem.?.tag, "a");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[0].CharData, "b");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[1].Element.tag, "c");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[2].CharData, "d");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[3].Element.tag, "e");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[4].CharData, "f");
|
||||
try testing.expectEqualSlices(u8, elem.?.children.items[5].Comment, "g");
|
||||
}
|
||||
}
|
||||
|
||||
fn tryParseProlog(ctx: *ParseContext, alloc: Allocator) !?*XmlDecl {
|
||||
const start = ctx.offset;
|
||||
if (!ctx.eatStr("<?") or !mem.eql(u8, try parseNameNoDupe(ctx), "xml")) {
|
||||
ctx.offset = start;
|
||||
return null;
|
||||
}
|
||||
|
||||
const decl = try alloc.create(XmlDecl);
|
||||
decl.encoding = null;
|
||||
decl.standalone = null;
|
||||
|
||||
// Version info is mandatory
|
||||
try ctx.expectWs();
|
||||
try ctx.expectStr("version");
|
||||
decl.version = try parseEqAttrValue(ctx, alloc);
|
||||
|
||||
if (ctx.eatWs()) {
|
||||
// Optional encoding and standalone info
|
||||
var require_ws = false;
|
||||
|
||||
if (ctx.eatStr("encoding")) {
|
||||
decl.encoding = try parseEqAttrValue(ctx, alloc);
|
||||
require_ws = true;
|
||||
}
|
||||
|
||||
if (require_ws == ctx.eatWs() and ctx.eatStr("standalone")) {
|
||||
const standalone = try parseEqAttrValue(ctx, alloc);
|
||||
if (std.mem.eql(u8, standalone, "yes")) {
|
||||
decl.standalone = true;
|
||||
} else if (std.mem.eql(u8, standalone, "no")) {
|
||||
decl.standalone = false;
|
||||
} else {
|
||||
return error.InvalidStandaloneValue;
|
||||
}
|
||||
}
|
||||
|
||||
_ = ctx.eatWs();
|
||||
}
|
||||
|
||||
try ctx.expectStr("?>");
|
||||
return decl;
|
||||
}
|
||||
|
||||
test "tryParseProlog" {
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<?xmla version='aa'?>");
|
||||
try testing.expectEqual(@as(?*XmlDecl, null), try tryParseProlog(&ctx, alloc));
|
||||
try testing.expectEqual(@as(?u8, '<'), ctx.peek());
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<?xml version='aa'?>");
|
||||
const decl = try tryParseProlog(&ctx, alloc);
|
||||
try testing.expectEqualSlices(u8, "aa", decl.?.version);
|
||||
try testing.expectEqual(@as(?[]const u8, null), decl.?.encoding);
|
||||
try testing.expectEqual(@as(?bool, null), decl.?.standalone);
|
||||
}
|
||||
|
||||
{
|
||||
var ctx = ParseContext.init("<?xml version=\"aa\" encoding = 'bbb' standalone \t = 'yes'?>");
|
||||
const decl = try tryParseProlog(&ctx, alloc);
|
||||
try testing.expectEqualSlices(u8, "aa", decl.?.version);
|
||||
try testing.expectEqualSlices(u8, "bbb", decl.?.encoding.?);
|
||||
try testing.expectEqual(@as(?bool, true), decl.?.standalone.?);
|
||||
}
|
||||
}
|
||||
|
||||
fn trySkipComments(ctx: *ParseContext, alloc: Allocator) !void {
|
||||
while (try tryParseComment(ctx, alloc)) |_| {
|
||||
_ = ctx.eatWs();
|
||||
}
|
||||
}
|
||||
|
||||
fn tryParseComment(ctx: *ParseContext, alloc: Allocator) !?[]const u8 {
|
||||
if (!ctx.eatStr("<!--")) return null;
|
||||
|
||||
const begin = ctx.offset;
|
||||
while (!ctx.eatStr("-->")) {
|
||||
_ = ctx.consume() catch return error.UnclosedComment;
|
||||
}
|
||||
|
||||
const end = ctx.offset - "-->".len;
|
||||
return try alloc.dupe(u8, ctx.source[begin..end]);
|
||||
}
|
||||
|
||||
fn unescapeEntity(text: []const u8) !u8 {
|
||||
const EntitySubstition = struct { text: []const u8, replacement: u8 };
|
||||
|
||||
const entities = [_]EntitySubstition{
|
||||
.{ .text = "<", .replacement = '<' },
|
||||
.{ .text = ">", .replacement = '>' },
|
||||
.{ .text = "&", .replacement = '&' },
|
||||
.{ .text = "'", .replacement = '\'' },
|
||||
.{ .text = """, .replacement = '"' },
|
||||
};
|
||||
|
||||
for (entities) |entity| {
|
||||
if (std.mem.eql(u8, text, entity.text)) return entity.replacement;
|
||||
}
|
||||
|
||||
return error.InvalidEntity;
|
||||
}
|
||||
|
||||
fn dupeAndUnescape(alloc: Allocator, text: []const u8) ![]const u8 {
|
||||
const str = try alloc.alloc(u8, text.len);
|
||||
|
||||
var j: usize = 0;
|
||||
var i: usize = 0;
|
||||
while (i < text.len) : (j += 1) {
|
||||
if (text[i] == '&') {
|
||||
const entity_end = 1 + (mem.indexOfScalarPos(u8, text, i, ';') orelse return error.InvalidEntity);
|
||||
str[j] = try unescapeEntity(text[i..entity_end]);
|
||||
i = entity_end;
|
||||
} else {
|
||||
str[j] = text[i];
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return try alloc.realloc(str, j);
|
||||
}
|
||||
|
||||
test "dupeAndUnescape" {
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
try testing.expectEqualSlices(u8, "test", try dupeAndUnescape(alloc, "test"));
|
||||
try testing.expectEqualSlices(u8, "a<b&c>d\"e'f<", try dupeAndUnescape(alloc, "a<b&c>d"e'f<"));
|
||||
try testing.expectError(error.InvalidEntity, dupeAndUnescape(alloc, "python&"));
|
||||
try testing.expectError(error.InvalidEntity, dupeAndUnescape(alloc, "python&&"));
|
||||
try testing.expectError(error.InvalidEntity, dupeAndUnescape(alloc, "python&test;"));
|
||||
try testing.expectError(error.InvalidEntity, dupeAndUnescape(alloc, "python&boa"));
|
||||
}
|
||||
|
||||
test "Top level comments" {
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
const doc = try parse(alloc, "<?xml version='aa'?><!--comment--><python color='green'/><!--another comment-->");
|
||||
try testing.expectEqualSlices(u8, "python", doc.root.tag);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,245 +0,0 @@
|
|||
//
|
||||
// File: vk_icd.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2016 Valve Corporation
|
||||
* Copyright (c) 2015-2016 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef VKICD_H
|
||||
#define VKICD_H
|
||||
|
||||
#include "vulkan.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
// Loader-ICD version negotiation API. Versions add the following features:
|
||||
// Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr
|
||||
// or vk_icdNegotiateLoaderICDInterfaceVersion.
|
||||
// Version 1 - Add support for vk_icdGetInstanceProcAddr.
|
||||
// Version 2 - Add Loader/ICD Interface version negotiation
|
||||
// via vk_icdNegotiateLoaderICDInterfaceVersion.
|
||||
// Version 3 - Add ICD creation/destruction of KHR_surface objects.
|
||||
// Version 4 - Add unknown physical device extension querying via
|
||||
// vk_icdGetPhysicalDeviceProcAddr.
|
||||
// Version 5 - Tells ICDs that the loader is now paying attention to the
|
||||
// application version of Vulkan passed into the ApplicationInfo
|
||||
// structure during vkCreateInstance. This will tell the ICD
|
||||
// that if the loader is older, it should automatically fail a
|
||||
// call for any API version > 1.0. Otherwise, the loader will
|
||||
// manually determine if it can support the expected version.
|
||||
// Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices.
|
||||
#define CURRENT_LOADER_ICD_INTERFACE_VERSION 6
|
||||
#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
|
||||
#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
|
||||
|
||||
// Old typedefs that don't follow a proper naming convention but are preserved for compatibility
|
||||
typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
|
||||
// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
|
||||
// file directly, it won't be found.
|
||||
#ifndef PFN_GetPhysicalDeviceProcAddr
|
||||
typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
|
||||
#endif
|
||||
|
||||
// Typedefs for loader/ICD interface
|
||||
typedef VkResult (VKAPI_PTR *PFN_vk_icdNegotiateLoaderICDInterfaceVersion)(uint32_t* pVersion);
|
||||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetInstanceProcAddr)(VkInstance instance, const char* pName);
|
||||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
typedef VkResult (VKAPI_PTR *PFN_vk_icdEnumerateAdapterPhysicalDevices)(VkInstance instance, LUID adapterLUID,
|
||||
uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
|
||||
#endif
|
||||
|
||||
// Prototypes for loader/ICD interface
|
||||
#if !defined(VK_NO_PROTOTYPES)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pVersion);
|
||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName);
|
||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char* pName);
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID,
|
||||
uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ICD must reserve space for a pointer for the loader's dispatch
|
||||
* table, at the start of <each object>.
|
||||
* The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
|
||||
*/
|
||||
|
||||
#define ICD_LOADER_MAGIC 0x01CDC0DE
|
||||
|
||||
typedef union {
|
||||
uintptr_t loaderMagic;
|
||||
void *loaderData;
|
||||
} VK_LOADER_DATA;
|
||||
|
||||
static inline void set_loader_magic_value(void *pNewObject) {
|
||||
VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
|
||||
loader_info->loaderMagic = ICD_LOADER_MAGIC;
|
||||
}
|
||||
|
||||
static inline bool valid_loader_magic_value(void *pNewObject) {
|
||||
const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
|
||||
return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
|
||||
* contains the platform-specific connection and surface information.
|
||||
*/
|
||||
typedef enum {
|
||||
VK_ICD_WSI_PLATFORM_MIR,
|
||||
VK_ICD_WSI_PLATFORM_WAYLAND,
|
||||
VK_ICD_WSI_PLATFORM_WIN32,
|
||||
VK_ICD_WSI_PLATFORM_XCB,
|
||||
VK_ICD_WSI_PLATFORM_XLIB,
|
||||
VK_ICD_WSI_PLATFORM_ANDROID,
|
||||
VK_ICD_WSI_PLATFORM_MACOS,
|
||||
VK_ICD_WSI_PLATFORM_IOS,
|
||||
VK_ICD_WSI_PLATFORM_DISPLAY,
|
||||
VK_ICD_WSI_PLATFORM_HEADLESS,
|
||||
VK_ICD_WSI_PLATFORM_METAL,
|
||||
VK_ICD_WSI_PLATFORM_DIRECTFB,
|
||||
VK_ICD_WSI_PLATFORM_VI,
|
||||
VK_ICD_WSI_PLATFORM_GGP,
|
||||
VK_ICD_WSI_PLATFORM_SCREEN,
|
||||
} VkIcdWsiPlatform;
|
||||
|
||||
typedef struct {
|
||||
VkIcdWsiPlatform platform;
|
||||
} VkIcdSurfaceBase;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MIR_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
MirConnection *connection;
|
||||
MirSurface *mirSurface;
|
||||
} VkIcdSurfaceMir;
|
||||
#endif // VK_USE_PLATFORM_MIR_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
struct wl_display *display;
|
||||
struct wl_surface *surface;
|
||||
} VkIcdSurfaceWayland;
|
||||
#endif // VK_USE_PLATFORM_WAYLAND_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
HINSTANCE hinstance;
|
||||
HWND hwnd;
|
||||
} VkIcdSurfaceWin32;
|
||||
#endif // VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
xcb_connection_t *connection;
|
||||
xcb_window_t window;
|
||||
} VkIcdSurfaceXcb;
|
||||
#endif // VK_USE_PLATFORM_XCB_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
Display *dpy;
|
||||
Window window;
|
||||
} VkIcdSurfaceXlib;
|
||||
#endif // VK_USE_PLATFORM_XLIB_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
IDirectFB *dfb;
|
||||
IDirectFBSurface *surface;
|
||||
} VkIcdSurfaceDirectFB;
|
||||
#endif // VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
struct ANativeWindow *window;
|
||||
} VkIcdSurfaceAndroid;
|
||||
#endif // VK_USE_PLATFORM_ANDROID_KHR
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MACOS_MVK
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const void *pView;
|
||||
} VkIcdSurfaceMacOS;
|
||||
#endif // VK_USE_PLATFORM_MACOS_MVK
|
||||
|
||||
#ifdef VK_USE_PLATFORM_IOS_MVK
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const void *pView;
|
||||
} VkIcdSurfaceIOS;
|
||||
#endif // VK_USE_PLATFORM_IOS_MVK
|
||||
|
||||
#ifdef VK_USE_PLATFORM_GGP
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
GgpStreamDescriptor streamDescriptor;
|
||||
} VkIcdSurfaceGgp;
|
||||
#endif // VK_USE_PLATFORM_GGP
|
||||
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
VkDisplayModeKHR displayMode;
|
||||
uint32_t planeIndex;
|
||||
uint32_t planeStackIndex;
|
||||
VkSurfaceTransformFlagBitsKHR transform;
|
||||
float globalAlpha;
|
||||
VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
|
||||
VkExtent2D imageExtent;
|
||||
} VkIcdSurfaceDisplay;
|
||||
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
} VkIcdSurfaceHeadless;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
const CAMetalLayer *pLayer;
|
||||
} VkIcdSurfaceMetal;
|
||||
#endif // VK_USE_PLATFORM_METAL_EXT
|
||||
|
||||
#ifdef VK_USE_PLATFORM_VI_NN
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
void *window;
|
||||
} VkIcdSurfaceVi;
|
||||
#endif // VK_USE_PLATFORM_VI_NN
|
||||
|
||||
#ifdef VK_USE_PLATFORM_SCREEN_QNX
|
||||
typedef struct {
|
||||
VkIcdSurfaceBase base;
|
||||
struct _screen_context *context;
|
||||
struct _screen_window *window;
|
||||
} VkIcdSurfaceScreen;
|
||||
#endif // VK_USE_PLATFORM_SCREEN_QNX
|
||||
|
||||
#endif // VKICD_H
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
//
|
||||
// File: vk_layer.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2017 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2017 Valve Corporation
|
||||
* Copyright (c) 2015-2017 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Need to define dispatch table
|
||||
* Core struct can then have ptr to dispatch table at the top
|
||||
* Along with object ptrs for current and next OBJ
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "vulkan.h"
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define VK_LAYER_EXPORT __attribute__((visibility("default")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||
#define VK_LAYER_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define VK_LAYER_EXPORT
|
||||
#endif
|
||||
|
||||
#define MAX_NUM_UNKNOWN_EXTS 250
|
||||
|
||||
// Loader-Layer version negotiation API. Versions add the following features:
|
||||
// Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr
|
||||
// or vk_icdNegotiateLoaderLayerInterfaceVersion.
|
||||
// Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and
|
||||
// vk_icdNegotiateLoaderLayerInterfaceVersion.
|
||||
#define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2
|
||||
#define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1
|
||||
|
||||
#define VK_CURRENT_CHAIN_VERSION 1
|
||||
|
||||
// Typedef for use in the interfaces below
|
||||
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
|
||||
|
||||
// Version negotiation values
|
||||
typedef enum VkNegotiateLayerStructType {
|
||||
LAYER_NEGOTIATE_UNINTIALIZED = 0,
|
||||
LAYER_NEGOTIATE_INTERFACE_STRUCT = 1,
|
||||
} VkNegotiateLayerStructType;
|
||||
|
||||
// Version negotiation structures
|
||||
typedef struct VkNegotiateLayerInterface {
|
||||
VkNegotiateLayerStructType sType;
|
||||
void *pNext;
|
||||
uint32_t loaderLayerInterfaceVersion;
|
||||
PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr;
|
||||
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr;
|
||||
PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr;
|
||||
} VkNegotiateLayerInterface;
|
||||
|
||||
// Version negotiation functions
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct);
|
||||
|
||||
// Function prototype for unknown physical device extension command
|
||||
typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// CreateInstance and CreateDevice support structures
|
||||
|
||||
/* Sub type of structure for instance and device loader ext of CreateInfo.
|
||||
* When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
|
||||
* or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
|
||||
* then VkLayerFunction indicates struct type pointed to by pNext
|
||||
*/
|
||||
typedef enum VkLayerFunction_ {
|
||||
VK_LAYER_LINK_INFO = 0,
|
||||
VK_LOADER_DATA_CALLBACK = 1,
|
||||
VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2,
|
||||
VK_LOADER_FEATURES = 3,
|
||||
} VkLayerFunction;
|
||||
|
||||
typedef struct VkLayerInstanceLink_ {
|
||||
struct VkLayerInstanceLink_ *pNext;
|
||||
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
|
||||
PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr;
|
||||
} VkLayerInstanceLink;
|
||||
|
||||
/*
|
||||
* When creating the device chain the loader needs to pass
|
||||
* down information about it's device structure needed at
|
||||
* the end of the chain. Passing the data via the
|
||||
* VkLayerDeviceInfo avoids issues with finding the
|
||||
* exact instance being used.
|
||||
*/
|
||||
typedef struct VkLayerDeviceInfo_ {
|
||||
void *device_info;
|
||||
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
|
||||
} VkLayerDeviceInfo;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
|
||||
void *object);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
|
||||
void *object);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
|
||||
typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction);
|
||||
|
||||
typedef enum VkLoaderFeastureFlagBits {
|
||||
VK_LOADER_FEATURE_PHYSICAL_DEVICE_SORTING = 0x00000001,
|
||||
} VkLoaderFlagBits;
|
||||
typedef VkFlags VkLoaderFeatureFlags;
|
||||
|
||||
typedef struct {
|
||||
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
|
||||
const void *pNext;
|
||||
VkLayerFunction function;
|
||||
union {
|
||||
VkLayerInstanceLink *pLayerInfo;
|
||||
PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData;
|
||||
struct {
|
||||
PFN_vkLayerCreateDevice pfnLayerCreateDevice;
|
||||
PFN_vkLayerDestroyDevice pfnLayerDestroyDevice;
|
||||
} layerDevice;
|
||||
VkLoaderFeatureFlags loaderFeatures;
|
||||
} u;
|
||||
} VkLayerInstanceCreateInfo;
|
||||
|
||||
typedef struct VkLayerDeviceLink_ {
|
||||
struct VkLayerDeviceLink_ *pNext;
|
||||
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
|
||||
PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr;
|
||||
} VkLayerDeviceLink;
|
||||
|
||||
typedef struct {
|
||||
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
|
||||
const void *pNext;
|
||||
VkLayerFunction function;
|
||||
union {
|
||||
VkLayerDeviceLink *pLayerInfo;
|
||||
PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData;
|
||||
} u;
|
||||
} VkLayerDeviceCreateInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct);
|
||||
|
||||
typedef enum VkChainType {
|
||||
VK_CHAIN_TYPE_UNKNOWN = 0,
|
||||
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1,
|
||||
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2,
|
||||
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3,
|
||||
} VkChainType;
|
||||
|
||||
typedef struct VkChainHeader {
|
||||
VkChainType type;
|
||||
uint32_t version;
|
||||
uint32_t size;
|
||||
} VkChainHeader;
|
||||
|
||||
typedef struct VkEnumerateInstanceExtensionPropertiesChain {
|
||||
VkChainHeader header;
|
||||
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *,
|
||||
VkExtensionProperties *);
|
||||
const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const {
|
||||
return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties);
|
||||
}
|
||||
#endif
|
||||
} VkEnumerateInstanceExtensionPropertiesChain;
|
||||
|
||||
typedef struct VkEnumerateInstanceLayerPropertiesChain {
|
||||
VkChainHeader header;
|
||||
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *);
|
||||
const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const {
|
||||
return pfnNextLayer(pNextLink, pPropertyCount, pProperties);
|
||||
}
|
||||
#endif
|
||||
} VkEnumerateInstanceLayerPropertiesChain;
|
||||
|
||||
typedef struct VkEnumerateInstanceVersionChain {
|
||||
VkChainHeader header;
|
||||
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *);
|
||||
const struct VkEnumerateInstanceVersionChain *pNextLink;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline VkResult CallDown(uint32_t *pApiVersion) const {
|
||||
return pfnNextLayer(pNextLink, pApiVersion);
|
||||
}
|
||||
#endif
|
||||
} VkEnumerateInstanceVersionChain;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
//
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright 2014-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Platform-specific directives and type declarations
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
||||
* with the same calling conventions that the Vulkan implementation expects.
|
||||
*
|
||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
// On Windows, Vulkan commands use the stdcall convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL __stdcall
|
||||
#define VKAPI_PTR VKAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
||||
#error "Vulkan is not supported for the 'armeabi' NDK ABI"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
||||
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
|
||||
// calling convention, i.e. float parameters are passed in registers. This
|
||||
// is true even if the rest of the application passes floats on the stack,
|
||||
// as it does by default when compiling for the armeabi-v7a NDK ABI.
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR VKAPI_ATTR
|
||||
#else
|
||||
// On other platforms, use the default calling convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR
|
||||
#endif
|
||||
|
||||
#if !defined(VK_NO_STDDEF_H)
|
||||
#include <stddef.h>
|
||||
#endif // !defined(VK_NO_STDDEF_H)
|
||||
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif // !defined(VK_NO_STDINT_H)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
//
|
||||
// File: vk_sdk_platform.h
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The Khronos Group Inc.
|
||||
* Copyright (c) 2015-2016 Valve Corporation
|
||||
* Copyright (c) 2015-2016 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef VK_SDK_PLATFORM_H
|
||||
#define VK_SDK_PLATFORM_H
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define NOMINMAX
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#define inline __inline
|
||||
#endif // __cplusplus
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
|
||||
// C99:
|
||||
// Microsoft didn't implement C99 in Visual Studio; but started adding it with
|
||||
// VS2013. However, VS2013 still didn't have snprintf(). The following is a
|
||||
// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the
|
||||
// "CMakeLists.txt" file).
|
||||
// NOTE: This is fixed in Visual Studio 2015.
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define strdup _strdup
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
// Check for noexcept support using clang, with fallback to Windows or GCC version numbers
|
||||
#ifndef NOEXCEPT
|
||||
#if defined(__clang__)
|
||||
#if __has_feature(cxx_noexcept)
|
||||
#define HAS_NOEXCEPT
|
||||
#endif
|
||||
#else
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46
|
||||
#define HAS_NOEXCEPT
|
||||
#else
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS
|
||||
#define HAS_NOEXCEPT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAS_NOEXCEPT
|
||||
#define NOEXCEPT noexcept
|
||||
#else
|
||||
#define NOEXCEPT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // VK_SDK_PLATFORM_H
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
#ifndef VULKAN_H_
|
||||
#define VULKAN_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "vk_platform.h"
|
||||
#include "vulkan_core.h"
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include "vulkan_android.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
#include <zircon/types.h>
|
||||
#include "vulkan_fuchsia.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_IOS_MVK
|
||||
#include "vulkan_ios.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MACOS_MVK
|
||||
#include "vulkan_macos.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
#include "vulkan_metal.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_VI_NN
|
||||
#include "vulkan_vi.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#include <wayland-client.h>
|
||||
#include "vulkan_wayland.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
#include <windows.h>
|
||||
#include "vulkan_win32.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
#include <xcb/xcb.h>
|
||||
#include "vulkan_xcb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
#include <X11/Xlib.h>
|
||||
#include "vulkan_xlib.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
#include <directfb.h>
|
||||
#include "vulkan_directfb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include "vulkan_xlib_xrandr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_GGP
|
||||
#include <ggp_c/vulkan_types.h>
|
||||
#include "vulkan_ggp.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_SCREEN_QNX
|
||||
#include <screen/screen.h>
|
||||
#include "vulkan_screen.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
#include "vulkan_beta.h"
|
||||
#endif
|
||||
|
||||
#endif // VULKAN_H_
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
#ifndef VULKAN_ANDROID_H_
|
||||
#define VULKAN_ANDROID_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_android_surface 1
|
||||
struct ANativeWindow;
|
||||
#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
|
||||
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
|
||||
typedef struct VkAndroidSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkAndroidSurfaceCreateFlagsKHR flags;
|
||||
struct ANativeWindow* window;
|
||||
} VkAndroidSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_ANDROID_external_memory_android_hardware_buffer 1
|
||||
struct AHardwareBuffer;
|
||||
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 5
|
||||
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer"
|
||||
typedef struct VkAndroidHardwareBufferUsageANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint64_t androidHardwareBufferUsage;
|
||||
} VkAndroidHardwareBufferUsageANDROID;
|
||||
|
||||
typedef struct VkAndroidHardwareBufferPropertiesANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkDeviceSize allocationSize;
|
||||
uint32_t memoryTypeBits;
|
||||
} VkAndroidHardwareBufferPropertiesANDROID;
|
||||
|
||||
typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFormat format;
|
||||
uint64_t externalFormat;
|
||||
VkFormatFeatureFlags formatFeatures;
|
||||
VkComponentMapping samplerYcbcrConversionComponents;
|
||||
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
|
||||
VkSamplerYcbcrRange suggestedYcbcrRange;
|
||||
VkChromaLocation suggestedXChromaOffset;
|
||||
VkChromaLocation suggestedYChromaOffset;
|
||||
} VkAndroidHardwareBufferFormatPropertiesANDROID;
|
||||
|
||||
typedef struct VkImportAndroidHardwareBufferInfoANDROID {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
struct AHardwareBuffer* buffer;
|
||||
} VkImportAndroidHardwareBufferInfoANDROID;
|
||||
|
||||
typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceMemory memory;
|
||||
} VkMemoryGetAndroidHardwareBufferInfoANDROID;
|
||||
|
||||
typedef struct VkExternalFormatANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint64_t externalFormat;
|
||||
} VkExternalFormatANDROID;
|
||||
|
||||
typedef struct VkAndroidHardwareBufferFormatProperties2ANDROID {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFormat format;
|
||||
uint64_t externalFormat;
|
||||
VkFormatFeatureFlags2 formatFeatures;
|
||||
VkComponentMapping samplerYcbcrConversionComponents;
|
||||
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
|
||||
VkSamplerYcbcrRange suggestedYcbcrRange;
|
||||
VkChromaLocation suggestedXChromaOffset;
|
||||
VkChromaLocation suggestedYChromaOffset;
|
||||
} VkAndroidHardwareBufferFormatProperties2ANDROID;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(
|
||||
VkDevice device,
|
||||
const struct AHardwareBuffer* buffer,
|
||||
VkAndroidHardwareBufferPropertiesANDROID* pProperties);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(
|
||||
VkDevice device,
|
||||
const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo,
|
||||
struct AHardwareBuffer** pBuffer);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,990 +0,0 @@
|
|||
#ifndef VULKAN_BETA_H_
|
||||
#define VULKAN_BETA_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_video_queue 1
|
||||
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR)
|
||||
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR)
|
||||
#define VK_KHR_VIDEO_QUEUE_SPEC_VERSION 3
|
||||
#define VK_KHR_VIDEO_QUEUE_EXTENSION_NAME "VK_KHR_video_queue"
|
||||
|
||||
typedef enum VkQueryResultStatusKHR {
|
||||
VK_QUERY_RESULT_STATUS_ERROR_KHR = -1,
|
||||
VK_QUERY_RESULT_STATUS_NOT_READY_KHR = 0,
|
||||
VK_QUERY_RESULT_STATUS_COMPLETE_KHR = 1,
|
||||
VK_QUERY_RESULT_STATUS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkQueryResultStatusKHR;
|
||||
|
||||
typedef enum VkVideoCodecOperationFlagBitsKHR {
|
||||
VK_VIDEO_CODEC_OPERATION_INVALID_BIT_KHR = 0,
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT = 0x00010000,
|
||||
#endif
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT = 0x00020000,
|
||||
#endif
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_EXT = 0x00000001,
|
||||
#endif
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_EXT = 0x00000002,
|
||||
#endif
|
||||
VK_VIDEO_CODEC_OPERATION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoCodecOperationFlagBitsKHR;
|
||||
typedef VkFlags VkVideoCodecOperationFlagsKHR;
|
||||
|
||||
typedef enum VkVideoChromaSubsamplingFlagBitsKHR {
|
||||
VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_BIT_KHR = 0,
|
||||
VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR = 0x00000002,
|
||||
VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR = 0x00000004,
|
||||
VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR = 0x00000008,
|
||||
VK_VIDEO_CHROMA_SUBSAMPLING_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoChromaSubsamplingFlagBitsKHR;
|
||||
typedef VkFlags VkVideoChromaSubsamplingFlagsKHR;
|
||||
|
||||
typedef enum VkVideoComponentBitDepthFlagBitsKHR {
|
||||
VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR = 0,
|
||||
VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR = 0x00000004,
|
||||
VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR = 0x00000010,
|
||||
VK_VIDEO_COMPONENT_BIT_DEPTH_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoComponentBitDepthFlagBitsKHR;
|
||||
typedef VkFlags VkVideoComponentBitDepthFlagsKHR;
|
||||
|
||||
typedef enum VkVideoCapabilityFlagBitsKHR {
|
||||
VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR = 0x00000002,
|
||||
VK_VIDEO_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoCapabilityFlagBitsKHR;
|
||||
typedef VkFlags VkVideoCapabilityFlagsKHR;
|
||||
|
||||
typedef enum VkVideoSessionCreateFlagBitsKHR {
|
||||
VK_VIDEO_SESSION_CREATE_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_SESSION_CREATE_PROTECTED_CONTENT_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_SESSION_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoSessionCreateFlagBitsKHR;
|
||||
typedef VkFlags VkVideoSessionCreateFlagsKHR;
|
||||
typedef VkFlags VkVideoBeginCodingFlagsKHR;
|
||||
typedef VkFlags VkVideoEndCodingFlagsKHR;
|
||||
|
||||
typedef enum VkVideoCodingControlFlagBitsKHR {
|
||||
VK_VIDEO_CODING_CONTROL_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_CODING_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoCodingControlFlagBitsKHR;
|
||||
typedef VkFlags VkVideoCodingControlFlagsKHR;
|
||||
|
||||
typedef enum VkVideoCodingQualityPresetFlagBitsKHR {
|
||||
VK_VIDEO_CODING_QUALITY_PRESET_NORMAL_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_CODING_QUALITY_PRESET_POWER_BIT_KHR = 0x00000002,
|
||||
VK_VIDEO_CODING_QUALITY_PRESET_QUALITY_BIT_KHR = 0x00000004,
|
||||
VK_VIDEO_CODING_QUALITY_PRESET_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoCodingQualityPresetFlagBitsKHR;
|
||||
typedef VkFlags VkVideoCodingQualityPresetFlagsKHR;
|
||||
typedef struct VkQueueFamilyQueryResultStatusProperties2KHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 supported;
|
||||
} VkQueueFamilyQueryResultStatusProperties2KHR;
|
||||
|
||||
typedef struct VkVideoQueueFamilyProperties2KHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoCodecOperationFlagsKHR videoCodecOperations;
|
||||
} VkVideoQueueFamilyProperties2KHR;
|
||||
|
||||
typedef struct VkVideoProfileKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoCodecOperationFlagBitsKHR videoCodecOperation;
|
||||
VkVideoChromaSubsamplingFlagsKHR chromaSubsampling;
|
||||
VkVideoComponentBitDepthFlagsKHR lumaBitDepth;
|
||||
VkVideoComponentBitDepthFlagsKHR chromaBitDepth;
|
||||
} VkVideoProfileKHR;
|
||||
|
||||
typedef struct VkVideoProfilesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t profileCount;
|
||||
const VkVideoProfileKHR* pProfiles;
|
||||
} VkVideoProfilesKHR;
|
||||
|
||||
typedef struct VkVideoCapabilitiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoCapabilityFlagsKHR capabilityFlags;
|
||||
VkDeviceSize minBitstreamBufferOffsetAlignment;
|
||||
VkDeviceSize minBitstreamBufferSizeAlignment;
|
||||
VkExtent2D videoPictureExtentGranularity;
|
||||
VkExtent2D minExtent;
|
||||
VkExtent2D maxExtent;
|
||||
uint32_t maxReferencePicturesSlotsCount;
|
||||
uint32_t maxReferencePicturesActiveCount;
|
||||
VkExtensionProperties stdHeaderVersion;
|
||||
} VkVideoCapabilitiesKHR;
|
||||
|
||||
typedef struct VkPhysicalDeviceVideoFormatInfoKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkImageUsageFlags imageUsage;
|
||||
const VkVideoProfilesKHR* pVideoProfiles;
|
||||
} VkPhysicalDeviceVideoFormatInfoKHR;
|
||||
|
||||
typedef struct VkVideoFormatPropertiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFormat format;
|
||||
} VkVideoFormatPropertiesKHR;
|
||||
|
||||
typedef struct VkVideoPictureResourceKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkOffset2D codedOffset;
|
||||
VkExtent2D codedExtent;
|
||||
uint32_t baseArrayLayer;
|
||||
VkImageView imageViewBinding;
|
||||
} VkVideoPictureResourceKHR;
|
||||
|
||||
typedef struct VkVideoReferenceSlotKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
int8_t slotIndex;
|
||||
const VkVideoPictureResourceKHR* pPictureResource;
|
||||
} VkVideoReferenceSlotKHR;
|
||||
|
||||
typedef struct VkVideoGetMemoryPropertiesKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t memoryBindIndex;
|
||||
VkMemoryRequirements2* pMemoryRequirements;
|
||||
} VkVideoGetMemoryPropertiesKHR;
|
||||
|
||||
typedef struct VkVideoBindMemoryKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t memoryBindIndex;
|
||||
VkDeviceMemory memory;
|
||||
VkDeviceSize memoryOffset;
|
||||
VkDeviceSize memorySize;
|
||||
} VkVideoBindMemoryKHR;
|
||||
|
||||
typedef struct VkVideoSessionCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t queueFamilyIndex;
|
||||
VkVideoSessionCreateFlagsKHR flags;
|
||||
const VkVideoProfileKHR* pVideoProfile;
|
||||
VkFormat pictureFormat;
|
||||
VkExtent2D maxCodedExtent;
|
||||
VkFormat referencePicturesFormat;
|
||||
uint32_t maxReferencePicturesSlotsCount;
|
||||
uint32_t maxReferencePicturesActiveCount;
|
||||
const VkExtensionProperties* pStdHeaderVersion;
|
||||
} VkVideoSessionCreateInfoKHR;
|
||||
|
||||
typedef struct VkVideoSessionParametersCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoSessionParametersKHR videoSessionParametersTemplate;
|
||||
VkVideoSessionKHR videoSession;
|
||||
} VkVideoSessionParametersCreateInfoKHR;
|
||||
|
||||
typedef struct VkVideoSessionParametersUpdateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t updateSequenceCount;
|
||||
} VkVideoSessionParametersUpdateInfoKHR;
|
||||
|
||||
typedef struct VkVideoBeginCodingInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoBeginCodingFlagsKHR flags;
|
||||
VkVideoCodingQualityPresetFlagsKHR codecQualityPreset;
|
||||
VkVideoSessionKHR videoSession;
|
||||
VkVideoSessionParametersKHR videoSessionParameters;
|
||||
uint32_t referenceSlotCount;
|
||||
const VkVideoReferenceSlotKHR* pReferenceSlots;
|
||||
} VkVideoBeginCodingInfoKHR;
|
||||
|
||||
typedef struct VkVideoEndCodingInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoEndCodingFlagsKHR flags;
|
||||
} VkVideoEndCodingInfoKHR;
|
||||
|
||||
typedef struct VkVideoCodingControlInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoCodingControlFlagsKHR flags;
|
||||
} VkVideoCodingControlInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)(VkPhysicalDevice physicalDevice, const VkVideoProfileKHR* pVideoProfile, VkVideoCapabilitiesKHR* pCapabilities);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, uint32_t* pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR* pVideoFormatProperties);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionKHR)(VkDevice device, const VkVideoSessionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionKHR* pVideoSession);
|
||||
typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionKHR)(VkDevice device, VkVideoSessionKHR videoSession, const VkAllocationCallbacks* pAllocator);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetVideoSessionMemoryRequirementsKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pVideoSessionMemoryRequirementsCount, VkVideoGetMemoryPropertiesKHR* pVideoSessionMemoryRequirements);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkBindVideoSessionMemoryKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t videoSessionBindMemoryCount, const VkVideoBindMemoryKHR* pVideoSessionBindMemories);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionParametersKHR)(VkDevice device, const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionParametersKHR* pVideoSessionParameters);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkUpdateVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkAllocationCallbacks* pAllocator);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdBeginVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoBeginCodingInfoKHR* pBeginInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdEndVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoEndCodingInfoKHR* pEndCodingInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdControlVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoCodingControlInfoKHR* pCodingControlInfo);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoCapabilitiesKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkVideoProfileKHR* pVideoProfile,
|
||||
VkVideoCapabilitiesKHR* pCapabilities);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoFormatPropertiesKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo,
|
||||
uint32_t* pVideoFormatPropertyCount,
|
||||
VkVideoFormatPropertiesKHR* pVideoFormatProperties);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionKHR(
|
||||
VkDevice device,
|
||||
const VkVideoSessionCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkVideoSessionKHR* pVideoSession);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionKHR(
|
||||
VkDevice device,
|
||||
VkVideoSessionKHR videoSession,
|
||||
const VkAllocationCallbacks* pAllocator);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetVideoSessionMemoryRequirementsKHR(
|
||||
VkDevice device,
|
||||
VkVideoSessionKHR videoSession,
|
||||
uint32_t* pVideoSessionMemoryRequirementsCount,
|
||||
VkVideoGetMemoryPropertiesKHR* pVideoSessionMemoryRequirements);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkBindVideoSessionMemoryKHR(
|
||||
VkDevice device,
|
||||
VkVideoSessionKHR videoSession,
|
||||
uint32_t videoSessionBindMemoryCount,
|
||||
const VkVideoBindMemoryKHR* pVideoSessionBindMemories);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionParametersKHR(
|
||||
VkDevice device,
|
||||
const VkVideoSessionParametersCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkVideoSessionParametersKHR* pVideoSessionParameters);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkUpdateVideoSessionParametersKHR(
|
||||
VkDevice device,
|
||||
VkVideoSessionParametersKHR videoSessionParameters,
|
||||
const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionParametersKHR(
|
||||
VkDevice device,
|
||||
VkVideoSessionParametersKHR videoSessionParameters,
|
||||
const VkAllocationCallbacks* pAllocator);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdBeginVideoCodingKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkVideoBeginCodingInfoKHR* pBeginInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdEndVideoCodingKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkVideoEndCodingInfoKHR* pEndCodingInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdControlVideoCodingKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkVideoCodingControlInfoKHR* pCodingControlInfo);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_video_decode_queue 1
|
||||
#define VK_KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION 4
|
||||
#define VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME "VK_KHR_video_decode_queue"
|
||||
|
||||
typedef enum VkVideoDecodeCapabilityFlagBitsKHR {
|
||||
VK_VIDEO_DECODE_CAPABILITY_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR = 0x00000002,
|
||||
VK_VIDEO_DECODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoDecodeCapabilityFlagBitsKHR;
|
||||
typedef VkFlags VkVideoDecodeCapabilityFlagsKHR;
|
||||
|
||||
typedef enum VkVideoDecodeFlagBitsKHR {
|
||||
VK_VIDEO_DECODE_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_DECODE_RESERVED_0_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_DECODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoDecodeFlagBitsKHR;
|
||||
typedef VkFlags VkVideoDecodeFlagsKHR;
|
||||
typedef struct VkVideoDecodeCapabilitiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoDecodeCapabilityFlagsKHR flags;
|
||||
} VkVideoDecodeCapabilitiesKHR;
|
||||
|
||||
typedef struct VkVideoDecodeInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoDecodeFlagsKHR flags;
|
||||
VkBuffer srcBuffer;
|
||||
VkDeviceSize srcBufferOffset;
|
||||
VkDeviceSize srcBufferRange;
|
||||
VkVideoPictureResourceKHR dstPictureResource;
|
||||
const VkVideoReferenceSlotKHR* pSetupReferenceSlot;
|
||||
uint32_t referenceSlotCount;
|
||||
const VkVideoReferenceSlotKHR* pReferenceSlots;
|
||||
} VkVideoDecodeInfoKHR;
|
||||
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdDecodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoDecodeInfoKHR* pFrameInfo);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdDecodeVideoKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkVideoDecodeInfoKHR* pFrameInfo);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_portability_subset 1
|
||||
#define VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION 1
|
||||
#define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset"
|
||||
typedef struct VkPhysicalDevicePortabilitySubsetFeaturesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 constantAlphaColorBlendFactors;
|
||||
VkBool32 events;
|
||||
VkBool32 imageViewFormatReinterpretation;
|
||||
VkBool32 imageViewFormatSwizzle;
|
||||
VkBool32 imageView2DOn3DImage;
|
||||
VkBool32 multisampleArrayImage;
|
||||
VkBool32 mutableComparisonSamplers;
|
||||
VkBool32 pointPolygons;
|
||||
VkBool32 samplerMipLodBias;
|
||||
VkBool32 separateStencilMaskRef;
|
||||
VkBool32 shaderSampleRateInterpolationFunctions;
|
||||
VkBool32 tessellationIsolines;
|
||||
VkBool32 tessellationPointMode;
|
||||
VkBool32 triangleFans;
|
||||
VkBool32 vertexAttributeAccessBeyondStride;
|
||||
} VkPhysicalDevicePortabilitySubsetFeaturesKHR;
|
||||
|
||||
typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t minVertexInputBindingStrideAlignment;
|
||||
} VkPhysicalDevicePortabilitySubsetPropertiesKHR;
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_video_encode_queue 1
|
||||
#define VK_KHR_VIDEO_ENCODE_QUEUE_SPEC_VERSION 5
|
||||
#define VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME "VK_KHR_video_encode_queue"
|
||||
|
||||
typedef enum VkVideoEncodeFlagBitsKHR {
|
||||
VK_VIDEO_ENCODE_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_ENCODE_RESERVED_0_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_ENCODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoEncodeFlagBitsKHR;
|
||||
typedef VkFlags VkVideoEncodeFlagsKHR;
|
||||
|
||||
typedef enum VkVideoEncodeCapabilityFlagBitsKHR {
|
||||
VK_VIDEO_ENCODE_CAPABILITY_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_ENCODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoEncodeCapabilityFlagBitsKHR;
|
||||
typedef VkFlags VkVideoEncodeCapabilityFlagsKHR;
|
||||
|
||||
typedef enum VkVideoEncodeRateControlModeFlagBitsKHR {
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR = 0,
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR = 1,
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR = 2,
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoEncodeRateControlModeFlagBitsKHR;
|
||||
typedef VkFlags VkVideoEncodeRateControlModeFlagsKHR;
|
||||
|
||||
typedef enum VkVideoEncodeRateControlFlagBitsKHR {
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_DEFAULT_KHR = 0,
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_RESERVED_0_BIT_KHR = 0x00000001,
|
||||
VK_VIDEO_ENCODE_RATE_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
|
||||
} VkVideoEncodeRateControlFlagBitsKHR;
|
||||
typedef VkFlags VkVideoEncodeRateControlFlagsKHR;
|
||||
typedef struct VkVideoEncodeInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoEncodeFlagsKHR flags;
|
||||
uint32_t qualityLevel;
|
||||
VkBuffer dstBitstreamBuffer;
|
||||
VkDeviceSize dstBitstreamBufferOffset;
|
||||
VkDeviceSize dstBitstreamBufferMaxRange;
|
||||
VkVideoPictureResourceKHR srcPictureResource;
|
||||
const VkVideoReferenceSlotKHR* pSetupReferenceSlot;
|
||||
uint32_t referenceSlotCount;
|
||||
const VkVideoReferenceSlotKHR* pReferenceSlots;
|
||||
uint32_t precedingExternallyEncodedBytes;
|
||||
} VkVideoEncodeInfoKHR;
|
||||
|
||||
typedef struct VkVideoEncodeCapabilitiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoEncodeCapabilityFlagsKHR flags;
|
||||
VkVideoEncodeRateControlModeFlagsKHR rateControlModes;
|
||||
uint8_t rateControlLayerCount;
|
||||
uint8_t qualityLevelCount;
|
||||
VkExtent2D inputImageDataFillAlignment;
|
||||
} VkVideoEncodeCapabilitiesKHR;
|
||||
|
||||
typedef struct VkVideoEncodeRateControlLayerInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t averageBitrate;
|
||||
uint32_t maxBitrate;
|
||||
uint32_t frameRateNumerator;
|
||||
uint32_t frameRateDenominator;
|
||||
uint32_t virtualBufferSizeInMs;
|
||||
uint32_t initialVirtualBufferSizeInMs;
|
||||
} VkVideoEncodeRateControlLayerInfoKHR;
|
||||
|
||||
typedef struct VkVideoEncodeRateControlInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkVideoEncodeRateControlFlagsKHR flags;
|
||||
VkVideoEncodeRateControlModeFlagBitsKHR rateControlMode;
|
||||
uint8_t layerCount;
|
||||
const VkVideoEncodeRateControlLayerInfoKHR* pLayerConfigs;
|
||||
} VkVideoEncodeRateControlInfoKHR;
|
||||
|
||||
typedef void (VKAPI_PTR *PFN_vkCmdEncodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoEncodeInfoKHR* pEncodeInfo);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdEncodeVideoKHR(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkVideoEncodeInfoKHR* pEncodeInfo);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_EXT_video_encode_h264 1
|
||||
#include "vk_video/vulkan_video_codec_h264std.h"
|
||||
#include "vk_video/vulkan_video_codec_h264std_encode.h"
|
||||
#define VK_EXT_VIDEO_ENCODE_H264_SPEC_VERSION 7
|
||||
#define VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME "VK_EXT_video_encode_h264"
|
||||
|
||||
typedef enum VkVideoEncodeH264CapabilityFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DIRECT_8X8_INFERENCE_ENABLED_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DIRECT_8X8_INFERENCE_DISABLED_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_SEPARATE_COLOUR_PLANE_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_QPPRIME_Y_ZERO_TRANSFORM_BYPASS_BIT_EXT = 0x00000008,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_SCALING_LISTS_BIT_EXT = 0x00000010,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_EXT = 0x00000020,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_CHROMA_QP_OFFSET_BIT_EXT = 0x00000040,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_SECOND_CHROMA_QP_OFFSET_BIT_EXT = 0x00000080,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_PIC_INIT_QP_MINUS26_BIT_EXT = 0x00000100,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_PRED_BIT_EXT = 0x00000200,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BIPRED_EXPLICIT_BIT_EXT = 0x00000400,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BIPRED_IMPLICIT_BIT_EXT = 0x00000800,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_PRED_NO_TABLE_BIT_EXT = 0x00001000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_TRANSFORM_8X8_BIT_EXT = 0x00002000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_CABAC_BIT_EXT = 0x00004000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_CAVLC_BIT_EXT = 0x00008000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_DISABLED_BIT_EXT = 0x00010000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_ENABLED_BIT_EXT = 0x00020000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_PARTIAL_BIT_EXT = 0x00040000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DISABLE_DIRECT_SPATIAL_MV_PRED_BIT_EXT = 0x00080000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_MULTIPLE_SLICE_PER_FRAME_BIT_EXT = 0x00100000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_SLICE_MB_COUNT_BIT_EXT = 0x00200000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_EXT = 0x00400000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_EXT = 0x00800000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT = 0x01000000,
|
||||
VK_VIDEO_ENCODE_H264_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH264CapabilityFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH264CapabilityFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH264InputModeFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H264_INPUT_MODE_FRAME_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H264_INPUT_MODE_SLICE_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H264_INPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H264_INPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH264InputModeFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH264InputModeFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH264OutputModeFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FRAME_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_SLICE_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH264OutputModeFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH264OutputModeFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH264RateControlStructureFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT = 0,
|
||||
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_FLAT_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_DYADIC_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH264RateControlStructureFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH264RateControlStructureFlagsEXT;
|
||||
typedef struct VkVideoEncodeH264CapabilitiesEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoEncodeH264CapabilityFlagsEXT flags;
|
||||
VkVideoEncodeH264InputModeFlagsEXT inputModeFlags;
|
||||
VkVideoEncodeH264OutputModeFlagsEXT outputModeFlags;
|
||||
uint8_t maxPPictureL0ReferenceCount;
|
||||
uint8_t maxBPictureL0ReferenceCount;
|
||||
uint8_t maxL1ReferenceCount;
|
||||
VkBool32 motionVectorsOverPicBoundariesFlag;
|
||||
uint32_t maxBytesPerPicDenom;
|
||||
uint32_t maxBitsPerMbDenom;
|
||||
uint32_t log2MaxMvLengthHorizontal;
|
||||
uint32_t log2MaxMvLengthVertical;
|
||||
} VkVideoEncodeH264CapabilitiesEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264SessionParametersAddInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t spsStdCount;
|
||||
const StdVideoH264SequenceParameterSet* pSpsStd;
|
||||
uint32_t ppsStdCount;
|
||||
const StdVideoH264PictureParameterSet* pPpsStd;
|
||||
} VkVideoEncodeH264SessionParametersAddInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264SessionParametersCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t maxSpsStdCount;
|
||||
uint32_t maxPpsStdCount;
|
||||
const VkVideoEncodeH264SessionParametersAddInfoEXT* pParametersAddInfo;
|
||||
} VkVideoEncodeH264SessionParametersCreateInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264DpbSlotInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
int8_t slotIndex;
|
||||
const StdVideoEncodeH264ReferenceInfo* pStdReferenceInfo;
|
||||
} VkVideoEncodeH264DpbSlotInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264ReferenceListsEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint8_t referenceList0EntryCount;
|
||||
const VkVideoEncodeH264DpbSlotInfoEXT* pReferenceList0Entries;
|
||||
uint8_t referenceList1EntryCount;
|
||||
const VkVideoEncodeH264DpbSlotInfoEXT* pReferenceList1Entries;
|
||||
const StdVideoEncodeH264RefMemMgmtCtrlOperations* pMemMgmtCtrlOperations;
|
||||
} VkVideoEncodeH264ReferenceListsEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264NaluSliceEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t mbCount;
|
||||
const VkVideoEncodeH264ReferenceListsEXT* pReferenceFinalLists;
|
||||
const StdVideoEncodeH264SliceHeader* pSliceHeaderStd;
|
||||
} VkVideoEncodeH264NaluSliceEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264VclFrameInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const VkVideoEncodeH264ReferenceListsEXT* pReferenceFinalLists;
|
||||
uint32_t naluSliceEntryCount;
|
||||
const VkVideoEncodeH264NaluSliceEXT* pNaluSliceEntries;
|
||||
const StdVideoEncodeH264PictureInfo* pCurrentPictureInfo;
|
||||
} VkVideoEncodeH264VclFrameInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264EmitPictureParametersEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint8_t spsId;
|
||||
VkBool32 emitSpsEnable;
|
||||
uint32_t ppsIdEntryCount;
|
||||
const uint8_t* ppsIdEntries;
|
||||
} VkVideoEncodeH264EmitPictureParametersEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264ProfileEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
StdVideoH264ProfileIdc stdProfileIdc;
|
||||
} VkVideoEncodeH264ProfileEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264RateControlInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t gopFrameCount;
|
||||
uint32_t idrPeriod;
|
||||
uint32_t consecutiveBFrameCount;
|
||||
VkVideoEncodeH264RateControlStructureFlagBitsEXT rateControlStructure;
|
||||
uint8_t temporalLayerCount;
|
||||
} VkVideoEncodeH264RateControlInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264QpEXT {
|
||||
int32_t qpI;
|
||||
int32_t qpP;
|
||||
int32_t qpB;
|
||||
} VkVideoEncodeH264QpEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264FrameSizeEXT {
|
||||
uint32_t frameISize;
|
||||
uint32_t framePSize;
|
||||
uint32_t frameBSize;
|
||||
} VkVideoEncodeH264FrameSizeEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH264RateControlLayerInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint8_t temporalLayerId;
|
||||
VkBool32 useInitialRcQp;
|
||||
VkVideoEncodeH264QpEXT initialRcQp;
|
||||
VkBool32 useMinQp;
|
||||
VkVideoEncodeH264QpEXT minQp;
|
||||
VkBool32 useMaxQp;
|
||||
VkVideoEncodeH264QpEXT maxQp;
|
||||
VkBool32 useMaxFrameSize;
|
||||
VkVideoEncodeH264FrameSizeEXT maxFrameSize;
|
||||
} VkVideoEncodeH264RateControlLayerInfoEXT;
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_video_encode_h265 1
|
||||
#include "vk_video/vulkan_video_codec_h265std.h"
|
||||
#include "vk_video/vulkan_video_codec_h265std_encode.h"
|
||||
#define VK_EXT_VIDEO_ENCODE_H265_SPEC_VERSION 7
|
||||
#define VK_EXT_VIDEO_ENCODE_H265_EXTENSION_NAME "VK_EXT_video_encode_h265"
|
||||
|
||||
typedef enum VkVideoEncodeH265CapabilityFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_SEPARATE_COLOUR_PLANE_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_SCALING_LISTS_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_SAMPLE_ADAPTIVE_OFFSET_ENABLED_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_PCM_ENABLE_BIT_EXT = 0x00000008,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_SPS_TEMPORAL_MVP_ENABLED_BIT_EXT = 0x00000010,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_EXT = 0x00000020,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_INIT_QP_MINUS26_BIT_EXT = 0x00000040,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_LOG2_PARALLEL_MERGE_LEVEL_MINUS2_BIT_EXT = 0x00000080,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_SIGN_DATA_HIDING_ENABLED_BIT_EXT = 0x00000100,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSFORM_SKIP_ENABLED_BIT_EXT = 0x00000200,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSFORM_SKIP_DISABLED_BIT_EXT = 0x00000400,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT_BIT_EXT = 0x00000800,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_PRED_BIT_EXT = 0x00001000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_BIPRED_BIT_EXT = 0x00002000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_PRED_NO_TABLE_BIT_EXT = 0x00004000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSQUANT_BYPASS_ENABLED_BIT_EXT = 0x00008000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_ENTROPY_CODING_SYNC_ENABLED_BIT_EXT = 0x00010000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_DEBLOCKING_FILTER_OVERRIDE_ENABLED_BIT_EXT = 0x00020000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILE_PER_FRAME_BIT_EXT = 0x00040000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_PER_TILE_BIT_EXT = 0x00080000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILE_PER_SLICE_BIT_EXT = 0x00100000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_SLICE_SEGMENT_CTB_COUNT_BIT_EXT = 0x00200000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_EXT = 0x00400000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_DEPENDENT_SLICE_SEGMENT_BIT_EXT = 0x00800000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_EXT = 0x01000000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT = 0x02000000,
|
||||
VK_VIDEO_ENCODE_H265_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH265CapabilityFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH265CapabilityFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH265InputModeFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H265_INPUT_MODE_FRAME_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H265_INPUT_MODE_SLICE_SEGMENT_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H265_INPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H265_INPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH265InputModeFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH265InputModeFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH265OutputModeFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_FRAME_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_SLICE_SEGMENT_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_NON_VCL_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H265_OUTPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH265OutputModeFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH265OutputModeFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH265CtbSizeFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H265_CTB_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH265CtbSizeFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH265CtbSizeFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH265TransformBlockSizeFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_4_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_8_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_16_BIT_EXT = 0x00000004,
|
||||
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_32_BIT_EXT = 0x00000008,
|
||||
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH265TransformBlockSizeFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH265TransformBlockSizeFlagsEXT;
|
||||
|
||||
typedef enum VkVideoEncodeH265RateControlStructureFlagBitsEXT {
|
||||
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT = 0,
|
||||
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_FLAT_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_DYADIC_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoEncodeH265RateControlStructureFlagBitsEXT;
|
||||
typedef VkFlags VkVideoEncodeH265RateControlStructureFlagsEXT;
|
||||
typedef struct VkVideoEncodeH265CapabilitiesEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkVideoEncodeH265CapabilityFlagsEXT flags;
|
||||
VkVideoEncodeH265InputModeFlagsEXT inputModeFlags;
|
||||
VkVideoEncodeH265OutputModeFlagsEXT outputModeFlags;
|
||||
VkVideoEncodeH265CtbSizeFlagsEXT ctbSizes;
|
||||
VkVideoEncodeH265TransformBlockSizeFlagsEXT transformBlockSizes;
|
||||
uint8_t maxPPictureL0ReferenceCount;
|
||||
uint8_t maxBPictureL0ReferenceCount;
|
||||
uint8_t maxL1ReferenceCount;
|
||||
uint8_t maxSubLayersCount;
|
||||
uint8_t minLog2MinLumaCodingBlockSizeMinus3;
|
||||
uint8_t maxLog2MinLumaCodingBlockSizeMinus3;
|
||||
uint8_t minLog2MinLumaTransformBlockSizeMinus2;
|
||||
uint8_t maxLog2MinLumaTransformBlockSizeMinus2;
|
||||
uint8_t minMaxTransformHierarchyDepthInter;
|
||||
uint8_t maxMaxTransformHierarchyDepthInter;
|
||||
uint8_t minMaxTransformHierarchyDepthIntra;
|
||||
uint8_t maxMaxTransformHierarchyDepthIntra;
|
||||
uint8_t maxDiffCuQpDeltaDepth;
|
||||
uint8_t minMaxNumMergeCand;
|
||||
uint8_t maxMaxNumMergeCand;
|
||||
} VkVideoEncodeH265CapabilitiesEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265SessionParametersAddInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t vpsStdCount;
|
||||
const StdVideoH265VideoParameterSet* pVpsStd;
|
||||
uint32_t spsStdCount;
|
||||
const StdVideoH265SequenceParameterSet* pSpsStd;
|
||||
uint32_t ppsStdCount;
|
||||
const StdVideoH265PictureParameterSet* pPpsStd;
|
||||
} VkVideoEncodeH265SessionParametersAddInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265SessionParametersCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t maxVpsStdCount;
|
||||
uint32_t maxSpsStdCount;
|
||||
uint32_t maxPpsStdCount;
|
||||
const VkVideoEncodeH265SessionParametersAddInfoEXT* pParametersAddInfo;
|
||||
} VkVideoEncodeH265SessionParametersCreateInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265DpbSlotInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
int8_t slotIndex;
|
||||
const StdVideoEncodeH265ReferenceInfo* pStdReferenceInfo;
|
||||
} VkVideoEncodeH265DpbSlotInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265ReferenceListsEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint8_t referenceList0EntryCount;
|
||||
const VkVideoEncodeH265DpbSlotInfoEXT* pReferenceList0Entries;
|
||||
uint8_t referenceList1EntryCount;
|
||||
const VkVideoEncodeH265DpbSlotInfoEXT* pReferenceList1Entries;
|
||||
const StdVideoEncodeH265ReferenceModifications* pReferenceModifications;
|
||||
} VkVideoEncodeH265ReferenceListsEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265NaluSliceSegmentEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t ctbCount;
|
||||
const VkVideoEncodeH265ReferenceListsEXT* pReferenceFinalLists;
|
||||
const StdVideoEncodeH265SliceSegmentHeader* pSliceSegmentHeaderStd;
|
||||
} VkVideoEncodeH265NaluSliceSegmentEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265VclFrameInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const VkVideoEncodeH265ReferenceListsEXT* pReferenceFinalLists;
|
||||
uint32_t naluSliceSegmentEntryCount;
|
||||
const VkVideoEncodeH265NaluSliceSegmentEXT* pNaluSliceSegmentEntries;
|
||||
const StdVideoEncodeH265PictureInfo* pCurrentPictureInfo;
|
||||
} VkVideoEncodeH265VclFrameInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265EmitPictureParametersEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint8_t vpsId;
|
||||
uint8_t spsId;
|
||||
VkBool32 emitVpsEnable;
|
||||
VkBool32 emitSpsEnable;
|
||||
uint32_t ppsIdEntryCount;
|
||||
const uint8_t* ppsIdEntries;
|
||||
} VkVideoEncodeH265EmitPictureParametersEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265ProfileEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
StdVideoH265ProfileIdc stdProfileIdc;
|
||||
} VkVideoEncodeH265ProfileEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265RateControlInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t gopFrameCount;
|
||||
uint32_t idrPeriod;
|
||||
uint32_t consecutiveBFrameCount;
|
||||
VkVideoEncodeH265RateControlStructureFlagBitsEXT rateControlStructure;
|
||||
uint8_t subLayerCount;
|
||||
} VkVideoEncodeH265RateControlInfoEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265QpEXT {
|
||||
int32_t qpI;
|
||||
int32_t qpP;
|
||||
int32_t qpB;
|
||||
} VkVideoEncodeH265QpEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265FrameSizeEXT {
|
||||
uint32_t frameISize;
|
||||
uint32_t framePSize;
|
||||
uint32_t frameBSize;
|
||||
} VkVideoEncodeH265FrameSizeEXT;
|
||||
|
||||
typedef struct VkVideoEncodeH265RateControlLayerInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint8_t temporalId;
|
||||
VkBool32 useInitialRcQp;
|
||||
VkVideoEncodeH265QpEXT initialRcQp;
|
||||
VkBool32 useMinQp;
|
||||
VkVideoEncodeH265QpEXT minQp;
|
||||
VkBool32 useMaxQp;
|
||||
VkVideoEncodeH265QpEXT maxQp;
|
||||
VkBool32 useMaxFrameSize;
|
||||
VkVideoEncodeH265FrameSizeEXT maxFrameSize;
|
||||
} VkVideoEncodeH265RateControlLayerInfoEXT;
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_video_decode_h264 1
|
||||
#include "vk_video/vulkan_video_codec_h264std_decode.h"
|
||||
#define VK_EXT_VIDEO_DECODE_H264_SPEC_VERSION 5
|
||||
#define VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME "VK_EXT_video_decode_h264"
|
||||
|
||||
typedef enum VkVideoDecodeH264PictureLayoutFlagBitsEXT {
|
||||
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_EXT = 0,
|
||||
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_EXT = 0x00000001,
|
||||
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_EXT = 0x00000002,
|
||||
VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkVideoDecodeH264PictureLayoutFlagBitsEXT;
|
||||
typedef VkFlags VkVideoDecodeH264PictureLayoutFlagsEXT;
|
||||
typedef struct VkVideoDecodeH264ProfileEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
StdVideoH264ProfileIdc stdProfileIdc;
|
||||
VkVideoDecodeH264PictureLayoutFlagsEXT pictureLayout;
|
||||
} VkVideoDecodeH264ProfileEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH264CapabilitiesEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
StdVideoH264Level maxLevel;
|
||||
VkOffset2D fieldOffsetGranularity;
|
||||
} VkVideoDecodeH264CapabilitiesEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH264SessionParametersAddInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t spsStdCount;
|
||||
const StdVideoH264SequenceParameterSet* pSpsStd;
|
||||
uint32_t ppsStdCount;
|
||||
const StdVideoH264PictureParameterSet* pPpsStd;
|
||||
} VkVideoDecodeH264SessionParametersAddInfoEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH264SessionParametersCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t maxSpsStdCount;
|
||||
uint32_t maxPpsStdCount;
|
||||
const VkVideoDecodeH264SessionParametersAddInfoEXT* pParametersAddInfo;
|
||||
} VkVideoDecodeH264SessionParametersCreateInfoEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH264PictureInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const StdVideoDecodeH264PictureInfo* pStdPictureInfo;
|
||||
uint32_t slicesCount;
|
||||
const uint32_t* pSlicesDataOffsets;
|
||||
} VkVideoDecodeH264PictureInfoEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH264MvcEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const StdVideoDecodeH264Mvc* pStdMvc;
|
||||
} VkVideoDecodeH264MvcEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH264DpbSlotInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const StdVideoDecodeH264ReferenceInfo* pStdReferenceInfo;
|
||||
} VkVideoDecodeH264DpbSlotInfoEXT;
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_video_decode_h265 1
|
||||
#include "vk_video/vulkan_video_codec_h265std_decode.h"
|
||||
#define VK_EXT_VIDEO_DECODE_H265_SPEC_VERSION 3
|
||||
#define VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME "VK_EXT_video_decode_h265"
|
||||
typedef struct VkVideoDecodeH265ProfileEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
StdVideoH265ProfileIdc stdProfileIdc;
|
||||
} VkVideoDecodeH265ProfileEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH265CapabilitiesEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
StdVideoH265Level maxLevel;
|
||||
} VkVideoDecodeH265CapabilitiesEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH265SessionParametersAddInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t vpsStdCount;
|
||||
const StdVideoH265VideoParameterSet* pVpsStd;
|
||||
uint32_t spsStdCount;
|
||||
const StdVideoH265SequenceParameterSet* pSpsStd;
|
||||
uint32_t ppsStdCount;
|
||||
const StdVideoH265PictureParameterSet* pPpsStd;
|
||||
} VkVideoDecodeH265SessionParametersAddInfoEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH265SessionParametersCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t maxVpsStdCount;
|
||||
uint32_t maxSpsStdCount;
|
||||
uint32_t maxPpsStdCount;
|
||||
const VkVideoDecodeH265SessionParametersAddInfoEXT* pParametersAddInfo;
|
||||
} VkVideoDecodeH265SessionParametersCreateInfoEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH265PictureInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
StdVideoDecodeH265PictureInfo* pStdPictureInfo;
|
||||
uint32_t slicesCount;
|
||||
const uint32_t* pSlicesDataOffsets;
|
||||
} VkVideoDecodeH265PictureInfoEXT;
|
||||
|
||||
typedef struct VkVideoDecodeH265DpbSlotInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const StdVideoDecodeH265ReferenceInfo* pStdReferenceInfo;
|
||||
} VkVideoDecodeH265DpbSlotInfoEXT;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef VULKAN_DIRECTFB_H_
|
||||
#define VULKAN_DIRECTFB_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_directfb_surface 1
|
||||
#define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1
|
||||
#define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface"
|
||||
typedef VkFlags VkDirectFBSurfaceCreateFlagsEXT;
|
||||
typedef struct VkDirectFBSurfaceCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDirectFBSurfaceCreateFlagsEXT flags;
|
||||
IDirectFB* dfb;
|
||||
IDirectFBSurface* surface;
|
||||
} VkDirectFBSurfaceCreateInfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateDirectFBSurfaceEXT)(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB* dfb);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT(
|
||||
VkInstance instance,
|
||||
const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
IDirectFB* dfb);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
#ifndef VULKAN_FUCHSIA_H_
|
||||
#define VULKAN_FUCHSIA_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_FUCHSIA_imagepipe_surface 1
|
||||
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1
|
||||
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface"
|
||||
typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA;
|
||||
typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkImagePipeSurfaceCreateFlagsFUCHSIA flags;
|
||||
zx_handle_t imagePipeHandle;
|
||||
} VkImagePipeSurfaceCreateInfoFUCHSIA;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA(
|
||||
VkInstance instance,
|
||||
const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_FUCHSIA_external_memory 1
|
||||
#define VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION 1
|
||||
#define VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME "VK_FUCHSIA_external_memory"
|
||||
typedef struct VkImportMemoryZirconHandleInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
zx_handle_t handle;
|
||||
} VkImportMemoryZirconHandleInfoFUCHSIA;
|
||||
|
||||
typedef struct VkMemoryZirconHandlePropertiesFUCHSIA {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t memoryTypeBits;
|
||||
} VkMemoryZirconHandlePropertiesFUCHSIA;
|
||||
|
||||
typedef struct VkMemoryGetZirconHandleInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceMemory memory;
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
} VkMemoryGetZirconHandleInfoFUCHSIA;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandleFUCHSIA)(VkDevice device, const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, zx_handle_t zirconHandle, VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandleFUCHSIA(
|
||||
VkDevice device,
|
||||
const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
|
||||
zx_handle_t* pZirconHandle);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA(
|
||||
VkDevice device,
|
||||
VkExternalMemoryHandleTypeFlagBits handleType,
|
||||
zx_handle_t zirconHandle,
|
||||
VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_FUCHSIA_external_semaphore 1
|
||||
#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION 1
|
||||
#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_FUCHSIA_external_semaphore"
|
||||
typedef struct VkImportSemaphoreZirconHandleInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkSemaphore semaphore;
|
||||
VkSemaphoreImportFlags flags;
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
zx_handle_t zirconHandle;
|
||||
} VkImportSemaphoreZirconHandleInfoFUCHSIA;
|
||||
|
||||
typedef struct VkSemaphoreGetZirconHandleInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkSemaphore semaphore;
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
} VkSemaphoreGetZirconHandleInfoFUCHSIA;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreZirconHandleFUCHSIA(
|
||||
VkDevice device,
|
||||
const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA(
|
||||
VkDevice device,
|
||||
const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
|
||||
zx_handle_t* pZirconHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_FUCHSIA_buffer_collection 1
|
||||
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferCollectionFUCHSIA)
|
||||
#define VK_FUCHSIA_BUFFER_COLLECTION_SPEC_VERSION 2
|
||||
#define VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME "VK_FUCHSIA_buffer_collection"
|
||||
typedef VkFlags VkImageFormatConstraintsFlagsFUCHSIA;
|
||||
|
||||
typedef enum VkImageConstraintsInfoFlagBitsFUCHSIA {
|
||||
VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_RARELY_FUCHSIA = 0x00000001,
|
||||
VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_OFTEN_FUCHSIA = 0x00000002,
|
||||
VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_RARELY_FUCHSIA = 0x00000004,
|
||||
VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_OFTEN_FUCHSIA = 0x00000008,
|
||||
VK_IMAGE_CONSTRAINTS_INFO_PROTECTED_OPTIONAL_FUCHSIA = 0x00000010,
|
||||
VK_IMAGE_CONSTRAINTS_INFO_FLAG_BITS_MAX_ENUM_FUCHSIA = 0x7FFFFFFF
|
||||
} VkImageConstraintsInfoFlagBitsFUCHSIA;
|
||||
typedef VkFlags VkImageConstraintsInfoFlagsFUCHSIA;
|
||||
typedef struct VkBufferCollectionCreateInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
zx_handle_t collectionToken;
|
||||
} VkBufferCollectionCreateInfoFUCHSIA;
|
||||
|
||||
typedef struct VkImportMemoryBufferCollectionFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkBufferCollectionFUCHSIA collection;
|
||||
uint32_t index;
|
||||
} VkImportMemoryBufferCollectionFUCHSIA;
|
||||
|
||||
typedef struct VkBufferCollectionImageCreateInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkBufferCollectionFUCHSIA collection;
|
||||
uint32_t index;
|
||||
} VkBufferCollectionImageCreateInfoFUCHSIA;
|
||||
|
||||
typedef struct VkBufferCollectionConstraintsInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t minBufferCount;
|
||||
uint32_t maxBufferCount;
|
||||
uint32_t minBufferCountForCamping;
|
||||
uint32_t minBufferCountForDedicatedSlack;
|
||||
uint32_t minBufferCountForSharedSlack;
|
||||
} VkBufferCollectionConstraintsInfoFUCHSIA;
|
||||
|
||||
typedef struct VkBufferConstraintsInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkBufferCreateInfo createInfo;
|
||||
VkFormatFeatureFlags requiredFormatFeatures;
|
||||
VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints;
|
||||
} VkBufferConstraintsInfoFUCHSIA;
|
||||
|
||||
typedef struct VkBufferCollectionBufferCreateInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkBufferCollectionFUCHSIA collection;
|
||||
uint32_t index;
|
||||
} VkBufferCollectionBufferCreateInfoFUCHSIA;
|
||||
|
||||
typedef struct VkSysmemColorSpaceFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t colorSpace;
|
||||
} VkSysmemColorSpaceFUCHSIA;
|
||||
|
||||
typedef struct VkBufferCollectionPropertiesFUCHSIA {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t memoryTypeBits;
|
||||
uint32_t bufferCount;
|
||||
uint32_t createInfoIndex;
|
||||
uint64_t sysmemPixelFormat;
|
||||
VkFormatFeatureFlags formatFeatures;
|
||||
VkSysmemColorSpaceFUCHSIA sysmemColorSpaceIndex;
|
||||
VkComponentMapping samplerYcbcrConversionComponents;
|
||||
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
|
||||
VkSamplerYcbcrRange suggestedYcbcrRange;
|
||||
VkChromaLocation suggestedXChromaOffset;
|
||||
VkChromaLocation suggestedYChromaOffset;
|
||||
} VkBufferCollectionPropertiesFUCHSIA;
|
||||
|
||||
typedef struct VkImageFormatConstraintsInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkImageCreateInfo imageCreateInfo;
|
||||
VkFormatFeatureFlags requiredFormatFeatures;
|
||||
VkImageFormatConstraintsFlagsFUCHSIA flags;
|
||||
uint64_t sysmemPixelFormat;
|
||||
uint32_t colorSpaceCount;
|
||||
const VkSysmemColorSpaceFUCHSIA* pColorSpaces;
|
||||
} VkImageFormatConstraintsInfoFUCHSIA;
|
||||
|
||||
typedef struct VkImageConstraintsInfoFUCHSIA {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t formatConstraintsCount;
|
||||
const VkImageFormatConstraintsInfoFUCHSIA* pFormatConstraints;
|
||||
VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints;
|
||||
VkImageConstraintsInfoFlagsFUCHSIA flags;
|
||||
} VkImageConstraintsInfoFUCHSIA;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferCollectionFUCHSIA)(VkDevice device, const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferCollectionFUCHSIA* pCollection);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionImageConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo);
|
||||
typedef void (VKAPI_PTR *PFN_vkDestroyBufferCollectionFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkAllocationCallbacks* pAllocator);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetBufferCollectionPropertiesFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, VkBufferCollectionPropertiesFUCHSIA* pProperties);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferCollectionFUCHSIA(
|
||||
VkDevice device,
|
||||
const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkBufferCollectionFUCHSIA* pCollection);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionImageConstraintsFUCHSIA(
|
||||
VkDevice device,
|
||||
VkBufferCollectionFUCHSIA collection,
|
||||
const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionBufferConstraintsFUCHSIA(
|
||||
VkDevice device,
|
||||
VkBufferCollectionFUCHSIA collection,
|
||||
const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo);
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyBufferCollectionFUCHSIA(
|
||||
VkDevice device,
|
||||
VkBufferCollectionFUCHSIA collection,
|
||||
const VkAllocationCallbacks* pAllocator);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferCollectionPropertiesFUCHSIA(
|
||||
VkDevice device,
|
||||
VkBufferCollectionFUCHSIA collection,
|
||||
VkBufferCollectionPropertiesFUCHSIA* pProperties);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
#ifndef VULKAN_GGP_H_
|
||||
#define VULKAN_GGP_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_GGP_stream_descriptor_surface 1
|
||||
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1
|
||||
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface"
|
||||
typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP;
|
||||
typedef struct VkStreamDescriptorSurfaceCreateInfoGGP {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkStreamDescriptorSurfaceCreateFlagsGGP flags;
|
||||
GgpStreamDescriptor streamDescriptor;
|
||||
} VkStreamDescriptorSurfaceCreateInfoGGP;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP(
|
||||
VkInstance instance,
|
||||
const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_GGP_frame_token 1
|
||||
#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1
|
||||
#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token"
|
||||
typedef struct VkPresentFrameTokenGGP {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
GgpFrameToken frameToken;
|
||||
} VkPresentFrameTokenGGP;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#ifndef VULKAN_IOS_H_
|
||||
#define VULKAN_IOS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_MVK_ios_surface 1
|
||||
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 3
|
||||
#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface"
|
||||
typedef VkFlags VkIOSSurfaceCreateFlagsMVK;
|
||||
typedef struct VkIOSSurfaceCreateInfoMVK {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkIOSSurfaceCreateFlagsMVK flags;
|
||||
const void* pView;
|
||||
} VkIOSSurfaceCreateInfoMVK;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK(
|
||||
VkInstance instance,
|
||||
const VkIOSSurfaceCreateInfoMVK* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#ifndef VULKAN_MACOS_H_
|
||||
#define VULKAN_MACOS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_MVK_macos_surface 1
|
||||
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3
|
||||
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
|
||||
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
||||
typedef struct VkMacOSSurfaceCreateInfoMVK {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkMacOSSurfaceCreateFlagsMVK flags;
|
||||
const void* pView;
|
||||
} VkMacOSSurfaceCreateInfoMVK;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(
|
||||
VkInstance instance,
|
||||
const VkMacOSSurfaceCreateInfoMVK* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef VULKAN_METAL_H_
|
||||
#define VULKAN_METAL_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_metal_surface 1
|
||||
|
||||
#ifdef __OBJC__
|
||||
@class CAMetalLayer;
|
||||
#else
|
||||
typedef void CAMetalLayer;
|
||||
#endif
|
||||
|
||||
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
|
||||
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
|
||||
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
|
||||
typedef struct VkMetalSurfaceCreateInfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkMetalSurfaceCreateFlagsEXT flags;
|
||||
const CAMetalLayer* pLayer;
|
||||
} VkMetalSurfaceCreateInfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(
|
||||
VkInstance instance,
|
||||
const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,255 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2021-2022 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* DO NOT EDIT: This file is generated.
|
||||
*/
|
||||
|
||||
#ifndef VULKAN_PROFILES_H_
|
||||
#define VULKAN_PROFILES_H_ 1
|
||||
|
||||
#define VPAPI_ATTR
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if defined(VK_VERSION_1_0) && \
|
||||
defined(VK_EXT_swapchain_colorspace) && \
|
||||
defined(VK_GOOGLE_display_timing) && \
|
||||
defined(VK_KHR_android_surface) && \
|
||||
defined(VK_KHR_dedicated_allocation) && \
|
||||
defined(VK_KHR_descriptor_update_template) && \
|
||||
defined(VK_KHR_external_fence) && \
|
||||
defined(VK_KHR_external_fence_capabilities) && \
|
||||
defined(VK_KHR_external_fence_fd) && \
|
||||
defined(VK_KHR_external_memory) && \
|
||||
defined(VK_KHR_external_memory_capabilities) && \
|
||||
defined(VK_KHR_external_semaphore) && \
|
||||
defined(VK_KHR_external_semaphore_capabilities) && \
|
||||
defined(VK_KHR_external_semaphore_fd) && \
|
||||
defined(VK_KHR_get_memory_requirements2) && \
|
||||
defined(VK_KHR_get_physical_device_properties2) && \
|
||||
defined(VK_KHR_get_surface_capabilities2) && \
|
||||
defined(VK_KHR_incremental_present) && \
|
||||
defined(VK_KHR_maintenance1) && \
|
||||
defined(VK_KHR_storage_buffer_storage_class) && \
|
||||
defined(VK_KHR_surface) && \
|
||||
defined(VK_KHR_swapchain) && \
|
||||
defined(VK_KHR_variable_pointers)
|
||||
#define VP_ANDROID_baseline_2021 1
|
||||
#define VP_ANDROID_BASELINE_2021_NAME "VP_ANDROID_baseline_2021"
|
||||
#define VP_ANDROID_BASELINE_2021_SPEC_VERSION 1
|
||||
#define VP_ANDROID_BASELINE_2021_MIN_API_VERSION VK_MAKE_VERSION(1, 0, 68)
|
||||
#endif
|
||||
|
||||
#if defined(VK_VERSION_1_3) && \
|
||||
defined(VK_KHR_global_priority)
|
||||
#define VP_KHR_roadmap_2022 1
|
||||
#define VP_KHR_ROADMAP_2022_NAME "VP_KHR_roadmap_2022"
|
||||
#define VP_KHR_ROADMAP_2022_SPEC_VERSION 1
|
||||
#define VP_KHR_ROADMAP_2022_MIN_API_VERSION VK_MAKE_VERSION(1, 3, 204)
|
||||
#endif
|
||||
|
||||
#if defined(VK_VERSION_1_1) && \
|
||||
defined(VK_EXT_descriptor_indexing) && \
|
||||
defined(VK_EXT_host_query_reset) && \
|
||||
defined(VK_EXT_robustness2) && \
|
||||
defined(VK_EXT_scalar_block_layout) && \
|
||||
defined(VK_EXT_subgroup_size_control) && \
|
||||
defined(VK_EXT_texel_buffer_alignment) && \
|
||||
defined(VK_EXT_vertex_attribute_divisor) && \
|
||||
defined(VK_KHR_8bit_storage) && \
|
||||
defined(VK_KHR_create_renderpass2) && \
|
||||
defined(VK_KHR_depth_stencil_resolve) && \
|
||||
defined(VK_KHR_driver_properties) && \
|
||||
defined(VK_KHR_image_format_list) && \
|
||||
defined(VK_KHR_imageless_framebuffer) && \
|
||||
defined(VK_KHR_sampler_mirror_clamp_to_edge) && \
|
||||
defined(VK_KHR_shader_float16_int8) && \
|
||||
defined(VK_KHR_swapchain) && \
|
||||
defined(VK_KHR_swapchain_mutable_format) && \
|
||||
defined(VK_KHR_timeline_semaphore) && \
|
||||
defined(VK_KHR_uniform_buffer_standard_layout)
|
||||
#define VP_LUNARG_desktop_portability_2021 1
|
||||
#define VP_LUNARG_DESKTOP_PORTABILITY_2021_NAME "VP_LUNARG_desktop_portability_2021"
|
||||
#define VP_LUNARG_DESKTOP_PORTABILITY_2021_SPEC_VERSION 1
|
||||
#define VP_LUNARG_DESKTOP_PORTABILITY_2021_MIN_API_VERSION VK_MAKE_VERSION(1, 1, 142)
|
||||
#endif
|
||||
|
||||
#if defined(VK_VERSION_1_1) && \
|
||||
defined(VK_EXT_descriptor_indexing) && \
|
||||
defined(VK_EXT_host_query_reset) && \
|
||||
defined(VK_EXT_robustness2) && \
|
||||
defined(VK_EXT_scalar_block_layout) && \
|
||||
defined(VK_EXT_subgroup_size_control) && \
|
||||
defined(VK_EXT_texel_buffer_alignment) && \
|
||||
defined(VK_EXT_vertex_attribute_divisor) && \
|
||||
defined(VK_KHR_8bit_storage) && \
|
||||
defined(VK_KHR_create_renderpass2) && \
|
||||
defined(VK_KHR_depth_stencil_resolve) && \
|
||||
defined(VK_KHR_driver_properties) && \
|
||||
defined(VK_KHR_image_format_list) && \
|
||||
defined(VK_KHR_imageless_framebuffer) && \
|
||||
defined(VK_KHR_portability_subset) && \
|
||||
defined(VK_KHR_sampler_mirror_clamp_to_edge) && \
|
||||
defined(VK_KHR_shader_float16_int8) && \
|
||||
defined(VK_KHR_swapchain) && \
|
||||
defined(VK_KHR_swapchain_mutable_format) && \
|
||||
defined(VK_KHR_timeline_semaphore) && \
|
||||
defined(VK_KHR_uniform_buffer_standard_layout)
|
||||
#define VP_LUNARG_desktop_portability_2021_subset 1
|
||||
#define VP_LUNARG_DESKTOP_PORTABILITY_2021_SUBSET_NAME "VP_LUNARG_desktop_portability_2021_subset"
|
||||
#define VP_LUNARG_DESKTOP_PORTABILITY_2021_SUBSET_SPEC_VERSION 1
|
||||
#define VP_LUNARG_DESKTOP_PORTABILITY_2021_SUBSET_MIN_API_VERSION VK_MAKE_VERSION(1, 1, 154)
|
||||
#endif
|
||||
|
||||
#define VP_MAX_PROFILE_NAME_SIZE 256U
|
||||
|
||||
typedef struct VpProfileProperties {
|
||||
char profileName[VP_MAX_PROFILE_NAME_SIZE];
|
||||
uint32_t specVersion;
|
||||
} VpProfileProperties;
|
||||
|
||||
typedef enum VpInstanceCreateFlagBits {
|
||||
// Default behavior:
|
||||
// - profile extensions are used (application must not specify extensions)
|
||||
|
||||
// Merge application provided extension list and profile extension list
|
||||
VP_INSTANCE_CREATE_MERGE_EXTENSIONS_BIT = 0x00000001,
|
||||
|
||||
// Use application provided extension list
|
||||
VP_INSTANCE_CREATE_OVERRIDE_EXTENSIONS_BIT = 0x00000002,
|
||||
|
||||
VP_INSTANCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} VpInstanceCreateFlagBits;
|
||||
typedef VkFlags VpInstanceCreateFlags;
|
||||
|
||||
typedef struct VpInstanceCreateInfo {
|
||||
const VkInstanceCreateInfo* pCreateInfo;
|
||||
const VpProfileProperties* pProfile;
|
||||
VpInstanceCreateFlags flags;
|
||||
} VpInstanceCreateInfo;
|
||||
|
||||
typedef enum VpDeviceCreateFlagBits {
|
||||
// Default behavior:
|
||||
// - profile extensions are used (application must not specify extensions)
|
||||
// - profile feature structures are used (application must not specify any of them) extended
|
||||
// with any other application provided struct that isn't defined by the profile
|
||||
|
||||
// Merge application provided extension list and profile extension list
|
||||
VP_DEVICE_CREATE_MERGE_EXTENSIONS_BIT = 0x00000001,
|
||||
|
||||
// Use application provided extension list
|
||||
VP_DEVICE_CREATE_OVERRIDE_EXTENSIONS_BIT = 0x00000002,
|
||||
|
||||
// Merge application provided versions of feature structures with the profile features
|
||||
// Currently unsupported, but is considered for future inclusion in which case the
|
||||
// default behavior could potentially be changed to merging as the currently defined
|
||||
// default behavior is forward-compatible with that
|
||||
// VP_DEVICE_CREATE_MERGE_FEATURES_BIT = 0x00000004,
|
||||
|
||||
// Use application provided versions of feature structures but use the profile feature
|
||||
// structures when the application doesn't provide one (robust access disable flags are
|
||||
// ignored if the application overrides the corresponding feature structures)
|
||||
VP_DEVICE_CREATE_OVERRIDE_FEATURES_BIT = 0x00000008,
|
||||
|
||||
// Only use application provided feature structures, don't add any profile specific
|
||||
// feature structures (robust access disable flags are ignored in this case and only the
|
||||
// application provided structures are used)
|
||||
VP_DEVICE_CREATE_OVERRIDE_ALL_FEATURES_BIT = 0x00000010,
|
||||
|
||||
VP_DEVICE_CREATE_DISABLE_ROBUST_BUFFER_ACCESS_BIT = 0x00000020,
|
||||
VP_DEVICE_CREATE_DISABLE_ROBUST_IMAGE_ACCESS_BIT = 0x00000040,
|
||||
VP_DEVICE_CREATE_DISABLE_ROBUST_ACCESS =
|
||||
VP_DEVICE_CREATE_DISABLE_ROBUST_BUFFER_ACCESS_BIT | VP_DEVICE_CREATE_DISABLE_ROBUST_IMAGE_ACCESS_BIT,
|
||||
|
||||
VP_DEVICE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} VpDeviceCreateFlagBits;
|
||||
typedef VkFlags VpDeviceCreateFlags;
|
||||
|
||||
typedef struct VpDeviceCreateInfo {
|
||||
const VkDeviceCreateInfo* pCreateInfo;
|
||||
const VpProfileProperties* pProfile;
|
||||
VpDeviceCreateFlags flags;
|
||||
} VpDeviceCreateInfo;
|
||||
|
||||
// Query the list of available profiles in the library
|
||||
VPAPI_ATTR VkResult vpGetProfiles(uint32_t *pPropertyCount, VpProfileProperties *pProperties);
|
||||
|
||||
// List the recommended fallback profiles of a profile
|
||||
VPAPI_ATTR VkResult vpGetProfileFallbacks(const VpProfileProperties *pProfile, uint32_t *pPropertyCount, VpProfileProperties *pProperties);
|
||||
|
||||
// Check whether a profile is supported at the instance level
|
||||
VPAPI_ATTR VkResult vpGetInstanceProfileSupport(const char *pLayerName, const VpProfileProperties *pProfile, VkBool32 *pSupported);
|
||||
|
||||
// Create a VkInstance with the profile instance extensions enabled
|
||||
VPAPI_ATTR VkResult vpCreateInstance(const VpInstanceCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
|
||||
|
||||
// Check whether a profile is supported by the physical device
|
||||
VPAPI_ATTR VkResult vpGetPhysicalDeviceProfileSupport(VkInstance instance, VkPhysicalDevice physicalDevice,
|
||||
const VpProfileProperties *pProfile, VkBool32 *pSupported);
|
||||
|
||||
// Create a VkDevice with the profile features and device extensions enabled
|
||||
VPAPI_ATTR VkResult vpCreateDevice(VkPhysicalDevice physicalDevice, const VpDeviceCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
|
||||
|
||||
// Query the list of instance extensions of a profile
|
||||
VPAPI_ATTR VkResult vpGetProfileInstanceExtensionProperties(const VpProfileProperties *pProfile, uint32_t *pPropertyCount,
|
||||
VkExtensionProperties *pProperties);
|
||||
|
||||
// Query the list of device extensions of a profile
|
||||
VPAPI_ATTR VkResult vpGetProfileDeviceExtensionProperties(const VpProfileProperties *pProfile, uint32_t *pPropertyCount,
|
||||
VkExtensionProperties *pProperties);
|
||||
|
||||
// Fill the feature structures with the requirements of a profile
|
||||
VPAPI_ATTR void vpGetProfileFeatures(const VpProfileProperties *pProfile, void *pNext);
|
||||
|
||||
// Query the list of feature structure types specified by the profile
|
||||
VPAPI_ATTR VkResult vpGetProfileFeatureStructureTypes(const VpProfileProperties *pProfile, uint32_t *pStructureTypeCount,
|
||||
VkStructureType *pStructureTypes);
|
||||
|
||||
// Fill the property structures with the requirements of a profile
|
||||
VPAPI_ATTR void vpGetProfileProperties(const VpProfileProperties *pProfile, void *pNext);
|
||||
|
||||
// Query the list of property structure types specified by the profile
|
||||
VPAPI_ATTR VkResult vpGetProfilePropertyStructureTypes(const VpProfileProperties *pProfile, uint32_t *pStructureTypeCount,
|
||||
VkStructureType *pStructureTypes);
|
||||
|
||||
// Query the requirements of queue families by a profile
|
||||
VPAPI_ATTR VkResult vpGetProfileQueueFamilyProperties(const VpProfileProperties *pProfile, uint32_t *pPropertyCount,
|
||||
VkQueueFamilyProperties2KHR *pProperties);
|
||||
|
||||
// Query the list of query family structure types specified by the profile
|
||||
VPAPI_ATTR VkResult vpGetProfileQueueFamilyStructureTypes(const VpProfileProperties *pProfile, uint32_t *pStructureTypeCount,
|
||||
VkStructureType *pStructureTypes);
|
||||
|
||||
// Query the list of formats with specified requirements by a profile
|
||||
VPAPI_ATTR VkResult vpGetProfileFormats(const VpProfileProperties *pProfile, uint32_t *pFormatCount, VkFormat *pFormats);
|
||||
|
||||
// Query the requirements of a format for a profile
|
||||
VPAPI_ATTR void vpGetProfileFormatProperties(const VpProfileProperties *pProfile, VkFormat format, void *pNext);
|
||||
|
||||
// Query the list of format structure types specified by the profile
|
||||
VPAPI_ATTR VkResult vpGetProfileFormatStructureTypes(const VpProfileProperties *pProfile, uint32_t *pStructureTypeCount,
|
||||
VkStructureType *pStructureTypes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // VULKAN_PROFILES_H_
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef VULKAN_SCREEN_H_
|
||||
#define VULKAN_SCREEN_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_QNX_screen_surface 1
|
||||
#define VK_QNX_SCREEN_SURFACE_SPEC_VERSION 1
|
||||
#define VK_QNX_SCREEN_SURFACE_EXTENSION_NAME "VK_QNX_screen_surface"
|
||||
typedef VkFlags VkScreenSurfaceCreateFlagsQNX;
|
||||
typedef struct VkScreenSurfaceCreateInfoQNX {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkScreenSurfaceCreateFlagsQNX flags;
|
||||
struct _screen_context* context;
|
||||
struct _screen_window* window;
|
||||
} VkScreenSurfaceCreateInfoQNX;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateScreenSurfaceQNX)(VkInstance instance, const VkScreenSurfaceCreateInfoQNX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct _screen_window* window);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateScreenSurfaceQNX(
|
||||
VkInstance instance,
|
||||
const VkScreenSurfaceCreateInfoQNX* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceScreenPresentationSupportQNX(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
struct _screen_window* window);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#ifndef VULKAN_VI_H_
|
||||
#define VULKAN_VI_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_NN_vi_surface 1
|
||||
#define VK_NN_VI_SURFACE_SPEC_VERSION 1
|
||||
#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface"
|
||||
typedef VkFlags VkViSurfaceCreateFlagsNN;
|
||||
typedef struct VkViSurfaceCreateInfoNN {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkViSurfaceCreateFlagsNN flags;
|
||||
void* window;
|
||||
} VkViSurfaceCreateInfoNN;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN(
|
||||
VkInstance instance,
|
||||
const VkViSurfaceCreateInfoNN* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef VULKAN_WAYLAND_H_
|
||||
#define VULKAN_WAYLAND_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_wayland_surface 1
|
||||
#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface"
|
||||
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
||||
typedef struct VkWaylandSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkWaylandSurfaceCreateFlagsKHR flags;
|
||||
struct wl_display* display;
|
||||
struct wl_surface* surface;
|
||||
} VkWaylandSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
struct wl_display* display);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,315 +0,0 @@
|
|||
#ifndef VULKAN_WIN32_H_
|
||||
#define VULKAN_WIN32_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_win32_surface 1
|
||||
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
|
||||
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
|
||||
typedef struct VkWin32SurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkWin32SurfaceCreateFlagsKHR flags;
|
||||
HINSTANCE hinstance;
|
||||
HWND hwnd;
|
||||
} VkWin32SurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_external_memory_win32 1
|
||||
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
|
||||
typedef struct VkImportMemoryWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
HANDLE handle;
|
||||
LPCWSTR name;
|
||||
} VkImportMemoryWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkExportMemoryWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
LPCWSTR name;
|
||||
} VkExportMemoryWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkMemoryWin32HandlePropertiesKHR {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
uint32_t memoryTypeBits;
|
||||
} VkMemoryWin32HandlePropertiesKHR;
|
||||
|
||||
typedef struct VkMemoryGetWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkDeviceMemory memory;
|
||||
VkExternalMemoryHandleTypeFlagBits handleType;
|
||||
} VkMemoryGetWin32HandleInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo,
|
||||
HANDLE* pHandle);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
|
||||
VkDevice device,
|
||||
VkExternalMemoryHandleTypeFlagBits handleType,
|
||||
HANDLE handle,
|
||||
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_win32_keyed_mutex 1
|
||||
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
|
||||
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
|
||||
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t acquireCount;
|
||||
const VkDeviceMemory* pAcquireSyncs;
|
||||
const uint64_t* pAcquireKeys;
|
||||
const uint32_t* pAcquireTimeouts;
|
||||
uint32_t releaseCount;
|
||||
const VkDeviceMemory* pReleaseSyncs;
|
||||
const uint64_t* pReleaseKeys;
|
||||
} VkWin32KeyedMutexAcquireReleaseInfoKHR;
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_external_semaphore_win32 1
|
||||
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
|
||||
typedef struct VkImportSemaphoreWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkSemaphore semaphore;
|
||||
VkSemaphoreImportFlags flags;
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
HANDLE handle;
|
||||
LPCWSTR name;
|
||||
} VkImportSemaphoreWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkExportSemaphoreWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
LPCWSTR name;
|
||||
} VkExportSemaphoreWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkD3D12FenceSubmitInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t waitSemaphoreValuesCount;
|
||||
const uint64_t* pWaitSemaphoreValues;
|
||||
uint32_t signalSemaphoreValuesCount;
|
||||
const uint64_t* pSignalSemaphoreValues;
|
||||
} VkD3D12FenceSubmitInfoKHR;
|
||||
|
||||
typedef struct VkSemaphoreGetWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkSemaphore semaphore;
|
||||
VkExternalSemaphoreHandleTypeFlagBits handleType;
|
||||
} VkSemaphoreGetWin32HandleInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_KHR_external_fence_win32 1
|
||||
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
|
||||
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
|
||||
typedef struct VkImportFenceWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkFence fence;
|
||||
VkFenceImportFlags flags;
|
||||
VkExternalFenceHandleTypeFlagBits handleType;
|
||||
HANDLE handle;
|
||||
LPCWSTR name;
|
||||
} VkImportFenceWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkExportFenceWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
LPCWSTR name;
|
||||
} VkExportFenceWin32HandleInfoKHR;
|
||||
|
||||
typedef struct VkFenceGetWin32HandleInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkFence fence;
|
||||
VkExternalFenceHandleTypeFlagBits handleType;
|
||||
} VkFenceGetWin32HandleInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
|
||||
VkDevice device,
|
||||
const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo,
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_NV_external_memory_win32 1
|
||||
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
|
||||
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
|
||||
typedef struct VkImportMemoryWin32HandleInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkExternalMemoryHandleTypeFlagsNV handleType;
|
||||
HANDLE handle;
|
||||
} VkImportMemoryWin32HandleInfoNV;
|
||||
|
||||
typedef struct VkExportMemoryWin32HandleInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
const SECURITY_ATTRIBUTES* pAttributes;
|
||||
DWORD dwAccess;
|
||||
} VkExportMemoryWin32HandleInfoNV;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
|
||||
VkDevice device,
|
||||
VkDeviceMemory memory,
|
||||
VkExternalMemoryHandleTypeFlagsNV handleType,
|
||||
HANDLE* pHandle);
|
||||
#endif
|
||||
|
||||
|
||||
#define VK_NV_win32_keyed_mutex 1
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2
|
||||
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
|
||||
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
uint32_t acquireCount;
|
||||
const VkDeviceMemory* pAcquireSyncs;
|
||||
const uint64_t* pAcquireKeys;
|
||||
const uint32_t* pAcquireTimeoutMilliseconds;
|
||||
uint32_t releaseCount;
|
||||
const VkDeviceMemory* pReleaseSyncs;
|
||||
const uint64_t* pReleaseKeys;
|
||||
} VkWin32KeyedMutexAcquireReleaseInfoNV;
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_full_screen_exclusive 1
|
||||
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4
|
||||
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive"
|
||||
|
||||
typedef enum VkFullScreenExclusiveEXT {
|
||||
VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3,
|
||||
VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF
|
||||
} VkFullScreenExclusiveEXT;
|
||||
typedef struct VkSurfaceFullScreenExclusiveInfoEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkFullScreenExclusiveEXT fullScreenExclusive;
|
||||
} VkSurfaceFullScreenExclusiveInfoEXT;
|
||||
|
||||
typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT {
|
||||
VkStructureType sType;
|
||||
void* pNext;
|
||||
VkBool32 fullScreenExclusiveSupported;
|
||||
} VkSurfaceCapabilitiesFullScreenExclusiveEXT;
|
||||
|
||||
typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
HMONITOR hmonitor;
|
||||
} VkSurfaceFullScreenExclusiveWin32InfoEXT;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
|
||||
uint32_t* pPresentModeCount,
|
||||
VkPresentModeKHR* pPresentModes);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT(
|
||||
VkDevice device,
|
||||
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
|
||||
VkDeviceGroupPresentModeFlagsKHR* pModes);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef VULKAN_XCB_H_
|
||||
#define VULKAN_XCB_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_xcb_surface 1
|
||||
#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
|
||||
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
|
||||
typedef struct VkXcbSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkXcbSurfaceCreateFlagsKHR flags;
|
||||
xcb_connection_t* connection;
|
||||
xcb_window_t window;
|
||||
} VkXcbSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
xcb_connection_t* connection,
|
||||
xcb_visualid_t visual_id);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef VULKAN_XLIB_H_
|
||||
#define VULKAN_XLIB_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_KHR_xlib_surface 1
|
||||
#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6
|
||||
#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface"
|
||||
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
|
||||
typedef struct VkXlibSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkXlibSurfaceCreateFlagsKHR flags;
|
||||
Display* dpy;
|
||||
Window window;
|
||||
} VkXlibSurfaceCreateInfoKHR;
|
||||
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
|
||||
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
Display* dpy,
|
||||
VisualID visualID);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
#ifndef VULKAN_XLIB_XRANDR_H_
|
||||
#define VULKAN_XLIB_XRANDR_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2022 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define VK_EXT_acquire_xlib_display 1
|
||||
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1
|
||||
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display"
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);
|
||||
typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay);
|
||||
|
||||
#ifndef VK_NO_PROTOTYPES
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
Display* dpy,
|
||||
VkDisplayKHR display);
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
Display* dpy,
|
||||
RROutput rrOutput,
|
||||
VkDisplayKHR* pDisplay);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,15 +0,0 @@
|
|||
const vk = @import("vulkan");
|
||||
|
||||
const std = @import("std");
|
||||
pub const BaseDispatch = vk.BaseWrapper(.{
|
||||
.createInstance = true,
|
||||
.getInstanceProcAddr = true,
|
||||
.enumerateInstanceVersion = true,
|
||||
.enumerateInstanceLayerProperties = true,
|
||||
.enumerateInstanceExtensionProperties = true,
|
||||
});
|
||||
|
||||
test "hello-vulkan" {
|
||||
std.debug.print("GENERATED API VERSION = {any}\n", .{vk.HEADER_VERSION});
|
||||
std.debug.print("vkb table size = {d}\n", .{@sizeOf(BaseDispatch)});
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +0,0 @@
|
|||
id: uxw7q1ovyv4z3t7fi28agxovmhbrobglw7mwtl5p3pnsc1gu
|
||||
name: vulkan-zig
|
||||
main: generator/index.zig
|
||||
license: MIT
|
||||
description: Vulkan binding generator for Zig
|
||||
dependencies:
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
.zig-cache/
|
||||
build_runner.zig
|
||||
.DS_Store
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Alexandre Chêne
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
# glTF parser for Zig codebase
|
||||
|
||||
This project is a glTF 2.0 parser written in Zig, aiming to replace the use of some C/C++ libraries. All glTF types are fully documented, so it comes nicely with IDE autocompletion, reducing
|
||||
back and forth with the [specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html).
|
||||
|
||||
This library intends to mimic the glTF file structure in memory. Thereby it's designed around arrays and indexes instead of pointers as you may see in `cgltf` or other libraries. Also, it's the **user's responsibility** to load glTF files and their related binaries in memory.
|
||||
|
||||
Note: It's not as complete as the glTF specification yet, but because it's straightforward to add new parsed fields, we'll get new stuff incrementally and on-demand.
|
||||
|
||||
If you would like to contribute, don't hesitate! :)
|
||||
|
||||
## Examples
|
||||
|
||||
```zig
|
||||
const std = @import("std");
|
||||
const Gltf = @import("zgltf");
|
||||
|
||||
const allocator = std.heap.page_allocator;
|
||||
const print = std.debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
const buffer = try std.fs.cwd().readFileAllocOptions(
|
||||
allocator,
|
||||
"test-samples/rigged_simple/RiggedSimple.gltf",
|
||||
512_000,
|
||||
null,
|
||||
4,
|
||||
null
|
||||
);
|
||||
defer allocator.free(buf);
|
||||
|
||||
var gltf = Self.init(allocator);
|
||||
defer gltf.deinit();
|
||||
|
||||
try gltf.parse(buf);
|
||||
|
||||
for (gltf.nodes.items) |node| {
|
||||
const message =
|
||||
\\\ Node's name: {s}
|
||||
\\\ Children count: {}
|
||||
\\\ Have skin: {}
|
||||
;
|
||||
|
||||
print(message, .{
|
||||
node.name,
|
||||
node.children.items.len,
|
||||
node.skin != null,
|
||||
});
|
||||
}
|
||||
|
||||
// Or use the debufPrint method.
|
||||
gltf.debugPrint();
|
||||
}
|
||||
```
|
||||
|
||||
Also you could easily load data from an `Accessor` with `getDataFromBufferView`:
|
||||
|
||||
```zig
|
||||
const gltf = Gltf.init(allocator);
|
||||
try gltf.parse(my_gltf_buf);
|
||||
|
||||
const bin = try std.fs.cwd().readFileAllocOptions(
|
||||
allocator,
|
||||
"test-samples/rigged_simple/RiggedSimple0.bin",
|
||||
5_000_000,
|
||||
null,
|
||||
4,
|
||||
null
|
||||
);
|
||||
defer allocator.free(buf);
|
||||
|
||||
var vertices = ArrayList(f32).init(allocator);
|
||||
defer vertices.deinit();
|
||||
|
||||
const mesh = gltf.data.meshes.items[0];
|
||||
for (mesh.primitives.items) |primitive| {
|
||||
for (primitive.attributes.items) |attribute| {
|
||||
switch (attribute) {
|
||||
// Accessor for mesh vertices:
|
||||
.position => |accessor_index| {
|
||||
const accessor = gltf.data.accessors.items[accessor_index];
|
||||
gltf.getDataFromBufferView(f32, &vertices, accessor, bin);
|
||||
},
|
||||
else => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Also, there is an `iterator` method that helps you pull data from accessors:
|
||||
|
||||
```zig
|
||||
// ...
|
||||
for (primitive.attributes.items) |attribute| {
|
||||
switch (attribute) {
|
||||
.position => |idx| {
|
||||
const accessor = gltf.data.accessors.items[idx];
|
||||
var it = accessor.iterator(f32, &gltf, gltf.glb_binary.?);
|
||||
while (it.next()) |v| {
|
||||
try vertices.append(.{
|
||||
.pos = .{ v[0], v[1], v[2] },
|
||||
.normal = .{ 1, 0, 0 },
|
||||
.color = .{ 1, 1, 1, 1 },
|
||||
.uv_x = 0,
|
||||
.uv_y = 0,
|
||||
});
|
||||
}
|
||||
},
|
||||
.normal => |idx| {
|
||||
const accessor = gltf.data.accessors.items[idx];
|
||||
var it = accessor.iterator(f32, &gltf, gltf.glb_binary.?);
|
||||
var i: u32 = 0;
|
||||
while (it.next()) |n| : (i += 1) {
|
||||
vertices.items[initial_vertex + i].normal = .{ n[0], n[1], n[2] };
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Note: **Zig 0.11.x is required.**
|
||||
|
||||
```zig
|
||||
const zgltf = @import("path-to-zgltf/build.zig");
|
||||
exe.addModule("zgltf", zgltf.module(b));
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- [x] glTF 2.0 json file
|
||||
- [x] Scenes
|
||||
- [x] Nodes
|
||||
- [x] Buffers/BufferViews
|
||||
- [x] Meshes
|
||||
- [x] Images
|
||||
- [x] Materials
|
||||
- [x] Animations
|
||||
- [x] Skins
|
||||
- [x] Cameras
|
||||
- [x] Parse `glb` files
|
||||
- [ ] Morth targets
|
||||
- [ ] Extras data
|
||||
- [ ] glTF writer
|
||||
|
||||
Also, we supports some glTF extensions:
|
||||
|
||||
- [x] khr_lights_punctual
|
||||
- [x] khr_materials_emissive_strength
|
||||
- [x] khr_materials_ior
|
||||
- [x] khr_materials_transmission
|
||||
- [x] khr_materials_volume
|
||||
- [x] khr_materials_dispersion
|
||||
|
||||
## Contributing to the project
|
||||
|
||||
Don’t be shy about shooting any questions you may have. If you are a beginner/junior, don’t hesitate, I will always encourage you. It’s a safe place here. Also, I would be very happy to receive any kind of pull requests, you will have (at least) some feedback/guidance rapidly.
|
||||
|
||||
Behind screens, there are human beings, living any sort of story. So be always kind and respectful, because we all sheer to learn new things.
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
_ = b.addModule("zgltf", .{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
});
|
||||
|
||||
var tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests.step);
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
.{
|
||||
.name = "zgltf",
|
||||
.version = "0.1.0",
|
||||
.minimum_zig_version = "0.11.0",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
"test-samples",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
},
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
//
|
||||
// Mostly taken from `zalgebra`. I didn't wanted to import the all library.
|
||||
//
|
||||
|
||||
pub const Mat4 = [4][4]f32;
|
||||
pub const Vec3 = [3]f32;
|
||||
pub const Quat = [4]f32;
|
||||
pub const identity = Mat4{
|
||||
.{ 1, 0, 0, 0 },
|
||||
.{ 0, 1, 0, 0 },
|
||||
.{ 0, 0, 1, 0 },
|
||||
.{ 0, 0, 0, 1 },
|
||||
};
|
||||
|
||||
/// Return 4x4 matrix from given all transform components; `translation`, `rotation` and `scale`.
|
||||
/// The final order is T * R * S.
|
||||
pub fn recompose(translation: Vec3, rotation: Quat, scale: Vec3) Mat4 {
|
||||
const t = blk: {
|
||||
var mat = identity;
|
||||
mat[3][0] = translation[0];
|
||||
mat[3][1] = translation[1];
|
||||
mat[3][2] = translation[2];
|
||||
|
||||
break :blk mat;
|
||||
};
|
||||
|
||||
const r = blk: {
|
||||
var result = identity;
|
||||
|
||||
const x = rotation[0];
|
||||
const y = rotation[1];
|
||||
const z = rotation[2];
|
||||
const w = rotation[3];
|
||||
|
||||
const xx = x * x;
|
||||
const yy = y * y;
|
||||
const zz = z * z;
|
||||
const xy = x * y;
|
||||
const xz = x * z;
|
||||
const yz = y * z;
|
||||
const wx = w * x;
|
||||
const wy = w * y;
|
||||
const wz = w * z;
|
||||
|
||||
result[0][0] = 1.0 - 2.0 * (yy + zz);
|
||||
result[0][1] = 2.0 * (xy + wz);
|
||||
result[0][2] = 2.0 * (xz - wy);
|
||||
result[0][3] = 0.0;
|
||||
|
||||
result[1][0] = 2.0 * (xy - wz);
|
||||
result[1][1] = 1.0 - 2.0 * (xx + zz);
|
||||
result[1][2] = 2.0 * (yz + wx);
|
||||
result[1][3] = 0.0;
|
||||
|
||||
result[2][0] = 2.0 * (xz + wy);
|
||||
result[2][1] = 2.0 * (yz - wx);
|
||||
result[2][2] = 1.0 - 2.0 * (xx + yy);
|
||||
result[2][3] = 0.0;
|
||||
|
||||
result[3][0] = 0.0;
|
||||
result[3][1] = 0.0;
|
||||
result[3][2] = 0.0;
|
||||
result[3][3] = 1.0;
|
||||
|
||||
break :blk result;
|
||||
};
|
||||
|
||||
const s = blk: {
|
||||
var mat = identity;
|
||||
mat[0][0] = scale[0];
|
||||
mat[1][1] = scale[1];
|
||||
mat[2][2] = scale[2];
|
||||
|
||||
break :blk mat;
|
||||
};
|
||||
|
||||
return mul(t, mul(r, s));
|
||||
}
|
||||
|
||||
/// Matrices' multiplication.
|
||||
/// Produce a new matrix from given two matrices.
|
||||
pub fn mul(left: Mat4, right: Mat4) Mat4 {
|
||||
var result = identity;
|
||||
|
||||
for (result, 0..) |_, column| {
|
||||
for (result[column], 0..) |_, row| {
|
||||
var sum: f32 = 0;
|
||||
var left_column: usize = 0;
|
||||
|
||||
while (left_column < 4) : (left_column += 1) {
|
||||
sum += left[left_column][row] * right[column][left_column];
|
||||
}
|
||||
|
||||
result[column][row] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,636 +0,0 @@
|
|||
const std = @import("std");
|
||||
const Gltf = @import("main.zig");
|
||||
const pi = std.math.pi;
|
||||
const ArrayList = std.ArrayList;
|
||||
const panic = std.debug.panic;
|
||||
|
||||
/// Index of element in data arrays.
|
||||
pub const Index = usize;
|
||||
|
||||
/// A node in the node hierarchy.
|
||||
///
|
||||
/// When the node contains skin, all mesh.primitives must contain
|
||||
/// JOINTS_0 and WEIGHTS_0 attributes. A node may have either a matrix
|
||||
/// or any combination of translation/rotation/scale (TRS) properties.
|
||||
/// TRS properties are converted to matrices and postmultiplied in
|
||||
/// the T * R * S order to compose the transformation matrix.
|
||||
/// If none are provided, the transform is the identity.
|
||||
///
|
||||
/// When a node is targeted for animation (referenced by
|
||||
/// an animation.channel.target), matrix must not be present.
|
||||
pub const Node = struct {
|
||||
/// The user-defined name of this object.
|
||||
/// Default to `Node_{index}`.
|
||||
name: []const u8,
|
||||
/// The index of the node's parent.
|
||||
/// A node is called a root node when it doesn’t have a parent.
|
||||
parent: ?Index = null,
|
||||
/// The index of the mesh in this node.
|
||||
mesh: ?Index = null,
|
||||
/// The index of the camera referenced by this node.
|
||||
camera: ?Index = null,
|
||||
/// The index of the skin referenced by this node.
|
||||
skin: ?Index = null,
|
||||
/// The indices of this node’s children.
|
||||
children: ArrayList(Index),
|
||||
/// A floating-point 4x4 transformation matrix stored in column-major order.
|
||||
matrix: ?[16]f32 = null,
|
||||
/// The node’s unit quaternion rotation in the order (x, y, z, w),
|
||||
/// where w is the scalar.
|
||||
rotation: [4]f32 = [_]f32{ 0, 0, 0, 1 },
|
||||
/// The node’s non-uniform scale, given as the scaling factors
|
||||
/// along the x, y, and z axes.
|
||||
scale: [3]f32 = [_]f32{ 1, 1, 1 },
|
||||
/// The node’s translation along the x, y, and z axes.
|
||||
translation: [3]f32 = [_]f32{ 0, 0, 0 },
|
||||
/// The weights of the instantiated morph target.
|
||||
/// The number of array elements must match the number of morph targets
|
||||
/// of the referenced mesh. When defined, mesh mush also be defined.
|
||||
weights: ?[]usize = null,
|
||||
///The index of the light referenced by this node.
|
||||
light: ?Index = null,
|
||||
};
|
||||
|
||||
/// A buffer points to binary geometry, animation, or skins.
|
||||
pub const Buffer = struct {
|
||||
/// Relative paths are relative to the current glTF asset.
|
||||
/// It could contains a data:-URI instead of a path.
|
||||
/// Note: data-uri isn't implemented in this library.
|
||||
uri: ?[]const u8 = null,
|
||||
/// The length of the buffer in bytes.
|
||||
byte_length: usize,
|
||||
};
|
||||
|
||||
/// A view into a buffer generally representing a subset of the buffer.
|
||||
pub const BufferView = struct {
|
||||
/// The index of the buffer.
|
||||
buffer: Index,
|
||||
/// The length of the bufferView in bytes.
|
||||
byte_length: usize,
|
||||
/// The offset into the buffer in bytes.
|
||||
byte_offset: usize = 0,
|
||||
/// The stride, in bytes.
|
||||
byte_stride: ?usize = null,
|
||||
/// The hint representing the intended GPU buffer type
|
||||
/// to use with this buffer view.
|
||||
target: ?Target = null,
|
||||
};
|
||||
|
||||
/// A typed view into a buffer view that contains raw binary data.
|
||||
pub const Accessor = struct {
|
||||
/// The index of the bufferView.
|
||||
buffer_view: ?Index = null,
|
||||
/// The offset relative to the start of the buffer view in bytes.
|
||||
byte_offset: usize = 0,
|
||||
/// The datatype of the accessor’s components.
|
||||
component_type: ComponentType,
|
||||
/// Specifies if the accessor’s elements are scalars, vectors, or matrices.
|
||||
type: AccessorType,
|
||||
/// Computed stride: @sizeOf(component_type) * type.
|
||||
stride: usize,
|
||||
/// The number of elements referenced by this accessor.
|
||||
count: i32,
|
||||
/// Specifies whether integer data values are normalized before usage.
|
||||
normalized: bool = false,
|
||||
|
||||
pub fn iterator(
|
||||
accessor: Accessor,
|
||||
comptime T: type,
|
||||
gltf: *const Gltf,
|
||||
binary: []align(4) const u8,
|
||||
) AccessorIterator(T) {
|
||||
if (switch (accessor.component_type) {
|
||||
.byte => T != i8,
|
||||
.unsigned_byte => T != u8,
|
||||
.short => T != i16,
|
||||
.unsigned_short => T != u16,
|
||||
.unsigned_integer => T != u32,
|
||||
.float => T != f32,
|
||||
}) {
|
||||
panic(
|
||||
"Mismatch between gltf component '{}' and given type '{}'.",
|
||||
.{ accessor.component_type, T },
|
||||
);
|
||||
}
|
||||
|
||||
if (accessor.buffer_view == null) {
|
||||
panic("Accessors without buffer_view are not supported yet.", .{});
|
||||
}
|
||||
|
||||
const buffer_view = gltf.data.buffer_views.items[accessor.buffer_view.?];
|
||||
|
||||
const comp_size = @sizeOf(T);
|
||||
const offset = (accessor.byte_offset + buffer_view.byte_offset) / comp_size;
|
||||
|
||||
const stride = blk: {
|
||||
if (buffer_view.byte_stride) |byte_stride| {
|
||||
break :blk byte_stride / comp_size;
|
||||
} else {
|
||||
break :blk accessor.stride / comp_size;
|
||||
}
|
||||
};
|
||||
|
||||
const total_count: usize = @intCast(accessor.count);
|
||||
const datum_count: usize = switch (accessor.type) {
|
||||
.scalar => 1,
|
||||
.vec2 => 2,
|
||||
.vec3 => 3,
|
||||
.vec4 => 4,
|
||||
.mat4x4 => 16,
|
||||
else => {
|
||||
panic("Accessor type '{}' not implemented.", .{accessor.type});
|
||||
},
|
||||
};
|
||||
|
||||
const data: [*]const T = @ptrCast(@alignCast(binary.ptr));
|
||||
|
||||
return .{
|
||||
.offset = offset,
|
||||
.stride = stride,
|
||||
.total_count = total_count,
|
||||
.datum_count = datum_count,
|
||||
.data = data,
|
||||
.current = 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/// Iterator over accessor elements
|
||||
pub fn AccessorIterator(comptime T: type) type {
|
||||
return struct {
|
||||
offset: usize,
|
||||
stride: usize,
|
||||
total_count: usize,
|
||||
datum_count: usize,
|
||||
data: [*]const T,
|
||||
|
||||
current: usize,
|
||||
|
||||
/// Returns the next element of the accessor, or null if iteration is done.
|
||||
pub fn next(self: *@This()) ?[]const T {
|
||||
if (self.current >= self.total_count) return null;
|
||||
|
||||
const slice = (self.data + self.offset + self.current * self.stride)[0..self.datum_count];
|
||||
self.current += 1;
|
||||
return slice;
|
||||
}
|
||||
|
||||
/// Returns the next element of the accessor, or null if iteration is done. Does not change self.current.
|
||||
pub fn peek(self: *const @This()) ?[]const T {
|
||||
var copy = self.*;
|
||||
return copy.next();
|
||||
}
|
||||
|
||||
/// Resets the iterator to the first element
|
||||
pub fn reset(self: *@This()) void {
|
||||
self.current = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The root nodes of a scene.
|
||||
pub const Scene = struct {
|
||||
/// The user-defined name of this object.
|
||||
name: []const u8,
|
||||
/// The indices of each root node.
|
||||
nodes: ?ArrayList(Index) = null,
|
||||
};
|
||||
|
||||
/// Joints and matrices defining a skin.
|
||||
pub const Skin = struct {
|
||||
/// The user-defined name of this object.
|
||||
name: []const u8,
|
||||
/// The index of the accessor containing the floating-point
|
||||
/// 4x4 inverse-bind matrices.
|
||||
inverse_bind_matrices: ?Index = null,
|
||||
/// The index of the node used as a skeleton root.
|
||||
skeleton: ?Index = null,
|
||||
/// Indices of skeleton nodes, used as joints in this skin.
|
||||
joints: ArrayList(Index),
|
||||
};
|
||||
|
||||
/// Reference to a texture.
|
||||
const TextureInfo = struct {
|
||||
/// The index of the texture.
|
||||
index: Index,
|
||||
/// The set index of texture’s TEXCOORD attribute
|
||||
/// used for texture coordinate mapping.
|
||||
texcoord: i32 = 0,
|
||||
};
|
||||
|
||||
/// Reference to a normal texture.
|
||||
const NormalTextureInfo = struct {
|
||||
/// The index of the texture.
|
||||
index: Index,
|
||||
/// The set index of texture’s TEXCOORD attribute
|
||||
/// used for texture coordinate mapping.
|
||||
texcoord: i32 = 0,
|
||||
/// The scalar parameter applied to each normal
|
||||
/// vector of the normal texture.
|
||||
scale: f32 = 1,
|
||||
};
|
||||
|
||||
/// Reference to an occlusion texture.
|
||||
const OcclusionTextureInfo = struct {
|
||||
/// The index of the texture.
|
||||
index: Index,
|
||||
/// The set index of texture’s TEXCOORD attribute
|
||||
/// used for texture coordinate mapping.
|
||||
texcoord: i32 = 0,
|
||||
/// A scalar multiplier controlling the amount of occlusion applied.
|
||||
strength: f32 = 1,
|
||||
};
|
||||
|
||||
/// A set of parameter values that are used to define
|
||||
/// the metallic-roughness material model
|
||||
/// from Physically-Based Rendering methodology.
|
||||
pub const MetallicRoughness = struct {
|
||||
/// The factors for the base color of the material.
|
||||
base_color_factor: [4]f32 = [_]f32{ 1, 1, 1, 1 },
|
||||
/// The base color texture.
|
||||
base_color_texture: ?TextureInfo = null,
|
||||
/// The factor for the metalness of the material.
|
||||
metallic_factor: f32 = 1,
|
||||
/// The factor for the roughness of the material.
|
||||
roughness_factor: f32 = 1,
|
||||
/// The metallic-roughness texture.
|
||||
metallic_roughness_texture: ?TextureInfo = null,
|
||||
};
|
||||
|
||||
/// The material appearance of a primitive.
|
||||
pub const Material = struct {
|
||||
/// The user-defined name of this object.
|
||||
name: []const u8,
|
||||
/// A set of parameter values that are used to define
|
||||
/// the metallic-roughness material model
|
||||
/// from Physically Based Rendering methodology.
|
||||
metallic_roughness: MetallicRoughness = .{},
|
||||
/// The tangent space normal texture.
|
||||
normal_texture: ?NormalTextureInfo = null,
|
||||
/// The occlusion texture.
|
||||
occlusion_texture: ?OcclusionTextureInfo = null,
|
||||
/// The emissive texture.
|
||||
emissive_texture: ?TextureInfo = null,
|
||||
/// The factors for the emissive color of the material.
|
||||
emissive_factor: [3]f32 = [_]f32{ 0, 0, 0 },
|
||||
/// The alpha rendering mode of the material.
|
||||
alpha_mode: AlphaMode = .@"opaque",
|
||||
/// The alpha cutoff value of the material.
|
||||
alpha_cutoff: f32 = 0.5,
|
||||
/// Specifies whether the material is double sided.
|
||||
/// If it's false, back-face culling is enabled.
|
||||
/// If it's true, back-face culling is disabled and
|
||||
/// double sided lighting is enabled.
|
||||
is_double_sided: bool = false,
|
||||
/// Emissive strength multiplier for the emissive factor/texture.
|
||||
/// Note: from khr_materials_emissive_strength extension.
|
||||
emissive_strength: f32 = 1.0,
|
||||
/// Index of refraction of material.
|
||||
/// Note: from khr_materials_ior extension.
|
||||
ior: f32 = 1.5,
|
||||
/// The factor for the transmission of the material.
|
||||
/// Note: from khr_materials_transmission extension.
|
||||
transmission_factor: f32 = 0.0,
|
||||
/// The transmission texture.
|
||||
/// Note: from khr_materials_transmission extension.
|
||||
transmission_texture: ?TextureInfo = null,
|
||||
/// The thickness of the volume beneath the surface.
|
||||
/// Note: from khr_materials_volume extension.
|
||||
thickness_factor: f32 = 0.0,
|
||||
/// A texture that defines the thickness, stored in the G channel.
|
||||
/// Note: from khr_materials_volume extension.
|
||||
thickness_texture: ?TextureInfo = null,
|
||||
/// Density of the medium.
|
||||
/// Note: from khr_materials_volume extension.
|
||||
attenuation_distance: f32 = std.math.inf(f32),
|
||||
/// The color that white light turns into due to absorption.
|
||||
/// Note: from khr_materials_volume extension.
|
||||
attenuation_color: [3]f32 = [_]f32{ 1, 1, 1 },
|
||||
/// The strength of the dispersion effect.
|
||||
/// Note: from khr_materials_dispersion extension.
|
||||
dispersion: f32 = 0.0,
|
||||
};
|
||||
|
||||
/// The material’s alpha rendering mode enumeration specifying
|
||||
/// the interpretation of the alpha value of the base color.
|
||||
const AlphaMode = enum {
|
||||
/// The alpha value is ignored, and the rendered output is fully opaque.
|
||||
@"opaque",
|
||||
/// The rendered output is either fully opaque or fully transparent
|
||||
/// depending on the alpha value and the specified alpha_cutoff value.
|
||||
/// Note: The exact appearance of the edges may be subject to
|
||||
/// implementation-specific techniques such as “Alpha-to-Coverage”.
|
||||
mask,
|
||||
/// The alpha value is used to composite the source and destination areas.
|
||||
/// The rendered output is combined with the background using
|
||||
/// the normal painting operation (i.e. the Porter and Duff over operator).
|
||||
blend,
|
||||
};
|
||||
|
||||
/// A texture and its sampler.
|
||||
pub const Texture = struct {
|
||||
/// The index of the sampler used by this texture.
|
||||
/// When undefined, a sampler with repeat wrapping and
|
||||
/// auto filtering should be used.
|
||||
sampler: ?Index = null,
|
||||
/// The index of the image used by this texture.
|
||||
/// When undefined, an extension or other mechanism should supply
|
||||
/// an alternate texture source, otherwise behavior is undefined.
|
||||
source: ?Index = null,
|
||||
};
|
||||
|
||||
/// Image data used to create a texture.
|
||||
/// Image may be referenced by an uri or a buffer view index.
|
||||
pub const Image = struct {
|
||||
/// The URI (or IRI) of the image.
|
||||
uri: ?[]const u8 = null,
|
||||
/// The image’s media type.
|
||||
/// This field must be defined when bufferView is defined.
|
||||
mime_type: ?[]const u8 = null,
|
||||
/// The index of the bufferView that contains the image.
|
||||
/// Note: This field must not be defined when uri is defined.
|
||||
buffer_view: ?Index = null,
|
||||
/// The image's data calculated from the buffer/buffer_view.
|
||||
/// Only there if glb file is loaded.
|
||||
data: ?[]const u8 = null,
|
||||
};
|
||||
|
||||
pub const WrapMode = enum(u32) {
|
||||
clamp_to_edge = 33071,
|
||||
mirrored_repeat = 33648,
|
||||
repeat = 10497,
|
||||
};
|
||||
|
||||
pub const MinFilter = enum(u32) {
|
||||
nearest = 9728,
|
||||
linear = 9729,
|
||||
nearest_mipmap_nearest = 9984,
|
||||
linear_mipmap_nearest = 9985,
|
||||
nearest_mipmap_linear = 9986,
|
||||
linear_mipmap_linear = 9987,
|
||||
};
|
||||
|
||||
pub const MagFilter = enum(u32) {
|
||||
nearest = 9728,
|
||||
linear = 9729,
|
||||
};
|
||||
|
||||
/// Texture sampler properties for filtering and wrapping modes.
|
||||
pub const TextureSampler = struct {
|
||||
/// Magnification filter.
|
||||
mag_filter: ?MagFilter = null,
|
||||
/// Minification filter.
|
||||
min_filter: ?MinFilter = null,
|
||||
/// S (U) wrapping mode.
|
||||
wrap_s: WrapMode = .repeat,
|
||||
/// T (U) wrapping mode.
|
||||
wrap_t: WrapMode = .repeat,
|
||||
};
|
||||
|
||||
/// Values are Accessor's index.
|
||||
pub const Attribute = union(enum) {
|
||||
position: Index,
|
||||
normal: Index,
|
||||
tangent: Index,
|
||||
texcoord: Index,
|
||||
color: Index,
|
||||
joints: Index,
|
||||
weights: Index,
|
||||
};
|
||||
|
||||
pub const AccessorType = enum {
|
||||
scalar,
|
||||
vec2,
|
||||
vec3,
|
||||
vec4,
|
||||
mat2x2,
|
||||
mat3x3,
|
||||
mat4x4,
|
||||
};
|
||||
|
||||
/// Enum values from GLTF 2.0 spec.
|
||||
pub const Target = enum(u32) {
|
||||
array_buffer = 34962,
|
||||
element_array_buffer = 34963,
|
||||
};
|
||||
|
||||
/// Enum values from GLTF 2.0 spec.
|
||||
pub const ComponentType = enum(u32) {
|
||||
/// i8.
|
||||
byte = 5120,
|
||||
/// u8.
|
||||
unsigned_byte = 5121,
|
||||
/// i16.
|
||||
short = 5122,
|
||||
/// u16.
|
||||
unsigned_short = 5123,
|
||||
/// u32.
|
||||
unsigned_integer = 5125,
|
||||
/// f32.
|
||||
float = 5126,
|
||||
};
|
||||
|
||||
/// The topology type of primitives to render.
|
||||
pub const Mode = enum(u32) {
|
||||
points = 0,
|
||||
lines = 1,
|
||||
line_loop = 2,
|
||||
line_strip = 3,
|
||||
triangles = 4,
|
||||
triangle_strip = 5,
|
||||
triangle_fan = 6,
|
||||
};
|
||||
|
||||
/// The name of the node’s TRS property to animate.
|
||||
pub const TargetProperty = enum {
|
||||
/// For the "translation" property, the values that are provided by the
|
||||
/// sampler are the translation along the X, Y, and Z axes.
|
||||
translation,
|
||||
/// For the "rotation" property, the values are a quaternion
|
||||
/// in the order (x, y, z, w), where w is the scalar.
|
||||
rotation,
|
||||
/// For the "scale" property, the values are the scaling
|
||||
/// factors along the X, Y, and Z axes.
|
||||
scale,
|
||||
/// The "weights" of the Morph Targets it instantiates.
|
||||
weights,
|
||||
};
|
||||
|
||||
/// An animation channel combines an animation sampler
|
||||
/// with a target property being animated.
|
||||
pub const Channel = struct {
|
||||
/// The index of a sampler in this animation used to
|
||||
/// compute the value for the target.
|
||||
sampler: Index,
|
||||
/// The descriptor of the animated property.
|
||||
target: struct {
|
||||
/// The index of the node to animate.
|
||||
/// When undefined, the animated object may be defined by an extension.
|
||||
node: Index,
|
||||
/// The name of the node’s TRS property to animate, or the "weights"
|
||||
/// of the Morph Targets it instantiates.
|
||||
property: TargetProperty,
|
||||
},
|
||||
};
|
||||
|
||||
/// Interpolation algorithm.
|
||||
pub const Interpolation = enum {
|
||||
/// The animated values are linearly interpolated between keyframes.
|
||||
/// When targeting a rotation, spherical linear interpolation (slerp)
|
||||
/// should be used to interpolate quaternions.
|
||||
linear,
|
||||
/// The animated values remain constant to the output of the first
|
||||
/// keyframe, until the next keyframe.
|
||||
step,
|
||||
/// The animation’s interpolation is computed using a cubic
|
||||
/// spline with specified tangents.
|
||||
cubicspline,
|
||||
};
|
||||
|
||||
/// An animation sampler combines timestamps
|
||||
/// with a sequence of output values and defines an interpolation algorithm.
|
||||
pub const AnimationSampler = struct {
|
||||
/// The index of an accessor containing keyframe timestamps.
|
||||
input: Index,
|
||||
/// The index of an accessor, containing keyframe output values.
|
||||
output: Index,
|
||||
/// Interpolation algorithm.
|
||||
interpolation: Interpolation = .linear,
|
||||
};
|
||||
|
||||
/// A keyframe animation.
|
||||
pub const Animation = struct {
|
||||
/// The user-defined name of this object.
|
||||
name: []const u8,
|
||||
/// An array of animation channels.
|
||||
/// An animation channel combines an animation sampler with a target
|
||||
/// property being animated.
|
||||
/// Different channels of the same animation must not have the same targets.
|
||||
channels: ArrayList(Channel),
|
||||
/// An array of animation samplers.
|
||||
/// An animation sampler combines timestamps with a sequence of output
|
||||
/// values and defines an interpolation algorithm.
|
||||
samplers: ArrayList(AnimationSampler),
|
||||
};
|
||||
|
||||
/// Geometry to be rendered with the given material.
|
||||
pub const Primitive = struct {
|
||||
attributes: ArrayList(Attribute),
|
||||
/// The topology type of primitives to render.
|
||||
mode: Mode = .triangles,
|
||||
/// The index of the accessor that contains the vertex indices.
|
||||
indices: ?Index = null,
|
||||
/// The index of the material to apply to this primitive when rendering.
|
||||
material: ?Index = null,
|
||||
};
|
||||
|
||||
/// A set of primitives to be rendered.
|
||||
/// Its global transform is defined by a node that references it.
|
||||
pub const Mesh = struct {
|
||||
/// The user-defined name of this object.
|
||||
name: []const u8,
|
||||
/// An array of primitives, each defining geometry to be rendered.
|
||||
primitives: ArrayList(Primitive),
|
||||
};
|
||||
|
||||
/// Metadata about the glTF asset.
|
||||
pub const Asset = struct {
|
||||
/// The glTF version that this asset targets.
|
||||
version: []const u8,
|
||||
/// Tool that generated this glTF model. Useful for debugging.
|
||||
generator: ?[]const u8 = null,
|
||||
/// A copyright message suitable for display to credit the content creator.
|
||||
copyright: ?[]const u8 = null,
|
||||
};
|
||||
|
||||
/// A camera’s projection.
|
||||
/// A node may reference a camera to apply a transform to place the camera
|
||||
/// in the scene.
|
||||
pub const Camera = struct {
|
||||
/// A perspective camera containing properties to create a
|
||||
/// perspective projection matrix.
|
||||
pub const Perspective = struct {
|
||||
/// The aspect ratio of the field of view.
|
||||
aspect_ratio: ?f32,
|
||||
/// The vertical field of view in radians.
|
||||
/// This value should be less than π.
|
||||
yfov: f32,
|
||||
/// The distance to the far clipping plane.
|
||||
zfar: ?f32,
|
||||
/// The distance to the near clipping plane.
|
||||
znear: f32,
|
||||
};
|
||||
|
||||
/// An orthographic camera containing properties to create an
|
||||
/// orthographic projection matrix.
|
||||
pub const Orthographic = struct {
|
||||
/// The horizontal magnification of the view.
|
||||
/// This value must not be equal to zero.
|
||||
/// This value should not be negative.
|
||||
xmag: f32,
|
||||
/// The vertical magnification of the view.
|
||||
/// This value must not be equal to zero.
|
||||
/// This value should not be negative.
|
||||
ymag: f32,
|
||||
/// The distance to the far clipping plane.
|
||||
/// This value must not be equal to zero.
|
||||
/// This value must be greater than znear.
|
||||
zfar: f32,
|
||||
/// The distance to the near clipping plane.
|
||||
znear: f32,
|
||||
};
|
||||
|
||||
name: []const u8,
|
||||
type: union(enum) {
|
||||
perspective: Perspective,
|
||||
orthographic: Orthographic,
|
||||
},
|
||||
};
|
||||
|
||||
/// Specifies the light type.
|
||||
pub const LightType = enum {
|
||||
/// Directional lights act as though they are infinitely far away and emit light in the direction of the local -z axis.
|
||||
/// This light type inherits the orientation of the node that it belongs to; position and scale are ignored
|
||||
/// except for their effect on the inherited node orientation. Because it is at an infinite distance,
|
||||
/// the light is not attenuated. Its intensity is defined in lumens per metre squared, or lux (lm/m^2).
|
||||
directional,
|
||||
/// Point lights emit light in all directions from their position in space; rotation and scale are ignored except
|
||||
/// for their effect on the inherited node position.
|
||||
/// The brightness of the light attenuates in a physically correct manner as distance increases from
|
||||
/// the light's position (i.e. brightness goes like the inverse square of the distance).
|
||||
/// Point light intensity is defined in candela, which is lumens per square radian (lm/sr).
|
||||
point,
|
||||
/// Spot lights emit light in a cone in the direction of the local -z axis.
|
||||
/// The angle and falloff of the cone is defined using two numbers, the innerConeAngle and outerConeAngle.
|
||||
/// As with point lights, the brightness also attenuates in a physically correct manner as distance
|
||||
/// increases from the light's position (i.e. brightness goes like the inverse square of the distance).
|
||||
/// Spot light intensity refers to the brightness inside the innerConeAngle (and at the location of the light) and
|
||||
/// is defined in candela, which is lumens per square radian (lm/sr).
|
||||
///
|
||||
/// Engines that don't support two angles for spotlights should use outerConeAngle as the spotlight angle,
|
||||
/// leaving innerConeAngle to implicitly be 0.
|
||||
spot,
|
||||
};
|
||||
|
||||
/// A directional, point or spot light.
|
||||
pub const Light = struct {
|
||||
name: ?[]const u8,
|
||||
/// Color of the light source.
|
||||
color: [3]f32 = .{ 1, 1, 1 },
|
||||
/// Intensity of the light source. `point` and `spot` lights use luminous intensity in candela (lm/sr)
|
||||
/// while `directional` lights use illuminance in lux (lm/m^2).
|
||||
intensity: f32 = 1,
|
||||
/// Specifies the light type.
|
||||
type: LightType,
|
||||
/// When a light's type is spot, the spot property on the light is required.
|
||||
spot: ?LightSpot,
|
||||
/// A distance cutoff at which the light's intensity may be considered to have reached zero.
|
||||
range: f32,
|
||||
};
|
||||
|
||||
pub const LightSpot = struct {
|
||||
/// Angle in radians from centre of spotlight where falloff begins.
|
||||
inner_cone_angle: f32 = 0,
|
||||
/// Angle in radians from centre of spotlight where falloff ends.
|
||||
outer_cone_angle: f32 = pi / @as(f32, 4),
|
||||
};
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
{
|
||||
"asset": {
|
||||
"generator": "COLLADA2GLTF",
|
||||
"version": "2.0"
|
||||
},
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"children": [
|
||||
1
|
||||
],
|
||||
"matrix": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"NORMAL": 1,
|
||||
"POSITION": 2
|
||||
},
|
||||
"indices": 0,
|
||||
"mode": 4,
|
||||
"material": 0
|
||||
}
|
||||
],
|
||||
"name": "Mesh"
|
||||
}
|
||||
],
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5123,
|
||||
"count": 36,
|
||||
"max": [
|
||||
23
|
||||
],
|
||||
"min": [
|
||||
0
|
||||
],
|
||||
"type": "SCALAR"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"min": [
|
||||
-1.0,
|
||||
-1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 288,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
-0.5
|
||||
],
|
||||
"type": "VEC3"
|
||||
}
|
||||
],
|
||||
"materials": [
|
||||
{
|
||||
"pbrMetallicRoughness": {
|
||||
"baseColorFactor": [
|
||||
0.800000011920929,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"metallicFactor": 0.0
|
||||
},
|
||||
"name": "Red"
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 576,
|
||||
"byteLength": 72,
|
||||
"target": 34963
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 0,
|
||||
"byteLength": 576,
|
||||
"byteStride": 12,
|
||||
"target": 34962
|
||||
}
|
||||
],
|
||||
"buffers": [
|
||||
{
|
||||
"byteLength": 648,
|
||||
"uri": "Box0.bin"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue