Source code

Revision control

Copy as Markdown

Other Tools

From 74dc5c8e9fd8a525772bb58762f78fcc7ca5674b Mon Sep 17 00:00:00 2001
From: Kelsey Gilbert <kelsey.gilbert@mozilla.com>
Date: Wed, 29 Mar 2023 16:13:39 -0700
Subject: [PATCH] Add ShCompileOptions.initGLPointSize.
Change-Id: I1d998867f3e829ed0dc8181fa76be5fe701dde70
---
include/GLSLANG/ShaderLang.h | 5 +++++
src/compiler/translator/Compiler.cpp | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
index f663f88..701f409 100644
--- a/include/GLSLANG/ShaderLang.h
+++ b/include/GLSLANG/ShaderLang.h
@@ -221,6 +221,11 @@ struct ShCompileOptions
// which incorrectly fail to link programs if gl_Position is not written.
uint64_t initGLPosition : 1;
+ // This flag initializes gl_PointSize to 0.0f at the beginning of the vertex shader's
+ // main(), and has no effect in the fragment shader. It is intended to assist in working around
+ // bugs on some drivers when this is left written and then POINTS are drawn.
+ uint64_t initGLPointSize : 1;
+
// This flag replaces
// "a && b" with "a ? b : false",
// "a || b" with "a ? true : b".
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 450d2a8..6d57bbc 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -1089,6 +1089,18 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
mGLPositionInitialized = true;
}
+ if (mShaderType == GL_VERTEX_SHADER && compileOptions.initGLPointSize)
+ {
+ InitVariableList list;
+ AddBuiltInToInitList(&mSymbolTable, mShaderVersion, root, "gl_PointSize", &list);
+
+ if (!list.empty() && !InitializeVariables(this, root, list, &mSymbolTable, mShaderVersion,
+ mExtensionBehavior, false))
+ {
+ return false;
+ }
+ }
+
// DeferGlobalInitializers needs to be run before other AST transformations that generate
// new statements from expressions. But it's fine to run DeferGlobalInitializers after the
// above SplitSequenceOperator and RemoveArrayLengthMethod since they only have an effect on
--
2.43.0