workaround for buggy macOS GLSL shader compiler
Bug: skia: Change-Id: Ib77e11d80f93f76e65eac6119dbf2bd03523aaf9 Reviewed-on: https://skia-review.googlesource.com/117626 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
c828109ebd
commit
b809efbbfa
@ -613,8 +613,7 @@ std::unique_ptr<Block> IRGenerator::applyInvocationIDWorkaround(std::unique_ptr<
|
||||
}
|
||||
|
||||
std::unique_ptr<Statement> IRGenerator::getNormalizeSkPositionCode() {
|
||||
// sk_Position = float4(sk_Position.x * rtAdjust.x + sk_Position.w * rtAdjust.y,
|
||||
// sk_Position.y * rtAdjust.z + sk_Position.w * rtAdjust.w,
|
||||
// sk_Position = float4(sk_Position.xy * rtAdjust.xz + sk_Position.ww * rtAdjust.yw,
|
||||
// 0,
|
||||
// sk_Position.w);
|
||||
ASSERT(fSkPerVertex && fRTAdjust);
|
||||
@ -627,16 +626,15 @@ std::unique_ptr<Statement> IRGenerator::getNormalizeSkPositionCode() {
|
||||
#define ADJUST (fRTAdjustInterfaceBlock ? \
|
||||
FIELD(fRTAdjustInterfaceBlock, fRTAdjustFieldIndex) : \
|
||||
REF(fRTAdjust))
|
||||
#define SWIZZLE(expr, field) std::unique_ptr<Expression>(new Swizzle(fContext, expr, { field }))
|
||||
#define OP(left, op, right) std::unique_ptr<Expression>(\
|
||||
new BinaryExpression(-1, left, op, right, *fContext.fFloat_Type))
|
||||
#define SWIZZLE(expr, ...) std::unique_ptr<Expression>(new Swizzle(fContext, expr, \
|
||||
{ __VA_ARGS__ }))
|
||||
#define OP(left, op, right) std::unique_ptr<Expression>( \
|
||||
new BinaryExpression(-1, left, op, right, \
|
||||
*fContext.fFloat2_Type))
|
||||
std::vector<std::unique_ptr<Expression>> children;
|
||||
children.push_back(OP(OP(SWIZZLE(POS, 0), Token::STAR, SWIZZLE(ADJUST, 0)),
|
||||
children.push_back(OP(OP(SWIZZLE(POS, 0, 1), Token::STAR, SWIZZLE(ADJUST, 0, 2)),
|
||||
Token::PLUS,
|
||||
OP(SWIZZLE(POS, 3), Token::STAR, SWIZZLE(ADJUST, 1))));
|
||||
children.push_back(OP(OP(SWIZZLE(POS, 1), Token::STAR, SWIZZLE(ADJUST, 2)),
|
||||
Token::PLUS,
|
||||
OP(SWIZZLE(POS, 3), Token::STAR, SWIZZLE(ADJUST, 3))));
|
||||
OP(SWIZZLE(POS, 3, 3), Token::STAR, SWIZZLE(ADJUST, 1, 3))));
|
||||
children.push_back(std::unique_ptr<Expression>(new FloatLiteral(fContext, -1, 0.0)));
|
||||
children.push_back(SWIZZLE(POS, 3));
|
||||
std::unique_ptr<Expression> result = OP(POS, Token::EQ,
|
||||
@ -646,6 +644,7 @@ std::unique_ptr<Statement> IRGenerator::getNormalizeSkPositionCode() {
|
||||
return std::unique_ptr<Statement>(new ExpressionStatement(std::move(result)));
|
||||
}
|
||||
|
||||
|
||||
void IRGenerator::convertFunction(const ASTFunction& f) {
|
||||
const Type* returnType = this->convertType(*f.fReturnType);
|
||||
if (!returnType) {
|
||||
|
@ -1136,9 +1136,8 @@ DEF_TEST(SkSLFragCoord, r) {
|
||||
"in vec4 pos;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragCoord_Workaround = (gl_Position = pos);\n"
|
||||
" gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * sk_RTAdjust.y, "
|
||||
"gl_Position.y * sk_RTAdjust.z + gl_Position.w * sk_RTAdjust.w, 0.0, "
|
||||
"gl_Position.w);\n"
|
||||
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw,"
|
||||
" 0.0, gl_Position.w);\n"
|
||||
"}\n",
|
||||
SkSL::Program::kVertex_Kind);
|
||||
|
||||
@ -1818,10 +1817,8 @@ DEF_TEST(SkSLNormalization, r) {
|
||||
"uniform vec4 sk_RTAdjust;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = vec4(1.0);\n"
|
||||
" gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * sk_RTAdjust.y, "
|
||||
"gl_Position.y * sk_RTAdjust.z + gl_Position.w * sk_RTAdjust.w, "
|
||||
"0.0, "
|
||||
"gl_Position.w);\n"
|
||||
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * "
|
||||
"sk_RTAdjust.yw, 0.0, gl_Position.w);\n"
|
||||
"}\n",
|
||||
SkSL::Program::kVertex_Kind);
|
||||
test(r,
|
||||
@ -1845,16 +1842,14 @@ DEF_TEST(SkSLNormalization, r) {
|
||||
"void main() {\n"
|
||||
" gl_Position = gl_in[0].gl_Position + vec4(-0.5, 0.0, 0.0, float(gl_InvocationID));\n"
|
||||
" {\n"
|
||||
" gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * "
|
||||
"sk_RTAdjust.y, gl_Position.y * sk_RTAdjust.z + gl_Position.w * "
|
||||
"sk_RTAdjust.w, 0.0, gl_Position.w);\n"
|
||||
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * "
|
||||
"sk_RTAdjust.yw, 0.0, gl_Position.w);\n"
|
||||
" EmitVertex();\n"
|
||||
" }\n"
|
||||
" gl_Position = gl_in[0].gl_Position + vec4(0.5, 0.0, 0.0, float(gl_InvocationID));\n"
|
||||
" {\n"
|
||||
" gl_Position = vec4(gl_Position.x * sk_RTAdjust.x + gl_Position.w * "
|
||||
"sk_RTAdjust.y, gl_Position.y * sk_RTAdjust.z + gl_Position.w * "
|
||||
"sk_RTAdjust.w, 0.0, gl_Position.w);\n"
|
||||
" gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * "
|
||||
"sk_RTAdjust.yw, 0.0, gl_Position.w);\n"
|
||||
" EmitVertex();\n"
|
||||
" }\n"
|
||||
" EndPrimitive();\n"
|
||||
|
Loading…
Reference in New Issue
Block a user