capi: fix missing vulkan definitions

This commit is contained in:
chyyran 2023-01-13 19:17:57 -05:00
parent 7e34b991e5
commit 07eee3724f
6 changed files with 282 additions and 30 deletions

192
.clang-format Normal file
View file

@ -0,0 +1,192 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

6
.idea/misc.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace">
<contentRoot DIR="$PROJECT_DIR$" />
</component>
</project>

View file

@ -1,28 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/librashader-preprocess/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-presets/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-reflect/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/naga/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/naga/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/naga/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/librashader-runtime-gl/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-compiler/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-common/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-runtime-d3d11/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-runtime-gl46/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-runtime/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-capi/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-capi-exports/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-capi/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/librashader-runtime-vk/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/librashader-capi/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<module classpath="CMake" type="CPP_MODULE" version="4" />

View file

@ -94,9 +94,13 @@ typedef struct libra_source_image_gl_t {
/// Defines the output viewport for a rendered frame.
typedef struct libra_viewport_t {
/// The x offset in the viewport framebuffer to begin rendering from.
float x;
/// The y offset in the viewport framebuffer to begin rendering from.
float y;
/// The width of the viewport framebuffer.
uint32_t width;
/// The height of the viewport framebuffer.
uint32_t height;
} libra_viewport_t;
@ -209,6 +213,10 @@ typedef struct FrameOptionsVulkan {
int32_t frame_direction;
} FrameOptionsVulkan;
/// Function pointer definition for
///libra_preset_create
typedef libra_error_t (*PFN_libra_preset_create)(const char *filename, libra_shader_preset_t *out);
/// Function pointer definition for
///libra_preset_free
typedef libra_error_t (*PFN_libra_preset_free)(libra_shader_preset_t *preset);
@ -229,17 +237,23 @@ typedef libra_error_t (*PFN_libra_preset_get_param)(libra_shader_preset_t *prese
///libra_preset_print
typedef libra_error_t (*PFN_libra_preset_print)(libra_shader_preset_t *preset);
/// Function pointer definition for libra_preset_get_runtime_param_names
typedef libra_error_t (*PFN_libra_preset_get_runtime_param_names)(libra_shader_preset_t *preset,
const char **value);
/// Function pointer definition for libra_error_errno
typedef LIBRA_ERRNO (*PFN_libra_error_errno)(libra_error_t error);
/// Function pointer definition for libra_error_print
typedef int32_t (*PFN_libra_error_print)(libra_error_t error);
/// Function pointer definition for libra_error_free
typedef int32_t (*PFN_libra_error_free)(libra_error_t *error);
/// Function pointer definition for libra_error_write
typedef int32_t (*PFN_libra_error_write)(libra_error_t error, char **out);
/// Function pointer definition for libra_error_free_string
typedef int32_t (*PFN_libra_error_free_string)(char **out);
#if defined(LIBRA_RUNTIME_OPENGL)
@ -301,6 +315,34 @@ typedef libra_error_t (*PFN_libra_d3d11_filter_chain_frame)(libra_d3d11_filter_c
typedef libra_error_t (*PFN_libra_d3d11_filter_chain_free)(libra_d3d11_filter_chain_t *chain);
#endif
#if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_create
typedef libra_error_t (*PFN_libra_vk_filter_chain_create)(struct libra_device_vk_t vulkan,
libra_shader_preset_t *preset,
const struct filter_chain_vk_opt_t *options,
libra_vk_filter_chain_t *out);
#endif
#if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_frame
typedef libra_error_t (*PFN_libra_vk_filter_chain_frame)(libra_vk_filter_chain_t *chain,
VkCommandBuffer command_buffer,
size_t frame_count,
struct libra_image_vk_t image,
struct libra_viewport_t viewport,
struct libra_image_vk_t out,
const float *mvp,
const struct FrameOptionsVulkan *opt);
#endif
#if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_free
typedef libra_error_t (*PFN_libra_vk_filter_chain_free)(libra_vk_filter_chain_t *chain);
#endif
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@ -387,7 +429,8 @@ libra_error_t libra_preset_print(libra_shader_preset_t *preset);
/// Get a list of runtime parameter names.
///
/// The returned value can not currently be freed.
/// This function should be considered in progress. Its use is discouraged.
/// This function should be considered work in progress. Its use is discouraged.
/// Removal of this function is exempted from semantic versioning.
libra_error_t libra_preset_get_runtime_param_names(libra_shader_preset_t *preset,
const char **value);

View file

@ -1,7 +1,12 @@
#ifndef __LIBRASHADER_LD_H__
#define __LIBRASHADER_LD_H__
#pragma once
#define LIBRA_RUNTIME_OPENGL
#define LIBRA_RUNTIME_D3D11
#define LIBRA_RUNTIME_VULKAN
#include "librashader.h"
#define _WIN32
#if defined(_WIN32)
#include <libloaderapi.h>
@ -10,7 +15,34 @@
#endif
typedef struct libra_instance_t {
PFN_libra_preset_create preset_create;
PFN_libra_preset_free preset_free;
PFN_libra_preset_set_param preset_set_param;
PFN_libra_preset_get_param preset_get_param;
PFN_libra_preset_print preset_print;
PFN_libra_preset_get_runtime_param_names preset_get_runtime_param_names;
};
PFN_libra_error_errno error_errno;
PFN_libra_error_print error_print;
PFN_libra_error_free error_free;
PFN_libra_error_write error_write;
PFN_libra_error_free_string error_free_string;
PFN_libra_gl_init_context gl_init_context;
PFN_libra_gl_filter_chain_create gl_filter_chain_create;
PFN_libra_gl_filter_chain_frame gl_filter_chain_frame;
PFN_libra_gl_filter_chain_free gl_filter_chain_free;
PFN_libra_d3d11_filter_chain_create d3d11_filter_chain_create;
PFN_libra_d3d11_filter_chain_frame d3d11_filter_chain_frame;
PFN_libra_d3d11_filter_chain_free d3d11_filter_chain_free;
PFN_libra_vk_filter_chain_create vk_filter_chain_create;
PFN_libra_vk_filter_chain_frame vk_filter_chain_frame;
PFN_libra_vk_filter_chain_free vk_filter_chain_free;
} libra_instance_t;
libra_instance_t librashader_load_instance(const char *filename) {
}
#endif

View file

@ -34,7 +34,7 @@ prefix_with_name = true
[export]
include = [
# preset
"PFN_libra_load_preset",
"PFN_libra_preset_create",
"PFN_libra_preset_free",
"PFN_libra_preset_set_param",
"PFN_libra_preset_get_param",
@ -58,6 +58,11 @@ include = [
"PFN_libra_d3d11_filter_chain_create",
"PFN_libra_d3d11_filter_chain_frame",
"PFN_libra_d3d11_filter_chain_free",
# d3d11
"PFN_libra_vk_filter_chain_create",
"PFN_libra_vk_filter_chain_frame",
"PFN_libra_vk_filter_chain_free",
]
[export.rename]