Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux and GCC support #3

Open
wants to merge 46 commits into
base: master
Choose a base branch
from

Conversation

Zakhrov
Copy link

@Zakhrov Zakhrov commented Jul 24, 2019

I have cleaned up the Vulkan backend to get it to compile on Linux with GCC 9.1 and replaced the DirectXMath library with GLM. The code compiles successfully and creates the static libraries but I haven't been able to run the glTFSample project

@YvanDaSilva
Copy link

I don't have time to try it on Windows again, did you try it ?

I just had a quick look at the changes and at the code quality of this repo in general.
Has this sdk been reviewed by someone before ?
Lots of random spaces, lack of name consistency, src contains a different license file and other "basic" workflow stuff that shouldn't be commit like that.

I would suggest that a cleanup occur before this PR is applied, so the change is a bit clearer, and maybe travis is also added so we can ensure Cross platform compatibility at least at build time.
Maybe lets get some info about other gpuopen repos like:
https://github.com/GPUOpen-LibrariesAndSDKs/Anvil
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator

@luntik2012
Copy link

luntik2012 commented Jul 24, 2019

please, add build $ cmake .. -DGFX_API=VK/DX12 to build instructions in readme.md

@Zakhrov
Copy link
Author

Zakhrov commented Jul 24, 2019

please, add build $ cmake .. -DGFX_API=VK/DX12 to build instructions in readme.md,

Done in the latest commit on my fork

src/VK/CMakeLists.txt Outdated Show resolved Hide resolved
@Mixaill
Copy link
Contributor

Mixaill commented Jul 28, 2019

@Zakhrov I've updated a bit your branch with further fixes. Now Cauldron compiles on Windows and Linux, but there is a big amount of work to get it into the working state.

https://github.com/Mixaill/Cauldron/tree/linux-fixes

@Zakhrov
Copy link
Author

Zakhrov commented Jul 30, 2019

@Zakhrov I've updated a bit your branch with further fixes. Now Cauldron compiles on Windows and Linux, but there is a big amount of work to get it into the working state.

https://github.com/Mixaill/Cauldron/tree/linux-fixes

I still had problems resolving <DirectXMath.h> It seems to be working now that I passed in a relative include path. I still have to see if the glTFSample compiles

@aguaviva
Copy link
Contributor

Maintainer here, just to set some expectations, the plan is to not support linux officially (maybe for now) but I still pay attention to all your comments and suggestions, so from now on I will try to be more GCC friendly :)

@Zakhrov
Copy link
Author

Zakhrov commented Jul 30, 2019

Maintainer here, just to set some expectations, the plan is to not support linux officially (maybe for now) but I still pay attention to all your comments and suggestions, so from now on I will try to be more GCC friendly :)

OK thanks for letting us know. Will close the PR for now

@Zakhrov Zakhrov closed this Jul 30, 2019
@Hi-Angel
Copy link

For the sake of cross-references: this fixes #1

@Zakhrov Zakhrov reopened this Jul 16, 2021
@rys rys self-assigned this Jul 16, 2021
@rys rys added enhancement New feature or request platform Platform support labels Jul 16, 2021
@Zakhrov
Copy link
Author

Zakhrov commented Jul 16, 2021

I've updated the code to Cauldron V1.4.1 and fixed the build errors with GCC. There is still a lot of work to be done before its actually usable though.

TODO

  • Create Linux specific Vulkan surfaces using VkXlibSurfaceCreateInfoKHR and VkWaylandSurfaceCreateInfoKHR
  • Port sample glTF projects to Linux

Some doubts

  • Can we move the Vulkan components from DirectXMath to GLM? I'm right now using a patched fork of DirectXMath that compiles without the sal.h headers that are Windows specific. I don't think that would be feasible in the long run.
  • It looks like it uses the DirectX shader compiler for compiling shaders on both DX12 and Vulkan. Can we use the default SPV shader compiler along with GLSL vertex and fragment shaders on Vulkan?

@Mixaill
Copy link
Contributor

Mixaill commented Jul 16, 2021

Can we move the Vulkan components from DirectXMath to GLM? I'm right now using a patched fork of DirectXMath that compiles without the sal.h headers that are Windows specific. I don't think that would be feasible in the long run.

  • You should just use the vanilla DirectXMath and MIT-licensed SAL from https://github.com/dotnet/corert/blob/master/src/Native/inc/unix/sal.h
  • At the first look there are only few usages of DirectXMath (Vec3/Vec4 and several constants), the other math was converted to the Sony vectormath library. I think it should be easy to eliminate DirectXMath usage for non-D3D code at least.
  • GLM is not needed at all.

