Fixing vulkan

This commit is contained in:
Dynamitos
2024-04-23 08:11:44 +02:00
parent 8ea9c34ed4
commit 89571e5298
33 changed files with 217 additions and 926 deletions
-244
View File
@@ -1,244 +0,0 @@
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
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
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: true
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...
View File
+1
View File
@@ -32,6 +32,7 @@ bld/
[Oo]bj/ [Oo]bj/
[Ll]og/ [Ll]og/
vcpkg_installed/ vcpkg_installed/
build/
# Visual Studio 2015/2017 cache/options directory # Visual Studio 2015/2017 cache/options directory
.vs/ .vs/
-36
View File
@@ -1,36 +0,0 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/src/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.20348.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe",
"cppStandard": "c++20",
"intelliSenseMode": "windows-msvc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/src/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "/usr/bin/clang",
"cppStandard": "c++20",
"intelliSenseMode": "macos-clang-arm64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
+6 -6
View File
@@ -8,10 +8,10 @@
"name": "Editor", "name": "Editor",
"type": "cppvsdbg", "type": "cppvsdbg",
"request": "launch", "request": "launch",
"program": "${workspaceRoot}/bin/Editor.exe", "program": "${workspaceRoot}/build/Editor.exe",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceRoot}/bin", "cwd": "${workspaceRoot}/build",
"console": "internalConsole", "console": "internalConsole",
"environment": [], "environment": [],
"symbolSearchPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\lib\\x64", "symbolSearchPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\lib\\x64",
@@ -28,10 +28,10 @@
"name": "Editor (Mac)", "name": "Editor (Mac)",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"program": "${workspaceRoot}/bin/Editor", "program": "${workspaceRoot}/build/Editor",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceRoot}/bin", "cwd": "${workspaceRoot}/build",
"environment": [ "environment": [
{ {
"name": "VK_LAYER_PATH", "name": "VK_LAYER_PATH",
@@ -49,10 +49,10 @@
"name": "Editor (Linux)", "name": "Editor (Linux)",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceRoot}/bin/Editor", "program": "${workspaceRoot}/build/Editor",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceRoot}/bin", "cwd": "${workspaceRoot}/build",
"environment": [], "environment": [],
"externalConsole": false, "externalConsole": false,
"MIMode": "gdb", "MIMode": "gdb",
+1 -141
View File
@@ -1,144 +1,5 @@
{ {
"telemetry.enableTelemetry": false,
"cmake.cmakePath": "cmake", "cmake.cmakePath": "cmake",
"cmake.buildDirectory": "${workspaceFolder}/bin",
"files.associations": {
"*.h": "cpp",
"*.ush": "hlsl",
"*.slang": "hlsl",
"*.pl": "prolog",
"xstring": "cpp",
"list": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xmemory": "cpp",
"xtree": "cpp",
"type_traits": "cpp",
"vector": "cpp",
"*.rh": "cpp",
"memory": "cpp",
"*.ipp": "cpp",
"iostream": "cpp",
"initializer_list": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"map": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"set": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"valarray": "cpp",
"xfacet": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"xutility": "cpp",
"filesystem": "cpp",
"bitset": "cpp",
"complex": "cpp",
"csignal": "cpp",
"deque": "cpp",
"locale": "cpp",
"optional": "cpp",
"typeindex": "cpp",
"variant": "cpp",
"xlocbuf": "cpp",
"xlocmes": "cpp",
"codecvt": "cpp",
"regex": "cpp",
"strstream": "cpp",
"resumable": "cpp",
"future": "cpp",
"cstdarg": "cpp",
"cwctype": "cpp",
"queue": "cpp",
"random": "cpp",
"shared_mutex": "cpp",
"unordered_set": "cpp",
"csetjmp": "cpp",
"memory_resource": "cpp",
"*.inc": "cpp",
"any": "cpp",
"bit": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"compare": "cpp",
"execution": "cpp",
"hash_map": "cpp",
"hash_set": "cpp",
"scoped_allocator": "cpp",
"stack": "cpp",
"coroutine": "cpp",
"*.tcc": "cpp",
"stop_token": "cpp",
"span": "cpp",
"charconv": "cpp",
"format": "cpp",
"semaphore": "cpp",
"netfwd": "cpp",
"string_view": "cpp",
"rope": "cpp",
"slist": "cpp",
"numbers": "cpp",
"barrier": "cpp",
"latch": "cpp",
"ranges": "cpp",
"source_location": "cpp",
"syncstream": "cpp",
"stdfloat": "cpp",
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__verbose_abort": "cpp"
},
"cmake.skipConfigureIfCachePresent": false, "cmake.skipConfigureIfCachePresent": false,
"cmake.configureArgs": [ "cmake.configureArgs": [
"-Wno-dev" "-Wno-dev"
@@ -163,6 +24,5 @@
"lldb.displayFormat": "auto", "lldb.displayFormat": "auto",
"lldb.showDisassembly": "auto", "lldb.showDisassembly": "auto",
"lldb.dereferencePointers": true, "lldb.dereferencePointers": true,
"lldb.consoleMode": "commands", "lldb.consoleMode": "commands"
"cmake.generator": "Xcode",
} }
+9 -15
View File
@@ -28,15 +28,16 @@ project (Seele)
include(cmake/SuperBuild.cmake) include(cmake/SuperBuild.cmake)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
#Workaround for vs, because it places artifacts into an additional subfolder #Workaround for vs, because it places artifacts into an additional subfolder
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/build)
find_package(Vulkan REQUIRED) find_package(Vulkan REQUIRED)
find_package(assimp CONFIG REQUIRED) find_package(assimp CONFIG REQUIRED)
@@ -49,7 +50,6 @@ find_package(Ktx CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED)
find_package(VulkanMemoryAllocator CONFIG REQUIRED) find_package(VulkanMemoryAllocator CONFIG REQUIRED)
find_package(glslang CONFIG REQUIRED)
if(UNIX) if(UNIX)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
@@ -75,11 +75,7 @@ target_link_libraries(Engine PUBLIC crcpp)
target_link_libraries(Engine PUBLIC fmt::fmt) target_link_libraries(Engine PUBLIC fmt::fmt)
target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator) target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator)
target_link_libraries(Engine PUBLIC slang) target_link_libraries(Engine PUBLIC slang)
target_link_libraries(Engine PUBLIC glslang::glslang)
if(APPLE) if(APPLE)
target_include_directories(Engine PUBLIC /usr/local/include)
target_link_directories(Engine PUBLIC /usr/local/lib)
target_link_libraries(Engine PUBLIC metalirconverter)
target_link_libraries(Engine PUBLIC metal) target_link_libraries(Engine PUBLIC metal)
SET(CMAKE_OSX_DEPLOYMENT_TARGET 14.3) SET(CMAKE_OSX_DEPLOYMENT_TARGET 14.3)
endif() endif()
@@ -152,8 +148,6 @@ install(
Editor Editor
Engine Engine
crcpp crcpp
metal
slang
EXPORT EXPORT
EngineTargets EngineTargets
FILE_SET HEADERS FILE_SET HEADERS
+27 -30
View File
@@ -2,37 +2,34 @@ include (ExternalProject)
#--------------SLang------------------------------ #--------------SLang------------------------------
set(SLANG_ROOT ${EXTERNAL_ROOT}/slang) add_library(slang SHARED IMPORTED)
#add_library(shader-slang SHARED IMPORTED) if(WIN32)
#if(WIN32) add_library(slang-glslang SHARED IMPORTED)
# add_library(shader-slang-glslang SHARED IMPORTED) set(SLANG_ROOT ${EXTERNAL_ROOT}/slang/bin/windows-x64/release/)
# set(SLANG_ROOT ${EXTERNAL_ROOT}/slang/bin/windows-x64/release/) set_target_properties(slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}slang-glslang.dll)
# set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/slang-glslang.dll) set_target_properties(slang-glslang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}slang.lib)
# set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}/lib/slang.lib) set_target_properties(slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}slang.dll)
# set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/slang.dll) set_target_properties(slang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}slang.lib)
# set_target_properties(shader-slang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}/lib/slang.lib) target_link_libraries(slang INTERFACE slang-glslang)
# target_link_libraries(shader-slang INTERFACE shader-slang-glslang) install(FILES
# install(FILES ${SLANG_ROOT}slang-glslang.dll
# ${SLANG_ROOT}/bin/slang-glslang.dll ${SLANG_ROOT}slang.dll
# ${SLANG_ROOT}/bin/slang.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(FILES
# install(FILES ${SLANG_ROOT}slang.lib
# ${SLANG_ROOT}/lib/slang.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
# DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) elseif(APPLE)
#elseif(APPLE) set(BINARY_ROOT ${SLANG_ROOT}/bin/macosx-aarch64/release/)
# set(BINARY_ROOT ${SLANG_ROOT}/bin/macosx-aarch64/release/) set_target_properties(slang PROPERTIES IMPORTED_LOCATION ${BINARY_ROOT}/libslang.dylib)
# set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${BINARY_ROOT}/libslang.dylib) install(FILES
# install(FILES ${BINARY_ROOT}/libslang.dylib
# ${BINARY_ROOT}/libslang.dylib DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif()
#endif() target_include_directories(slang INTERFACE
#target_include_directories(shader-slang INTERFACE $<BUILD_INTERFACE:${EXTERNAL_ROOT}/slang>
# $<BUILD_INTERFACE:${SLANG_ROOT}/> $<INSTALL_INTERFACE:include>
# $<INSTALL_INTERFACE:include> )
#)
add_subdirectory(${SLANG_ROOT})
target_compile_definitions(compiler-core PUBLIC SLANG_ENABLE_DXIL_SUPPORT=1)
#--------------CRC++------------------------------ #--------------CRC++------------------------------
add_library(crcpp INTERFACE) add_library(crcpp INTERFACE)
-1
View File
@@ -1 +0,0 @@
bin/compile_commands.json
+1 -1
+8 -180
View File
@@ -5,12 +5,14 @@
#include "Asset/MeshLoader.h" #include "Asset/MeshLoader.h"
#include "Asset/TextureLoader.h" #include "Asset/TextureLoader.h"
#include "Graphics/Initializer.h" #include "Graphics/Initializer.h"
#ifdef __APPLE__
#include "Graphics/Metal/Graphics.h" #include "Graphics/Metal/Graphics.h"
#else
#include "Graphics/Vulkan/Graphics.h"
#endif
#include "Graphics/StaticMeshVertexData.h" #include "Graphics/StaticMeshVertexData.h"
#include "Graphics/Vulkan/Graphics.h" #include "Graphics/Vulkan/Graphics.h"
#include "Window/InspectorView.h"
#include "Window/PlayView.h" #include "Window/PlayView.h"
#include "Window/SceneView.h"
#include "Window/WindowManager.h" #include "Window/WindowManager.h"
#include <fmt/core.h> #include <fmt/core.h>
@@ -21,6 +23,7 @@ using namespace Seele::Editor;
static Gfx::OGraphics graphics; static Gfx::OGraphics graphics;
int main() { int main() {
std::string gameName = "MeshShadingDemo";
#ifdef WIN32 #ifdef WIN32
std::filesystem::path outputPath = "C:/Users/Dynamitos/MeshShadingDemoGame"; std::filesystem::path outputPath = "C:/Users/Dynamitos/MeshShadingDemoGame";
std::filesystem::path sourcePath = "C:/Users/Dynamitos/MeshShadingDemo"; std::filesystem::path sourcePath = "C:/Users/Dynamitos/MeshShadingDemo";
@@ -34,7 +37,6 @@ int main() {
std::filesystem::path sourcePath = "/home/dynamitos/MeshShadingDemo"; std::filesystem::path sourcePath = "/home/dynamitos/MeshShadingDemo";
std::filesystem::path binaryPath = sourcePath / "cmake" / "libMeshShadingDemo.so"; std::filesystem::path binaryPath = sourcePath / "cmake" / "libMeshShadingDemo.so";
#endif #endif
std::string gameName = "MeshShadingDemo";
std::filesystem::path cmakePath = outputPath / "cmake"; std::filesystem::path cmakePath = outputPath / "cmake";
#ifdef __APPLE__ #ifdef __APPLE__
@@ -52,178 +54,12 @@ int main() {
AssetImporter::importFont(FontImportArgs{ AssetImporter::importFont(FontImportArgs{
.filePath = "./fonts/Calibri.ttf", .filePath = "./fonts/Calibri.ttf",
}); });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath = sourcePath / "old_resources/models/arena.fbx",
// });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath = sourcePath / "old_resources/models/frog.fbx",
// });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath = sourcePath / "old_resources/models/train.fbx",
// });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/bird.fbx",
// });
AssetImporter::importMesh(MeshImportArgs{ AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "import/models/cube.fbx", .filePath = sourcePath / "import/models/cube.fbx",
}); });
// AssetImporter::importMesh(MeshImportArgs{ AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/flameThrower.fbx", .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.blend"
// }); });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/player.fbx",
// });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/shotgun.fbx",
// });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/track.fbx",
// });
// AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/zombie.fbx",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Dirt.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/DirtGrass.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Grass.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Ice.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Lava.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Obsidian.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Rocks.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Sand.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Water.png",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/Wood.png",
// });
//
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level0/blendMap.png",
// .importPath = "level0",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level0/heightMap.png",
// .importPath = "level0",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level0/trackMap.png",
// .importPath = "level0",
// });
// AssetImporter::importMaterial(MaterialImportArgs{
// .filePath= sourcePath / "old_resources/shaders/TerrainMaterial.json",
// .importPath = "level0",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level1/blendMap.png",
// .importPath = "level1",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level1/heightMap.png",
// .importPath = "level1",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level1/trackMap.png",
// .importPath = "level1",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level2/blendMap.png",
// .importPath = "level2",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level2/heightMap.png",
// .importPath = "level2",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level2/trackMap.png",
// .importPath = "level2",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level3/blendMap.png",
// .importPath = "level3",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level3/heightMap.png",
// .importPath = "level3",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level3/trackMap.png",
// .importPath = "level3",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level4/blendMap.png",
// .importPath = "level4",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level4/heightMap.png",
// .importPath = "level4",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level4/trackMap.png",
// .importPath = "level4",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level5/blendMap.png",
// .importPath = "level5",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level5/heightMap.png",
// .importPath = "level5",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level5/trackMap.png",
// .importPath = "level5",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level6/blendMap.png",
// .importPath = "level6",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level6/heightMap.png",
// .importPath = "level6",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level6/trackMap.png",
// .importPath = "level6",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level7/blendMap.png",
// .importPath = "level7",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level7/heightMap.png",
// .importPath = "level7",
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/textures/level7/trackMap.png",
// .importPath = "level7",
// });
//
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/skyboxes/FS000_Day_01.png",
// .type = TextureImportType::TEXTURE_CUBEMAP,
// });
// AssetImporter::importTexture(TextureImportArgs{
// .filePath= sourcePath / "old_resources/skyboxes/FS000_Night_01.png",
// .type = TextureImportType::TEXTURE_CUBEMAP,
// });
WindowCreateInfo mainWindowInfo; WindowCreateInfo mainWindowInfo;
mainWindowInfo.title = "SeeleEngine"; mainWindowInfo.title = "SeeleEngine";
mainWindowInfo.width = 1920; mainWindowInfo.width = 1920;
@@ -237,14 +73,6 @@ int main() {
sceneViewInfo.dimensions.offset.y = 0; sceneViewInfo.dimensions.offset.y = 0;
sceneViewInfo.numSamples = Gfx::SE_SAMPLE_COUNT_1_BIT; sceneViewInfo.numSamples = Gfx::SE_SAMPLE_COUNT_1_BIT;
OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string()); OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string());
// ViewportCreateInfo inspectorViewInfo;
// inspectorViewInfo.dimensions.size.x = 640;
// inspectorViewInfo.dimensions.size.y = 720;
// inspectorViewInfo.dimensions.offset.x = 640;
// inspectorViewInfo.dimensions.offset.y = 0;
// PInspectorView inspectorView = new InspectorView(graphics, window, inspectorViewInfo);
// window->addView(inspectorView);
sceneView->setFocused(); sceneView->setFocused();
while (windowManager->isActive()) { while (windowManager->isActive()) {
+5 -5
View File
@@ -323,15 +323,15 @@ void AssetRegistry::saveAsset(PAsset asset, uint64 identifier, const std::filesy
std::string path = (folderPath / name).replace_extension("asset").string(); std::string path = (folderPath / name).replace_extension("asset").string();
auto assetStream = createWriteStream(std::move(path), std::ios::binary); auto assetStream = createWriteStream(std::move(path), std::ios::binary);
ArchiveBuffer assetBuffer(graphics); ArchiveBuffer buffer(graphics);
// write identifier // write identifier
Serialization::save(assetBuffer, identifier); Serialization::save(buffer, identifier);
// write name // write name
Serialization::save(assetBuffer, name); Serialization::save(buffer, name);
// write folder // write folder
Serialization::save(assetBuffer, folderPath.string()); Serialization::save(buffer, folderPath.string());
// write asset data // write asset data
asset->save(assetBuffer); asset->save(buffer);
assetBuffer.writeToStream(assetStream); assetBuffer.writeToStream(assetStream);
} }
+2 -1
View File
@@ -67,6 +67,7 @@ public:
bool operator<(PDescriptorSet other); bool operator<(PDescriptorSet other);
constexpr PDescriptorLayout getLayout() const { return layout; } constexpr PDescriptorLayout getLayout() const { return layout; }
constexpr const std::string& getName() const { return layout->getName(); }
protected: protected:
PDescriptorLayout layout; PDescriptorLayout layout;
@@ -83,7 +84,7 @@ public:
void addPushConstants(const SePushConstantRange& pushConstants); void addPushConstants(const SePushConstantRange& pushConstants);
constexpr uint32 getHash() const { return layoutHash; } constexpr uint32 getHash() const { return layoutHash; }
constexpr const Map<std::string, PDescriptorLayout>& getLayouts() const { return descriptorSetLayouts; } constexpr const Map<std::string, PDescriptorLayout>& getLayouts() const { return descriptorSetLayouts; }
constexpr uint32 findParameter(const std::string& name) const { return parameterMapping[name]; } constexpr uint32 findParameter(const std::string& param) const { return parameterMapping[param]; }
void addMapping(Map<std::string, uint32> mapping); void addMapping(Map<std::string, uint32> mapping);
constexpr std::string getName() const {return name;}; constexpr std::string getName() const {return name;};
+1 -1
View File
@@ -118,9 +118,9 @@ struct ShaderBufferCreateInfo
DECLARE_NAME_REF(Gfx, PipelineLayout) DECLARE_NAME_REF(Gfx, PipelineLayout)
struct ShaderCreateInfo struct ShaderCreateInfo
{ {
std::string name; // Debug info
std::string mainModule; std::string mainModule;
Array<std::string> additionalModules; Array<std::string> additionalModules;
std::string name; // Debug info
std::string entryPoint; std::string entryPoint;
Array<Pair<const char*, const char*>> typeParameter; Array<Pair<const char*, const char*>> typeParameter;
Map<const char*, const char*> defines; Map<const char*, const char*> defines;
+1 -1
View File
@@ -124,9 +124,9 @@ void DebugPass::createRenderPass()
pipelineLayout->create(); pipelineLayout->create();
ShaderCreateInfo createInfo = { ShaderCreateInfo createInfo = {
.name = "DebugVertex",
.mainModule = "Debug", .mainModule = "Debug",
.additionalModules = { "Debug" }, .additionalModules = { "Debug" },
.name = "DebugVertex",
.entryPoint = "vertexMain", .entryPoint = "vertexMain",
}; };
vertexShader = graphics->createVertexShader(createInfo); vertexShader = graphics->createVertexShader(createInfo);
@@ -133,8 +133,8 @@ void LightCullingPass::publishOutputs()
ShaderCreateInfo createInfo = { ShaderCreateInfo createInfo = {
.name = "Culling", .name = "Culling",
.additionalModules = {"LightCulling"},
.mainModule = "LightCulling", .mainModule = "LightCulling",
.additionalModules = {"LightCulling"},
.entryPoint = "cullLights", .entryPoint = "cullLights",
.rootSignature = cullingLayout, .rootSignature = cullingLayout,
}; };
@@ -226,8 +226,8 @@ void LightCullingPass::setupFrustums()
frustumLayout->create(); frustumLayout->create();
ShaderCreateInfo createInfo = { ShaderCreateInfo createInfo = {
.name = "Frustum", .name = "Frustum",
.additionalModules = {"ComputeFrustums"},
.mainModule = "ComputeFrustums", .mainModule = "ComputeFrustums",
.additionalModules = {"ComputeFrustums"},
.entryPoint = "computeFrustums", .entryPoint = "computeFrustums",
.rootSignature = frustumLayout, .rootSignature = frustumLayout,
}; };
@@ -111,9 +111,9 @@ void SkyboxRenderPass::createRenderPass()
}); });
ShaderCreateInfo createInfo = { ShaderCreateInfo createInfo = {
.name = "SkyboxVertex",
.mainModule = "Skybox", .mainModule = "Skybox",
.additionalModules = {"Skybox"}, .additionalModules = {"Skybox"},
.name = "SkyboxVertex",
.entryPoint = "vertexMain", .entryPoint = "vertexMain",
}; };
vertexShader = graphics->createVertexShader(createInfo); vertexShader = graphics->createVertexShader(createInfo);
+2 -2
View File
@@ -139,7 +139,7 @@ void UIPass::createRenderPass()
descriptorSet->updateSampler(1, backgroundSampler); descriptorSet->updateSampler(1, backgroundSampler);
descriptorSet->writeChanges(); descriptorSet->writeChanges();
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout(); pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(descriptorLayout); pipelineLayout->addDescriptorLayout(descriptorLayout);
pipelineLayout->create(); pipelineLayout->create();
@@ -153,7 +153,7 @@ void UIPass::createRenderPass()
pipelineInfo.vertexShader = vertexShader; pipelineInfo.vertexShader = vertexShader;
pipelineInfo.fragmentShader = fragmentShader; pipelineInfo.fragmentShader = fragmentShader;
pipelineInfo.renderPass = renderPass; pipelineInfo.renderPass = renderPass;
pipelineInfo.pipelineLayout = std::move(pipelineLayout); pipelineInfo.pipelineLayout = pipelineLayout;
pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE; pipelineInfo.rasterizationState.cullMode = Gfx::SE_CULL_MODE_NONE;
pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; pipelineInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
+85 -152
View File
@@ -15,54 +15,20 @@ struct PendingBuffer {
static Map<Vulkan::Buffer*, PendingBuffer> pendingBuffers; static Map<Vulkan::Buffer*, PendingBuffer> pendingBuffers;
Buffer::Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Buffer::Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Gfx::QueueType& queueType, bool dynamic,
Gfx::QueueType &queueType, bool dynamic, std::string name) std::string name)
: graphics(graphics), currentBuffer(0), size(size), owner(queueType), : graphics(graphics), currentBuffer(0), size(size), owner(queueType), usage(usage), name(name) {
name(name) {
if (dynamic) { if (dynamic) {
numBuffers = Gfx::numFramesBuffered; numBuffers = Gfx::numFramesBuffered;
} else { } else {
numBuffers = 1; numBuffers = 1;
} }
VkBufferCreateInfo info = { createBuffer();
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.size = size,
.usage = usage,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
};
VmaAllocationCreateInfo allocInfo = {
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT |
VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
};
for (uint32 i = 0; i < numBuffers; ++i) {
vmaCreateBuffer(graphics->getAllocator(), &info, &allocInfo,
&buffers[i].buffer, &buffers[i].allocation,
&buffers[i].info);
vmaGetAllocationMemoryProperties(graphics->getAllocator(),
buffers[i].allocation,
&buffers[i].properties);
// std::cout << "Create buffer " << std::hex << (uint64)buffers[i].buffer <<
// std::dec;
if (!name.empty()) {
VkDebugUtilsObjectNameInfoEXT nameInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = nullptr,
.objectType = VK_OBJECT_TYPE_BUFFER,
.objectHandle = (uint64)buffers[i].buffer,
.pObjectName = this->name.c_str()};
graphics->vkSetDebugUtilsObjectNameEXT(&nameInfo);
// std::cout << ": " << name;
}
// std::cout << std::endl;
}
} }
Buffer::~Buffer() { Buffer::~Buffer() {
for (uint32 i = 0; i < numBuffers; ++i) { for (uint32 i = 0; i < numBuffers; ++i) {
graphics->getDestructionManager()->queueBuffer( graphics->getDestructionManager()->queueBuffer(graphics->getQueueCommands(owner)->getCommands(), buffers[i].buffer,
graphics->getQueueCommands(owner)->getCommands(), buffers[i].buffer,
buffers[i].allocation); buffers[i].allocation);
} }
} }
@@ -112,16 +78,12 @@ void Buffer::executeOwnershipBarrier(Gfx::QueueType newOwner) {
dynamicBarriers[i] = barrier; dynamicBarriers[i] = barrier;
dynamicBarriers[i].buffer = buffers[i].buffer; dynamicBarriers[i].buffer = buffers[i].buffer;
} }
vkCmdPipelineBarrier(srcCommand, srcStage, srcStage, 0, 0, nullptr, vkCmdPipelineBarrier(srcCommand, srcStage, srcStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
numBuffers, dynamicBarriers, 0, nullptr); vkCmdPipelineBarrier(dstCommand, dstStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
vkCmdPipelineBarrier(dstCommand, dstStage, dstStage, 0, 0, nullptr,
numBuffers, dynamicBarriers, 0, nullptr);
sourcePool->submitCommands(); sourcePool->submitCommands();
} }
void Buffer::executePipelineBarrier(VkAccessFlags srcAccess, void Buffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess,
VkPipelineStageFlags dstStage) { VkPipelineStageFlags dstStage) {
PCommand commandBuffer = graphics->getQueueCommands(owner)->getCommands(); PCommand commandBuffer = graphics->getQueueCommands(owner)->getCommands();
VkBufferMemoryBarrier barrier = { VkBufferMemoryBarrier barrier = {
@@ -139,14 +101,14 @@ void Buffer::executePipelineBarrier(VkAccessFlags srcAccess,
dynamicBarriers[i] = barrier; dynamicBarriers[i] = barrier;
dynamicBarriers[i].buffer = buffers[i].buffer; dynamicBarriers[i].buffer = buffers[i].buffer;
} }
vkCmdPipelineBarrier(commandBuffer->getHandle(), srcStage, dstStage, 0, 0, vkCmdPipelineBarrier(commandBuffer->getHandle(), srcStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0,
nullptr, numBuffers, dynamicBarriers, 0, nullptr); nullptr);
} }
void* Buffer::map(bool writeOnly) { return mapRegion(0, size, writeOnly); } void* Buffer::map(bool writeOnly) { return mapRegion(0, size, writeOnly); }
void *Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, void* Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly) {
bool writeOnly) {
void* data = nullptr; void* data = nullptr;
PendingBuffer pending; PendingBuffer pending;
@@ -155,10 +117,8 @@ void *Buffer::mapRegion(uint64 regionOffset, uint64 regionSize,
pending.offset = regionOffset; pending.offset = regionOffset;
pending.size = regionSize; pending.size = regionSize;
if (writeOnly) { if (writeOnly) {
if (buffers[currentBuffer].properties & if (buffers[currentBuffer].properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { VK_CHECK(vmaMapMemory(graphics->getAllocator(), buffers[currentBuffer].allocation, &data));
VK_CHECK(vmaMapMemory(graphics->getAllocator(),
buffers[currentBuffer].allocation, &data));
} else { } else {
VkBufferCreateInfo stagingInfo = { VkBufferCreateInfo stagingInfo = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
@@ -172,8 +132,7 @@ void *Buffer::mapRegion(uint64 regionOffset, uint64 regionSize,
.usage = VMA_MEMORY_USAGE_AUTO, .usage = VMA_MEMORY_USAGE_AUTO,
.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, .requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
}; };
VK_CHECK(vmaCreateBuffer(graphics->getAllocator(), &stagingInfo, VK_CHECK(vmaCreateBuffer(graphics->getAllocator(), &stagingInfo, &allocInfo, &pending.stagingBuffer,
&allocInfo, &pending.stagingBuffer,
&pending.allocation, nullptr)); &pending.allocation, nullptr));
vmaMapMemory(graphics->getAllocator(), pending.allocation, &data); vmaMapMemory(graphics->getAllocator(), pending.allocation, &data);
} }
@@ -191,13 +150,10 @@ void Buffer::unmap() {
if (found != pendingBuffers.end()) { if (found != pendingBuffers.end()) {
PendingBuffer& pending = found->value; PendingBuffer& pending = found->value;
if (pending.writeOnly) { if (pending.writeOnly) {
if (buffers[currentBuffer].properties & if (buffers[currentBuffer].properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { vmaUnmapMemory(graphics->getAllocator(), buffers[currentBuffer].allocation);
vmaUnmapMemory(graphics->getAllocator(),
buffers[currentBuffer].allocation);
} else { } else {
vmaFlushAllocation(graphics->getAllocator(), pending.allocation, 0, vmaFlushAllocation(graphics->getAllocator(), pending.allocation, 0, VK_WHOLE_SIZE);
VK_WHOLE_SIZE);
vmaUnmapMemory(graphics->getAllocator(), pending.allocation); vmaUnmapMemory(graphics->getAllocator(), pending.allocation);
PCommand command = graphics->getQueueCommands(owner)->getCommands(); PCommand command = graphics->getQueueCommands(owner)->getCommands();
VkCommandBuffer cmdHandle = command->getHandle(); VkCommandBuffer cmdHandle = command->getHandle();
@@ -218,11 +174,9 @@ void Buffer::unmap() {
.offset = 0, .offset = 0,
.size = size, .size = size,
}; };
vkCmdPipelineBarrier(cmdHandle, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, vkCmdPipelineBarrier(cmdHandle, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, nullptr, 1, &barrier, 0, nullptr);
&barrier, 0, nullptr); vkCmdCopyBuffer(cmdHandle, pending.stagingBuffer, buffers[currentBuffer].buffer, 1, &region);
vkCmdCopyBuffer(cmdHandle, pending.stagingBuffer,
buffers[currentBuffer].buffer, 1, &region);
barrier = { barrier = {
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
.pNext = nullptr, .pNext = nullptr,
@@ -234,24 +188,46 @@ void Buffer::unmap() {
.offset = 0, .offset = 0,
.size = size, .size = size,
}; };
vkCmdPipelineBarrier(cmdHandle, VK_PIPELINE_STAGE_TRANSFER_BIT, vkCmdPipelineBarrier(cmdHandle, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, nullptr, 1, &barrier, 0, nullptr);
1, &barrier, 0, nullptr); graphics->getDestructionManager()->queueBuffer(command, pending.stagingBuffer, pending.allocation);
graphics->getDestructionManager()->queueBuffer(
command, pending.stagingBuffer, pending.allocation);
} }
} }
// requestOwnershipTransfer(pending.prevQueue);
pendingBuffers.erase(this); pendingBuffers.erase(this);
} }
} }
UniformBuffer::UniformBuffer(PGraphics graphics, void Buffer::createBuffer()
const UniformBufferCreateInfo &createInfo) {
VkBufferCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.size = size,
.usage = usage,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
};
VmaAllocationCreateInfo allocInfo = {
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT |
VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
};
buffers.add();
vmaCreateBuffer(graphics->getAllocator(), &info, &allocInfo, &buffers.back().buffer, &buffers.back().allocation,
&buffers.back().info);
vmaGetAllocationMemoryProperties(graphics->getAllocator(), buffers.back().allocation, &buffers.back().properties);
if (!name.empty()) {
VkDebugUtilsObjectNameInfoEXT nameInfo = { .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = nullptr,
.objectType = VK_OBJECT_TYPE_BUFFER,
.objectHandle = (uint64)buffers.back().buffer,
.pObjectName = this->name.c_str() };
graphics->vkSetDebugUtilsObjectNameEXT(&nameInfo);
}
}
UniformBuffer::UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo& createInfo)
: Gfx::UniformBuffer(graphics->getFamilyMapping(), createInfo.sourceData), : Gfx::UniformBuffer(graphics->getFamilyMapping(), createInfo.sourceData),
Vulkan::Buffer(graphics, createInfo.sourceData.size, Vulkan::Buffer(graphics, createInfo.sourceData.size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, currentOwner,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, currentOwner,
createInfo.dynamic, createInfo.name) { createInfo.dynamic, createInfo.name) {
if (createInfo.sourceData.data != nullptr) { if (createInfo.sourceData.data != nullptr) {
void* data = map(); void* data = map();
@@ -273,8 +249,6 @@ bool UniformBuffer::updateContents(const DataSource &sourceData) {
return true; return true;
} }
void UniformBuffer::beginFrame() { Vulkan::Buffer::advanceBuffer(); }
void UniformBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) { void UniformBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) {
Gfx::QueueOwnedResource::transferOwnership(newOwner); Gfx::QueueOwnedResource::transferOwnership(newOwner);
} }
@@ -283,28 +257,18 @@ void UniformBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner) {
Vulkan::Buffer::executeOwnershipBarrier(newOwner); Vulkan::Buffer::executeOwnershipBarrier(newOwner);
} }
void UniformBuffer::executePipelineBarrier(VkAccessFlags srcAccess, void UniformBuffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) {
VkAccessFlags dstAccess, Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
VkPipelineStageFlags dstStage) {
Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess,
dstStage);
} }
VkAccessFlags UniformBuffer::getSourceAccessMask() { VkAccessFlags UniformBuffer::getSourceAccessMask() { return VK_ACCESS_MEMORY_WRITE_BIT; }
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags UniformBuffer::getDestAccessMask() { VkAccessFlags UniformBuffer::getDestAccessMask() { return VK_ACCESS_UNIFORM_READ_BIT; }
return VK_ACCESS_UNIFORM_READ_BIT;
}
ShaderBuffer::ShaderBuffer(PGraphics graphics, ShaderBuffer::ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo& sourceData)
const ShaderBufferCreateInfo &sourceData) : Gfx::ShaderBuffer(graphics->getFamilyMapping(), sourceData.numElements, sourceData.sourceData),
: Gfx::ShaderBuffer(graphics->getFamilyMapping(), sourceData.numElements, Vulkan::Buffer(graphics, sourceData.sourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, currentOwner,
sourceData.sourceData),
Vulkan::Buffer(graphics, sourceData.sourceData.size,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, currentOwner,
sourceData.dynamic, sourceData.name) { sourceData.dynamic, sourceData.name) {
if (sourceData.sourceData.data != nullptr) { if (sourceData.sourceData.data != nullptr) {
void* data = map(); void* data = map();
@@ -325,8 +289,6 @@ bool ShaderBuffer::updateContents(const DataSource &sourceData) {
return true; return true;
} }
void ShaderBuffer::beginFrame() { Vulkan::Buffer::advanceBuffer(); }
void ShaderBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) { void ShaderBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) {
Gfx::QueueOwnedResource::transferOwnership(newOwner); Gfx::QueueOwnedResource::transferOwnership(newOwner);
} }
@@ -335,28 +297,19 @@ void ShaderBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner) {
Vulkan::Buffer::executeOwnershipBarrier(newOwner); Vulkan::Buffer::executeOwnershipBarrier(newOwner);
} }
void ShaderBuffer::executePipelineBarrier(VkAccessFlags srcAccess, void ShaderBuffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) {
VkAccessFlags dstAccess, Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
VkPipelineStageFlags dstStage) {
Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess,
dstStage);
} }
VkAccessFlags ShaderBuffer::getSourceAccessMask() { VkAccessFlags ShaderBuffer::getSourceAccessMask() { return VK_ACCESS_MEMORY_WRITE_BIT; }
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags ShaderBuffer::getDestAccessMask() { VkAccessFlags ShaderBuffer::getDestAccessMask() { return VK_ACCESS_MEMORY_READ_BIT; }
return VK_ACCESS_MEMORY_READ_BIT;
}
VertexBuffer::VertexBuffer(PGraphics graphics, VertexBuffer::VertexBuffer(PGraphics graphics, const VertexBufferCreateInfo& sourceData)
const VertexBufferCreateInfo &sourceData) : Gfx::VertexBuffer(graphics->getFamilyMapping(), sourceData.numVertices, sourceData.vertexSize,
: Gfx::VertexBuffer(graphics->getFamilyMapping(), sourceData.numVertices, sourceData.sourceData.owner),
sourceData.vertexSize, sourceData.sourceData.owner), Vulkan::Buffer(graphics, sourceData.sourceData.size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, currentOwner, false,
Vulkan::Buffer(graphics, sourceData.sourceData.size,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, currentOwner, false,
sourceData.name) { sourceData.name) {
if (sourceData.sourceData.data != nullptr) { if (sourceData.sourceData.data != nullptr) {
void* data = map(); void* data = map();
@@ -380,8 +333,6 @@ void VertexBuffer::download(Array<uint8> &buffer) {
unmap(); unmap();
} }
void VertexBuffer::beginFrame() { Vulkan::Buffer::advanceBuffer(); }
void VertexBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) { void VertexBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) {
Gfx::QueueOwnedResource::transferOwnership(newOwner); Gfx::QueueOwnedResource::transferOwnership(newOwner);
} }
@@ -390,28 +341,19 @@ void VertexBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner) {
Vulkan::Buffer::executeOwnershipBarrier(newOwner); Vulkan::Buffer::executeOwnershipBarrier(newOwner);
} }
void VertexBuffer::executePipelineBarrier(VkAccessFlags srcAccess, void VertexBuffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) {
VkAccessFlags dstAccess, Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
VkPipelineStageFlags dstStage) {
Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess,
dstStage);
} }
VkAccessFlags VertexBuffer::getSourceAccessMask() { VkAccessFlags VertexBuffer::getSourceAccessMask() { return VK_ACCESS_MEMORY_WRITE_BIT; }
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags VertexBuffer::getDestAccessMask() { VkAccessFlags VertexBuffer::getDestAccessMask() { return VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT; }
return VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
}
IndexBuffer::IndexBuffer(PGraphics graphics, IndexBuffer::IndexBuffer(PGraphics graphics, const IndexBufferCreateInfo& sourceData)
const IndexBufferCreateInfo &sourceData) : Gfx::IndexBuffer(graphics->getFamilyMapping(), sourceData.sourceData.size, sourceData.indexType,
: Gfx::IndexBuffer(graphics->getFamilyMapping(), sourceData.sourceData.size, sourceData.sourceData.owner),
sourceData.indexType, sourceData.sourceData.owner), Vulkan::Buffer(graphics, sourceData.sourceData.size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, currentOwner, false,
Vulkan::Buffer(graphics, sourceData.sourceData.size,
VK_BUFFER_USAGE_INDEX_BUFFER_BIT, currentOwner, false,
sourceData.name) { sourceData.name) {
if (sourceData.sourceData.data != nullptr) { if (sourceData.sourceData.data != nullptr) {
void* data = map(); void* data = map();
@@ -429,8 +371,6 @@ void IndexBuffer::download(Array<uint8> &buffer) {
unmap(); unmap();
} }
void IndexBuffer::beginFrame() { Vulkan::Buffer::advanceBuffer(); }
void IndexBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) { void IndexBuffer::requestOwnershipTransfer(Gfx::QueueType newOwner) {
Gfx::QueueOwnedResource::transferOwnership(newOwner); Gfx::QueueOwnedResource::transferOwnership(newOwner);
} }
@@ -439,18 +379,11 @@ void IndexBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner) {
Vulkan::Buffer::executeOwnershipBarrier(newOwner); Vulkan::Buffer::executeOwnershipBarrier(newOwner);
} }
void IndexBuffer::executePipelineBarrier(VkAccessFlags srcAccess, void IndexBuffer::executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) {
VkAccessFlags dstAccess, Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess, dstStage);
VkPipelineStageFlags dstStage) {
Vulkan::Buffer::executePipelineBarrier(srcAccess, srcStage, dstAccess,
dstStage);
} }
VkAccessFlags IndexBuffer::getSourceAccessMask() { VkAccessFlags IndexBuffer::getSourceAccessMask() { return VK_ACCESS_MEMORY_WRITE_BIT; }
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags IndexBuffer::getDestAccessMask() { VkAccessFlags IndexBuffer::getDestAccessMask() { return VK_ACCESS_INDEX_READ_BIT; }
return VK_ACCESS_INDEX_READ_BIT;
}
+4
View File
@@ -4,6 +4,8 @@
namespace Seele { namespace Seele {
namespace Vulkan { namespace Vulkan {
DECLARE_REF(Command)
DECLARE_REF(Fence)
class Buffer { class Buffer {
public: public:
Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage, Buffer(PGraphics graphics, uint64 size, VkBufferUsageFlags usage,
@@ -28,8 +30,10 @@ protected:
uint64 size; uint64 size;
Gfx::QueueType &owner; Gfx::QueueType &owner;
Array<BufferAllocation> buffers; Array<BufferAllocation> buffers;
VkBufferUsageFlags usage;
uint32 numBuffers; uint32 numBuffers;
std::string name; std::string name;
void createBuffer();
void executeOwnershipBarrier(Gfx::QueueType newOwner); void executeOwnershipBarrier(Gfx::QueueType newOwner);
void executePipelineBarrier(VkAccessFlags srcAccess, void executePipelineBarrier(VkAccessFlags srcAccess,
+10 -10
View File
@@ -279,7 +279,7 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
descriptor->bind(); descriptor->bind();
VkDescriptorSet setHandle = descriptor->getHandle(); VkDescriptorSet setHandle = descriptor->getHandle();
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr); vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle, 0, nullptr);
} }
void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets)
{ {
@@ -292,7 +292,7 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
descriptorSet->bind(); descriptorSet->bind();
boundDescriptors.add(descriptorSet.getHandle()); boundDescriptors.add(descriptorSet.getHandle());
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle(); sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
} }
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, nullptr); vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, nullptr);
delete[] sets; delete[] sets;
@@ -416,7 +416,7 @@ void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
descriptor->bind(); descriptor->bind();
VkDescriptorSet setHandle = descriptor->getHandle(); VkDescriptorSet setHandle = descriptor->getHandle();
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr); vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle, 0, nullptr);
} }
void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets)
@@ -431,7 +431,7 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl; //std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
boundDescriptors.add(descriptorSet.getHandle()); boundDescriptors.add(descriptorSet.getHandle());
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle(); sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
} }
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, nullptr); vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, nullptr);
delete[] sets; delete[] sets;
@@ -469,9 +469,9 @@ CommandPool::CommandPool(PGraphics graphics, PQueue queue)
CommandPool::~CommandPool() CommandPool::~CommandPool()
{ {
vkDeviceWaitIdle(graphics->getDevice()); vkDeviceWaitIdle(graphics->getDevice());
for (auto& command : allocatedBuffers) for (auto& cmd : allocatedBuffers)
{ {
command->checkFence(); cmd->checkFence();
} }
allocatedRenderCommands.clear(); allocatedRenderCommands.clear();
allocatedComputeCommands.clear(); allocatedComputeCommands.clear();
@@ -487,17 +487,17 @@ PCommand CommandPool::getCommands()
} }
void CommandPool::cacheCommands(Array<ORenderCommand> commands) void CommandPool::cacheCommands(Array<ORenderCommand> commands)
{ {
for(auto&& command : commands) for(auto&& cmd : commands)
{ {
allocatedRenderCommands.add(std::move(command)); allocatedRenderCommands.add(std::move(cmd));
} }
} }
void CommandPool::cacheCommands(Array<OComputeCommand> commands) void CommandPool::cacheCommands(Array<OComputeCommand> commands)
{ {
for(auto&& command : commands) for(auto&& cmd : commands)
{ {
allocatedComputeCommands.add(std::move(command)); allocatedComputeCommands.add(std::move(cmd));
} }
} }
+9 -16
View File
@@ -73,18 +73,13 @@ public:
virtual void setViewport(Gfx::PViewport viewport) override; virtual void setViewport(Gfx::PViewport viewport) override;
virtual void bindPipeline(Gfx::PGraphicsPipeline pipeline) override; virtual void bindPipeline(Gfx::PGraphicsPipeline pipeline) override;
virtual void bindDescriptor(Gfx::PDescriptorSet descriptorSet) override; virtual void bindDescriptor(Gfx::PDescriptorSet descriptorSet) override;
virtual void virtual void bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) override;
bindDescriptor(const Array<Gfx::PDescriptorSet> &descriptorSets) override; virtual void bindVertexBuffer(const Array<Gfx::PVertexBuffer>& buffers) override;
virtual void
bindVertexBuffer(const Array<Gfx::PVertexBuffer> &buffers) override;
virtual void bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) override; virtual void bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) override;
virtual void pushConstants(Gfx::PPipelineLayout layout, virtual void pushConstants(Gfx::PPipelineLayout layout, Gfx::SeShaderStageFlags stage, uint32 offset, uint32 size,
Gfx::SeShaderStageFlags stage, uint32 offset, const void* data) override;
uint32 size, const void *data) override; virtual void draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, uint32 firstInstance) override;
virtual void draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, virtual void drawIndexed(uint32 indexCount, uint32 instanceCount, int32 firstIndex, uint32 vertexOffset,
uint32 firstInstance) override;
virtual void drawIndexed(uint32 indexCount, uint32 instanceCount,
int32 firstIndex, uint32 vertexOffset,
uint32 firstInstance) override; uint32 firstInstance) override;
virtual void drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) override; virtual void drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) override;
@@ -114,11 +109,9 @@ public:
virtual void bindPipeline(Gfx::PComputePipeline pipeline) override; virtual void bindPipeline(Gfx::PComputePipeline pipeline) override;
virtual void bindDescriptor(Gfx::PDescriptorSet set) override; virtual void bindDescriptor(Gfx::PDescriptorSet set) override;
virtual void bindDescriptor(const Array<Gfx::PDescriptorSet>& sets) override; virtual void bindDescriptor(const Array<Gfx::PDescriptorSet>& sets) override;
virtual void pushConstants(Gfx::PPipelineLayout layout, virtual void pushConstants(Gfx::PPipelineLayout layout, Gfx::SeShaderStageFlags stage, uint32 offset, uint32 size,
Gfx::SeShaderStageFlags stage, uint32 offset, const void* data) override;
uint32 size, const void *data) override; virtual void dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) override;
virtual void dispatch(uint32 threadX, uint32 threadY,
uint32 threadZ) override;
private: private:
PComputePipeline pipeline; PComputePipeline pipeline;
+6 -10
View File
@@ -161,6 +161,7 @@ void DescriptorPool::reset() {
DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner) DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
: Gfx::DescriptorSet(owner->getLayout()), setHandle(VK_NULL_HANDLE), graphics(graphics), owner(owner), bindCount(0), : Gfx::DescriptorSet(owner->getLayout()), setHandle(VK_NULL_HANDLE), graphics(graphics), owner(owner), bindCount(0),
currentlyInUse(false) {} currentlyInUse(false) {}
DescriptorSet::~DescriptorSet() {} DescriptorSet::~DescriptorSet() {}
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) { void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) {
@@ -315,8 +316,8 @@ void DescriptorSet::writeChanges() {
} }
} }
PipelineLayout::PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout) PipelineLayout::PipelineLayout(PGraphics graphics, const std::string& name, Gfx::PPipelineLayout baseLayout)
: Gfx::PipelineLayout(baseLayout), graphics(graphics), layoutHandle(VK_NULL_HANDLE) {} : Gfx::PipelineLayout(name, baseLayout), graphics(graphics), layoutHandle(VK_NULL_HANDLE) {}
PipelineLayout::~PipelineLayout() {} PipelineLayout::~PipelineLayout() {}
@@ -324,15 +325,10 @@ Map<uint32, VkPipelineLayout> cachedLayouts;
void PipelineLayout::create() { void PipelineLayout::create() {
vulkanDescriptorLayouts.resize(descriptorSetLayouts.size()); vulkanDescriptorLayouts.resize(descriptorSetLayouts.size());
for (size_t i = 0; i < descriptorSetLayouts.size(); ++i) { for (auto [name, desc] : descriptorSetLayouts) {
// There could be unused descriptor set indices PDescriptorLayout layout = desc.cast<DescriptorLayout>();
if (descriptorSetLayouts[i] == nullptr) {
vulkanDescriptorLayouts[i] = VK_NULL_HANDLE;
continue;
}
PDescriptorLayout layout = descriptorSetLayouts[i].cast<DescriptorLayout>();
layout->create(); layout->create();
vulkanDescriptorLayouts[i] = layout->getHandle(); vulkanDescriptorLayouts[parameterMapping[layout->getName()]] = layout->getHandle();
} }
Array<VkPushConstantRange> vkPushConstants(pushConstants.size()); Array<VkPushConstantRange> vkPushConstants(pushConstants.size());
+1 -1
View File
@@ -84,7 +84,7 @@ DEFINE_REF(DescriptorSet)
class PipelineLayout : public Gfx::PipelineLayout { class PipelineLayout : public Gfx::PipelineLayout {
public: public:
PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout); PipelineLayout(PGraphics graphics, const std::string& name, Gfx::PPipelineLayout baseLayout);
virtual ~PipelineLayout(); virtual ~PipelineLayout();
virtual void create(); virtual void create();
constexpr VkPipelineLayout getHandle() const { return layoutHandle; } constexpr VkPipelineLayout getHandle() const { return layoutHandle; }
-36
View File
@@ -102,24 +102,6 @@ VkShaderStageFlagBits Seele::Vulkan::cast(const Seele::Gfx::SeShaderStageFlagBit
return VK_SHADER_STAGE_ALL_GRAPHICS; return VK_SHADER_STAGE_ALL_GRAPHICS;
case SE_SHADER_STAGE_ALL: case SE_SHADER_STAGE_ALL:
return VK_SHADER_STAGE_ALL; return VK_SHADER_STAGE_ALL;
#ifdef USE_EXTENSIONS
case SE_SHADER_STAGE_RAYGEN_BIT_NV:
return VK_SHADER_STAGE_RAYGEN_BIT_NV;
case SE_SHADER_STAGE_ANY_HIT_BIT_NV:
return VK_SHADER_STAGE_ANY_HIT_BIT_NV;
case SE_SHADER_STAGE_CLOSEST_HIT_BIT_NV:
return VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV;
case SE_SHADER_STAGE_MISS_BIT_NV:
return VK_SHADER_STAGE_MISS_BIT_NV;
case SE_SHADER_STAGE_INTERSECTION_BIT_NV:
return VK_SHADER_STAGE_INTERSECTION_BIT_NV;
case SE_SHADER_STAGE_CALLABLE_BIT_NV:
return VK_SHADER_STAGE_CALLABLE_BIT_NV;
case SE_SHADER_STAGE_TASK_BIT_NV:
return VK_SHADER_STAGE_TASK_BIT_NV;
case SE_SHADER_STAGE_MESH_BIT_NV:
return VK_SHADER_STAGE_MESH_BIT_NV;
#endif
default: throw std::logic_error("Not implemented"); default: throw std::logic_error("Not implemented");
} }
@@ -145,24 +127,6 @@ Seele::Gfx::SeShaderStageFlagBits Seele::Vulkan::cast(const VkShaderStageFlagBit
return SE_SHADER_STAGE_ALL_GRAPHICS; return SE_SHADER_STAGE_ALL_GRAPHICS;
case VK_SHADER_STAGE_ALL: case VK_SHADER_STAGE_ALL:
return SE_SHADER_STAGE_ALL; return SE_SHADER_STAGE_ALL;
#ifdef USE_EXTENSIONS
case VK_SHADER_STAGE_RAYGEN_BIT_NV:
return SE_SHADER_STAGE_RAYGEN_BIT_NV;
case VK_SHADER_STAGE_ANY_HIT_BIT_NV:
return SE_SHADER_STAGE_ANY_HIT_BIT_NV;
case VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV:
return SE_SHADER_STAGE_CLOSEST_HIT_BIT_NV;
case VK_SHADER_STAGE_MISS_BIT_NV:
return SE_SHADER_STAGE_MISS_BIT_NV;
case VK_SHADER_STAGE_INTERSECTION_BIT_NV:
return SE_SHADER_STAGE_INTERSECTION_BIT_NV;
case VK_SHADER_STAGE_CALLABLE_BIT_NV:
return SE_SHADER_STAGE_CALLABLE_BIT_NV;
case VK_SHADER_STAGE_TASK_BIT_NV:
return SE_SHADER_STAGE_TASK_BIT_NV;
case VK_SHADER_STAGE_MESH_BIT_NV:
return SE_SHADER_STAGE_MESH_BIT_NV;
#endif
default: throw std::logic_error("Not implemented"); default: throw std::logic_error("Not implemented");
} }
+2 -2
View File
@@ -247,9 +247,9 @@ Gfx::ODescriptorLayout Graphics::createDescriptorLayout(const std::string& name)
return new DescriptorLayout(this, name); return new DescriptorLayout(this, name);
} }
Gfx::OPipelineLayout Graphics::createPipelineLayout(Gfx::PPipelineLayout baseLayout) Gfx::OPipelineLayout Graphics::createPipelineLayout(const std::string& name, Gfx::PPipelineLayout baseLayout)
{ {
return new PipelineLayout(this, baseLayout); return new PipelineLayout(this, name, baseLayout);
} }
Gfx::OVertexInput Graphics::createVertexInput(VertexInputStateCreateInfo createInfo) Gfx::OVertexInput Graphics::createVertexInput(VertexInputStateCreateInfo createInfo)
+2 -2
View File
@@ -14,7 +14,7 @@ VertexInput::~VertexInput()
{ {
} }
GraphicsPipeline::GraphicsPipeline(PGraphics graphics, VkPipeline handle, Gfx::OPipelineLayout pipelineLayout) GraphicsPipeline::GraphicsPipeline(PGraphics graphics, VkPipeline handle, Gfx::PPipelineLayout pipelineLayout)
: Gfx::GraphicsPipeline(std::move(pipelineLayout)) : Gfx::GraphicsPipeline(std::move(pipelineLayout))
, graphics(graphics) , graphics(graphics)
, pipeline(handle) , pipeline(handle)
@@ -35,7 +35,7 @@ VkPipelineLayout GraphicsPipeline::getLayout() const
return Gfx::PPipelineLayout(layout).cast<PipelineLayout>()->getHandle(); return Gfx::PPipelineLayout(layout).cast<PipelineLayout>()->getHandle();
} }
ComputePipeline::ComputePipeline(PGraphics graphics, VkPipeline handle, Gfx::OPipelineLayout pipelineLayout) ComputePipeline::ComputePipeline(PGraphics graphics, VkPipeline handle, Gfx::PPipelineLayout pipelineLayout)
: Gfx::ComputePipeline(std::move(pipelineLayout)) : Gfx::ComputePipeline(std::move(pipelineLayout))
, graphics(graphics) , graphics(graphics)
, pipeline(handle) , pipeline(handle)
+2 -2
View File
@@ -18,7 +18,7 @@ DECLARE_REF(Graphics)
class GraphicsPipeline : public Gfx::GraphicsPipeline class GraphicsPipeline : public Gfx::GraphicsPipeline
{ {
public: public:
GraphicsPipeline(PGraphics graphics, VkPipeline handle, Gfx::OPipelineLayout pipelineLayout); GraphicsPipeline(PGraphics graphics, VkPipeline handle, Gfx::PPipelineLayout pipelineLayout);
virtual ~GraphicsPipeline(); virtual ~GraphicsPipeline();
void bind(VkCommandBuffer handle); void bind(VkCommandBuffer handle);
VkPipelineLayout getLayout() const; VkPipelineLayout getLayout() const;
@@ -30,7 +30,7 @@ DEFINE_REF(GraphicsPipeline)
class ComputePipeline : public Gfx::ComputePipeline class ComputePipeline : public Gfx::ComputePipeline
{ {
public: public:
ComputePipeline(PGraphics graphics, VkPipeline handle, Gfx::OPipelineLayout pipelineLayout); ComputePipeline(PGraphics graphics, VkPipeline handle, Gfx::PPipelineLayout pipelineLayout);
virtual ~ComputePipeline(); virtual ~ComputePipeline();
void bind(VkCommandBuffer handle); void bind(VkCommandBuffer handle);
VkPipelineLayout getLayout() const; VkPipelineLayout getLayout() const;
+3 -3
View File
@@ -252,7 +252,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count(); int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count();
std::cout << "Gfx creation time: " << delta << std::endl; std::cout << "Gfx creation time: " << delta << std::endl;
OGraphicsPipeline pipeline = new GraphicsPipeline(graphics, pipelineHandle, std::move(gfxInfo.pipelineLayout)); OGraphicsPipeline pipeline = new GraphicsPipeline(graphics, pipelineHandle, gfxInfo.pipelineLayout);
PGraphicsPipeline result = pipeline; PGraphicsPipeline result = pipeline;
graphicsPipelines[hash] = std::move(pipeline); graphicsPipelines[hash] = std::move(pipeline);
return result; return result;
@@ -423,7 +423,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxI
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count(); int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count();
std::cout << "Gfx creation time: " << delta << std::endl; std::cout << "Gfx creation time: " << delta << std::endl;
OGraphicsPipeline pipeline = new GraphicsPipeline(graphics, pipelineHandle, std::move(gfxInfo.pipelineLayout)); OGraphicsPipeline pipeline = new GraphicsPipeline(graphics, pipelineHandle, gfxInfo.pipelineLayout);
PGraphicsPipeline result = pipeline; PGraphicsPipeline result = pipeline;
graphicsPipelines[hash] = std::move(pipeline); graphicsPipelines[hash] = std::move(pipeline);
return result; return result;
@@ -462,7 +462,7 @@ PComputePipeline PipelineCache::createPipeline(Gfx::ComputePipelineCreateInfo co
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count(); int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count();
std::cout << "Compute creation time: " << delta << std::endl; std::cout << "Compute creation time: " << delta << std::endl;
OComputePipeline pipeline = new ComputePipeline(graphics, pipelineHandle, std::move(computeInfo.pipelineLayout)); OComputePipeline pipeline = new ComputePipeline(graphics, pipelineHandle, computeInfo.pipelineLayout);
PComputePipeline result = pipeline; PComputePipeline result = pipeline;
graphicsPipelines[hash] = std::move(pipeline); graphicsPipelines[hash] = std::move(pipeline);
return result; return result;
+3 -1
View File
@@ -30,7 +30,9 @@ uint32 Seele::Vulkan::Shader::getShaderHash() const
void Shader::create(const ShaderCreateInfo& createInfo) void Shader::create(const ShaderCreateInfo& createInfo)
{ {
Slang::ComPtr<slang::IBlob> kernelBlob = generateShader(createInfo, SLANG_SPIRV); Map<std::string, uint32> paramMapping;
Slang::ComPtr<slang::IBlob> kernelBlob = generateShader(createInfo, SLANG_SPIRV, paramMapping);
const_cast<Gfx::PipelineLayout*>(createInfo.rootSignature.getHandle())->addMapping(paramMapping);
VkShaderModuleCreateInfo moduleInfo = VkShaderModuleCreateInfo moduleInfo =
{ {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
+1
View File
@@ -143,6 +143,7 @@ void Window::endFrame()
VK_CHECK(r); VK_CHECK(r);
} }
currentSemaphoreIndex = (currentSemaphoreIndex + 1) % Gfx::numFramesBuffered; currentSemaphoreIndex = (currentSemaphoreIndex + 1) % Gfx::numFramesBuffered;
graphics->waitDeviceIdle();
} }
void Window::onWindowCloseEvent() void Window::onWindowCloseEvent()
-1
View File
@@ -1,5 +1,4 @@
#include "slang-compile.h" #include "slang-compile.h"
#include <slang-com-ptr.h>
#include <slang.h> #include <slang.h>
#include "Containers/Array.h" #include "Containers/Array.h"
#include <fmt/core.h> #include <fmt/core.h>
+1 -2
View File
@@ -12,7 +12,6 @@
"fmt", "fmt",
"gtest", "gtest",
"vulkan-memory-allocator", "vulkan-memory-allocator",
"shader-slang", "shader-slang"
"glslang"
] ]
} }