ld: finish librashader_ld

This commit is contained in:
chyyran 2023-01-14 01:38:59 -05:00
parent f0e4546e57
commit da4f61fcc4
6 changed files with 323 additions and 160 deletions

View file

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

View file

@ -1,3 +1,28 @@
/*
librashader.h
SPDX-License-Identifier: MIT
This file is part of the librashader C headers.
Copyright 2022 chyyran
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.
*/
#ifndef __LIBRASHADER_H__ #ifndef __LIBRASHADER_H__
#define __LIBRASHADER_H__ #define __LIBRASHADER_H__

View file

@ -1,3 +1,28 @@
/*
librashader_ld.h
SPDX-License-Identifier: MIT
This file is part of the librashader C headers.
Copyright 2022 chyyran
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.
*/
#ifndef __LIBRASHADER_LD_H__ #ifndef __LIBRASHADER_LD_H__
#define __LIBRASHADER_LD_H__ #define __LIBRASHADER_LD_H__
#pragma once #pragma once
@ -5,14 +30,116 @@
#define LIBRA_RUNTIME_D3D11 #define LIBRA_RUNTIME_D3D11
#define LIBRA_RUNTIME_VULKAN #define LIBRA_RUNTIME_VULKAN
#include "librashader.h"
#define _WIN32
#if defined(_WIN32) #if defined(_WIN32)
#include <libloaderapi.h> #include <libloaderapi.h>
#elif defined(__linux__) #elif defined(__linux__)
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
#include "librashader.h"
LIBRA_ERRNO __librashader__noop_error_errno(libra_error_t error) {
return LIBRA_ERRNO_UNKNOWN_ERROR;
}
int32_t __librashader__noop_error_print(libra_error_t error) { return 1; }
int32_t __librashader__noop_error_free(libra_error_t *error) { return 1; }
int32_t __librashader__noop_error_write(libra_error_t error, char **out) {
return 1;
}
int32_t __librashader__noop_error_free_string(char **out) { return 1; }
libra_error_t __librashader__noop_preset_create(const char *filename,
libra_shader_preset_t *out) {
return NULL;
}
libra_error_t __librashader__noop_preset_free(libra_shader_preset_t *preset) {
return NULL;
}
libra_error_t __librashader__noop_preset_set_param(
libra_shader_preset_t *preset, const char *name, float value) {
return NULL;
}
libra_error_t __librashader__noop_preset_get_param(
libra_shader_preset_t *preset, const char *name, float *value) {
return NULL;
}
libra_error_t __librashader__noop_preset_print(libra_shader_preset_t *preset) {
return NULL;
}
libra_error_t __librashader__noop_preset_get_runtime_param_names(
libra_shader_preset_t *preset, const char **value) {
return NULL;
}
libra_error_t __librashader__noop_gl_init_context(libra_gl_loader_t loader) {
return NULL;
}
libra_error_t __librashader__noop_gl_filter_chain_create(
libra_shader_preset_t *preset, const struct filter_chain_gl_opt_t *options,
libra_gl_filter_chain_t *out) {
return NULL;
}
libra_error_t __librashader__noop_gl_filter_chain_frame(
libra_gl_filter_chain_t *chain, size_t frame_count,
struct libra_source_image_gl_t image, struct libra_viewport_t viewport,
struct libra_draw_framebuffer_gl_t out, const float *mvp,
const struct frame_gl_opt_t *opt) {
return NULL;
}
libra_error_t __librashader__noop_gl_filter_chain_free(
libra_gl_filter_chain_t *chain) {
return NULL;
}
libra_error_t __librashader__noop_d3d11_filter_chain_create(
libra_shader_preset_t *preset,
const struct filter_chain_d3d11_opt_t *options, const ID3D11Device *device,
libra_d3d11_filter_chain_t *out) {
return NULL;
}
libra_error_t __librashader__noop_d3d11_filter_chain_frame(
libra_d3d11_filter_chain_t *chain, size_t frame_count,
struct libra_source_image_d3d11_t image, struct libra_viewport_t viewport,
const ID3D11RenderTargetView *out, const float *mvp,
const struct frame_vk_opt_t *opt) {
return NULL;
}
libra_error_t __librashader__noop_d3d11_filter_chain_free(
libra_d3d11_filter_chain_t *chain) {
return NULL;
}
libra_error_t __librashader__noop_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) {
return NULL;
}
libra_error_t __librashader__noop_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) {
return NULL;
}
libra_error_t __librashader__noop_vk_filter_chain_free(
libra_vk_filter_chain_t *chain) {
return NULL;
}
typedef struct libra_instance_t { typedef struct libra_instance_t {
PFN_libra_preset_create preset_create; PFN_libra_preset_create preset_create;
@ -42,7 +169,132 @@ typedef struct libra_instance_t {
PFN_libra_vk_filter_chain_free vk_filter_chain_free; PFN_libra_vk_filter_chain_free vk_filter_chain_free;
} libra_instance_t; } libra_instance_t;
libra_instance_t librashader_load_instance(const char *filename) { libra_instance_t __librashader_make_null_instance() {
return libra_instance_t{
.preset_create = __librashader__noop_preset_create,
.preset_free = __librashader__noop_preset_free,
.preset_set_param = __librashader__noop_preset_set_param,
.preset_get_param = __librashader__noop_preset_get_param,
.preset_print = __librashader__noop_preset_print,
.preset_get_runtime_param_names =
__librashader__noop_preset_get_runtime_param_names,
.error_errno = __librashader__noop_error_errno,
.error_print = __librashader__noop_error_print,
.error_free = __librashader__noop_error_free,
.error_write = __librashader__noop_error_write,
.error_free_string = __librashader__noop_error_free_string,
.gl_init_context = __librashader__noop_gl_init_context,
.gl_filter_chain_create = __librashader__noop_gl_filter_chain_create,
.gl_filter_chain_frame = __librashader__noop_gl_filter_chain_frame,
.gl_filter_chain_free = __librashader__noop_gl_filter_chain_free,
.d3d11_filter_chain_create =
__librashader__noop_d3d11_filter_chain_create,
.d3d11_filter_chain_frame =
__librashader__noop_d3d11_filter_chain_frame,
.d3d11_filter_chain_free = __librashader__noop_d3d11_filter_chain_free,
.vk_filter_chain_create = __librashader__noop_vk_filter_chain_create,
.vk_filter_chain_frame = __librashader__noop_vk_filter_chain_frame,
.vk_filter_chain_free = __librashader__noop_vk_filter_chain_free,
};
} }
#if defined(_WIN32)
#define _LIBRASHADER_ASSIGN_FARPROC(HMOD, INSTANCE, NAME) \
{ \
FARPROC address = GetProcAddress(HMOD, "libra_" #NAME); \
if (address != NULL) { \
(INSTANCE).NAME = (PFN_libra_##NAME)address; \
} \
}
libra_instance_t librashader_load_instance() {
HMODULE librashader = LoadLibraryW(L"librashader.dll");
libra_instance_t instance = __librashader_make_null_instance();
if (librashader == 0) {
return instance;
}
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, preset_create);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, preset_free);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, preset_set_param);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, preset_get_param);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, preset_print);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, preset_get_runtime_param_names);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, error_errno);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, error_print);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, error_free);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, error_write);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, error_free_string);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, gl_init_context);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, gl_filter_chain_create);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, gl_filter_chain_frame);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, gl_filter_chain_free);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, d3d11_filter_chain_create);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, d3d11_filter_chain_frame);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, d3d11_filter_chain_free);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, vk_filter_chain_create);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, vk_filter_chain_frame);
_LIBRASHADER_ASSIGN_FARPROC(librashader, instance, vk_filter_chain_free);
return instance;
}
#elif defined(__linux__)
#define _LIBRASHADER_ASSIGN_DLSYM(HMOD, INSTANCE, NAME) \
{ \
void* address = dlsym(HMOD, "libra_" #NAME); \
if (address != NULL) { \
(INSTANCE).NAME = (PFN_libra_##NAME)address; \
} \
}
libra_instance_t librashader_load_instance() {
void* librashader = dlopen(L"librashader.so", RTLD_LAZY);
libra_instance_t instance = __librashader_make_null_instance();
if (librashader == NULL) {
return instance;
}
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, preset_create);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, preset_free);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, preset_set_param);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, preset_get_param);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, preset_print);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, preset_get_runtime_param_names);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, error_errno);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, error_print);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, error_free);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, error_write);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, error_free_string);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, gl_init_context);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, gl_filter_chain_create);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, gl_filter_chain_frame);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, gl_filter_chain_free);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, d3d11_filter_chain_create);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, d3d11_filter_chain_frame);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, d3d11_filter_chain_free);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, vk_filter_chain_create);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, vk_filter_chain_frame);
_LIBRASHADER_ASSIGN_DLSYM(librashader, instance, vk_filter_chain_free);
return instance;
}
#else
libra_instance_t librashader_load_instance() {
return __librashader_make_null_instance();
}
#endif
#endif #endif