It looks like it uses the DirectX shader compiler for compiling shaders on both DX12 and Vulkan. Can we use the default SPV shader compiler along with GLSL vertex and fragment shaders on Vulkan?

TODO

Mouse/Keyboard handling for the ImGui should be implemented too. Looks like it is worth to outsource Mouse/Keyboard and Window handling to something like SDL2.

Copy link

@Micket Micket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: I'm not affiliated with AMD in any way, I just wanted to give some feedback to hope that this could move forward.
I have some specific comments, but, overall, I believe a PR like this is completely unmergeable. It's not even review-able. I'm going to echo @YvanDaSilva here, but it's just waaaaay to big, with waaaay to many changes unrelated to the specific purpose.

  1. Whitespace changes: Either leave as is or fix in it's own PR.
  2. nullptr modernization: Either leave as is or fix in it's own PR.
  3. UINT8 -> uint8_t etc.: Either leave (just introduce define flags for them on linux if necessary) or replace in it's own PR.
  4. Fix case errors with filenames (without linux changes) as much as possible in separate PR
    and so on (probably splitting up the remaining
    then the rest of the interesting fixes can be added gradually, preferably in a few distinct PRs working ones way up to a fully working build.

I would create a new branch, cherry pick the changes from here and open up PRs comparable to the steps above (or according to whatever format AMD prefers) to break this down
Then, possibly rebase what is left of this PR on that.

Again: I don't speak for anyone else but myself here.

Comment on lines +76 to +77
strcpy(includeName, pRootDir);
strncat(includeName, pName, pch - pName);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe functions here is a bad idea.

#include <algorithm>
#include <mutex>
#else
// ... handle this for other compilers
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this duplicated code is standard and must be the same across each platform, no need to group them all under each ifdefs.

@@ -359,7 +359,7 @@ namespace CAULDRON_VK
for (int i = 1; i < m_mipCount; i++)
{
char buf[32];
sprintf_s<32>(buf, "weight %i", i);
sprintf(buf, "weight %i", i);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe

#include "Base/UploadHeap.h"
#include "Base/Helper.h"
#include "Base/Texture.h"
#include "base/DynamicBufferRing.h"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the many many many changes like this. Wouldn't it be better to rename the directory?

Comment on lines +138 to +142
VkXlibSurfaceCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
createInfo.pNext = NULL;
createInfo.dpy = NULL;
res = vkCreateXlibSurfaceKHR(m_instance, &createInfo, NULL, &m_surface);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

if(MSVC)
add_compile_options(/MP)
else()
add_compile_options(-M)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent

Comment on lines +18 to +32
set(shader_compiler_src
"base/ShaderCompiler.cpp"
"base/ShaderCompiler.h"
"base/ShaderCompilerCache.cpp"
"base/ShaderCompilerCache.h"
"base/DXCHelper.cpp"
"base/DXCHelper.h"
)
else()
set(shader_compiler_src
"base/ShaderCompiler.cpp"
"base/ShaderCompiler.h"
"base/ShaderCompilerCache.cpp"
"base/ShaderCompilerCache.h"
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nicer to just have the platform specific parts separated out sharing the common sources

if(MSVC)
   list(APPEND shader_compiler_src 
        "base/DXCHelper.cpp"
        "base/DXCHelper.h"
    )
endif()

@@ -146,6 +146,5 @@ math::Vector4 GetElementVector(json::object_t &root, const char *path, math::Vec
return GetVector(root[path].get<json::array_t>());
}
else
return default;
return default_value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be right, the function arguments haven't changed, only the return statements have gotten the replacement default -> default_value


if (keyDown['W'])
#ifdef _WIN32
if (keyDown['W'])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation mismatch

@@ -121,8 +134,6 @@ void Trace(const char* pFormat, ...)
//
bool ReadFile(const char *name, char **data, size_t *size, bool isbinary)
{
FILE *file;

//Open file
if (fopen_s(&file, name, isbinary ? "rb" : "r") != 0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unintentional? file will be undefined below here, this can't be right.

set(CMAKE_GENERATOR_PLATFORM x64)
add_compile_options(/MP)
else()
add_compile_options(-M)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this hide all compile error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform Platform support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants