Revert "Revert "Slang: Feedback support. Doesn't completely work yet.""

This reverts commit 814323513d.
This commit is contained in:
Brandon Wright 2019-01-27 16:28:18 -06:00
parent 814323513d
commit 58e1bfadfa
3 changed files with 30 additions and 13 deletions

View File

@ -598,6 +598,13 @@ void GLSLShader::render(GLuint &orig,
pass[0].width = width;
pass[0].height = height;
for (int i = 1; i < (int)pass.size(); i++)
{
GLuint tmp = pass[i].texture;
pass[i].texture = pass[i].feedback_texture;
pass[i].feedback_texture = tmp;
}
// loop through all real passes
for (unsigned int i = 1; i < pass.size(); i++)
{
@ -705,18 +712,10 @@ void GLSLShader::render(GLuint &orig,
glBindTexture(GL_TEXTURE_2D, pass[i - 1].texture);
glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) pass[i - 1].width);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER,
filter);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
filter);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_WRAP_S,
pass[i].wrap_mode);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_WRAP_T,
pass[i].wrap_mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, pass[i].wrap_mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, pass[i].wrap_mode);
glUseProgram(pass[i].program);
#ifdef USE_SLANG

View File

@ -81,7 +81,8 @@ enum
SL_LUTSIZE = 6,
SL_MVP = 7,
SL_FRAMECOUNT = 8,
SL_PARAM = 9
SL_PARAM = 9,
SL_FEEDBACK = 10
};
typedef struct
@ -124,6 +125,7 @@ typedef struct
std::vector<SlangUniform> uniforms;
std::vector<uint8_t> ubo_buffer;
GLuint ubo;
GLuint feedback_texture;
#endif
} GLSLPass;
@ -189,6 +191,8 @@ typedef struct
void slang_introspect();
void slang_set_shader_vars(int p);
void slang_clear_shader_vars();
bool using_feedback = false;
#endif
} GLSLShader;

View File

@ -377,6 +377,7 @@ void GLSLShader::slang_introspect()
for (int i = 1; i < (int)pass.size(); i++)
{
GLSLPass &p = pass[i];
p.feedback_texture = 0;
int num_uniforms;
glGetProgramiv(p.program, GL_ACTIVE_UNIFORMS, &num_uniforms);
@ -491,6 +492,13 @@ void GLSLShader::slang_introspect()
{
u.num++;
}
else if (indexedtexorsize("PassFeedback", SL_FEEDBACK))
{
using_feedback = true;
u.num++;
if (u.type == SL_FEEDBACK + 1)
u.type = SL_PASSSIZE;
}
else if (indexedtexorsize("User", SL_LUTTEXTURE))
{
}
@ -642,6 +650,7 @@ void GLSLShader::slang_set_shader_vars(int p)
case SL_PREVIOUSFRAMETEXTURE:
case SL_PASSTEXTURE:
case SL_LUTTEXTURE:
case SL_FEEDBACK:
glActiveTexture(GL_TEXTURE0 + texunit);
if (u.type == SL_PASSTEXTURE)
@ -650,6 +659,8 @@ void GLSLShader::slang_set_shader_vars(int p)
glBindTexture(GL_TEXTURE_2D, prev_frame[u.num - 1].texture);
else if (u.type == SL_LUTTEXTURE)
glBindTexture(GL_TEXTURE_2D, lut[u.num].texture);
else if (u.type == SL_FEEDBACK)
glBindTexture(GL_TEXTURE_2D, pass[u.num].feedback_texture);
if (u.location == -1)
*((GLint *)(ubo + u.offset)) = texunit;
@ -727,6 +738,9 @@ void GLSLShader::slang_set_shader_vars(int p)
break;
}
}
if (using_feedback)
for (int i = 1; i < (int)pass.size(); i++)
glGenTextures(1, &pass[i].feedback_texture);
if (pass[p].ubo_buffer.size() > 0)
{