From 07eee3724f08a76589b7cda8649c6d96fcbdafcc Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 13 Jan 2023 19:17:57 -0500 Subject: [PATCH] capi: fix missing vulkan definitions --- .clang-format | 192 +++++++++++++++++++++++++++++++++ .idea/misc.xml | 6 ++ .idea/src.iml | 28 +---- include/librashader.h | 45 +++++++- include/librashader_ld.h | 34 +++++- librashader-capi/cbindgen.toml | 7 +- 6 files changed, 282 insertions(+), 30 deletions(-) create mode 100644 .clang-format create mode 100644 .idea/misc.xml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..48b2c67 --- /dev/null +++ b/.clang-format @@ -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 +... + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8cb85cd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/src.iml b/.idea/src.iml index 15b5307..f08604b 100644 --- a/.idea/src.iml +++ b/.idea/src.iml @@ -1,28 +1,2 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/include/librashader.h b/include/librashader.h index 04502a8..ebfeb34 100644 --- a/include/librashader.h +++ b/include/librashader.h @@ -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); diff --git a/include/librashader_ld.h b/include/librashader_ld.h index f2e340a..8a389d0 100644 --- a/include/librashader_ld.h +++ b/include/librashader_ld.h @@ -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 @@ -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 \ No newline at end of file diff --git a/librashader-capi/cbindgen.toml b/librashader-capi/cbindgen.toml index 04609de..7796faf 100644 --- a/librashader-capi/cbindgen.toml +++ b/librashader-capi/cbindgen.toml @@ -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]