mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Avoid GL undefined behavior in ubershaders
This commit is contained in:
parent
a9920ae54f
commit
65a83785fd
6 changed files with 59 additions and 6 deletions
|
@ -19,6 +19,7 @@ class LegacyGLHeaderStruct:
|
|||
self.enums = {}
|
||||
self.texunits = []
|
||||
self.texunit_names = []
|
||||
self.shadow_texunits = []
|
||||
self.ubos = []
|
||||
self.ubo_names = []
|
||||
|
||||
|
@ -106,6 +107,8 @@ def include_file_in_legacygl_header(filename, header_data, depth):
|
|||
|
||||
if not x in header_data.texunit_names:
|
||||
header_data.texunits += [(x, texunit)]
|
||||
if line.find("sampler2DShadow") != -1:
|
||||
header_data.shadow_texunits += [texunit]
|
||||
header_data.texunit_names += [x]
|
||||
|
||||
elif line.find("uniform") != -1 and line.lower().find("ubo:") != -1:
|
||||
|
@ -483,6 +486,15 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
|||
else:
|
||||
fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n")
|
||||
|
||||
if not gles2:
|
||||
if header_data.shadow_texunits:
|
||||
fd.write("\t\tstatic int _shadow_texunits[]={")
|
||||
for x in header_data.shadow_texunits:
|
||||
fd.write(str(x) + ',')
|
||||
fd.write("};\n\n")
|
||||
else:
|
||||
fd.write("\t\tstatic int *_shadow_texunits=NULL;\n")
|
||||
|
||||
if not gles2 and header_data.ubos:
|
||||
fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n")
|
||||
for x in header_data.ubos:
|
||||
|
@ -537,6 +549,8 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
|||
+ str(len(header_data.attributes))
|
||||
+ ", _texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ", _shadow_texunits,"
|
||||
+ str(len(header_data.shadow_texunits))
|
||||
+ ",_ubo_pairs,"
|
||||
+ str(len(header_data.ubos))
|
||||
+ ",_feedbacks,"
|
||||
|
@ -566,6 +580,8 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
|||
+ str(len(header_data.uniforms))
|
||||
+ ",_texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_shadow_texunits,"
|
||||
+ str(len(header_data.shadow_texunits))
|
||||
+ ",_enums,"
|
||||
+ str(len(header_data.enums))
|
||||
+ ",_enum_values,"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue