tdf#100080 set unused shader attribs with values, fixes GL on AMD
AMD drivers don't work well if a shader has a defined but not enabled shader attributes. For this reason we need to make sure that all attributes are set to some value even if the shader doesn't use that attribute. Intel drivers, on the other hand, crash if you enable an attribute and don't set it (set it to null) - so we can't use this workaround. Change-Id: Ic076cf8a5fac8ef048d0054e6e4340b47b4d5188 Reviewed-on: https://gerrit.libreoffice.org/25591 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
8915919b57
commit
fdcd13c1c2
@@ -615,6 +615,8 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
|
||||
GLfloat(nX), GLfloat(nY)
|
||||
};
|
||||
|
||||
std::vector<GLfloat> aExtrusion(3, 0);
|
||||
mpProgram->SetExtrusionVectors(aExtrusion.data());
|
||||
ApplyProgramMatrices(0.5f);
|
||||
mpProgram->DrawArrays(GL_POINTS, pPoint);
|
||||
CHECK_GL_ERROR();
|
||||
@@ -959,6 +961,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
|
||||
}
|
||||
|
||||
ApplyProgramMatrices();
|
||||
std::vector<GLfloat> aExtrusion(nPoints * 3, 0);
|
||||
mpProgram->SetExtrusionVectors(aExtrusion.data());
|
||||
mpProgram->DrawArrays(GL_TRIANGLE_FAN, aVertices);
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
@@ -1002,6 +1006,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, b
|
||||
}
|
||||
|
||||
ApplyProgramMatrices();
|
||||
std::vector<GLfloat> aExtrusion(nPoints * 3, 0);
|
||||
mpProgram->SetExtrusionVectors(aExtrusion.data());
|
||||
mpProgram->DrawArrays(GL_TRIANGLE_FAN, aVertices);
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
@@ -1052,6 +1058,8 @@ void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoi
|
||||
}
|
||||
|
||||
ApplyProgramMatrices();
|
||||
std::vector<GLfloat> aExtrusion(nPoints * 3, 0);
|
||||
mpProgram->SetExtrusionVectors(aExtrusion.data());
|
||||
mpProgram->DrawArrays(GL_TRIANGLE_FAN, aVertices);
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
@@ -1163,25 +1171,23 @@ void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion )
|
||||
ADD_VERTICE( rRect.BottomRight() );
|
||||
}
|
||||
#undef ADD_VERTICE
|
||||
|
||||
std::vector<GLfloat> aExtrusion(aRects.size() * 6 * 3, 0);
|
||||
mpProgram->SetExtrusionVectors(aExtrusion.data());
|
||||
ApplyProgramMatrices();
|
||||
mpProgram->DrawArrays(GL_TRIANGLES, aVertices);
|
||||
CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted )
|
||||
void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& /*rTexture*/, const SalTwoRect& rPosAry, bool /*bInverted*/ )
|
||||
{
|
||||
OpenGLZone aZone;
|
||||
|
||||
SAL_INFO("vcl.opengl", "draw texture rect");
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord( aTexCoord, rPosAry, bInverted );
|
||||
mpProgram->SetTextureCoord( aTexCoord );
|
||||
DrawRect( rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight );
|
||||
}
|
||||
|
||||
void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& pPosAry, bool bInverted )
|
||||
void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted )
|
||||
{
|
||||
OpenGLZone aZone;
|
||||
|
||||
@@ -1192,7 +1198,14 @@ void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRe
|
||||
mpProgram->SetShaderType(TextureShaderType::Normal);
|
||||
mpProgram->SetIdentityTransform("transform");
|
||||
mpProgram->SetTexture("texture", rTexture);
|
||||
DrawTextureRect( rTexture, pPosAry, bInverted );
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord(aTexCoord, rPosAry, bInverted);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
mpProgram->SetMaskCoord(aTexCoord);
|
||||
mpProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
DrawTextureRect( rTexture, rPosAry, bInverted );
|
||||
mpProgram->Clean();
|
||||
}
|
||||
|
||||
@@ -1405,6 +1418,13 @@ void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const Sal
|
||||
mpProgram->SetTexture("texture", rTexture);
|
||||
mpProgram->SetBlendMode( bPremultiplied ? GL_ONE : GL_SRC_ALPHA,
|
||||
GL_ONE_MINUS_SRC_ALPHA );
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord(aTexCoord, rPosAry, bInverted);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
mpProgram->SetMaskCoord(aTexCoord);
|
||||
mpProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
DrawTextureRect( rTexture, rPosAry, bInverted );
|
||||
mpProgram->Clean();
|
||||
}
|
||||
@@ -1421,6 +1441,11 @@ void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLText
|
||||
mpProgram->SetTexture( "mask", rMask );
|
||||
mpProgram->SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord(aTexCoord, rPosAry, bInverted);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
mpProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
GLfloat aMaskCoord[8];
|
||||
rMask.GetCoord(aMaskCoord, rPosAry, bInverted);
|
||||
mpProgram->SetMaskCoord(aMaskCoord);
|
||||
@@ -1444,6 +1469,7 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGL
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord(aTexCoord, rPosAry);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
mpProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
GLfloat aMaskCoord[8];
|
||||
rMask.GetCoord(aMaskCoord, rPosAry);
|
||||
@@ -1464,6 +1490,10 @@ void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLT
|
||||
mpProgram->SetTexture( "mask", rMask );
|
||||
mpProgram->SetTexture( "alpha", rAlpha );
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord(aTexCoord, rPosAry);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
|
||||
GLfloat aAlphaCoord[8];
|
||||
rAlpha.GetCoord(aAlphaCoord, rPosAry);
|
||||
mpProgram->SetAlphaCoord(aAlphaCoord);
|
||||
@@ -1477,7 +1507,7 @@ void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLT
|
||||
mpProgram->Clean();
|
||||
}
|
||||
|
||||
void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& pPosAry )
|
||||
void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& rPosAry )
|
||||
{
|
||||
OpenGLZone aZone;
|
||||
|
||||
@@ -1487,8 +1517,15 @@ void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor,
|
||||
mpProgram->SetIdentityTransform("transform");
|
||||
mpProgram->SetColor( "color", nMaskColor, 0 );
|
||||
mpProgram->SetTexture("texture", rMask);
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rMask.GetCoord(aTexCoord, rPosAry);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
mpProgram->SetMaskCoord(aTexCoord);
|
||||
mpProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
mpProgram->SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
DrawTextureRect( rMask, pPosAry );
|
||||
DrawTextureRect(rMask, rPosAry);
|
||||
mpProgram->Clean();
|
||||
}
|
||||
|
||||
@@ -1560,6 +1597,8 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing()
|
||||
TextureDrawParameters& rParameters = rColorTwoRectPair.second;
|
||||
ApplyProgramMatrices();
|
||||
mpProgram->SetTextureCoord(rParameters.maTextureCoords.data());
|
||||
mpProgram->SetMaskCoord(rParameters.maTextureCoords.data());
|
||||
mpProgram->SetAlphaCoord(rParameters.maTextureCoords.data());
|
||||
mpProgram->DrawArrays(GL_TRIANGLES, rParameters.maVertices);
|
||||
}
|
||||
}
|
||||
@@ -2069,6 +2108,13 @@ bool OpenGLSalGraphicsImpl::blendBitmap(
|
||||
mpProgram->SetShaderType(TextureShaderType::Normal);
|
||||
mpProgram->SetIdentityTransform("transform");
|
||||
mpProgram->SetTexture("texture", rTexture);
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
rTexture.GetCoord(aTexCoord, rPosAry);
|
||||
mpProgram->SetTextureCoord(aTexCoord);
|
||||
mpProgram->SetMaskCoord(aTexCoord);
|
||||
mpProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
mpProgram->SetBlendMode(GL_ZERO, GL_SRC_COLOR);
|
||||
DrawTextureRect(rTexture, rPosAry);
|
||||
mpProgram->Clean();
|
||||
@@ -2363,7 +2409,9 @@ void OpenGLSalGraphicsImpl::doFlush()
|
||||
|
||||
GLfloat aTexCoord[8];
|
||||
maOffscreenTex.GetCoord( aTexCoord, aPosAry );
|
||||
pProgram->SetTextureCoord( aTexCoord );
|
||||
pProgram->SetTextureCoord(aTexCoord);
|
||||
pProgram->SetMaskCoord(aTexCoord);
|
||||
pProgram->SetAlphaCoord(aTexCoord);
|
||||
|
||||
GLfloat fWidth( maOffscreenTex.GetWidth() );
|
||||
GLfloat fHeight( maOffscreenTex.GetHeight() );
|
||||
|
Reference in New Issue
Block a user