Vulkan works again with newest SDK 1.2.154.1 on Windows

This commit is contained in:
Robert Beckebans 2020-11-12 10:16:56 +01:00
parent 6eb7925c77
commit 1115feefa7
3 changed files with 56 additions and 165 deletions

View file

@ -325,6 +325,45 @@ macro(SET_OPTION option value)
endmacro()
if(USE_VULKAN)
# RB: moved this above the general Vulkan part so glslang does not include Vulkan SDK headers
# which causes all kinds of weird segmentation faults because struct sizes don't match
if(SPIRV_SHADERC)
add_definitions(-DSPIRV_SHADERC)
if(CMAKE_CL_64)
link_directories($ENV{VULKAN_SDK}/Lib)
else()
link_directories($ENV{VULKAN_SDK}/Lib32)
endif()
else()
# override Glslang build options
# options required by November 2018 release
SET_OPTION(ENABLE_SPVREMAPPER ON)
SET_OPTION(ENABLE_GLSLANG_BINARIES OFF)
SET_OPTION(ENABLE_HLSL OFF)
SET_OPTION(ENABLE_OPT ON)
SET_OPTION(SPIRV_SKIP_EXECUTABLES ON)
# options required by July 2020 release
SET_OPTION(ENABLE_PCH OFF)
SET_OPTION(ENABLE_CTEST OFF)
SET_OPTION(BUILD_EXTERNAL OFF)
SET_OPTION(SKIP_GLSLANG_INSTALL ON)
#add_definitions(-DGLSLANG_MINOR_VERSION=13)
set(GLSLANG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/glslang)
add_subdirectory(${GLSLANG_DIR})
include_directories(${GLSLANG_DIR}/glslang)
#link_directories($ENV{VULKAN_SDK}/Lib)
endif()
# Use FindVulkan module added with CMAKE 3.7
if(NOT CMAKE_VERSION VERSION_LESS 3.7.0)
message( STATUS "Using module to find Vulkan" )
@ -353,36 +392,7 @@ if(USE_VULKAN)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
endif()
if(SPIRV_SHADERC)
add_definitions(-DSPIRV_SHADERC)
if(CMAKE_CL_64)
link_directories($ENV{VULKAN_SDK}/Lib)
else()
link_directories($ENV{VULKAN_SDK}/Lib32)
endif()
else()
# override Glslang build options
# options required by November 2018 release
SET_OPTION(ENABLE_SPVREMAPPER OFF)
SET_OPTION(ENABLE_GLSLANG_BINARIES OFF)
SET_OPTION(ENABLE_HLSL OFF)
SET_OPTION(ENABLE_OPT ON)
SET_OPTION(SPIRV_SKIP_EXECUTABLES ON)
# options required by November 2019 release
#SET_OPTION(ENABLE_PCH OFF)
#SET_OPTION(ENABLE_CTEST OFF)
#SET_OPTION(BUILD_EXTERNAL OFF)
#SET_OPTION(SKIP_GLSLANG_INSTALL ON)
set(GLSLANG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/glslang)
add_subdirectory(${GLSLANG_DIR})
include_directories(${GLSLANG_DIR}/glslang)
endif()
else()

2
neo/extern/glslang vendored

@ -1 +1 @@
Subproject commit 1bc601c674aecc2fee0dee8ff7a118db76b4c439
Subproject commit bcf6a2430e99e8fc24f9f266e99316905e6d5134

View file

@ -398,135 +398,12 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
//#include <glslang/Public/ShaderLang.h>
//#include <glslang/Include/ResourceLimits.h>
//#include <SPIRV/GlslangToSpv.h>
//#include <glslang/StandAlone/DirStackFileIncluder.h>
#include "../../extern/glslang/glslang/Public/ShaderLang.h"
#include "../../extern/glslang/glslang/Include/ResourceLimits.h"
#include "../../extern/glslang/SPIRV/GlslangToSpv.h"
//#include <glslang/StandAlone/DirStackFileIncluder.h>
namespace glslang
{
// These are the default resources for TBuiltInResources, used for both
// - parsing this string for the case where the user didn't supply one,
// - dumping out a template for user construction of a config file.
#if 0
// RB: if you want to use this then you need to compile GLSLANG with ENABLE_GLSLANG_BINARIES ON
extern const TBuiltInResource DefaultTBuiltInResource;
//#else
// RB: see RBDOOM-3-BFG\neo\extern\glslang\StandAlone\ResourceLimits.cpp
const TBuiltInResource DefaultTBuiltInResource =
{
/* .MaxLights = */ 32,
/* .MaxClipPlanes = */ 6,
/* .MaxTextureUnits = */ 32,
/* .MaxTextureCoords = */ 32,
/* .MaxVertexAttribs = */ 64,
/* .MaxVertexUniformComponents = */ 4096,
/* .MaxVaryingFloats = */ 64,
/* .MaxVertexTextureImageUnits = */ 32,
/* .MaxCombinedTextureImageUnits = */ 80,
/* .MaxTextureImageUnits = */ 32,
/* .MaxFragmentUniformComponents = */ 4096,
/* .MaxDrawBuffers = */ 32,
/* .MaxVertexUniformVectors = */ 128,
/* .MaxVaryingVectors = */ 8,
/* .MaxFragmentUniformVectors = */ 16,
/* .MaxVertexOutputVectors = */ 16,
/* .MaxFragmentInputVectors = */ 15,
/* .MinProgramTexelOffset = */ -8,
/* .MaxProgramTexelOffset = */ 7,
/* .MaxClipDistances = */ 8,
/* .MaxComputeWorkGroupCountX = */ 65535,
/* .MaxComputeWorkGroupCountY = */ 65535,
/* .MaxComputeWorkGroupCountZ = */ 65535,
/* .MaxComputeWorkGroupSizeX = */ 1024,
/* .MaxComputeWorkGroupSizeY = */ 1024,
/* .MaxComputeWorkGroupSizeZ = */ 64,
/* .MaxComputeUniformComponents = */ 1024,
/* .MaxComputeTextureImageUnits = */ 16,
/* .MaxComputeImageUniforms = */ 8,
/* .MaxComputeAtomicCounters = */ 8,
/* .MaxComputeAtomicCounterBuffers = */ 1,
/* .MaxVaryingComponents = */ 60,
/* .MaxVertexOutputComponents = */ 64,
/* .MaxGeometryInputComponents = */ 64,
/* .MaxGeometryOutputComponents = */ 128,
/* .MaxFragmentInputComponents = */ 128,
/* .MaxImageUnits = */ 8,
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8,
/* .MaxCombinedShaderOutputResources = */ 8,
/* .MaxImageSamples = */ 0,
/* .MaxVertexImageUniforms = */ 0,
/* .MaxTessControlImageUniforms = */ 0,
/* .MaxTessEvaluationImageUniforms = */ 0,
/* .MaxGeometryImageUniforms = */ 0,
/* .MaxFragmentImageUniforms = */ 8,
/* .MaxCombinedImageUniforms = */ 8,
/* .MaxGeometryTextureImageUnits = */ 16,
/* .MaxGeometryOutputVertices = */ 256,
/* .MaxGeometryTotalOutputComponents = */ 1024,
/* .MaxGeometryUniformComponents = */ 1024,
/* .MaxGeometryVaryingComponents = */ 64,
/* .MaxTessControlInputComponents = */ 128,
/* .MaxTessControlOutputComponents = */ 128,
/* .MaxTessControlTextureImageUnits = */ 16,
/* .MaxTessControlUniformComponents = */ 1024,
/* .MaxTessControlTotalOutputComponents = */ 4096,
/* .MaxTessEvaluationInputComponents = */ 128,
/* .MaxTessEvaluationOutputComponents = */ 128,
/* .MaxTessEvaluationTextureImageUnits = */ 16,
/* .MaxTessEvaluationUniformComponents = */ 1024,
/* .MaxTessPatchComponents = */ 120,
/* .MaxPatchVertices = */ 32,
/* .MaxTessGenLevel = */ 64,
/* .MaxViewports = */ 16,
/* .MaxVertexAtomicCounters = */ 0,
/* .MaxTessControlAtomicCounters = */ 0,
/* .MaxTessEvaluationAtomicCounters = */ 0,
/* .MaxGeometryAtomicCounters = */ 0,
/* .MaxFragmentAtomicCounters = */ 8,
/* .MaxCombinedAtomicCounters = */ 8,
/* .MaxAtomicCounterBindings = */ 1,
/* .MaxVertexAtomicCounterBuffers = */ 0,
/* .MaxTessControlAtomicCounterBuffers = */ 0,
/* .MaxTessEvaluationAtomicCounterBuffers = */ 0,
/* .MaxGeometryAtomicCounterBuffers = */ 0,
/* .MaxFragmentAtomicCounterBuffers = */ 1,
/* .MaxCombinedAtomicCounterBuffers = */ 1,
/* .MaxAtomicCounterBufferSize = */ 16384,
/* .MaxTransformFeedbackBuffers = */ 4,
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4,
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
/* .limits = */ {
/* .nonInductiveForLoops = */ false,
/* .whileLoops = */ false,
/* .doWhileLoops = */ false,
/* .generalUniformIndexing = */ false,
/* .generalAttributeMatrixVectorIndexing = */ false,
/* .generalVaryingIndexing = */ false,
/* .generalSamplerIndexing = */ false,
/* .generalVariableIndexing = */ false,
/* .generalConstantMatrixVectorIndexing = */ false,
}
};
#endif
}
static bool glslangInitialized = false;
static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, const rpStage_t stage, uint32** spirvBuffer )
@ -564,6 +441,7 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
shader.setEnvClient( glslang::EShClientVulkan, vulkanClientVersion );
shader.setEnvTarget( glslang::EShTargetSpv, targetVersion );
// RB: see RBDOOM-3-BFG\neo\extern\glslang\StandAlone\ResourceLimits.cpp
static TBuiltInResource resources;
resources.maxLights = 32;
resources.maxClipPlanes = 6;
@ -658,17 +536,16 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
resources.maxTaskWorkGroupSizeZ_NV = 1;
resources.maxMeshViewCountNV = 4;
resources.limits.nonInductiveForLoops = false;
resources.limits.whileLoops = false;
resources.limits.doWhileLoops = false;
resources.limits.generalUniformIndexing = false;
resources.limits.generalAttributeMatrixVectorIndexing = false;
resources.limits.generalVaryingIndexing = false;
resources.limits.generalSamplerIndexing = false;
resources.limits.generalVariableIndexing = false;
resources.limits.generalConstantMatrixVectorIndexing = false;
resources.limits.nonInductiveForLoops = true;
resources.limits.whileLoops = true;
resources.limits.doWhileLoops = true;
resources.limits.generalUniformIndexing = true;
resources.limits.generalAttributeMatrixVectorIndexing = true;
resources.limits.generalVaryingIndexing = true;
resources.limits.generalSamplerIndexing = true;
resources.limits.generalVariableIndexing = true;
resources.limits.generalConstantMatrixVectorIndexing = true;
//resources = glslang::DefaultTBuiltInResource;
EShMessages messages = ( EShMessages )( EShMsgSpvRules | EShMsgVulkanRules );
const int defaultVersion = 100;
@ -678,6 +555,9 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
idLib::Printf( "GLSL parsing failed for: %s\n", filename );
idLib::Printf( "%s\n", shader.getInfoLog() );
idLib::Printf( "%s\n", shader.getInfoDebugLog() );
//*spirvBuffer = NULL;
//return 0;
}
glslang::TProgram program;
@ -690,7 +570,7 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
idLib::Printf( "%s\n", shader.getInfoDebugLog() );
}
// All that<EFBFBD>s left to do now is to convert the program<61>s intermediate representation into SpirV:
// All that's left to do now is to convert the program's intermediate representation into SpirV:
std::vector<unsigned int> spirV;
spv::SpvBuildLogger logger;
glslang::SpvOptions spvOptions;
@ -707,6 +587,7 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
}
#endif
/*