Skip to content

Commit d7c3a4d

Browse files
committed
支持linux(现在嵌入Node.js暂时有bug)
1 parent 2c6bfb5 commit d7c3a4d

13 files changed

Lines changed: 157 additions & 51 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ file(GLOB RUNTIME_WIN32_MODULE_SOURCES
5050
list(REMOVE_ITEM RUNTIME_MODULE_SOURCES ${RUNTIME_WIN32_MODULE_SOURCES})
5151

5252

53+
file(GLOB RUNTIME_LINUX_MODULE_SOURCES
54+
LIST_DIRECTORIES false
55+
CONFIGURE_DEPENDS
56+
"./src/Runtime/Linux_*.cpp"
57+
)
58+
list(REMOVE_ITEM RUNTIME_MODULE_SOURCES ${RUNTIME_LINUX_MODULE_SOURCES})
59+
5360
file(GLOB RUNTIME_ANDROID_MODULE_HEADERS
5461
LIST_DIRECTORIES false
5562
CONFIGURE_DEPENDS
@@ -265,6 +272,12 @@ if (FCT_WIN32)
265272
)
266273
endif()
267274

275+
if (FCT_LINUX)
276+
target_sources(FCT PRIVATE
277+
${RUNTIME_LINUX_MODULE_SOURCES}
278+
)
279+
endif()
280+
268281
if (FCT_ANDROID)
269282
target_sources(FCT PRIVATE
270283
${UI_ANDROID_MODULE_SOURCES}

platform

src/Base/TokenGraph.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ namespace FCT {
1010
template<typename Token,typename Value>
1111
class TokenGraph : public Noncopyable
1212
{
13+
public:
14+
class NodeProbe;
1315
private:
14-
class NodeProbe;
1516
struct NodeInfo
1617
{
1718
private:

src/Base/string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define STRING_H
77
namespace FCT {
88
constexpr bool StringEquals(const char* a, const char* b) noexcept {
9-
if (a == b) return true;
9+
//if (a == b) return true;
1010
if (!a || !b) return false;
1111

1212
while (*a && *b) {

src/ModelLoader/ModelLoader.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace FCT
1111
* @brief 纹理类型枚举
1212
* @endcond
1313
*/
14-
enum class TextureType
14+
enum class TextureType : int
1515
{
1616
diffuse = 0, ///< @cond CHINESE 漫反射贴图 @endcond
1717
specular, ///< @cond CHINESE 镜面反射贴图 @endcond
@@ -149,8 +149,12 @@ namespace serialization {
149149
template<class Archive>
150150
void serialize(Archive & ar, FCT::ModelInfo::TextureType & t, const unsigned int version)
151151
{
152-
ar & static_cast<int&>(t);
152+
using UnderlyingType = std::underlying_type_t<FCT::ModelInfo::TextureType>;
153+
UnderlyingType value = static_cast<UnderlyingType>(t);
154+
ar & value;
155+
t = static_cast<FCT::ModelInfo::TextureType>(value);
153156
}
157+
154158
}
155159
}
156160
namespace FCT

src/RHI/ImageAspect.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,31 @@ namespace FCT
1111
};
1212
FCT_DECLARE_FLAGS(ImageAspect);
1313
#ifdef FCT_USE_VULKAN
14-
FCT_TO_VK_FLAG_BIT_BEGIN(ImageAspect)
15-
FCT_TO_VK_FLAG_BIT_CASE(ImageAspect,color, Color)
16-
FCT_TO_VK_FLAG_BIT_CASE(ImageAspect, depth, Depth)
17-
FCT_TO_VK_FLAG_BIT_CASE(ImageAspect, stencil, Stencil)
18-
FCT_TO_VK_FLAG_BIT_END(ImageAspect)
19-
FCT_TO_VK_FLAGS(ImageAspect)
14+
inline vk::ImageAspectFlagBits ToVkImageAspect(ImageAspect bit)
15+
{
16+
switch (bit)
17+
{
18+
case ImageAspect::color:
19+
return vk::ImageAspectFlagBits::eColor;
20+
case ImageAspect::depth:
21+
return vk::ImageAspectFlagBits::eDepth;
22+
case ImageAspect::stencil:
23+
return vk::ImageAspectFlagBits::eStencil;
24+
default:
25+
return vk::ImageAspectFlagBits(0);
26+
}
27+
}
28+
inline auto ToVkImageAspects(ImageAspects flags)
29+
{
30+
auto result = ToVkImageAspect(static_cast<ImageAspect>(0)) | ToVkImageAspect(static_cast<ImageAspect>(0));
31+
for (uint32_t i = 0; i < 32; ++i) {
32+
ImageAspect singleFlag = static_cast<ImageAspect>(1u << i);
33+
if (flags & singleFlag) {
34+
result |= ToVkImageAspect(singleFlag);
35+
}
36+
}
37+
return result;
38+
}
2039
#endif
2140
}
2241
#endif //IMAGEASPECT_H

src/RHI/ImageLayout.h

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,76 @@ namespace FCT {
4141
videoEncodeQuantizationMapKHR
4242
};
4343
#ifdef FCT_USE_VULKAN
44-
FCT_TO_VK_ENUM_BEGIN(ImageLayout)
45-
FCT_TO_VK_ENUM_CASE(ImageLayout, undefined, Undefined)
46-
FCT_TO_VK_ENUM_CASE(ImageLayout, general, General)
47-
FCT_TO_VK_ENUM_CASE(ImageLayout, colorAttachmentOptimal, ColorAttachmentOptimal)
48-
FCT_TO_VK_ENUM_CASE(ImageLayout, depthStencilAttachmentOptimal, DepthStencilAttachmentOptimal)
49-
FCT_TO_VK_ENUM_CASE(ImageLayout, depthStencilReadOnlyOptimal, DepthStencilReadOnlyOptimal)
50-
FCT_TO_VK_ENUM_CASE(ImageLayout, shaderReadOnlyOptimal, ShaderReadOnlyOptimal)
51-
FCT_TO_VK_ENUM_CASE(ImageLayout, transferSrcOptimal, TransferSrcOptimal)
52-
FCT_TO_VK_ENUM_CASE(ImageLayout, transferDstOptimal, TransferDstOptimal)
53-
FCT_TO_VK_ENUM_CASE(ImageLayout, preinitialized, Preinitialized)
54-
FCT_TO_VK_ENUM_CASE(ImageLayout, depthReadOnlyStencilAttachmentOptimal, DepthReadOnlyStencilAttachmentOptimal)
55-
FCT_TO_VK_ENUM_CASE(ImageLayout, depthAttachmentStencilReadOnlyOptimal, DepthAttachmentStencilReadOnlyOptimal)
56-
FCT_TO_VK_ENUM_CASE(ImageLayout, depthAttachmentOptimal, DepthAttachmentOptimal)
57-
FCT_TO_VK_ENUM_CASE(ImageLayout, depthReadOnlyOptimal, DepthReadOnlyOptimal)
58-
FCT_TO_VK_ENUM_CASE(ImageLayout, stencilAttachmentOptimal, StencilAttachmentOptimal)
59-
FCT_TO_VK_ENUM_CASE(ImageLayout, stencilReadOnlyOptimal, StencilReadOnlyOptimal)
60-
FCT_TO_VK_ENUM_CASE(ImageLayout, readOnlyOptimal, ReadOnlyOptimal)
61-
FCT_TO_VK_ENUM_CASE(ImageLayout, attachmentOptimal, AttachmentOptimal)
62-
FCT_TO_VK_ENUM_CASE(ImageLayout, renderingLocalRead, RenderingLocalRead)
63-
FCT_TO_VK_ENUM_CASE(ImageLayout, presentSrcKHR, PresentSrcKHR)
64-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoDecodeDstKHR, VideoDecodeDstKHR)
65-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoDecodeSrcKHR, VideoDecodeSrcKHR)
66-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoDecodeDpbKHR, VideoDecodeDpbKHR)
67-
FCT_TO_VK_ENUM_CASE(ImageLayout, sharedPresentKHR, SharedPresentKHR)
68-
FCT_TO_VK_ENUM_CASE(ImageLayout, fragmentDensityMapOptimalEXT, FragmentDensityMapOptimalEXT)
69-
FCT_TO_VK_ENUM_CASE(ImageLayout, fragmentShadingRateAttachmentOptimalKHR, FragmentShadingRateAttachmentOptimalKHR)
70-
FCT_TO_VK_ENUM_CASE(ImageLayout, shadingRateOptimalNV, ShadingRateOptimalNV)
71-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoEncodeDstKHR, VideoEncodeDstKHR)
72-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoEncodeSrcKHR, VideoEncodeSrcKHR)
73-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoEncodeDpbKHR, VideoEncodeDpbKHR)
74-
FCT_TO_VK_ENUM_CASE(ImageLayout, attachmentFeedbackLoopOptimalEXT, AttachmentFeedbackLoopOptimalEXT)
75-
FCT_TO_VK_ENUM_CASE(ImageLayout, videoEncodeQuantizationMapKHR, VideoEncodeQuantizationMapKHR)
76-
FCT_TO_VK_ENUM_END(ImageLayout)
44+
inline vk::ImageLayout ToVkImageLayout(ImageLayout e)
45+
{
46+
switch (e)
47+
{
48+
case ImageLayout::undefined:
49+
return vk::ImageLayout::eUndefined;
50+
case ImageLayout::general:
51+
return vk::ImageLayout::eGeneral;
52+
case ImageLayout::colorAttachmentOptimal:
53+
return vk::ImageLayout::eColorAttachmentOptimal;
54+
case ImageLayout::depthStencilAttachmentOptimal:
55+
return vk::ImageLayout::eDepthStencilAttachmentOptimal;
56+
case ImageLayout::depthStencilReadOnlyOptimal:
57+
return vk::ImageLayout::eDepthStencilReadOnlyOptimal;
58+
case ImageLayout::shaderReadOnlyOptimal:
59+
return vk::ImageLayout::eShaderReadOnlyOptimal;
60+
case ImageLayout::transferSrcOptimal:
61+
return vk::ImageLayout::eTransferSrcOptimal;
62+
case ImageLayout::transferDstOptimal:
63+
return vk::ImageLayout::eTransferDstOptimal;
64+
case ImageLayout::preinitialized:
65+
return vk::ImageLayout::ePreinitialized;
66+
case ImageLayout::depthReadOnlyStencilAttachmentOptimal:
67+
return vk::ImageLayout::eDepthReadOnlyStencilAttachmentOptimal;
68+
case ImageLayout::depthAttachmentStencilReadOnlyOptimal:
69+
return vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal;
70+
case ImageLayout::depthAttachmentOptimal:
71+
return vk::ImageLayout::eDepthAttachmentOptimal;
72+
case ImageLayout::depthReadOnlyOptimal:
73+
return vk::ImageLayout::eDepthReadOnlyOptimal;
74+
case ImageLayout::stencilAttachmentOptimal:
75+
return vk::ImageLayout::eStencilAttachmentOptimal;
76+
case ImageLayout::stencilReadOnlyOptimal:
77+
return vk::ImageLayout::eStencilReadOnlyOptimal;
78+
case ImageLayout::readOnlyOptimal:
79+
return vk::ImageLayout::eReadOnlyOptimal;
80+
case ImageLayout::attachmentOptimal:
81+
return vk::ImageLayout::eAttachmentOptimal;
82+
case ImageLayout::renderingLocalRead:
83+
return vk::ImageLayout::eRenderingLocalRead;
84+
case ImageLayout::presentSrcKHR:
85+
return vk::ImageLayout::ePresentSrcKHR;
86+
case ImageLayout::videoDecodeDstKHR:
87+
return vk::ImageLayout::eVideoDecodeDstKHR;
88+
case ImageLayout::videoDecodeSrcKHR:
89+
return vk::ImageLayout::eVideoDecodeSrcKHR;
90+
case ImageLayout::videoDecodeDpbKHR:
91+
return vk::ImageLayout::eVideoDecodeDpbKHR;
92+
case ImageLayout::sharedPresentKHR:
93+
return vk::ImageLayout::eSharedPresentKHR;
94+
case ImageLayout::fragmentDensityMapOptimalEXT:
95+
return vk::ImageLayout::eFragmentDensityMapOptimalEXT;
96+
case ImageLayout::fragmentShadingRateAttachmentOptimalKHR:
97+
return vk::ImageLayout::eFragmentShadingRateAttachmentOptimalKHR;
98+
case ImageLayout::shadingRateOptimalNV:
99+
return vk::ImageLayout::eShadingRateOptimalNV;
100+
case ImageLayout::videoEncodeDstKHR:
101+
return vk::ImageLayout::eVideoEncodeDstKHR;
102+
case ImageLayout::videoEncodeSrcKHR:
103+
return vk::ImageLayout::eVideoEncodeSrcKHR;
104+
case ImageLayout::videoEncodeDpbKHR:
105+
return vk::ImageLayout::eVideoEncodeDpbKHR;
106+
case ImageLayout::attachmentFeedbackLoopOptimalEXT:
107+
return vk::ImageLayout::eAttachmentFeedbackLoopOptimalEXT;
108+
case ImageLayout::videoEncodeQuantizationMapKHR:
109+
return vk::ImageLayout::eVideoEncodeQuantizationMapKHR;
110+
default:
111+
return vk::ImageLayout(0);
112+
}
113+
}
77114
#endif
78115
}
79116
#endif //IMAGELAYOUT_H

