-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemo.txt
107 lines (85 loc) · 3.53 KB
/
memo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*********/
/** Math */
/*********/
1.===================================
// DirectX 中是从左往右乘比如 mvp
// HLSL 中是从右往左乘比如 pvm
2. ==================================
// Rotation in d3d is in radians!!!
// D3D 中旋转用的是弧度!!!
/**********/
/** ImGui */
/**********/
# Docking 分支
1. 第二个参数可能会影响 win32 窗口外的消息捕获
PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)
/*********/
/** HLSL */
/*********/
alignas(16)
// 一定要注意字节对齐,不然就不能正确传到 GPU,可以使用 RenderDoc 调试
1. 在绑定常量缓冲区时:
GPU 端使用 float3 会自动填充一个 float 保证 是 16字节的倍数
而 CPU 端不会,所以需要手动填充,不然就会有问题
【解决方法1】:( 在变量前添加 alignas(16),编译器会为我们加上这些间隔 )
struct PointLightCBuf
{
alignas(16) DirectX::XMFLOAT3 pos;
alignas(16) DirectX::XMFLOAT3 materialColor;
alignas(16) DirectX::XMFLOAT3 ambient;
alignas(16) DirectX::XMFLOAT3 diffuseColor;
float diffuseIntensity;
float attConst;
float attLin;
float attQuad;
};
【解决方法2】:手动添加 float 去对齐
struct Test
{
DirectX::XMFLOAT3 pos;
float padding;
};
/***************/
/** 使用第三方库 */
/***************/
1. ================================
Assimp
// 这里直接写下正确操作
1. clone 或者下载 Assimp 源码,我这里放在 Engine/src/Vendor/Assimp
// 这里我改了名字 -> Assimp
2. 在 Engine/ CMakeLists.txt 中添加:( 注意link的 assimp 要小写!!!)
# *****************
# add subdirectory.
# *****************
# Assimp
set(BUILD_SHARED_LIBS OFF)
set(ASSIMP_BUILD_ZLIB ON)
set(USE_STATIC_CRT ON) # 这个很重要,看你是否是运行时静态
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF)
set(ASSIMP_BUILD_TESTS OFF)
set(ASSIMP_INSTALL OFF)
set(ASSIMP_INJECT_DEBUG_POSTFIX OFF)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/src/Vendor/Assimp)
# If it is a project the project is referenced first, if not, the library is linked.
# Notice that assimp is lowercase here!!!
target_link_libraries(${PROJECT_NAME} assimp)
3. 下载下来的 Assimp 太大了,删除一些不用的
(1) Engine/src/Vendor/Assimp/test/ 中的 models/ 和 models-nonbsd/
4. 我这里因为写法问题,需要额外做一些剔除操作(可参考),Assimp Begin 后面是我添加的
// Engine/CMakeLists.txt
# recursively find all.cpp and.h in the src directory.
file(GLOB_RECURSE EngineSrc src/*.cpp src/*.h)
# Assimp Begin --------------------------------------
# 1. Collect all Assimp files first
file(GLOB_RECURSE ExcludedFiles src/Vendor/Assimp/*.cpp src/Vendor/Assimp/*.h)
# 2. Removes excluded files from the result
list(REMOVE_ITEM EngineSrc ${ExcludedFiles})
# Assimp End --------------------------------------
5. 这是在 ProvingGround 也就是 "试验场",就是我生成应用程序使用的 Project,需要拷贝一下 assimp-vc143-mt.lib
#**************************************** Assimp.lib
# Command1
COMMAND ${CMAKE_COMMAND} -E copy
$<IF:$<CONFIG:Debug>,${CMAKE_SOURCE_DIR}/Engine/src/Vendor/Assimp/lib/Debug/assimp-vc143-mt.lib,${CMAKE_SOURCE_DIR}/Engine/src/Vendor/Assimp/lib/Release/assimp-vc143-mt.lib>
$<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_BINARY_DIR}/Debug/assimp-vc143-mt.lib,${CMAKE_CURRENT_BINARY_DIR}/Release/assimp-vc143-mt.lib>
# Log1: Message for Engine.lib
COMMAND ${CMAKE_COMMAND} -E echo "----[Devil Engine CMake Log]----: Copying **( Engine.lib )** based on build configuration!!!"