Archived
1
Fork 0

Fix shader compilation on windows

This commit is contained in:
redstrate 2020-08-12 22:34:09 -04:00
parent 211995a604
commit 7a905fcea6
4 changed files with 37 additions and 33 deletions

View file

@ -1,7 +1,7 @@
macro(compile_shader src) macro(compile_shader src)
string(REGEX REPLACE "\\.[^.]*$" "" MYFILE_WITHOUT_EXT ${src}) string(REGEX REPLACE "\\.[^.]*$" "" MYFILE_WITHOUT_EXT ${src})
set(SHADER_COMPILER_COMMAND "${CMAKE_BINARY_DIR}/bin/Debug/ShaderCompiler") set(SHADER_COMPILER_COMMAND $<TARGET_FILE:ShaderCompiler>)
if(ENABLE_IOS) if(ENABLE_IOS)
set(SHADER_COMPILER_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/../build/bin/Debug/ShaderCompiler") set(SHADER_COMPILER_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/../build/bin/Debug/ShaderCompiler")
endif() endif()

View file

@ -1,6 +1,8 @@
macro(set_engine_properties target) macro(set_engine_properties target)
target_compile_features(${target} PUBLIC cxx_std_17) target_compile_features(${target} PUBLIC cxx_std_17)
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF) set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
if(NOT ENABLE_WINDOWS)
target_compile_options(${target} PUBLIC target_compile_options(${target} PUBLIC
-Wall -Wall
-Wextra -Wextra
@ -12,6 +14,7 @@ macro(set_engine_properties target)
-Wno-system-headers -Wno-system-headers
-Wconversion -Wconversion
-Wno-sign-conversion) -Wno-sign-conversion)
endif()
if(ENABLE_MACOS) if(ENABLE_MACOS)
target_compile_definitions(${target} PUBLIC PLATFORM_MACOS) target_compile_definitions(${target} PUBLIC PLATFORM_MACOS)

View file

@ -1,23 +1,15 @@
include(../../cmake/AddPlatformExecutable.cmake) include(../../cmake/AddPlatformExecutable.cmake)
add_library(WindowsSupport
windows.cpp)
target_link_libraries(WindowsSupport PRIVATE Platform)
add_platform( add_platform(
MAIN_FILE MAIN_FILE
main.cpp.in main.cpp.in
SRC
${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows.cpp
EXECUTABLE_PROPERTIES EXECUTABLE_PROPERTIES
LINK_LIBRARIES LINK_LIBRARIES
Core Core
GFXVulkan GFXVulkan
FileWindows
LangWindows
WindowsSupport
GFXDummy
GFXOpenGL
Platform
COMPILE_OPTIONS
) )
add_custom_target(PlatformWindows_IDE SOURCES add_custom_target(PlatformWindows_IDE SOURCES

View file

@ -1,10 +1,18 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#ifdef PLATFORM_WINDOWS
#include <spirv_cpp.hpp>
#include <spirv_msl.hpp>
#include <glslang/Public/ShaderLang.h>
#include <SPIRV/GlslangToSpv.h>
#else
#include <spirv_cross/spirv_cpp.hpp> #include <spirv_cross/spirv_cpp.hpp>
#include <spirv_cross/spirv_msl.hpp> #include <spirv_cross/spirv_msl.hpp>
#include <glslang/Public/ShaderLang.h> #include <glslang/Public/ShaderLang.h>
#include <SPIRV/GlslangToSpv.h> #include <SPIRV/GlslangToSpv.h>
#endif
#include "DirStackIncluder.h" #include "DirStackIncluder.h"
#include "log.hpp" #include "log.hpp"
@ -102,17 +110,18 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .maxTaskWorkGroupSizeY_NV = */ 1, /* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1, /* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4, /* .maxMeshViewCountNV = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 4,
/* .limits = */ { /* .limits = */ TLimits{
/* .nonInductiveForLoops = */ 1, /* .nonInductiveForLoops = */ true,
/* .whileLoops = */ 1, /* .whileLoops = */ true,
/* .doWhileLoops = */ 1, /* .doWhileLoops = */ true,
/* .generalUniformIndexing = */ 1, /* .generalUniformIndexing = */ true,
/* .generalAttributeMatrixVectorIndexing = */ 1, /* .generalAttributeMatrixVectorIndexing = */ true,
/* .generalVaryingIndexing = */ 1, /* .generalVaryingIndexing = */ true,
/* .generalSamplerIndexing = */ 1, /* .generalSamplerIndexing = */ true,
/* .generalVariableIndexing = */ 1, /* .generalVariableIndexing = */ true,
/* .generalConstantMatrixVectorIndexing = */ 1, /* .generalConstantMatrixVectorIndexing = */ true,
}}; }};
const std::vector<unsigned int> CompileGLSL(const std::string& filename, EShLanguage ShaderType) { const std::vector<unsigned int> CompileGLSL(const std::string& filename, EShLanguage ShaderType) {