kwin: Bind fragdata locations in ShaderManager
Fragment shaders are expected to declare a vec4 fragColor output, which will be bound to the first draw buffer.
This commit is contained in:
parent
54b63a85a6
commit
54308889f0
2 changed files with 19 additions and 4 deletions
|
@ -788,6 +788,11 @@ void ShaderManager::popShader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderManager::bindFragDataLocations(GLShader *shader)
|
||||||
|
{
|
||||||
|
shader->bindFragDataLocation("fragColor", 0);
|
||||||
|
}
|
||||||
|
|
||||||
GLShader *ShaderManager::loadFragmentShader(ShaderType vertex, const QString &fragmentFile)
|
GLShader *ShaderManager::loadFragmentShader(ShaderType vertex, const QString &fragmentFile)
|
||||||
{
|
{
|
||||||
const char *vertexFile[] = {
|
const char *vertexFile[] = {
|
||||||
|
@ -796,7 +801,9 @@ GLShader *ShaderManager::loadFragmentShader(ShaderType vertex, const QString &fr
|
||||||
"scene-color-vertex.glsl"
|
"scene-color-vertex.glsl"
|
||||||
};
|
};
|
||||||
|
|
||||||
GLShader *shader = new GLShader(m_shaderDir + vertexFile[vertex], fragmentFile);
|
GLShader *shader = new GLShader(m_shaderDir + vertexFile[vertex], fragmentFile, GLShader::ExplicitLinking);
|
||||||
|
bindFragDataLocations(shader);
|
||||||
|
shader->link();
|
||||||
|
|
||||||
if (shader->isValid()) {
|
if (shader->isValid()) {
|
||||||
pushShader(shader);
|
pushShader(shader);
|
||||||
|
@ -816,7 +823,9 @@ GLShader *ShaderManager::loadVertexShader(ShaderType fragment, const QString &ve
|
||||||
"scene-color-fragment.glsl"
|
"scene-color-fragment.glsl"
|
||||||
};
|
};
|
||||||
|
|
||||||
GLShader *shader = new GLShader(vertexFile, m_shaderDir + fragmentFile[fragment]);
|
GLShader *shader = new GLShader(vertexFile, m_shaderDir + fragmentFile[fragment], GLShader::ExplicitLinking);
|
||||||
|
bindFragDataLocations(shader);
|
||||||
|
shader->link();
|
||||||
|
|
||||||
if (shader->isValid()) {
|
if (shader->isValid()) {
|
||||||
pushShader(shader);
|
pushShader(shader);
|
||||||
|
@ -829,8 +838,10 @@ GLShader *ShaderManager::loadVertexShader(ShaderType fragment, const QString &ve
|
||||||
|
|
||||||
GLShader *ShaderManager::loadShaderFromCode(const QByteArray &vertexSource, const QByteArray &fragmentSource)
|
GLShader *ShaderManager::loadShaderFromCode(const QByteArray &vertexSource, const QByteArray &fragmentSource)
|
||||||
{
|
{
|
||||||
GLShader *shader = new GLShader();
|
GLShader *shader = new GLShader(GLShader::ExplicitLinking);
|
||||||
shader->load(vertexSource, fragmentSource);
|
shader->load(vertexSource, fragmentSource);
|
||||||
|
bindFragDataLocations(shader);
|
||||||
|
shader->link();
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,7 +870,10 @@ void ShaderManager::initShaders()
|
||||||
m_valid = true;
|
m_valid = true;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
m_shader[i] = new GLShader(m_shaderDir + vertexFile[i], m_shaderDir + fragmentFile[i]);
|
m_shader[i] = new GLShader(m_shaderDir + vertexFile[i], m_shaderDir + fragmentFile[i],
|
||||||
|
GLShader::ExplicitLinking);
|
||||||
|
bindFragDataLocations(m_shader[i]);
|
||||||
|
m_shader[i]->link();
|
||||||
|
|
||||||
if (!m_shader[i]->isValid()) {
|
if (!m_shader[i]->isValid()) {
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
|
|
|
@ -390,6 +390,7 @@ private:
|
||||||
|
|
||||||
void initShaders();
|
void initShaders();
|
||||||
void resetShader(ShaderType type);
|
void resetShader(ShaderType type);
|
||||||
|
void bindFragDataLocations(GLShader *shader);
|
||||||
|
|
||||||
QStack<GLShader*> m_boundShaders;
|
QStack<GLShader*> m_boundShaders;
|
||||||
GLShader *m_shader[3];
|
GLShader *m_shader[3];
|
||||||
|
|
Loading…
Reference in a new issue