Revert "Revert "Rename gl_SampleMask to sk_SampleMask""
This reverts commit 40b815db97
.
Bug: skia:
Change-Id: I454d3e86219276996d0b4f9e7fcf177bb6dc45e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251004
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
3683a4f5ae
commit
4ac37632a8
@ -105,15 +105,15 @@ void GrGLSLFragmentShaderBuilder::maskOffMultisampleCoverage(
|
||||
if (!fHasModifiedSampleMask) {
|
||||
fHasModifiedSampleMask = true;
|
||||
if (ScopeFlags::kTopLevel != scopeFlags) {
|
||||
this->codePrependf("gl_SampleMask[0] = ~0;");
|
||||
this->codePrependf("sk_SampleMask[0] = ~0;");
|
||||
}
|
||||
if (!(ScopeFlags::kInsideLoop & scopeFlags)) {
|
||||
this->codeAppendf("gl_SampleMask[0] = (%s);", mask);
|
||||
this->codeAppendf("sk_SampleMask[0] = (%s);", mask);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this->codeAppendf("gl_SampleMask[0] &= (%s);", mask);
|
||||
this->codeAppendf("sk_SampleMask[0] &= (%s);", mask);
|
||||
}
|
||||
|
||||
void GrGLSLFragmentShaderBuilder::applyFnToMultisampleMask(
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define SK_HEIGHT_BUILTIN 10012
|
||||
#define SK_FRAGCOORD_BUILTIN 15
|
||||
#define SK_CLOCKWISE_BUILTIN 17
|
||||
#define SK_SAMPLEMASK_BUILTIN 20
|
||||
#define SK_VERTEXID_BUILTIN 42
|
||||
#define SK_INSTANCEID_BUILTIN 43
|
||||
#define SK_CLIPDISTANCE_BUILTIN 3
|
||||
|
@ -796,6 +796,10 @@ void GLSLCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
case SK_CLOCKWISE_BUILTIN:
|
||||
this->write(fProgram.fSettings.fFlipY ? "(!gl_FrontFacing)" : "gl_FrontFacing");
|
||||
break;
|
||||
case SK_SAMPLEMASK_BUILTIN:
|
||||
SkASSERT(fProgram.fSettings.fCaps->sampleVariablesSupport());
|
||||
this->write("gl_SampleMask");
|
||||
break;
|
||||
case SK_VERTEXID_BUILTIN:
|
||||
this->write("gl_VertexID");
|
||||
break;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "src/sksl/ir/SkSLIntLiteral.h"
|
||||
#include "src/sksl/ir/SkSLInterfaceBlock.h"
|
||||
#include "src/sksl/ir/SkSLLayout.h"
|
||||
#include "src/sksl/ir/SkSLNop.h"
|
||||
#include "src/sksl/ir/SkSLNullLiteral.h"
|
||||
#include "src/sksl/ir/SkSLPostfixExpression.h"
|
||||
#include "src/sksl/ir/SkSLPrefixExpression.h"
|
||||
@ -1166,6 +1167,9 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
|
||||
case SK_HEIGHT_BUILTIN:
|
||||
fInputs.fRTHeight = true;
|
||||
break;
|
||||
case SK_SAMPLEMASK_BUILTIN:
|
||||
fUsesSampleMask = true;
|
||||
break;
|
||||
#ifndef SKSL_STANDALONE
|
||||
case SK_FRAGCOORD_BUILTIN:
|
||||
fInputs.fFlipY = true;
|
||||
@ -2422,6 +2426,25 @@ void IRGenerator::setRefKind(const Expression& expr, VariableReference::RefKind
|
||||
}
|
||||
}
|
||||
|
||||
void IRGenerator::removeSampleMask(std::vector<std::unique_ptr<ProgramElement>>* out) {
|
||||
for (const auto& e : *out) {
|
||||
switch (e->fKind) {
|
||||
case ProgramElement::kVar_Kind: {
|
||||
VarDeclarations& vd = (VarDeclarations&) *e;
|
||||
for (auto iter = vd.fVars.begin(); iter != vd.fVars.end(); ++iter) {
|
||||
SkASSERT((*iter)->fKind == Statement::kVarDeclaration_Kind);
|
||||
const auto& v = (VarDeclaration&) **iter;
|
||||
if (v.fVar->fName == "sk_SampleMask") {
|
||||
vd.fVars.erase(iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IRGenerator::convertProgram(Program::Kind kind,
|
||||
const char* text,
|
||||
size_t length,
|
||||
@ -2487,6 +2510,9 @@ void IRGenerator::convertProgram(Program::Kind kind,
|
||||
ABORT("unsupported declaration: %s\n", decl.description().c_str());
|
||||
}
|
||||
}
|
||||
if (!fUsesSampleMask) {
|
||||
this->removeSampleMask(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,6 +143,7 @@ private:
|
||||
std::unique_ptr<Block> applyInvocationIDWorkaround(std::unique_ptr<Block> main);
|
||||
// returns a statement which converts sk_Position from device to normalized coordinates
|
||||
std::unique_ptr<Statement> getNormalizeSkPositionCode();
|
||||
void removeSampleMask(std::vector<std::unique_ptr<ProgramElement>>* out);
|
||||
|
||||
void checkValid(const Expression& expr);
|
||||
void setRefKind(const Expression& expr, VariableReference::RefKind kind);
|
||||
@ -168,6 +169,7 @@ private:
|
||||
Variable* fRTAdjustInterfaceBlock;
|
||||
int fRTAdjustFieldIndex;
|
||||
bool fStarted = false;
|
||||
bool fUsesSampleMask = false;
|
||||
|
||||
friend class AutoSymbolTable;
|
||||
friend class AutoLoopLevel;
|
||||
|
@ -2725,10 +2725,10 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
|
||||
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
|
||||
// in the OpenGL backend.
|
||||
SkASSERT(!(var->fModifiers.fFlags & (Modifiers::kReadOnly_Flag |
|
||||
Modifiers::kWriteOnly_Flag |
|
||||
Modifiers::kCoherent_Flag |
|
||||
Modifiers::kVolatile_Flag |
|
||||
Modifiers::kRestrict_Flag)));
|
||||
Modifiers::kWriteOnly_Flag |
|
||||
Modifiers::kCoherent_Flag |
|
||||
Modifiers::kVolatile_Flag |
|
||||
Modifiers::kRestrict_Flag)));
|
||||
if (var->fModifiers.fLayout.fBuiltin == BUILTIN_IGNORE) {
|
||||
continue;
|
||||
}
|
||||
|
@ -377,6 +377,12 @@ public:
|
||||
result->fRemovePowWithConstantExponent = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static sk_sp<GrShaderCaps> SampleMaskSupport() {
|
||||
sk_sp<GrShaderCaps> result = Default();
|
||||
result->fSampleVariablesSupport = true;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -4,6 +4,7 @@ STRINGIFY(
|
||||
|
||||
layout(builtin=15) in float4 sk_FragCoord;
|
||||
layout(builtin=3) float sk_ClipDistance[1];
|
||||
layout(builtin=20) out int sk_SampleMask[1];
|
||||
|
||||
// 9999 is a temporary value that causes us to ignore these declarations beyond
|
||||
// adding them to the symbol table. This works fine in GLSL (where they do not
|
||||
@ -12,8 +13,6 @@ layout(builtin=3) float sk_ClipDistance[1];
|
||||
layout(builtin=9999) float4 gl_LastFragData[1];
|
||||
layout(builtin=9999) half4 gl_LastFragColor;
|
||||
layout(builtin=9999) half4 gl_LastFragColorARM;
|
||||
layout(builtin=9999) int gl_SampleMaskIn[1];
|
||||
layout(builtin=9999) out int gl_SampleMask[1];
|
||||
layout(builtin=9999) half4 gl_SecondaryFragColorEXT;
|
||||
|
||||
layout(builtin=10003) half4 sk_InColor;
|
||||
|
@ -6,13 +6,12 @@ STRINGIFY(
|
||||
layout(builtin=15) in float4 sk_FragCoord;
|
||||
layout(builtin=17) in bool sk_Clockwise; // Similar to gl_FrontFacing, but defined in device space.
|
||||
layout(builtin=3) float sk_ClipDistance[1];
|
||||
layout(builtin=20) out int sk_SampleMask[1];
|
||||
|
||||
// 9999 is a temporary value that causes us to ignore these declarations beyond
|
||||
// adding them to the symbol table. This works fine in GLSL (where they do not
|
||||
// require any further handling) but will fail in SPIR-V. We'll have a better
|
||||
// solution for this soon.
|
||||
layout(builtin=9999) int gl_SampleMaskIn[1];
|
||||
layout(builtin=9999) out int gl_SampleMask[1];
|
||||
layout(builtin=9999) out half4 gl_SecondaryFragColorEXT;
|
||||
|
||||
layout(location=0,index=0,builtin=10001) out half4 sk_FragColor;
|
||||
|
@ -1316,6 +1316,16 @@ DEF_TEST(SkSLClockwise, r) {
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSampleMask, r) {
|
||||
test(r,
|
||||
"void main() { sk_SampleMask[0] |= 8; }",
|
||||
*SkSL::ShaderCapsFactory::SampleMaskSupport(),
|
||||
"#version 400\n"
|
||||
"void main() {\n"
|
||||
" gl_SampleMask[0] |= 8;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLVertexID, r) {
|
||||
test(r,
|
||||
"out int id; void main() { id = sk_VertexID; }",
|
||||
|
Loading…
Reference in New Issue
Block a user