Skip to content
Snippets Groups Projects
Commit d644ae48 authored by n0F4x's avatar n0F4x
Browse files

Remove source files

parent f8416c3b
No related branches found
No related tags found
No related merge requests found
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignConsecutiveMacros: Consecutive
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments:
Kind: Always
OverEmptyLines: 1
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: [ ]
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: MultiLine
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyNamespace: true
BreakAfterAttributes: Leave
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
# BreakBeforeInlineASMColon:
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: ''
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: true
ForEachMacros: [ 'RANGES_FOR', 'FOREACH' ]
IfMacros: [ 'IF' ]
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<glm/'
Priority: 1
- Regex: '^<vulkan/'
Priority: 2
- Regex: '<vk_mem_alloc.h>'
Priority: 3
- Regex: '^<glfw/'
Priority: 4
- Regex: '^<.*\..*'
Priority: 998
- Regex: '^<.*'
Priority: 1
- Regex: '\/.*'
Priority: 999
- Regex: '.*'
Priority: 1000
IncludeIsMainRegex: ''
# IncludeIsMainSourceRegex:
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertBraces: true
InsertNewlineAtEOF: true
IntegerLiteralSeparator:
Binary: 4
Decimal: 3
Hex: 2
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
NamespaceMacros: [ ]
PPIndentWidth: 2
PackConstructorInitializers: CurrentLine
#PenaltyBreakAssignment: 10
#PenaltyBreakBeforeFirstCallParameter: 30
#PenaltyBreakComment: 10
#PenaltyBreakFirstLessLess: 0
#PenaltyBreakOpenParenthesis: 10
#PenaltyBreakString: 10
#PenaltyBreakTemplateDeclaration: 20
#PenaltyExcessCharacter: 1
#PenaltyIndentedWhitespace: 0
#PenaltyReturnTypeOnItsOwnLine: 5
PointerAlignment: Left
QualifierAlignment: Custom
QualifierOrder: [ 'constexpr', 'inline', 'static', 'volatile', 'const', 'type', 'restrict' ]
RawStringFormats:
- Language: Cpp
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 0
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: false
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: true
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 3
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros: [ ]
StatementMacros: [ ]
TabWidth: 4
TypenameMacros: [ ]
UseTab: Never
WhitespaceSensitiveMacros: [ ]
---
cmake_minimum_required(VERSION 3.25)
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
project(renderer C CXX)
add_executable(${PROJECT_NAME})
option(engine_debug "Turn on debug mode" ON)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
/W4
/WX
)
else ()
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall
-Wextra
-Werror
-Wno-missing-field-initializers
)
endif ()
target_precompile_headers(${PROJECT_NAME} PRIVATE
<algorithm>
<concepts>
<fstream>
<functional>
<iostream>
<limits>
<memory>
<ranges>
<set>
<span>
<sstream>
<stdexcept>
<string>
<string_view>
<thread>
<type_traits>
<unordered_map>
<utility>
<vector>
<variant>
)
# Vulkan
find_package(Vulkan REQUIRED)
target_compile_definitions(${PROJECT_NAME} PRIVATE
VULKAN_HPP_NO_TO_STRING
VULKAN_HPP_NO_CONSTRUCTORS
VULKAN_HPP_NO_SETTERS
VULKAN_HPP_NO_SPACESHIP_OPERATOR
)
if (engine_debug)
target_compile_definitions(${PROJECT_NAME} PRIVATE ENGINE_VULKAN_DEBUG)
endif ()
target_precompile_headers(${PROJECT_NAME} PRIVATE <vulkan/vulkan.hpp>)
target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Vulkan)
# VulkanMemoryAllocator
set(STATIC_VULKAN_FUNCTIONS 0)
set(DYNAMIC_VULKAN_FUNCTIONS 1)
FetchContent_Declare(VulkanMemoryAllocator
GIT_REPOSITORY https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
GIT_TAG 2f382df
GIT_PROGRESS TRUE
SYSTEM
)
FetchContent_MakeAvailable(VulkanMemoryAllocator)
target_compile_definitions(${PROJECT_NAME} PRIVATE
VMA_STATIC_VULKAN_FUNCTIONS=${STATIC_VULKAN_FUNCTIONS}
VMA_DYNAMIC_VULKAN_FUNCTIONS=${DYNAMIC_VULKAN_FUNCTIONS}
)
target_link_libraries(${PROJECT_NAME} PRIVATE VulkanMemoryAllocator)
# GLFW
FetchContent_Declare(GLFW
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.3.9
GIT_PROGRESS TRUE
SYSTEM
)
FetchContent_MakeAvailable(GLFW)
target_compile_definitions(${PROJECT_NAME} PRIVATE
GLFW_INCLUDE_VULKAN
)
target_link_libraries(${PROJECT_NAME} PRIVATE glfw)
# glm
FetchContent_Declare(glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 1.0.0
GIT_PROGRESS TRUE
SYSTEM
)
FetchContent_MakeAvailable(glm)
target_compile_definitions(${PROJECT_NAME} PRIVATE
GLM_FORCE_DEPTH_ZERO_TO_ONE
)
target_precompile_headers(${PROJECT_NAME} PRIVATE <glm/glm.hpp>)
target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm)
add_subdirectory(src)
......@@ -5,7 +5,8 @@ Minden írásos anyag megtalálható a [docs](./docs) mappában. Ezek effektív
Ajánlott tanulós menetrend:
1. Szedd le a `starter` *branch*-en lévő kódot, és addig kupáld, amíg nem fordul. Kell hozzá CMake, C++20-as fordító, és Vulkan SDK.
2. Olvasd át a [bevezető előadás diái](./docs/Vulkan Bevezető.pptx)t.
2. Olvasd át a [bevezető előadás diái](./docs/lectures/Bevezető.pptx)t.
3. Menj végig a [lectures](./docs/lectures) mappában található olvasmányokon. (Ehhez ajánlott az mkdocs használata.)
A `master` *branch*-en található kód mindig a legfrissebb alkalmat tükrözi. Más alkalmak befejezett kódjai megtalálhatóak a hozzájuk tartozó *branch*-eken.
A `master` *branch*-en csak dokumentáció van.
Az egyes leckékhez tartozó kódok külön branch-eken vannak.
target_sources(${PROJECT_NAME} PRIVATE
main.cpp
Renderer.cpp
)
#include "Renderer.hpp"
#include <algorithm>
#include <ranges>
#include <vector>
const std::vector<const char*> g_layers{
#ifdef ENGINE_VULKAN_DEBUG
"VK_LAYER_KHRONOS_validation"
#endif
};
[[nodiscard]] static auto create_instance() -> vk::UniqueInstance
{
constexpr static vk::ApplicationInfo application_info{};
const vk::InstanceCreateInfo create_info{
.pApplicationInfo = &application_info,
.enabledLayerCount = static_cast<uint32_t>(g_layers.size()),
.ppEnabledLayerNames = g_layers.data(),
};
return vk::createInstanceUnique(create_info);
}
[[nodiscard]] static auto choose_physical_device(const vk::Instance t_instance)
-> vk::PhysicalDevice
{
const auto physical_devices{ t_instance.enumeratePhysicalDevices() };
if (std::ranges::empty(physical_devices)) {
throw std::runtime_error{ "No Vulkan physical device is available." };
}
auto ranked_devices_view{
physical_devices
| std::views::transform([](vk::PhysicalDevice t_physical_device) {
switch (t_physical_device.getProperties().deviceType) {
case vk::PhysicalDeviceType::eDiscreteGpu:
return std::make_pair(t_physical_device, 2);
case vk::PhysicalDeviceType::eIntegratedGpu:
return std::make_pair(t_physical_device, 1);
default: return std::make_pair(t_physical_device, 0);
}
})
};
std::vector ranked_devices(
ranked_devices_view.begin(), ranked_devices_view.end()
);
std::ranges::sort(
ranked_devices,
std::ranges::greater{},
&std::pair<vk::PhysicalDevice, int>::second
);
return ranked_devices.front().first;
}
[[nodiscard]] static auto find_graphics_queue_family(
const vk::PhysicalDevice t_physical_device
) -> uint32_t
{
uint32_t index{};
for (const auto& properties : t_physical_device.getQueueFamilyProperties())
{
if (properties.queueFlags & vk::QueueFlagBits::eGraphics) {
return index;
}
index++;
}
throw std::runtime_error{ "Could not find graphics queue family" };
}
[[nodiscard]] static auto create_device(const vk::PhysicalDevice t_physical_device)
-> vk::UniqueDevice
{
const vk::DeviceQueueCreateInfo queue_create_info{
.queueFamilyIndex = find_graphics_queue_family(t_physical_device),
.queueCount = 1,
};
vk::DeviceCreateInfo device_create_info{
.queueCreateInfoCount = 1,
.pQueueCreateInfos = &queue_create_info,
};
return t_physical_device.createDeviceUnique(device_create_info);
}
Renderer::Renderer()
: m_instance{ create_instance() },
m_physical_device{ choose_physical_device(*m_instance) },
m_graphics_queue_family{ find_graphics_queue_family(m_physical_device) },
m_device{ create_device(m_physical_device) },
m_graphics_queue{ m_device->getQueue(m_graphics_queue_family, 0) }
{}
#pragma once
#include <vulkan/vulkan.hpp>
class Renderer {
public:
Renderer();
private:
vk::UniqueInstance m_instance;
vk::PhysicalDevice m_physical_device;
uint32_t m_graphics_queue_family;
vk::UniqueDevice m_device;
vk::Queue m_graphics_queue;
};
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment