Initialize glslang struct using consteval

Doesn't seem like there's a way to bypass the need for default values in their API, and since their versions doesn't seem to be reliable enough to know whether maxDualSourceDrawBuffersEXT exists. This way it's default initialized to 0 which is fine for Cemu.
This commit is contained in:
Crementif 2022-08-28 19:23:24 +02:00
parent 454b587e36
commit 0f24b0663e
No known key found for this signature in database
GPG Key ID: 43903308F77B6C3B

View File

@ -32,116 +32,113 @@ class FileCache* s_spirvCache{nullptr};
extern std::atomic_int g_compiled_shaders_total;
extern std::atomic_int g_compiled_shaders_async;
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,
consteval TBuiltInResource GetDefaultBuiltInResource()
{
TBuiltInResource defaultResource = {};
defaultResource.maxLights = 32;
defaultResource.maxClipPlanes = 6;
defaultResource.maxTextureUnits = 32;
defaultResource.maxTextureCoords = 32;
defaultResource.maxVertexAttribs = 64;
defaultResource.maxVertexUniformComponents = 4096;
defaultResource.maxVaryingFloats = 64;
defaultResource.maxVertexTextureImageUnits = 32;
defaultResource.maxCombinedTextureImageUnits = 80;
defaultResource.maxTextureImageUnits = 32;
defaultResource.maxFragmentUniformComponents = 4096;
defaultResource.maxDrawBuffers = 32;
defaultResource.maxVertexUniformVectors = 128;
defaultResource.maxVaryingVectors = 8;
defaultResource.maxFragmentUniformVectors = 16;
defaultResource.maxVertexOutputVectors = 16;
defaultResource.maxFragmentInputVectors = 15;
defaultResource.minProgramTexelOffset = -8;
defaultResource.maxProgramTexelOffset = 7;
defaultResource.maxClipDistances = 8;
defaultResource.maxComputeWorkGroupCountX = 65535;
defaultResource.maxComputeWorkGroupCountY = 65535;
defaultResource.maxComputeWorkGroupCountZ = 65535;
defaultResource.maxComputeWorkGroupSizeX = 1024;
defaultResource.maxComputeWorkGroupSizeY = 1024;
defaultResource.maxComputeWorkGroupSizeZ = 64;
defaultResource.maxComputeUniformComponents = 1024;
defaultResource.maxComputeTextureImageUnits = 16;
defaultResource.maxComputeImageUniforms = 8;
defaultResource.maxComputeAtomicCounters = 8;
defaultResource.maxComputeAtomicCounterBuffers = 1;
defaultResource.maxVaryingComponents = 60;
defaultResource.maxVertexOutputComponents = 64;
defaultResource.maxGeometryInputComponents = 64;
defaultResource.maxGeometryOutputComponents = 128;
defaultResource.maxFragmentInputComponents = 128;
defaultResource.maxImageUnits = 8;
defaultResource.maxCombinedImageUnitsAndFragmentOutputs = 8;
defaultResource.maxCombinedShaderOutputResources = 8;
defaultResource.maxImageSamples = 0;
defaultResource.maxVertexImageUniforms = 0;
defaultResource.maxTessControlImageUniforms = 0;
defaultResource.maxTessEvaluationImageUniforms = 0;
defaultResource.maxGeometryImageUniforms = 0;
defaultResource.maxFragmentImageUniforms = 8;
defaultResource.maxCombinedImageUniforms = 8;
defaultResource.maxGeometryTextureImageUnits = 16;
defaultResource.maxGeometryOutputVertices = 256;
defaultResource.maxGeometryTotalOutputComponents = 1024;
defaultResource.maxGeometryUniformComponents = 1024;
defaultResource.maxGeometryVaryingComponents = 64;
defaultResource.maxTessControlInputComponents = 128;
defaultResource.maxTessControlOutputComponents = 128;
defaultResource.maxTessControlTextureImageUnits = 16;
defaultResource.maxTessControlUniformComponents = 1024;
defaultResource.maxTessControlTotalOutputComponents = 4096;
defaultResource.maxTessEvaluationInputComponents = 128;
defaultResource.maxTessEvaluationOutputComponents = 128;
defaultResource.maxTessEvaluationTextureImageUnits = 16;
defaultResource.maxTessEvaluationUniformComponents = 1024;
defaultResource.maxTessPatchComponents = 120;
defaultResource.maxPatchVertices = 32;
defaultResource.maxTessGenLevel = 64;
defaultResource.maxViewports = 16;
defaultResource.maxVertexAtomicCounters = 0;
defaultResource.maxTessControlAtomicCounters = 0;
defaultResource.maxTessEvaluationAtomicCounters = 0;
defaultResource.maxGeometryAtomicCounters = 0;
defaultResource.maxFragmentAtomicCounters = 8;
defaultResource.maxCombinedAtomicCounters = 8;
defaultResource.maxAtomicCounterBindings = 1;
defaultResource.maxVertexAtomicCounterBuffers = 0;
defaultResource.maxTessControlAtomicCounterBuffers = 0;
defaultResource.maxTessEvaluationAtomicCounterBuffers = 0;
defaultResource.maxGeometryAtomicCounterBuffers = 0;
defaultResource.maxFragmentAtomicCounterBuffers = 1;
defaultResource.maxCombinedAtomicCounterBuffers = 1;
defaultResource.maxAtomicCounterBufferSize = 16384;
defaultResource.maxTransformFeedbackBuffers = 4;
defaultResource.maxTransformFeedbackInterleavedComponents = 64;
defaultResource.maxCullDistances = 8;
defaultResource.maxCombinedClipAndCullDistances = 8;
defaultResource.maxSamples = 4;
defaultResource.maxMeshOutputVerticesNV = 256;
defaultResource.maxMeshOutputPrimitivesNV = 512;
defaultResource.maxMeshWorkGroupSizeX_NV = 32;
defaultResource.maxMeshWorkGroupSizeY_NV = 1;
defaultResource.maxMeshWorkGroupSizeZ_NV = 1;
defaultResource.maxTaskWorkGroupSizeX_NV = 32;
defaultResource.maxTaskWorkGroupSizeY_NV = 1;
defaultResource.maxTaskWorkGroupSizeZ_NV = 1;
defaultResource.maxMeshViewCountNV = 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,
#if GLSLANG_VERSION_LESS_OR_EQUAL_TO(11, 0, 0)
/* .maxDualSourceDrawBuffersEXT = */ 1,
#endif
/* .limits = */ {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
/* .generalUniformIndexing = */ 1,
/* .generalAttributeMatrixVectorIndexing = */ 1,
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1
}
defaultResource.limits = {};
defaultResource.limits.nonInductiveForLoops = true;
defaultResource.limits.whileLoops = true;
defaultResource.limits.doWhileLoops = true;
defaultResource.limits.generalUniformIndexing = true;
defaultResource.limits.generalAttributeMatrixVectorIndexing = true;
defaultResource.limits.generalVaryingIndexing = true;
defaultResource.limits.generalSamplerIndexing = true;
defaultResource.limits.generalVariableIndexing = true;
defaultResource.limits.generalConstantMatrixVectorIndexing = true;
return defaultResource;
};
class _ShaderVkThreadPool
@ -325,7 +322,7 @@ void RendererShaderVk::CompileInternal(bool isRenderThread)
Shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetLanguageVersion::EShTargetSpv_1_3);
TBuiltInResource Resources = DefaultTBuiltInResource;
TBuiltInResource Resources = GetDefaultBuiltInResource();
std::string PreprocessedGLSL;
VulkanRenderer* vkr = (VulkanRenderer*)g_renderer.get();