src/RHI/Pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ namespace FCT
2222
{
2323
public:
2424
static constexpr Pass* external = nullptr;
25-
static constexpr Pass* present = reinterpret_cast<Pass*>(-1);
26-
static constexpr Pass* begin = reinterpret_cast<Pass*>(-1);;
25+
inline static Pass* const present = reinterpret_cast<Pass*>(static_cast<uintptr_t>(-1));
26+
inline static Pass* const begin = reinterpret_cast<Pass*>(static_cast<uintptr_t>(-1));
2727
Pass()
2828
{
2929
m_group = nullptr;

src/Runtime/Linux_Runtime.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "../FCTAPI.h"
2+
3+
namespace FCT {
4+
struct Linux_RuntimeCommon : public RuntimeCommon {
5+
6+
};
7+
void Runtime::init() {
8+
g_common = FCT_NEW(Linux_RuntimeCommon);
9+
}
10+
void Runtime::term() {
11+
FCT_DELETE(g_common);
12+
}
13+
14+
Window* Runtime::createWindow()
15+
{
16+
#ifdef FCT_USE_GLFW
17+
Window* window = FCT_NEW(GLFW_Window,g_common->glfwUICommon,this);
18+
return window;
19+
#endif
20+
}
21+
22+
Context* Runtime::createContext()
23+
{
24+
return FCT_NEW(VK_Context,g_common->vkContextCommon);
25+
}
26+
27+
ImageLoader* Runtime::createImageLoader()
28+
{
29+
return FCT_NEW(FreeImage_ImageLoader);
30+
}
31+
32+
}

src/ThirdParty.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#ifdef FCT_USE_VULKAN
3939
#define GLFW_INCLUDE_VULKAN
4040
#endif
41-
#include <glfw/glfw3.h>
41+
#include <GLFW/glfw3.h>
4242
#endif
4343

4444
//#include <boost/lockfree/queue.hpp>

0 commit comments

Comments
 (0)