add bindings
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
BeefSpace_User.toml
|
||||
BeefSpace_Lock.toml
|
||||
build
|
||||
recovery
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "KTX-Software"]
|
||||
path = KTX-Software
|
||||
url = https://github.com/KhronosGroup/KTX-Software.git
|
||||
@@ -0,0 +1,14 @@
|
||||
FileVersion = 1
|
||||
|
||||
[Project]
|
||||
Name = "KTX"
|
||||
TargetType = "BeefLib"
|
||||
StartupObject = "KTX.Program"
|
||||
|
||||
[Dependencies]
|
||||
corlib = "*"
|
||||
"CxxBuildTool.git" = {Git = "https://git.unicon-gmbh.de/Rune/CxxBuildTool.git"}
|
||||
|
||||
[[ProjectFolder.Items]]
|
||||
Type = "IgnoreSource"
|
||||
Name = "KTXVulkan.bf"
|
||||
@@ -0,0 +1,8 @@
|
||||
FileVersion = 1
|
||||
|
||||
[Workspace]
|
||||
StartupProject = "KTX"
|
||||
|
||||
[Projects]
|
||||
KTX = {Path = "."}
|
||||
"CxxBuildTool.git" = {Git = "https://git.unicon-gmbh.de/Rune/CxxBuildTool.git"}
|
||||
Submodule
+1
Submodule KTX-Software added at b9bcfeb1df
@@ -0,0 +1,9 @@
|
||||
FileVersion = 1
|
||||
|
||||
[Project]
|
||||
Name = "KTX.Setup"
|
||||
StartupObject = "KTX.Setup.Program"
|
||||
|
||||
[Dependencies]
|
||||
corlib = "*"
|
||||
"Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/Rune/Cpp2Beef.git"}
|
||||
@@ -0,0 +1,8 @@
|
||||
FileVersion = 1
|
||||
|
||||
[Workspace]
|
||||
StartupProject = "KTX.Setup"
|
||||
|
||||
[Projects]
|
||||
"KTX.Setup" = {Path = "."}
|
||||
"Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/Rune/Cpp2Beef.git"}
|
||||
@@ -0,0 +1,5 @@
|
||||
#define VK_NO_PROTOTYPES
|
||||
#include "vulkan/vulkan_core.h"
|
||||
#include <ktx.h>
|
||||
#include <ktxvulkan.h>
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Cpp2Beef;
|
||||
using LibClang;
|
||||
|
||||
namespace KTX.Setup;
|
||||
|
||||
class ExampleGenerator : Cpp2BeefGenerator, this(Span<char8*> args)
|
||||
{
|
||||
protected override Span<char8*> Args => args;
|
||||
protected override Flags Flags => .None;
|
||||
|
||||
StreamWriter ktxWriter = new .()..Create("../src/KTX.bf")..Write("""
|
||||
// This file was generated by Cpp2Beef
|
||||
|
||||
using System;
|
||||
using System.Interop;
|
||||
|
||||
namespace KTX;
|
||||
|
||||
|
||||
""") ~ delete _;
|
||||
StreamWriter ktxVulkanWriter = new .()..Create("../src/KTXVulkan.bf")..Write("""
|
||||
// This file was generated by Cpp2Beef
|
||||
|
||||
using System;
|
||||
using System.Interop;
|
||||
|
||||
namespace KTX;
|
||||
|
||||
|
||||
""") ~ delete _;
|
||||
StreamWriter khrDfWriter = new .()..Create("../src/KHR_df.bf")..Write("""
|
||||
// This file was generated by Cpp2Beef
|
||||
|
||||
using System;
|
||||
using System.Interop;
|
||||
|
||||
namespace KTX;
|
||||
|
||||
|
||||
""") ~ delete _;
|
||||
|
||||
protected override StreamWriter GetWriterForHeader(StringView header)
|
||||
{
|
||||
if (header.EndsWith("ktx.h"))
|
||||
return ktxWriter;
|
||||
if (header.EndsWith("ktxvulkan.h"))
|
||||
return ktxVulkanWriter;
|
||||
if (header.EndsWith("khr_df.h"))
|
||||
return khrDfWriter;
|
||||
return null;
|
||||
}
|
||||
|
||||
Dictionary<String, CXType> vtblPfns = new .(24) ~ DeleteDictionaryAndKeys!(_);
|
||||
|
||||
protected override void HandleCursor(CXCursor cursor)
|
||||
{
|
||||
switch (cursor.kind)
|
||||
{
|
||||
case .TypedefDecl:
|
||||
let spelling = GetCursorSpelling!(cursor);
|
||||
if (spelling == "ktxHashList" || spelling == "ktxHashListEntry" || spelling == "ktxStream")
|
||||
return;
|
||||
case .MacroDefinition:
|
||||
let spelling = GetCursorSpelling!(cursor);
|
||||
if (spelling == "KTXTEXTURECLASSDEFN" || spelling == "KTX_APIENTRYP" || spelling == "KTX_API" ||
|
||||
spelling == "KTX_APIENTRY" || spelling == "KTX_error_code")
|
||||
return;
|
||||
|
||||
if (Clang.Cursor_IsMacroFunctionLike(cursor) == 0 || !spelling.StartsWith("ktx")) break;
|
||||
BeginCursor(cursor);
|
||||
AccessSpecifier(cursor);
|
||||
str.Append("static ");
|
||||
let nameInBindings = spelling[(spelling.IndexOf('_')+1)...];
|
||||
Runtime.Assert(vtblPfns.TryGetAlt(nameInBindings, ?, let pfnType));
|
||||
Type(Clang.GetResultType(pfnType));
|
||||
str.Append(' ');
|
||||
str.Append(nameInBindings);
|
||||
Flush();
|
||||
let tokens = ScopeTokenize!(cursor, unit);
|
||||
WriteTokens(tokens[1...], Clang.GetRangeEnd(Clang.Cursor_GetSpellingNameRange(cursor, 0, 0)), .Identifier);
|
||||
String buffer = scope .(256)..Append(str);
|
||||
uint32 argI = 0;
|
||||
insert: for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
switch (buffer[i])
|
||||
{
|
||||
case '(', ',':
|
||||
str.Clear();
|
||||
Type(Clang.GetArgType(pfnType, argI++));
|
||||
str.Append(' ');
|
||||
int idx = i+1 + (_ == ',' ? 1 : 0);
|
||||
buffer.Insert(idx, str);
|
||||
case ')':
|
||||
buffer.Insert(i+1, " =>");
|
||||
break insert;
|
||||
}
|
||||
}
|
||||
buffer.Replace("->", ".");
|
||||
str.Set(buffer);
|
||||
str.Append(';');
|
||||
return;
|
||||
case .StructDecl:
|
||||
if (Clang.Cursor_IsAnonymous(cursor) != 0)
|
||||
return;
|
||||
if (Clang.GetCursorLexicalParent(cursor).kind == .StructDecl)
|
||||
return;
|
||||
let spelling = GetCursorSpelling!(cursor);
|
||||
if (spelling == "ktxKVListEntry" || (spelling == "ktxStream" && Clang.EqualCursors(cursor, Clang.GetTypeDeclaration(Clang.GetCursorType(cursor))) != 0))
|
||||
return;
|
||||
BeginCursor(cursor);
|
||||
Record(cursor);
|
||||
return;
|
||||
case .FieldDecl:
|
||||
if (GetCursorSpelling!(Clang.GetCursorSemanticParent(cursor)) == "ktxTexture_vtbl")
|
||||
vtblPfns.Add(new .(GetCursorSpelling!(cursor)),
|
||||
Clang.GetPointeeType(Clang.GetTypedefDeclUnderlyingType(Clang.GetTypeDeclaration(Clang.GetCursorType(cursor))))
|
||||
);
|
||||
default:
|
||||
}
|
||||
base.HandleCursor(cursor);
|
||||
if (fileInfo.prevEnd == default)
|
||||
fileInfo.prevEnd = GetCursorAnchor(cursor);
|
||||
}
|
||||
|
||||
append String blockBuffer;
|
||||
protected override Block GetCursorBlock(CXCursor cursor)
|
||||
{
|
||||
if (cursor.kind == .FunctionDecl || cursor.kind == .MacroDefinition) do
|
||||
{
|
||||
let spelling = GetCursorSpelling!(cursor);
|
||||
if (!spelling.StartsWith("ktx")) break;
|
||||
int index = spelling.IndexOf('_');
|
||||
if (index < 0) break;
|
||||
blockBuffer.Set(spelling[..<index]);
|
||||
return .CustomBlock(blockBuffer);
|
||||
}
|
||||
return base.GetCursorBlock(cursor);
|
||||
}
|
||||
|
||||
protected override void WriteCustomAttributes(CXCursor cursor)
|
||||
{
|
||||
if (cursor.kind == .FunctionDecl || (cursor.kind == .TypedefDecl &&
|
||||
{
|
||||
let type = Clang.GetTypedefDeclUnderlyingType(cursor);
|
||||
let pointee = Clang.GetPointeeType(type).kind;
|
||||
type.kind == .Pointer && (pointee == .FunctionNoProto || pointee == .FunctionProto)
|
||||
}))
|
||||
{
|
||||
str.Append("[CallingConvention(KTX_APIENTRYP)] ");
|
||||
}
|
||||
base.WriteCustomAttributes(cursor);
|
||||
}
|
||||
|
||||
protected override void WriteTokensAfterEquals(CXCursor cursor)
|
||||
{
|
||||
if (cursor.kind == .ParmDecl)
|
||||
return; // avoid clang compiler bug
|
||||
base.WriteTokensAfterEquals(cursor);
|
||||
}
|
||||
|
||||
protected override void WriteToken(CXToken token)
|
||||
{
|
||||
if (currentCursor.kind == .MacroDefinition)
|
||||
{
|
||||
let cursorSpelling = GetCursorSpelling!(currentCursor);
|
||||
if (Clang.GetTokenKind(token) == .Punctuation && cursorSpelling == "KTX_IDENTIFIER_REF")
|
||||
switch (GetTokenSpelling!(token))
|
||||
{
|
||||
case "{": str.Append("uint8[?]("); return;
|
||||
case "}": str.Append(')'); return;
|
||||
}
|
||||
else if (cursorSpelling == "KTX_TRUE" || cursorSpelling == "KTX_FALSE")
|
||||
{
|
||||
str.Append(GetTokenSpelling!(token));
|
||||
return;
|
||||
}
|
||||
else if (cursorSpelling == "KTX_FACESLICE_WHOLE_LEVEL")
|
||||
{
|
||||
str.Append("uint32.MaxValue");
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.WriteToken(token);
|
||||
}
|
||||
|
||||
protected override void Type(CXType type, TypeParamMode paramMode = .None)
|
||||
{
|
||||
if (currentCursor.kind == .TypedefDecl && Clang.EqualTypes(Clang.GetCursorType(currentCursor), type) != 0 && GetTypeSpelling!(type) == "ktx_uint32_t")
|
||||
{
|
||||
let cursorSpelling = GetCursorSpelling!(currentCursor);
|
||||
str.Append(cursorSpelling);
|
||||
if (cursorSpelling.EndsWith("_flags"))
|
||||
{
|
||||
str.Length--;
|
||||
str.Append("_bits");
|
||||
}
|
||||
str.Append("_e");
|
||||
return;
|
||||
}
|
||||
base.Type(type, paramMode);
|
||||
}
|
||||
|
||||
protected override void GetNameInBindings(CXCursor cursor, String outString)
|
||||
{
|
||||
switch (cursor.kind)
|
||||
{
|
||||
case .EnumDecl:
|
||||
var spelling = GetCursorSpelling!(cursor);
|
||||
if (spelling.StartsWith("_khr"))
|
||||
spelling.RemoveFromStart(1);
|
||||
outString.Append(spelling);
|
||||
return;
|
||||
case .EnumConstantDecl:
|
||||
var parent = GetCursorSpelling!(Clang.GetCursorSemanticParent(cursor));
|
||||
if (parent == "ktx_error_code_e") break;
|
||||
if (parent == "_khr_word_e")
|
||||
parent = "khr_df_word_e";
|
||||
var spelling = GetCursorSpelling!(cursor);
|
||||
if (parent == "_khr_df_model_channels_e")
|
||||
{
|
||||
spelling.RemoveFromStart("KHR_DF_CHANNEL_".Length);
|
||||
outString.Append(spelling);
|
||||
return;
|
||||
}
|
||||
if (parent == "ktxSupercmpScheme")
|
||||
{
|
||||
spelling.RemoveFromStart("KTX_SS_".Length);
|
||||
UpperSnakeCase2PascalCase(spelling, outString);
|
||||
return;
|
||||
}
|
||||
if (parent == "ktxTextureCreateStorageEnum")
|
||||
{
|
||||
spelling.RemoveFromStart("KTX_TEXTURE_CREATE_".Length);
|
||||
UpperSnakeCase2PascalCase(spelling, outString);
|
||||
return;
|
||||
}
|
||||
if (parent == "ktxTextureCreateFlagBits")
|
||||
{
|
||||
spelling.RemoveFromStart("KTX_TEXTURE_CREATE_".Length);
|
||||
if (spelling.EndsWith("_BIT"))
|
||||
spelling.RemoveFromEnd(4);
|
||||
UpperSnakeCase2PascalCase(spelling, outString);
|
||||
return;
|
||||
}
|
||||
for (var part in parent.Split('_', .RemoveEmptyEntries))
|
||||
{
|
||||
if (part == "e") break;
|
||||
part.Length++;
|
||||
if (!spelling.StartsWith(part, .OrdinalIgnoreCase))
|
||||
{
|
||||
if (part.EndsWith("s_") && spelling.StartsWith(part[..<^2], .OrdinalIgnoreCase))
|
||||
part.Length--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
spelling.RemoveFromStart(part.Length);
|
||||
}
|
||||
if (spelling[0].IsDigit)
|
||||
outString.Append('_');
|
||||
UpperSnakeCase2PascalCase(spelling, outString);
|
||||
return;
|
||||
case .FunctionDecl:
|
||||
let spelling = GetCursorSpelling!(cursor);
|
||||
int index = spelling.IndexOf('_');
|
||||
if (index < 0) break;
|
||||
outString.Append(spelling[(index+1)...]);
|
||||
return;
|
||||
default:
|
||||
}
|
||||
base.GetNameInBindings(cursor, outString);
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
[CLink] static extern int32 system(char8*);
|
||||
|
||||
public static int Main(String[] args)
|
||||
{
|
||||
if (system("git -C .. submodule init") != 0)
|
||||
Runtime.FatalError("Failed to fetch KTX-Software");
|
||||
/*if (system(scope $"wget -O include/KHR/khr_df.h https://registry.khronos.org/DataFormat/api/1.3/khr_df.h") != 0)
|
||||
Runtime.FatalError("Failed to download khr_df.h");
|
||||
if (system(scope $"wget -O include/vulkan_core.h https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/refs/heads/main/include/vulkan/vulkan_core.h") != 0)
|
||||
Runtime.FatalError("Failed to download vulkan_core.h");
|
||||
if (system(scope $"wget -O include/vk_platform.h https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/refs/heads/main/include/vulkan/vk_platform.h") != 0)
|
||||
Runtime.FatalError("Failed to download vk_platform.h");*/
|
||||
|
||||
scope ExampleGenerator(char8*[?]("--language=c", "-I../KTX-Software/lib/include", "-I../KTX-Software/external/dfdutils", "-DKTX_DOXYGEN_SKIP")).Generate("include/all.h");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+691
@@ -0,0 +1,691 @@
|
||||
// This file was generated by Cpp2Beef
|
||||
|
||||
using System;
|
||||
using System.Interop;
|
||||
|
||||
namespace KTX;
|
||||
|
||||
static
|
||||
{
|
||||
/* The Khronos Data Format Specification (version 1.4.1) */
|
||||
/*
|
||||
** Copyright 2015-2026 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* This header defines a structure that can describe the layout of image
|
||||
formats in memory. This means that the data format is transparent to
|
||||
the application, and the expectation is that this should be used when
|
||||
the layout is defined external to the API. Many Khronos APIs deliberately
|
||||
keep the internal layout of images opaque, to allow proprietary layouts
|
||||
and optimisations. This structure is not appropriate for describing
|
||||
opaque layouts. */
|
||||
|
||||
/* We stick to standard C89 constructs for simplicity and portability. */
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Accessors */
|
||||
[AllowDuplicates] public enum khr_word_e : c_int {
|
||||
Vendorid = 0U,
|
||||
Descriptortype = 0U,
|
||||
Versionnumber = 1U,
|
||||
Descriptorblocksize = 1U,
|
||||
Model = 2U,
|
||||
Primaries = 2U,
|
||||
Transfer = 2U,
|
||||
Flags = 2U,
|
||||
Texelblockdimension0 = 3U,
|
||||
Texelblockdimension1 = 3U,
|
||||
Texelblockdimension2 = 3U,
|
||||
Texelblockdimension3 = 3U,
|
||||
Bytesplane0 = 4U,
|
||||
Bytesplane1 = 4U,
|
||||
Bytesplane2 = 4U,
|
||||
Bytesplane3 = 4U,
|
||||
Bytesplane4 = 5U,
|
||||
Bytesplane5 = 5U,
|
||||
Bytesplane6 = 5U,
|
||||
Bytesplane7 = 5U,
|
||||
Samplestart = 6U,
|
||||
Samplewords = 4U,
|
||||
} public typealias khr_df_word_e = khr_word_e;
|
||||
|
||||
[AllowDuplicates] public enum khr_df_shift_e : c_int {
|
||||
Vendorid = 0U,
|
||||
Descriptortype = 17U,
|
||||
Versionnumber = 0U,
|
||||
Descriptorblocksize = 16U,
|
||||
Model = 0U,
|
||||
Primaries = 8U,
|
||||
Transfer = 16U,
|
||||
Flags = 24U,
|
||||
Texelblockdimension0 = 0U,
|
||||
Texelblockdimension1 = 8U,
|
||||
Texelblockdimension2 = 16U,
|
||||
Texelblockdimension3 = 24U,
|
||||
Bytesplane0 = 0U,
|
||||
Bytesplane1 = 8U,
|
||||
Bytesplane2 = 16U,
|
||||
Bytesplane3 = 24U,
|
||||
Bytesplane4 = 0U,
|
||||
Bytesplane5 = 8U,
|
||||
Bytesplane6 = 16U,
|
||||
Bytesplane7 = 24U,
|
||||
}
|
||||
|
||||
[AllowDuplicates] public enum khr_df_mask_e : c_int {
|
||||
Vendorid = 0x1FFFFU,
|
||||
Descriptortype = 0x7FFFU,
|
||||
Versionnumber = 0xFFFFU,
|
||||
Descriptorblocksize = 0xFFFFU,
|
||||
Model = 0xFFU,
|
||||
Primaries = 0xFFU,
|
||||
Transfer = 0xFFU,
|
||||
Flags = 0xFFU,
|
||||
Texelblockdimension0 = 0xFFU,
|
||||
Texelblockdimension1 = 0xFFU,
|
||||
Texelblockdimension2 = 0xFFU,
|
||||
Texelblockdimension3 = 0xFFU,
|
||||
Bytesplane0 = 0xFFU,
|
||||
Bytesplane1 = 0xFFU,
|
||||
Bytesplane2 = 0xFFU,
|
||||
Bytesplane3 = 0xFFU,
|
||||
Bytesplane4 = 0xFFU,
|
||||
Bytesplane5 = 0xFFU,
|
||||
Bytesplane6 = 0xFFU,
|
||||
Bytesplane7 = 0xFFU,
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
/* Helper macro:
|
||||
Extract field X from basic descriptor block BDB */
|
||||
|
||||
|
||||
|
||||
|
||||
/* Helper macro:
|
||||
Set field X of basic descriptor block BDB */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Offsets relative to the start of a sample */
|
||||
[AllowDuplicates] public enum khr_df_sampleword_e : c_int {
|
||||
Bitoffset = 0U,
|
||||
Bitlength = 0U,
|
||||
Channelid = 0U,
|
||||
Qualifiers = 0U,
|
||||
Sampleposition0 = 1U,
|
||||
Sampleposition1 = 1U,
|
||||
Sampleposition2 = 1U,
|
||||
Sampleposition3 = 1U,
|
||||
SamplepositionAll = 1U,
|
||||
Samplelower = 2U,
|
||||
Sampleupper = 3U,
|
||||
}
|
||||
|
||||
[AllowDuplicates] public enum khr_df_sampleshift_e : c_int {
|
||||
Bitoffset = 0U,
|
||||
Bitlength = 16U,
|
||||
Channelid = 24U,
|
||||
/* N.B. Qualifiers are defined as an offset into a byte */
|
||||
Qualifiers = 24U,
|
||||
Sampleposition0 = 0U,
|
||||
Sampleposition1 = 8U,
|
||||
Sampleposition2 = 16U,
|
||||
Sampleposition3 = 24U,
|
||||
SamplepositionAll = 0U,
|
||||
Samplelower = 0U,
|
||||
Sampleupper = 0U,
|
||||
}
|
||||
|
||||
[AllowDuplicates] public enum khr_df_samplemask_e : c_int {
|
||||
Bitoffset = 0xFFFFU,
|
||||
Bitlength = 0xFFU,
|
||||
Channelid = 0xFU,
|
||||
/* N.B. Qualifiers are defined as an offset into a byte */
|
||||
Qualifiers = 0xF0U,
|
||||
Sampleposition0 = 0xFFU,
|
||||
Sampleposition1 = 0xFFU,
|
||||
Sampleposition2 = 0xFFU,
|
||||
Sampleposition3 = 0xFFU,
|
||||
/* ISO C restricts enum values to range of int hence the
|
||||
cast. We do it verbosely instead of using -1 to ensure
|
||||
it is a 32-bit value even if int is 64 bits. */
|
||||
SamplepositionAll = (int) 0xFFFFFFFFU,
|
||||
Samplelower = (int) 0xFFFFFFFFU,
|
||||
Sampleupper = (int) 0xFFFFFFFFU,
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
/* Helper macro:
|
||||
Extract field X of sample S from basic descriptor block BDB */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Helper macro:
|
||||
Set field X of sample S of basic descriptor block BDB */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Helper macro:
|
||||
Number of samples in basic descriptor block BDB */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Helper macro:
|
||||
Size in words of basic descriptor block for S samples */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Vendor ids */
|
||||
[AllowDuplicates] public enum khr_df_vendorid_e : c_int {
|
||||
/* Standard Khronos descriptor */
|
||||
Khronos = 0U,
|
||||
Max = 0x1FFFFU,
|
||||
}
|
||||
|
||||
/* Descriptor types */
|
||||
[AllowDuplicates] public enum khr_df_khr_descriptortype_e : c_int {
|
||||
/* Default Khronos basic descriptor block */
|
||||
Basicformat = 0U,
|
||||
/* Extension descriptor block for additional planes */
|
||||
AdditionalPlanes = 0x6001U,
|
||||
/* Extension descriptor block for additional dimensions */
|
||||
AdditionalDimensions = 0x6002U,
|
||||
/* Bit indicates modifying requires understanding this extension */
|
||||
NeededForWriteBit = 0x2000U,
|
||||
/* Bit indicates processing requires understanding this extension */
|
||||
NeededForDecodeBit = 0x4000U,
|
||||
Max = 0x7FFFU,
|
||||
}
|
||||
|
||||
/* Descriptor block version */
|
||||
[AllowDuplicates] public enum khr_df_versionnumber_e : c_int {
|
||||
/* Standard Khronos descriptor */
|
||||
_10 = 0U, /* Version 1.0 of the specification */
|
||||
_11 = 0U, /* Version 1.1 did not bump the version number */
|
||||
_12 = 1U, /* Version 1.2 increased the version number */
|
||||
_13 = 2U, /* Version 1.3 increased the version number */
|
||||
_14 = 2U, /* Version 1.4.0 did not bump the block version number */
|
||||
Latest = _14,
|
||||
Max = 0xFFFFU,
|
||||
}
|
||||
|
||||
/* Model in which the color coordinate space is defined.
|
||||
There is no requirement that a color format use all the
|
||||
channel types that are defined in the color model. */
|
||||
[AllowDuplicates] public enum khr_df_model_e : c_int {
|
||||
/* No interpretation of color channels defined */
|
||||
Unspecified = 0U,
|
||||
/* Color primaries (red, green, blue) + alpha, depth and stencil */
|
||||
Rgbsda = 1U,
|
||||
/* Color differences (Y', Cb, Cr) + alpha, depth and stencil */
|
||||
Yuvsda = 2U,
|
||||
/* Color differences (Y', I, Q) + alpha, depth and stencil */
|
||||
Yiqsda = 3U,
|
||||
/* Perceptual color (CIE L*a*b*) + alpha, depth and stencil */
|
||||
Labsda = 4U,
|
||||
/* Subtractive colors (cyan, magenta, yellow, black) + alpha */
|
||||
Cmyka = 5U,
|
||||
/* Non-color coordinate data (X, Y, Z, W) */
|
||||
Xyzw = 6U,
|
||||
/* Hue, saturation, value, hue angle on color circle, plus alpha */
|
||||
HsvaAng = 7U,
|
||||
/* Hue, saturation, lightness, hue angle on color circle, plus alpha */
|
||||
HslaAng = 8U,
|
||||
/* Hue, saturation, value, hue on color hexagon, plus alpha */
|
||||
HsvaHex = 9U,
|
||||
/* Hue, saturation, lightness, hue on color hexagon, plus alpha */
|
||||
HslaHex = 10U,
|
||||
/* Lightweight approximate color difference (luma, orange, green) */
|
||||
Ycgcoa = 11U,
|
||||
/* ITU BT.2020 constant luminance YcCbcCrc */
|
||||
Yccbccrc = 12U,
|
||||
/* ITU BT.2100 constant intensity ICtCp */
|
||||
Ictcp = 13U,
|
||||
/* CIE 1931 XYZ color coordinates (X, Y, Z) */
|
||||
Ciexyz = 14U,
|
||||
/* CIE 1931 xyY color coordinates (X, Y, Y) */
|
||||
Ciexyy = 15U,
|
||||
|
||||
/* Compressed formats start at 128. */
|
||||
/* These compressed formats should generally have a single sample,
|
||||
sited at the 0,0 position of the texel block. Where multiple
|
||||
channels are used to distinguish formats, these should be cosited. */
|
||||
/* Direct3D (and S3) compressed formats */
|
||||
/* Note that premultiplied status is recorded separately */
|
||||
/* DXT1 "channels" are RGB (0), Alpha (1) */
|
||||
/* DXT1/BC1 with one channel is opaque */
|
||||
/* DXT1/BC1 with a cosited alpha sample is transparent */
|
||||
Dxt1a = 128U,
|
||||
Bc1a = 128U,
|
||||
/* DXT2/DXT3/BC2, with explicit 4-bit alpha */
|
||||
Dxt2 = 129U,
|
||||
Dxt3 = 129U,
|
||||
Bc2 = 129U,
|
||||
/* DXT4/DXT5/BC3, with interpolated alpha */
|
||||
Dxt4 = 130U,
|
||||
Dxt5 = 130U,
|
||||
Bc3 = 130U,
|
||||
/* ATI1n/DXT5A/BC4 - single channel interpolated 8-bit data */
|
||||
/* (The UNORM/SNORM variation is recorded in the channel data) */
|
||||
Ati1n = 131U,
|
||||
Dxt5a = 131U,
|
||||
Bc4 = 131U,
|
||||
/* ATI2n_XY/DXN/BC5 - two channel interpolated 8-bit data */
|
||||
/* (The UNORM/SNORM variation is recorded in the channel data) */
|
||||
Ati2nXy = 132U,
|
||||
Dxn = 132U,
|
||||
Bc5 = 132U,
|
||||
/* BC6H - DX11 format for 16-bit float channels */
|
||||
Bc6h = 133U,
|
||||
/* BC7 - DX11 format */
|
||||
Bc7 = 134U,
|
||||
/* Gap left for future desktop expansion */
|
||||
|
||||
/* Mobile compressed formats follow */
|
||||
/* A format of ETC1 indicates that the format shall be decodable
|
||||
by an ETC1-compliant decoder and not rely on ETC2 features */
|
||||
Etc1 = 160U,
|
||||
/* A format of ETC2 is permitted to use ETC2 encodings on top of
|
||||
the baseline ETC1 specification */
|
||||
/* The ETC2 format has channels "red", "green", "RGB" and "alpha",
|
||||
which should be cosited samples */
|
||||
/* Punch-through alpha can be distinguished from full alpha by
|
||||
the plane size in bytes required for the texel block */
|
||||
Etc2 = 161U,
|
||||
/* Adaptive Scalable Texture Compression */
|
||||
/* ASTC HDR vs LDR is determined by the float flag in the channel */
|
||||
/* ASTC block size can be distinguished by texel block size */
|
||||
Astc = 162U,
|
||||
/* ETC1S is a simplified subset of ETC1 */
|
||||
Etc1s = 163U,
|
||||
/* PowerVR Texture Compression */
|
||||
Pvrtc = 164U,
|
||||
Pvrtc2 = 165U,
|
||||
/* UASTC for BASIS supercompression */
|
||||
Uastc = 166U,
|
||||
UastcLdr4x4 = 166U,
|
||||
UastcHdr4x4 = 167U,
|
||||
UastcHdr6x6 = 168U,
|
||||
/* Proprietary formats (ATITC, etc.) should follow */
|
||||
Max = 0xFFU,
|
||||
}
|
||||
|
||||
/* Definition of channel names for each color model */
|
||||
[AllowDuplicates] public enum khr_df_model_channels_e : c_int {
|
||||
/* Unspecified format with nominal channel numbering */
|
||||
UNSPECIFIED_0 = 0U,
|
||||
UNSPECIFIED_1 = 1U,
|
||||
UNSPECIFIED_2 = 2U,
|
||||
UNSPECIFIED_3 = 3U,
|
||||
UNSPECIFIED_4 = 4U,
|
||||
UNSPECIFIED_5 = 5U,
|
||||
UNSPECIFIED_6 = 6U,
|
||||
UNSPECIFIED_7 = 7U,
|
||||
UNSPECIFIED_8 = 8U,
|
||||
UNSPECIFIED_9 = 9U,
|
||||
UNSPECIFIED_10 = 10U,
|
||||
UNSPECIFIED_11 = 11U,
|
||||
UNSPECIFIED_12 = 12U,
|
||||
UNSPECIFIED_13 = 13U,
|
||||
UNSPECIFIED_14 = 14U,
|
||||
UNSPECIFIED_15 = 15U,
|
||||
/* MODEL_RGBSDA - red, green, blue, stencil, depth, alpha */
|
||||
RGBSDA_RED = 0U,
|
||||
RGBSDA_R = 0U,
|
||||
RGBSDA_GREEN = 1U,
|
||||
RGBSDA_G = 1U,
|
||||
RGBSDA_BLUE = 2U,
|
||||
RGBSDA_B = 2U,
|
||||
RGBSDA_STENCIL = 13U,
|
||||
RGBSDA_S = 13U,
|
||||
RGBSDA_DEPTH = 14U,
|
||||
RGBSDA_D = 14U,
|
||||
RGBSDA_ALPHA = 15U,
|
||||
RGBSDA_A = 15U,
|
||||
/* MODEL_YUVSDA - luma, Cb, Cr, stencil, depth, alpha */
|
||||
YUVSDA_Y = 0U,
|
||||
YUVSDA_CB = 1U,
|
||||
YUVSDA_U = 1U,
|
||||
YUVSDA_CR = 2U,
|
||||
YUVSDA_V = 2U,
|
||||
YUVSDA_STENCIL = 13U,
|
||||
YUVSDA_S = 13U,
|
||||
YUVSDA_DEPTH = 14U,
|
||||
YUVSDA_D = 14U,
|
||||
YUVSDA_ALPHA = 15U,
|
||||
YUVSDA_A = 15U,
|
||||
/* MODEL_YIQSDA - luma, in-phase, quadrature, stencil, depth, alpha */
|
||||
YIQSDA_Y = 0U,
|
||||
YIQSDA_I = 1U,
|
||||
YIQSDA_Q = 2U,
|
||||
YIQSDA_STENCIL = 13U,
|
||||
YIQSDA_S = 13U,
|
||||
YIQSDA_DEPTH = 14U,
|
||||
YIQSDA_D = 14U,
|
||||
YIQSDA_ALPHA = 15U,
|
||||
YIQSDA_A = 15U,
|
||||
/* MODEL_LABSDA - CIELAB/L*a*b* luma, red-green, blue-yellow, stencil, depth, alpha */
|
||||
LABSDA_L = 0U,
|
||||
LABSDA_A = 1U,
|
||||
LABSDA_B = 2U,
|
||||
LABSDA_STENCIL = 13U,
|
||||
LABSDA_S = 13U,
|
||||
LABSDA_DEPTH = 14U,
|
||||
LABSDA_D = 14U,
|
||||
LABSDA_ALPHA = 15U,
|
||||
/* NOTE: KHR_DF_CHANNEL_LABSDA_A is not a synonym for alpha! */
|
||||
/* MODEL_CMYKA - cyan, magenta, yellow, key/blacK, alpha */
|
||||
CMYKSDA_CYAN = 0U,
|
||||
CMYKSDA_C = 0U,
|
||||
CMYKSDA_MAGENTA = 1U,
|
||||
CMYKSDA_M = 1U,
|
||||
CMYKSDA_YELLOW = 2U,
|
||||
CMYKSDA_Y = 2U,
|
||||
CMYKSDA_KEY = 3U,
|
||||
CMYKSDA_BLACK = 3U,
|
||||
CMYKSDA_K = 3U,
|
||||
CMYKSDA_ALPHA = 15U,
|
||||
CMYKSDA_A = 15U,
|
||||
/* MODEL_XYZW - coordinates x, y, z, w */
|
||||
XYZW_X = 0U,
|
||||
XYZW_Y = 1U,
|
||||
XYZW_Z = 2U,
|
||||
XYZW_W = 3U,
|
||||
/* MODEL_HSVA_ANG - value (luma), saturation, hue, alpha, angular projection, conical space */
|
||||
HSVA_ANG_VALUE = 0U,
|
||||
HSVA_ANG_V = 0U,
|
||||
HSVA_ANG_SATURATION = 1U,
|
||||
HSVA_ANG_S = 1U,
|
||||
HSVA_ANG_HUE = 2U,
|
||||
HSVA_ANG_H = 2U,
|
||||
HSVA_ANG_ALPHA = 15U,
|
||||
HSVA_ANG_A = 15U,
|
||||
/* MODEL_HSLA_ANG - lightness (luma), saturation, hue, alpha, angular projection, double conical space */
|
||||
HSLA_ANG_LIGHTNESS = 0U,
|
||||
HSLA_ANG_L = 0U,
|
||||
HSLA_ANG_SATURATION = 1U,
|
||||
HSLA_ANG_S = 1U,
|
||||
HSLA_ANG_HUE = 2U,
|
||||
HSLA_ANG_H = 2U,
|
||||
HSLA_ANG_ALPHA = 15U,
|
||||
HSLA_ANG_A = 15U,
|
||||
/* MODEL_HSVA_HEX - value (luma), saturation, hue, alpha, hexagonal projection, conical space */
|
||||
HSVA_HEX_VALUE = 0U,
|
||||
HSVA_HEX_V = 0U,
|
||||
HSVA_HEX_SATURATION = 1U,
|
||||
HSVA_HEX_S = 1U,
|
||||
HSVA_HEX_HUE = 2U,
|
||||
HSVA_HEX_H = 2U,
|
||||
HSVA_HEX_ALPHA = 15U,
|
||||
HSVA_HEX_A = 15U,
|
||||
/* MODEL_HSLA_HEX - lightness (luma), saturation, hue, alpha, hexagonal projection, double conical space */
|
||||
HSLA_HEX_LIGHTNESS = 0U,
|
||||
HSLA_HEX_L = 0U,
|
||||
HSLA_HEX_SATURATION = 1U,
|
||||
HSLA_HEX_S = 1U,
|
||||
HSLA_HEX_HUE = 2U,
|
||||
HSLA_HEX_H = 2U,
|
||||
HSLA_HEX_ALPHA = 15U,
|
||||
HSLA_HEX_A = 15U,
|
||||
/* MODEL_YCGCOA - luma, green delta, orange delta, alpha */
|
||||
YCGCOA_Y = 0U,
|
||||
YCGCOA_CG = 1U,
|
||||
YCGCOA_CO = 2U,
|
||||
YCGCOA_ALPHA = 15U,
|
||||
YCGCOA_A = 15U,
|
||||
/* MODEL_CIEXYZ - CIE 1931 X, Y, Z */
|
||||
CIEXYZ_X = 0U,
|
||||
CIEXYZ_Y = 1U,
|
||||
CIEXYZ_Z = 2U,
|
||||
/* MODEL_CIEXYY - CIE 1931 x, y, Y */
|
||||
CIEXYY_X = 0U,
|
||||
CIEXYY_YCHROMA = 1U,
|
||||
CIEXYY_YLUMA = 2U,
|
||||
|
||||
/* Compressed formats */
|
||||
/* MODEL_DXT1A/MODEL_BC1A */
|
||||
DXT1A_COLOR = 0U,
|
||||
BC1A_COLOR = 0U,
|
||||
DXT1A_ALPHAPRESENT = 1U,
|
||||
DXT1A_ALPHA = 1U,
|
||||
BC1A_ALPHAPRESENT = 1U,
|
||||
BC1A_ALPHA = 1U,
|
||||
/* MODEL_DXT2/3/MODEL_BC2 */
|
||||
DXT2_COLOR = 0U,
|
||||
DXT3_COLOR = 0U,
|
||||
BC2_COLOR = 0U,
|
||||
DXT2_ALPHA = 15U,
|
||||
DXT3_ALPHA = 15U,
|
||||
BC2_ALPHA = 15U,
|
||||
/* MODEL_DXT4/5/MODEL_BC3 */
|
||||
DXT4_COLOR = 0U,
|
||||
DXT5_COLOR = 0U,
|
||||
BC3_COLOR = 0U,
|
||||
DXT4_ALPHA = 15U,
|
||||
DXT5_ALPHA = 15U,
|
||||
BC3_ALPHA = 15U,
|
||||
/* MODEL_BC4 */
|
||||
BC4_DATA = 0U,
|
||||
/* MODEL_BC5 */
|
||||
BC5_RED = 0U,
|
||||
BC5_R = 0U,
|
||||
BC5_GREEN = 1U,
|
||||
BC5_G = 1U,
|
||||
/* MODEL_BC6H */
|
||||
BC6H_COLOR = 0U,
|
||||
BC6H_DATA = 0U,
|
||||
/* MODEL_BC7 */
|
||||
BC7_DATA = 0U,
|
||||
BC7_COLOR = 0U,
|
||||
/* MODEL_ETC1 */
|
||||
ETC1_DATA = 0U,
|
||||
ETC1_COLOR = 0U,
|
||||
/* MODEL_ETC2 */
|
||||
ETC2_RED = 0U,
|
||||
ETC2_R = 0U,
|
||||
ETC2_GREEN = 1U,
|
||||
ETC2_G = 1U,
|
||||
ETC2_COLOR = 2U,
|
||||
ETC2_ALPHA = 15U,
|
||||
ETC2_A = 15U,
|
||||
/* MODEL_ASTC */
|
||||
ASTC_DATA = 0U,
|
||||
ASTC_RGBA = 0U,
|
||||
ASTC_RGB = 3U,
|
||||
/* MODEL_ETC1S */
|
||||
ETC1S_RGB = 0U,
|
||||
ETC1S_RRR = 3U,
|
||||
ETC1S_GGG = 4U,
|
||||
ETC1S_AAA = 15U,
|
||||
/* MODEL_PVRTC */
|
||||
PVRTC_DATA = 0U,
|
||||
PVRTC_COLOR = 0U,
|
||||
/* MODEL_PVRTC2 */
|
||||
PVRTC2_DATA = 0U,
|
||||
PVRTC2_COLOR = 0U,
|
||||
/* MODEL UASTC */
|
||||
UASTC_RGB = 0U,
|
||||
UASTC_RGBA = 3U,
|
||||
UASTC_RRR = 4U,
|
||||
UASTC_RRRG = 5U,
|
||||
UASTC_RG = 6U,
|
||||
/* MODEL UASTC_LDR_4x4 (alias) */
|
||||
UASTC_LDR_4x4_RGB = 0U,
|
||||
UASTC_LDR_4x4_RGBA = 3U,
|
||||
UASTC_LDR_4x4_RRR = 4U,
|
||||
UASTC_LDR_4x4_RRRG = 5U,
|
||||
UASTC_LDR_4x4_RG = 6U,
|
||||
/* MODEL UASTC_4x4_HDR */
|
||||
UASTC_HDR_4x4_RGB = 0U,
|
||||
/* MODEL UASTC_6x6_HDR */
|
||||
UASTC_HDR_6x6_RGB = 0U,
|
||||
|
||||
/* Common channel names shared by multiple formats */
|
||||
COMMON_LUMA = 0U,
|
||||
COMMON_L = 0U,
|
||||
COMMON_STENCIL = 13U,
|
||||
COMMON_S = 13U,
|
||||
COMMON_DEPTH = 14U,
|
||||
COMMON_D = 14U,
|
||||
COMMON_ALPHA = 15U,
|
||||
COMMON_A = 15U,
|
||||
}
|
||||
|
||||
/* Definition of the primary colors in color coordinates.
|
||||
This is implicitly responsible for defining the conversion
|
||||
between RGB an YUV color spaces.
|
||||
LAB and related absolute color models should use
|
||||
KHR_DF_PRIMARIES_CIEXYZ. */
|
||||
[AllowDuplicates] public enum khr_df_primaries_e : c_int {
|
||||
/* No color primaries defined */
|
||||
Unspecified = 0U,
|
||||
/* Color primaries of ITU-R BT.709 and sRGB */
|
||||
Bt709 = 1U,
|
||||
/* Synonym for KHR_DF_PRIMARIES_BT709 */
|
||||
Srgb = 1U,
|
||||
/* Color primaries of ITU-R BT.601 (625-line EBU variant) */
|
||||
Bt601Ebu = 2U,
|
||||
/* Color primaries of ITU-R BT.601 (525-line SMPTE C variant) */
|
||||
Bt601Smpte = 3U,
|
||||
/* Color primaries of ITU-R BT.2020 */
|
||||
Bt2020 = 4U,
|
||||
/* ITU-R BT.2100 uses the same primaries as BT.2020 */
|
||||
Bt2100 = 4U,
|
||||
/* CIE theoretical color coordinate space */
|
||||
Ciexyz = 5U,
|
||||
/* Academy Color Encoding System primaries */
|
||||
Aces = 6U,
|
||||
/* Color primaries of ACEScc */
|
||||
Acescc = 7U,
|
||||
/* Legacy NTSC 1953 primaries */
|
||||
Ntsc1953 = 8U,
|
||||
/* Legacy PAL 525-line primaries */
|
||||
Pal525 = 9U,
|
||||
/* Color primaries of Display P3 */
|
||||
Displayp3 = 10U,
|
||||
/* Color primaries of Adobe RGB (1998) */
|
||||
Adobergb = 11U,
|
||||
Max = 0xFFU,
|
||||
}
|
||||
|
||||
/* Definition of the optical to digital transfer function
|
||||
("gamma correction"). Most transfer functions are not a pure
|
||||
power function and also include a linear element.
|
||||
LAB and related absolute color representations should use
|
||||
KHR_DF_TRANSFER_UNSPECIFIED.
|
||||
These encodings indicate that the representation has had
|
||||
the corresponding transfer function applied relative to a
|
||||
linear representation; hence to process the linear intensity
|
||||
represented by the value, a corresponding inverse transform
|
||||
must be applied. */
|
||||
[AllowDuplicates] public enum khr_df_transfer_e : c_int {
|
||||
/* No transfer function defined */
|
||||
Unspecified = 0U,
|
||||
/* Linear transfer function (value proportional to intensity) */
|
||||
Linear = 1U,
|
||||
/* Perceptually-linear transfer function of sRGB (~2.2); also used for scRGB */
|
||||
Srgb = 2U,
|
||||
SrgbEotf = 2U,
|
||||
Scrgb = 2U,
|
||||
ScrgbEotf = 2U,
|
||||
/* Perceptually-linear transfer function of ITU BT.601, BT.709 and BT.2020 (~1/.45) */
|
||||
Itu = 3U,
|
||||
ItuOetf = 3U,
|
||||
Bt601 = 3U,
|
||||
Bt601Oetf = 3U,
|
||||
Bt709 = 3U,
|
||||
Bt709Oetf = 3U,
|
||||
Bt2020 = 3U,
|
||||
Bt2020Oetf = 3U,
|
||||
/* SMTPE170M (digital NTSC) defines an alias for the ITU transfer function (~1/.45) and a linear OOTF */
|
||||
Smtpe170m = 3U,
|
||||
Smtpe170mOetf = 3U,
|
||||
Smtpe170mEotf = 3U,
|
||||
/* Perceptually-linear gamma function of original NTSC (simple 2.2 gamma) */
|
||||
Ntsc = 4U,
|
||||
NtscEotf = 4U,
|
||||
/* Sony S-log used by Sony video cameras */
|
||||
Slog = 5U,
|
||||
SlogOetf = 5U,
|
||||
/* Sony S-log 2 used by Sony video cameras */
|
||||
Slog2 = 6U,
|
||||
Slog2Oetf = 6U,
|
||||
/* ITU BT.1886 EOTF */
|
||||
Bt1886 = 7U,
|
||||
Bt1886Eotf = 7U,
|
||||
/* ITU BT.2100 HLG OETF (typical scene-referred content), linear light normalized 0..1 */
|
||||
HlgOetf = 8U,
|
||||
/* ITU BT.2100 HLG EOTF (nominal HDR display of HLG content), linear light normalized 0..1 */
|
||||
HlgEotf = 9U,
|
||||
/* ITU BT.2100 PQ EOTF (typical HDR display-referred PQ content) */
|
||||
PqEotf = 10U,
|
||||
/* ITU BT.2100 PQ OETF (nominal scene described by PQ HDR content) */
|
||||
PqOetf = 11U,
|
||||
/* DCI P3 transfer function */
|
||||
Dcip3 = 12U,
|
||||
Dcip3Eotf = 12U,
|
||||
/* Legacy PAL OETF */
|
||||
PalOetf = 13U,
|
||||
/* Legacy PAL 625-line EOTF */
|
||||
Pal625Eotf = 14U,
|
||||
/* Legacy ST240 transfer function */
|
||||
St240 = 15U,
|
||||
St240Oetf = 15U,
|
||||
St240Eotf = 15U,
|
||||
/* ACEScc transfer function */
|
||||
Acescc = 16U,
|
||||
AcesccOetf = 16U,
|
||||
/* ACEScct transfer function */
|
||||
Acescct = 17U,
|
||||
AcescctOetf = 17U,
|
||||
/* Adobe RGB (1998) transfer function */
|
||||
Adobergb = 18U,
|
||||
AdobergbEotf = 18U,
|
||||
/* Legacy ITU BT.2100 HLG OETF (typical scene-referred content), linear light normalized 0..12 */
|
||||
HlgUnnormalizedOetf = 19U,
|
||||
Max = 0xFFU,
|
||||
}
|
||||
|
||||
[AllowDuplicates] public enum khr_df_flags_e : c_int {
|
||||
AlphaStraight = 0U,
|
||||
AlphaPremultiplied = 1U,
|
||||
}
|
||||
|
||||
[AllowDuplicates] public enum khr_df_sample_datatype_qualifiers_e : c_int {
|
||||
Linear = 1U << 4U,
|
||||
Exponent = 1U << 5U,
|
||||
Signed = 1U << 6U,
|
||||
Float = 1U << 7U,
|
||||
}
|
||||
|
||||
+2072
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,281 @@
|
||||
// This file was generated by Cpp2Beef
|
||||
|
||||
using System;
|
||||
using System.Interop;
|
||||
|
||||
namespace KTX;
|
||||
|
||||
static
|
||||
{
|
||||
/* -*- tab-width: 4; -*- */
|
||||
/* vi: set sw=2 ts=4 expandtab: */
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2017-2020 The Khronos Group, Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @file
|
||||
* @~English
|
||||
*
|
||||
* @brief Declares the public functions and structures of the
|
||||
* KTX Vulkan texture loading API.
|
||||
*
|
||||
* A separate header file is used to avoid extra dependencies for those not
|
||||
* using Vulkan. The nature of the Vulkan API, rampant structures and enums,
|
||||
* means that vulkan.h must be included @e before including this file. The
|
||||
* alternative is duplicating unattractively large parts of it.
|
||||
*
|
||||
* @author Mark Callow, github.com/MarkCallow
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* Avoid Vulkan include file */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @struct ktxVulkanFunctions
|
||||
* @~English
|
||||
* @brief Struct for applications to pass Vulkan function pointers to the
|
||||
* ktxTexture_VkUpload functions via a ktxVulkanDeviceInfo struct.
|
||||
*
|
||||
* @c vkGetInstanceProcAddr and @c vkGetDeviceProcAddr should be set, others
|
||||
* are optional.
|
||||
*/
|
||||
[CRepr] public struct ktxVulkanFunctions {
|
||||
// These are functions pointers we need to perform our vulkan duties.
|
||||
public PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
|
||||
public PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
|
||||
|
||||
// These we optionally specify
|
||||
public PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
|
||||
public PFN_vkAllocateMemory vkAllocateMemory;
|
||||
public PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
|
||||
public PFN_vkBindBufferMemory vkBindBufferMemory;
|
||||
public PFN_vkBindImageMemory vkBindImageMemory;
|
||||
public PFN_vkCmdBlitImage vkCmdBlitImage;
|
||||
public PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
|
||||
public PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
|
||||
public PFN_vkCreateImage vkCreateImage;
|
||||
public PFN_vkDestroyImage vkDestroyImage;
|
||||
public PFN_vkCreateBuffer vkCreateBuffer;
|
||||
public PFN_vkDestroyBuffer vkDestroyBuffer;
|
||||
public PFN_vkCreateFence vkCreateFence;
|
||||
public PFN_vkDestroyFence vkDestroyFence;
|
||||
public PFN_vkEndCommandBuffer vkEndCommandBuffer;
|
||||
public PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
|
||||
public PFN_vkFreeMemory vkFreeMemory;
|
||||
public PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
|
||||
public PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
|
||||
public PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
|
||||
public PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
|
||||
public PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
|
||||
public PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
|
||||
public PFN_vkMapMemory vkMapMemory;
|
||||
public PFN_vkQueueSubmit vkQueueSubmit;
|
||||
public PFN_vkQueueWaitIdle vkQueueWaitIdle;
|
||||
public PFN_vkUnmapMemory vkUnmapMemory;
|
||||
public PFN_vkWaitForFences vkWaitForFences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class ktxVulkanTexture
|
||||
* @~English
|
||||
* @brief Struct for returning information about the Vulkan texture image
|
||||
* created by the ktxTexture_VkUpload* functions.
|
||||
*
|
||||
* Creation of these objects is internal to the upload functions.
|
||||
*/
|
||||
[CRepr] public struct ktxVulkanTexture
|
||||
{
|
||||
public PFN_vkDestroyImage vkDestroyImage; /*!< Pointer to vkDestroyImage function */
|
||||
public PFN_vkFreeMemory vkFreeMemory; /*!< Pointer to vkFreeMemory function */
|
||||
|
||||
public VkImage image; /*!< Handle to the Vulkan image created by the loader. */
|
||||
public VkFormat imageFormat; /*!< Format of the image data. */
|
||||
public VkImageLayout imageLayout; /*!< Layout of the created image. Has the same
|
||||
value as @p layout parameter passed to the
|
||||
loader. */
|
||||
public VkDeviceMemory deviceMemory; /*!< The memory (sub)allocation for the
|
||||
image on the Vulkan device. Will not be
|
||||
used with suballocators.*/
|
||||
public VkImageViewType viewType; /*!< ViewType corresponding to @p image. Reflects
|
||||
the dimensionality, cubeness and arrayness
|
||||
of the image. */
|
||||
public uint32 width; /*!< The width of the image. */
|
||||
public uint32 height; /*!< The height of the image. */
|
||||
public uint32 depth; /*!< The depth of the image. */
|
||||
public uint32 levelCount; /*!< The number of MIP levels in the image. */
|
||||
public uint32 layerCount; /*!< The number of array layers in the image. */
|
||||
public uint64 allocationId; /*!< An id referencing suballocation(s). */
|
||||
}
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] public function uint64 ktxVulkanTexture_subAllocatorAllocMemFuncPtr(VkMemoryAllocateInfo* allocInfo, VkMemoryRequirements* memReq, uint64* pageCount);
|
||||
[CallingConvention(KTX_APIENTRYP)] public function VkResult ktxVulkanTexture_subAllocatorBindBufferFuncPtr(VkBuffer buffer, uint64 allocId);
|
||||
[CallingConvention(KTX_APIENTRYP)] public function VkResult ktxVulkanTexture_subAllocatorBindImageFuncPtr(VkImage image, uint64 allocId);
|
||||
[CallingConvention(KTX_APIENTRYP)] public function VkResult ktxVulkanTexture_subAllocatorMemoryMapFuncPtr(uint64 allocId, uint64 pageNumber, VkDeviceSize* mapLength, void** dataPtr);
|
||||
[CallingConvention(KTX_APIENTRYP)] public function void ktxVulkanTexture_subAllocatorMemoryUnmapFuncPtr(uint64 allocId, uint64 pageNumber);
|
||||
[CallingConvention(KTX_APIENTRYP)] public function void ktxVulkanTexture_subAllocatorFreeMemFuncPtr(uint64 allocId);
|
||||
/**
|
||||
* @class ktxVulkanTexture_subAllocatorCallbacks
|
||||
* @~English
|
||||
* @brief Struct that contains all callbacks necessary for suballocation.
|
||||
*
|
||||
* These pointers must all be provided for upload or destroy to occur using suballocator callbacks.
|
||||
*/
|
||||
[CRepr] public struct ktxVulkanTexture_subAllocatorCallbacks {
|
||||
public ktxVulkanTexture_subAllocatorAllocMemFuncPtr allocMemFuncPtr; /*!< Pointer to the memory procurement function. Can suballocate one or more pages. */
|
||||
public ktxVulkanTexture_subAllocatorBindBufferFuncPtr bindBufferFuncPtr; /*!< Pointer to bind-buffer-to-suballocation(s) function. */
|
||||
public ktxVulkanTexture_subAllocatorBindImageFuncPtr bindImageFuncPtr; /*!< Pointer to bind-image-to-suballocation(s) function. */
|
||||
public ktxVulkanTexture_subAllocatorMemoryMapFuncPtr memoryMapFuncPtr; /*!< Pointer to function for mapping the memory of a specific page. */
|
||||
public ktxVulkanTexture_subAllocatorMemoryUnmapFuncPtr memoryUnmapFuncPtr; /*!< Pointer to function for unmapping the memory of a specific page. */
|
||||
public ktxVulkanTexture_subAllocatorFreeMemFuncPtr freeMemFuncPtr; /*!< Pointer to the free procurement function. */
|
||||
}
|
||||
|
||||
|
||||
extension ktxVulkanTexture
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanTexture_Destruct_WithSuballocator")] public static extern ktx_error_code_e Destruct_WithSuballocator(ktxVulkanTexture* This, VkDevice device, VkAllocationCallbacks* pAllocator, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
|
||||
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanTexture_Destruct")] public static extern void Destruct(ktxVulkanTexture* This, VkDevice device, VkAllocationCallbacks* pAllocator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @class ktxVulkanDeviceInfo
|
||||
* @~English
|
||||
* @brief Struct for passing information about the Vulkan device on which
|
||||
* to create images to the texture image loading functions.
|
||||
*
|
||||
* Avoids passing a large number of parameters to each loading function.
|
||||
* Use of ktxVulkanDeviceInfo_create() or ktxVulkanDeviceInfo_construct() to
|
||||
* populate this structure is highly recommended.
|
||||
*
|
||||
* @code
|
||||
ktxVulkanDeviceInfo vdi;
|
||||
ktxVulkanTexture texture;
|
||||
|
||||
vdi = ktxVulkanDeviceInfo_create(physicalDevice,
|
||||
device,
|
||||
queue,
|
||||
cmdPool,
|
||||
&allocator);
|
||||
ktxLoadVkTextureN("texture_1.ktx", vdi, &texture, NULL, NULL);
|
||||
// ...
|
||||
ktxLoadVkTextureN("texture_n.ktx", vdi, &texture, NULL, NULL);
|
||||
ktxVulkanDeviceInfo_destroy(vdi);
|
||||
* @endcode
|
||||
*/
|
||||
[CRepr] public struct ktxVulkanDeviceInfo {
|
||||
public VkInstance instance; /*!< Instance used to communicate with vulkan. */
|
||||
public VkPhysicalDevice physicalDevice; /*!< Handle of the physical device. */
|
||||
public VkDevice device; /*!< Handle of the logical device. */
|
||||
public VkQueue queue; /*!< Handle to the queue to which to submit commands. */
|
||||
public VkCommandBuffer cmdBuffer; /*!< Handle of the cmdBuffer to use. */
|
||||
/** Handle of the command pool from which to allocate the command buffer. */
|
||||
public VkCommandPool cmdPool;
|
||||
/** Pointer to the allocator to use for the command buffer and created
|
||||
* images.
|
||||
*/
|
||||
public VkAllocationCallbacks* pAllocator;
|
||||
/** Memory properties of the Vulkan physical device. */
|
||||
public VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
|
||||
|
||||
/** The functions needed to operate functions */
|
||||
public ktxVulkanFunctions vkFuncs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extension ktxVulkanDeviceInfo
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_CreateEx")] public static extern ktxVulkanDeviceInfo* CreateEx(VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator, ktxVulkanFunctions* pFunctions);
|
||||
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Create")] public static extern ktxVulkanDeviceInfo* Create(VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator);
|
||||
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Construct")] public static extern ktx_error_code_e Construct(ktxVulkanDeviceInfo* This, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator);
|
||||
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_ConstructEx")] public static extern ktx_error_code_e ConstructEx(ktxVulkanDeviceInfo* This, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator, ktxVulkanFunctions* pFunctions);
|
||||
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Destruct")] public static extern void Destruct(ktxVulkanDeviceInfo* This);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Destroy")] public static extern void Destroy(ktxVulkanDeviceInfo* This);
|
||||
}
|
||||
|
||||
extension ktxTexture
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_VkUploadEx_WithSuballocator")] public static extern ktx_error_code_e VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_VkUploadEx")] public static extern ktx_error_code_e VkUploadEx(ktxTexture* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_VkUpload")] public static extern ktx_error_code_e VkUpload(ktxTexture* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture);
|
||||
}
|
||||
|
||||
extension ktxTexture1
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_VkUploadEx_WithSuballocator")] public static extern ktx_error_code_e VkUploadEx_WithSuballocator(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_VkUploadEx")] public static extern ktx_error_code_e VkUploadEx(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_VkUpload")] public static extern ktx_error_code_e VkUpload(ktxTexture1* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture);
|
||||
}
|
||||
|
||||
extension ktxTexture2
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_VkUploadEx_WithSuballocator")] public static extern ktx_error_code_e VkUploadEx_WithSuballocator(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_VkUploadEx")] public static extern ktx_error_code_e VkUploadEx(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout);
|
||||
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_VkUpload")] public static extern ktx_error_code_e VkUpload(ktxTexture2* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture);
|
||||
}
|
||||
|
||||
extension ktxTexture
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_GetVkFormat")] public static extern VkFormat GetVkFormat(ktxTexture* This);
|
||||
}
|
||||
|
||||
extension ktxTexture1
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_GetVkFormat")] public static extern VkFormat GetVkFormat(ktxTexture1* This);
|
||||
}
|
||||
|
||||
extension ktxTexture2
|
||||
{
|
||||
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_GetVkFormat")] public static extern VkFormat GetVkFormat(ktxTexture2* This);
|
||||
}
|
||||
|
||||
/* KTX_H_A55A6F00956F42F3A137C11929827FE1 */
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using CxxBuildTool;
|
||||
|
||||
namespace KTX;
|
||||
|
||||
static
|
||||
{
|
||||
public const CallingConventionAttribute.Kind KTX_APIENTRYP =
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
.Stdcall;
|
||||
#else
|
||||
.Cdecl;
|
||||
#endif
|
||||
|
||||
struct FILE;
|
||||
struct ktxTexture_vvtbl;
|
||||
struct ktxTexture_protected;
|
||||
struct ktxTexture1_private;
|
||||
struct ktxTexture2_private;
|
||||
|
||||
[OnCompile(.TypeDone)]
|
||||
private static void Build()
|
||||
{
|
||||
if (!Compiler.IsBuilding) return;
|
||||
CxxBuildTool.Ninja(
|
||||
Compiler.ProjectDir + "/KTX-Software/lib/src",
|
||||
Compiler.BuildDir + "/" + Compiler.ProjectName,
|
||||
"libktx",
|
||||
"-DKHRONOS_STATIC -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/lib/include\" -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/utils\" -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/other_include\" -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/external\" -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/external/basis_universal\" -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/external/basis_universal/zstd\" -I\"" +
|
||||
Compiler.ProjectDir + "/KTX-Software/external/dfdutils\"",
|
||||
|
||||
"astc_codec.cpp",
|
||||
"basis_transcode.cpp",
|
||||
"miniz_wrapper.cpp",
|
||||
"checkheader.c",
|
||||
"etcunpack.cxx",
|
||||
"filestream.c",
|
||||
"glformat_str.c",
|
||||
"hashlist.c",
|
||||
"info.c",
|
||||
"memstream.c",
|
||||
"strings.c",
|
||||
"swap.c",
|
||||
"texture.c",
|
||||
"texture2.c",
|
||||
"vkformat_check.c",
|
||||
"vkformat_check_variant.c",
|
||||
"vkformat_str.c",
|
||||
"vkformat_typesize.c"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[CRepr] struct ktxHashList { ktxHashListEntry* head; }
|
||||
[CRepr] struct ktxHashListEntry;
|
||||
Reference in New Issue
Block a user