View file

@ -6,8 +6,6 @@ usize_is_size_t = true
documentation_style = "c++" documentation_style = "c++"
after_includes = "#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)\n#include <d3d11.h>\n#else\ntypedef void ID3D11Device;typedef void ID3D11RenderTargetView;typedef void ID3D1ShaderResourceView;\n#endif\n#if defined(LIBRA_RUNTIME_VULKAN)\n#include <vulkan\\vulkan.h>\n#endif" after_includes = "#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)\n#include <d3d11.h>\n#else\ntypedef void ID3D11Device;typedef void ID3D11RenderTargetView;typedef void ID3D1ShaderResourceView;\n#endif\n#if defined(LIBRA_RUNTIME_VULKAN)\n#include <vulkan\\vulkan.h>\n#endif"
[defines] [defines]
"feature = runtime-opengl" = "LIBRA_RUNTIME_OPENGL" "feature = runtime-opengl" = "LIBRA_RUNTIME_OPENGL"
"feature = runtime-d3d11" = "LIBRA_RUNTIME_D3D11" "feature = runtime-d3d11" = "LIBRA_RUNTIME_D3D11"
@ -59,7 +57,7 @@ include = [
"PFN_libra_d3d11_filter_chain_frame", "PFN_libra_d3d11_filter_chain_frame",
"PFN_libra_d3d11_filter_chain_free", "PFN_libra_d3d11_filter_chain_free",
# d3d11 # vulkan
"PFN_libra_vk_filter_chain_create", "PFN_libra_vk_filter_chain_create",
"PFN_libra_vk_filter_chain_frame", "PFN_libra_vk_filter_chain_frame",
"PFN_libra_vk_filter_chain_free", "PFN_libra_vk_filter_chain_free",

View file

@ -4,21 +4,14 @@
#include <iostream> #include <iostream>
#include <filesystem> #include <filesystem>
#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; #include "../../../../include/librashader_ld.h"
VK_DEFINE_HANDLE(VkInstance)
typedef void (*PFN_vkVoidFunction)(void);
typedef PFN_vkVoidFunction(*PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName);
#define LIBRA_RUNTIME_OPENGL
#define LIBRA_RUNTIME_VULKAN
#include "../../../../include/librashader.h"
int main() int main()
{ {
std::cout << "Hello World!\n"; std::cout << "Hello World!\n";
std::cout << std::filesystem::current_path() << std::endl; std::cout << std::filesystem::current_path() << std::endl;
libra_shader_preset_t preset; auto instance = librashader_load_instance();
/*libra_shader_preset_t preset;
auto error = libra_preset_create("../../../slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp", &preset); auto error = libra_preset_create("../../../slang-shaders/border/gameboy-player/gameboy-player-crt-royale.slangp", &preset);
if (error != NULL) { if (error != NULL) {
std::cout << "error happened\n"; std::cout << "error happened\n";
@ -27,9 +20,6 @@ int main()
libra_gl_filter_chain_t chain; libra_gl_filter_chain_t chain;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
libra_PFN_vkGetInstanceProcAddr entry = reinterpret_cast<libra_PFN_vkGetInstanceProcAddr>(GetInstanceProcAddr);
error = libra_gl_filter_chain_create(NULL, NULL, &chain); error = libra_gl_filter_chain_create(NULL, NULL, &chain);
if (error != NULL) { if (error != NULL) {
libra_error_print(error); libra_error_print(error);
@ -38,7 +28,7 @@ int main()
printf("%s", error_str); printf("%s", error_str);
libra_error_free_string(&error_str); libra_error_free_string(&error_str);
printf("%s", error_str); printf("%s", error_str);
} }*/
return 0; return 0;
} }

View file

@ -142,16 +142,11 @@
<ClCompile Include="librashader-capi-tests.cpp" /> <ClCompile Include="librashader-capi-tests.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\..\librashader-capi\librashader.h" /> <ClInclude Include="..\..\..\..\include\librashader.h" />
<ClInclude Include="..\..\..\..\include\librashader_ld.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Library Include="..\..\..\..\target\debug\librashader_capi.dll.lib" /> <Library Include="..\..\..\..\target\debug\librashader.dll.lib" />
<Library Include="..\..\..\..\target\debug\librashader_capi.lib" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\..\target\debug\librashader_capi.dll">
<DeploymentContent>true</DeploymentContent>
</None>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">