Fix off-by-one error with PASSPREV.

Fix include bug in cg2glsl.py.
This commit is contained in:
Themaister 2014-05-16 16:17:02 +02:00
parent cf3c3efcb8
commit 59c64f9c5a
3 changed files with 17 additions and 16 deletions

View File

@ -746,7 +746,7 @@ static void set_program_attributes(unsigned i)
char pass_str[64];
snprintf(pass_str, sizeof(pass_str), "PASS%u", j + 1);
set_pass_attrib(&prg[i], &prg[i].fbo[j], pass_str);
snprintf(pass_str, sizeof(pass_str), "PASSPREV%u", i - j);
snprintf(pass_str, sizeof(pass_str), "PASSPREV%u", i - (j + 1));
set_pass_attrib(&prg[i], &prg[i].fbo[j], pass_str);
}
}

View File

@ -559,25 +559,25 @@ static void find_uniforms(unsigned pass, GLuint prog, struct shader_uniforms *un
find_uniforms_frame(prog, &uni->orig, frame_base);
}
for (i = 0; i < GFX_MAX_SHADERS; i++)
if (pass)
{
snprintf(frame_base, sizeof(frame_base), "Pass%u", i + 1);
clear_uniforms_frame(&uni->pass[i]);
find_uniforms_frame(prog, &uni->pass[i], frame_base);
if (i && pass > i + 1)
for (i = 0; i < pass - 1; i++)
{
snprintf(frame_base, sizeof(frame_base), "PassPrev%u", pass - i);
snprintf(frame_base, sizeof(frame_base), "Pass%u", i + 1);
clear_uniforms_frame(&uni->pass[i]);
find_uniforms_frame(prog, &uni->pass[i], frame_base);
snprintf(frame_base, sizeof(frame_base), "PassPrev%u", pass - (i + 1));
find_uniforms_frame(prog, &uni->pass[i], frame_base);
}
}
clear_uniforms_frame(&uni->prev[0]);
find_uniforms_frame(prog, &uni->prev[0], "Prev");
for (i = 1; i < PREV_TEXTURES; i++)
{
snprintf(frame_base, sizeof(frame_base), "Prev%u", i);
clear_uniforms_frame(&uni->prev[i]);
find_uniforms_frame(prog, &uni->prev[i], frame_base);
clear_uniforms_frame(&uni->prev[0]);
find_uniforms_frame(prog, &uni->prev[0], "Prev");
for (i = 1; i < PREV_TEXTURES; i++)
{
snprintf(frame_base, sizeof(frame_base), "Prev%u", i);
clear_uniforms_frame(&uni->prev[i]);
find_uniforms_frame(prog, &uni->prev[i], frame_base);
}
}
glUseProgram(0);

View File

@ -547,7 +547,8 @@ def preprocess_vertex(source_data):
def convert(source, dest):
# Have to preprocess first to resolve #includes so we can hack potential vertex shaders.
vert_cmd_preprocess = ['cgc', '-E', '-I', os.path.split(source)[0], source]
inc_dir = os.path.split(source)[0]
vert_cmd_preprocess = ['cgc', '-E', '-I', '.' if inc_dir == '' else inc_dir, source]
p = subprocess.Popen(vert_cmd_preprocess, stderr = subprocess.PIPE, stdout = subprocess.PIPE)
source_data, stderr_ret = p.communicate()
log(stderr_ret.decode())