Fix some miscompilations with unused variables.

This commit is contained in:
Themaister 2013-08-10 23:35:03 +02:00
parent 1a071c4992
commit ad12cc8ab6

View File

@ -326,15 +326,17 @@ def replace_varyings(source):
translated = translate_varying(orig) translated = translate_varying(orig)
if translated != orig and translated not in attribs: if translated != orig and translated not in attribs:
cg_attrib = line.split(':')[2].split(' ')[1] cg_attrib = line.split(':')[2].split(' ')[1]
translations.append((cg_attrib, translated)) if len(cg_attrib.strip()) > 0:
attribs.append(translated) translations.append((cg_attrib, translated))
attribs.append(translated)
elif ('//var' in line) or ('#var' in line): elif ('//var' in line) or ('#var' in line):
orig = line.split(' ')[2] orig = line.split(' ')[2]
translated = translate_texture_size(orig) translated = translate_texture_size(orig)
if translated != orig and translated not in uniforms: if translated != orig and translated not in uniforms:
cg_uniform = line.split(':')[2].split(' ')[1] cg_uniform = line.split(':')[2].split(' ')[1]
translations.append((cg_uniform, translated)) if len(cg_uniform.strip()) > 0:
uniforms.append(translated) translations.append((cg_uniform, translated))
uniforms.append(translated)
for index, line in enumerate(source): for index, line in enumerate(source):
if 'void main()' in line: if 'void main()' in line:
@ -494,9 +496,9 @@ def hack_source_fragment(source):
translated = translate_texture_size(orig) translated = translate_texture_size(orig)
if translated != orig and translated not in uniforms: if translated != orig and translated not in uniforms:
cg_uniform = line.split(':')[2].split(' ')[1] cg_uniform = line.split(':')[2].split(' ')[1]
translations.append((cg_uniform, translated)) if len(cg_uniform.strip()) > 0:
uniforms.append(translated) translations.append((cg_uniform, translated))
uniforms.append(translated)
for sampler in added_samplers: for sampler in added_samplers:
source.insert(ref_index, sampler) source.insert(ref_index, sampler)
@ -508,6 +510,7 @@ def hack_source_fragment(source):
ret = [] ret = []
for line in source: for line in source:
for translation in translations: for translation in translations:
log('Translation:', translation[0], '->', translation[1])
line = line.replace(translation[0], translation[1]) line = line.replace(translation[0], translation[1])
ret.append(line) ret.append(line)