Remove sk_SampleMask support from SkSL

Change-Id: I22837a4921238749664217e595d24d196503534d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388096
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2021-03-22 17:03:42 -04:00 committed by Skia Commit-Bot
parent f10535f6fa
commit d1f3b97a64
12 changed files with 168 additions and 260 deletions

View File

@ -394,7 +394,6 @@ sksl_shared_tests = [
"/sksl/shared/ReturnsValueOnEveryPathES2.sksl",
"/sksl/shared/ReturnsValueOnEveryPathES3.sksl",
"/sksl/shared/SampleLocations.vert",
"/sksl/shared/SampleMask.sksl",
"/sksl/shared/ScalarConversionConstructorsES2.sksl",
"/sksl/shared/ScalarConversionConstructorsES3.sksl",
"/sksl/shared/ScopedSymbol.sksl",

View File

@ -1,3 +0,0 @@
void main() {
sk_SampleMask[0] |= 8;
}

View File

@ -32,7 +32,6 @@
#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_INVOCATIONID_BUILTIN 8

View File

@ -804,10 +804,6 @@ void GLSLCodeGenerator::writeVariableReference(const VariableReference& ref) {
case SK_CLOCKWISE_BUILTIN:
this->write(fProgram.fConfig->fSettings.fFlipY ? "(!gl_FrontFacing)" : "gl_FrontFacing");
break;
case SK_SAMPLEMASK_BUILTIN:
SkASSERT(this->caps().sampleMaskSupport());
this->write("gl_SampleMask");
break;
case SK_VERTEXID_BUILTIN:
this->write("gl_VertexID");
break;

View File

@ -2868,15 +2868,10 @@ static bool is_dead(const Variable& var, const ProgramUsage* usage) {
if (counts.fRead || counts.fWrite) {
return false;
}
// not entirely sure what the rules are for when it's safe to elide interface variables, but it
// causes various problems to elide some of them even when dead. But it also causes problems
// *not* to elide sk_SampleMask when it's not being used.
if (!(var.modifiers().fFlags & (Modifiers::kIn_Flag |
Modifiers::kOut_Flag |
Modifiers::kUniform_Flag))) {
return true;
}
return var.modifiers().fLayout.fBuiltin == SK_SAMPLEMASK_BUILTIN;
// It's not entirely clear what the rules are for eliding interface variables. Generally, it
// causes problems to elide them, even when they're dead.
return !(var.modifiers().fFlags &
(Modifiers::kIn_Flag | Modifiers::kOut_Flag | Modifiers::kUniform_Flag));
}
void SPIRVCodeGenerator::writeGlobalVar(ProgramKind kind, const VarDeclaration& varDecl) {

View File

@ -1,11 +1,9 @@
static uint8_t SKSL_INCLUDE_sksl_fp[] = {60,1,
static uint8_t SKSL_INCLUDE_sksl_fp[] = {42,1,
14,71,114,67,108,105,112,69,100,103,101,84,121,112,101,
12,80,77,67,111,110,118,101,114,115,105,111,110,
0,
12,115,107,95,70,114,97,103,67,111,111,114,100,
6,102,108,111,97,116,52,
3,105,110,116,
13,115,107,95,83,97,109,112,108,101,77,97,115,107,
15,103,108,95,76,97,115,116,70,114,97,103,68,97,116,97,
16,103,108,95,76,97,115,116,70,114,97,103,67,111,108,111,114,
5,104,97,108,102,52,
@ -29,7 +27,7 @@ static uint8_t SKSL_INCLUDE_sksl_fp[] = {60,1,
5,107,76,97,115,116,
9,107,84,111,80,114,101,109,117,108,
11,107,84,111,85,110,112,114,101,109,117,108,
42,36,0,
42,34,0,
15,1,0,2,0,
15,2,0,17,0,
46,3,0,
@ -37,152 +35,145 @@ static uint8_t SKSL_INCLUDE_sksl_fp[] = {60,1,
29,0,32,0,0,255,255,255,255,255,15,0,255,255,255,255,30,0,30,0,0,2,31,0,
43,4,0,44,0,0,
0,5,0,
43,6,0,51,0,1,
40,4,0,1,
46,6,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,51,0,
40,5,0,0,
46,7,0,
30,
29,0,32,0,0,255,255,255,255,255,20,0,255,255,255,255,30,0,30,0,0,4,55,0,
40,5,0,0,
0,8,0,
40,4,0,1,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,67,0,
43,8,0,84,0,0,
46,9,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,69,0,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,90,0,
40,8,0,0,
46,10,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,85,0,
43,11,0,102,0,0,
46,12,0,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,110,0,
40,8,0,0,
46,11,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,108,0,
40,11,0,0,
29,0,32,0,0,255,255,255,255,255,27,39,255,255,255,255,30,0,30,0,0,0,135,0,
43,12,0,144,0,0,
46,13,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,30,0,30,0,0,0,128,0,
40,11,0,0,
29,0,32,0,0,255,255,255,255,255,28,39,255,255,255,255,30,0,30,0,0,0,149,0,
40,12,0,0,
46,14,0,
30,
29,0,32,0,0,255,255,255,255,255,27,39,255,255,255,255,30,0,30,0,0,0,153,0,
43,15,0,162,0,0,
46,16,0,
30,
29,0,32,0,0,255,255,255,255,255,28,39,255,255,255,255,30,0,30,0,0,0,167,0,
40,15,0,0,
9,159,0,
43,15,0,162,0,3,
23,16,0,
9,180,0,1,14,0,
40,8,0,
46,17,0,
9,177,0,
43,18,0,180,0,3,
23,19,0,
9,198,0,1,17,0,
40,11,0,
46,20,0,
9,177,0,
40,18,0,3,
46,21,0,
9,205,0,
43,22,0,215,0,3,
45,23,0,2,
40,19,0,
23,24,0,
9,198,0,2,20,0,21,0,
40,11,0,
40,24,0,
46,25,0,
9,177,0,
40,18,0,3,
46,26,0,
9,224,0,
43,27,0,231,0,3,
45,28,0,3,
40,19,0,
40,24,0,
23,29,0,
9,198,0,2,25,0,26,0,
40,11,0,
40,29,0,
46,30,0,
9,177,0,
40,18,0,3,
9,159,0,
40,15,0,3,
46,18,0,
9,187,0,
43,19,0,197,0,3,
45,20,0,2,
40,16,0,
23,21,0,
9,180,0,2,17,0,18,0,
40,8,0,
40,21,0,
46,22,0,
9,159,0,
40,15,0,3,
46,23,0,
9,206,0,
43,24,0,213,0,3,
45,25,0,3,
40,16,0,
40,21,0,
23,26,0,
9,180,0,2,22,0,23,0,
40,8,0,
40,26,0,
46,27,0,
9,159,0,
40,15,0,3,
46,28,0,
9,220,0,
40,8,0,3,
45,29,0,4,
40,16,0,
40,21,0,
40,26,0,
23,30,0,
9,180,0,2,27,0,28,0,
40,8,0,
40,30,0,
46,31,0,
9,238,0,
40,11,0,3,
45,32,0,4,
40,19,0,
40,24,0,
40,29,0,
23,33,0,
9,198,0,2,30,0,31,0,
40,11,0,
40,33,0,
46,34,0,
9,177,0,
40,18,0,3,
46,35,0,
9,238,0,
40,11,0,3,
9,159,0,
40,15,0,3,
46,32,0,
9,220,0,
40,8,0,3,
46,33,0,
9,187,0,
40,19,0,3,
45,34,0,5,
40,16,0,
40,21,0,
40,26,0,
40,30,0,
23,35,0,
9,180,0,3,31,0,32,0,33,0,
40,8,0,
40,35,0,
46,36,0,
9,205,0,
40,22,0,3,
45,37,0,5,
40,19,0,
40,24,0,
40,29,0,
40,33,0,
23,38,0,
9,198,0,3,34,0,35,0,36,0,
40,11,0,
40,38,0,
46,39,0,
9,177,0,
40,18,0,3,
46,40,0,
9,238,0,
40,11,0,3,
46,41,0,
9,224,0,
40,27,0,3,
45,42,0,6,
40,19,0,
40,24,0,
40,29,0,
40,33,0,
40,38,0,
23,43,0,
9,198,0,3,39,0,40,0,41,0,
40,11,0,
40,43,0,11,0,
9,159,0,
40,15,0,3,
46,37,0,
9,220,0,
40,8,0,3,
46,38,0,
9,206,0,
40,24,0,3,
45,39,0,6,
40,16,0,
40,21,0,
40,26,0,
40,30,0,
40,35,0,
23,40,0,
9,180,0,3,36,0,37,0,38,0,
40,8,0,
40,40,0,10,0,
0,0,
1,0,
7,0,
8,0,
5,0,
6,0,
9,0,
34,0,
2,0,
11,0,
4,0,
10,0,
7,0,
32,0,
2,0,
9,0,
8,0,
12,
14,2,0,
42,5,0,
46,41,0,
30,
8,1,226,0,
40,1,0,0,
46,42,0,
30,
8,1,234,0,
40,1,0,0,
46,43,0,
30,
8,1,242,0,
40,1,0,0,
46,44,0,
30,
8,1,244,0,
8,1,1,1,
40,1,0,0,
46,45,0,
30,
8,1,252,0,
40,1,0,0,
46,46,0,
30,
8,1,4,1,
40,1,0,0,
46,47,0,
30,
8,1,19,1,
40,1,0,0,
46,48,0,
30,
8,1,34,1,
8,1,16,1,
40,1,0,0,5,0,
1,0,
0,0,
@ -191,17 +182,17 @@ static uint8_t SKSL_INCLUDE_sksl_fp[] = {60,1,
4,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,
14,17,0,
42,3,0,
46,49,0,
46,46,0,
30,
8,1,40,1,
8,1,22,1,
40,2,0,0,
46,50,0,
46,47,0,
30,
8,1,50,1,
8,1,32,1,
40,2,0,0,
46,51,0,
46,48,0,
30,
8,1,34,1,
8,1,16,1,
40,2,0,0,3,0,
2,0,
0,0,
@ -211,32 +202,28 @@ static uint8_t SKSL_INCLUDE_sksl_fp[] = {60,1,
40,4,0,0,
50,
48,
47,7,0,
40,6,0,1,
50,
48,
47,9,0,
47,6,0,
40,4,0,1,
50,
48,
47,10,0,
40,11,0,0,
47,7,0,
40,8,0,0,
50,
48,
47,12,0,
40,11,0,0,
47,9,0,
40,8,0,0,
50,
48,
47,10,0,
40,8,0,0,
50,
48,
47,11,0,
40,12,0,0,
50,
48,
47,13,0,
40,11,0,0,
50,
48,
47,14,0,
40,15,0,0,
50,
48,
47,16,0,
40,15,0,0,
40,12,0,0,
50,
13,};
static constexpr size_t SKSL_INCLUDE_sksl_fp_LENGTH = sizeof(SKSL_INCLUDE_sksl_fp);

View File

@ -1,11 +1,9 @@
static uint8_t SKSL_INCLUDE_sksl_frag[] = {142,0,
static uint8_t SKSL_INCLUDE_sksl_frag[] = {124,0,
0,
12,115,107,95,70,114,97,103,67,111,111,114,100,
6,102,108,111,97,116,52,
12,115,107,95,67,108,111,99,107,119,105,115,101,
4,98,111,111,108,
3,105,110,116,
13,115,107,95,83,97,109,112,108,101,77,97,115,107,
24,103,108,95,83,101,99,111,110,100,97,114,121,70,114,97,103,67,111,108,111,114,69,88,84,
5,104,97,108,102,52,
12,115,107,95,70,114,97,103,67,111,108,111,114,
@ -13,7 +11,7 @@ static uint8_t SKSL_INCLUDE_sksl_frag[] = {142,0,
8,115,107,95,87,105,100,116,104,
4,104,97,108,102,
9,115,107,95,72,101,105,103,104,116,
42,9,0,
42,7,0,
46,1,0,
30,
29,0,32,0,0,255,255,255,255,255,15,0,255,255,255,255,2,0,2,0,0,2,3,0,
@ -22,40 +20,33 @@ static uint8_t SKSL_INCLUDE_sksl_frag[] = {142,0,
30,
29,0,32,0,0,255,255,255,255,255,17,0,255,255,255,255,2,0,2,0,0,2,23,0,
43,4,0,36,0,0,
0,5,0,
43,6,0,41,0,1,
46,5,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,2,0,2,0,0,4,41,0,
43,6,0,66,0,0,
46,7,0,
30,
29,0,32,0,0,255,255,255,255,255,20,0,255,255,255,255,2,0,2,0,0,4,45,0,
40,5,0,0,
29,0,41,0,0,0,255,255,0,255,17,39,255,255,255,255,2,0,2,0,0,4,72,0,
40,6,0,0,
46,8,0,
30,
29,0,32,0,0,255,255,255,255,255,15,39,255,255,255,255,2,0,2,0,0,4,59,0,
43,9,0,84,0,0,
46,10,0,
29,0,32,0,0,255,255,255,255,255,24,39,255,255,255,255,2,0,2,0,0,0,85,0,
40,6,0,0,
46,9,0,
30,
29,0,41,0,0,0,255,255,0,255,17,39,255,255,255,255,2,0,2,0,0,4,90,0,
40,9,0,0,
29,0,32,0,0,255,255,255,255,255,27,39,255,255,255,255,2,0,2,0,0,0,102,0,
43,10,0,111,0,0,
46,11,0,
30,
29,0,32,0,0,255,255,255,255,255,24,39,255,255,255,255,2,0,2,0,0,0,103,0,
40,9,0,0,
46,12,0,
30,
29,0,32,0,0,255,255,255,255,255,27,39,255,255,255,255,2,0,2,0,0,0,120,0,
43,13,0,129,0,0,
46,14,0,
30,
29,0,32,0,0,255,255,255,255,255,28,39,255,255,255,255,2,0,2,0,0,0,134,0,
40,13,0,0,8,0,
4,0,
29,0,32,0,0,255,255,255,255,255,28,39,255,255,255,255,2,0,2,0,0,0,116,0,
40,10,0,0,7,0,
2,0,
1,0,
5,0,
0,0,
8,0,
6,0,
3,0,
7,0,
0,0,
6,0,
4,0,
5,0,
12,
48,
47,1,0,
@ -66,28 +57,24 @@ static uint8_t SKSL_INCLUDE_sksl_frag[] = {142,0,
40,4,0,0,
50,
48,
47,5,0,
40,6,0,0,
50,
48,
47,7,0,
40,6,0,1,
40,6,0,0,
50,
48,
47,8,0,
40,9,0,0,
40,6,0,0,
50,
48,
47,10,0,
40,9,0,0,
47,9,0,
40,10,0,0,
50,
48,
47,11,0,
40,9,0,0,
50,
48,
47,12,0,
40,13,0,0,
50,
48,
47,14,0,
40,13,0,0,
40,10,0,0,
50,
13,};
static constexpr size_t SKSL_INCLUDE_sksl_frag_LENGTH = sizeof(SKSL_INCLUDE_sksl_frag);

View File

@ -4,7 +4,6 @@
// defines built-in interfaces supported by SkiaSL fragment shaders
layout(builtin=15) in float4 sk_FragCoord;
layout(builtin=20) out int sk_SampleMask[1];
// 9999 is a sentinel value that causes us to ignore these declarations, beyond adding them to the
// symbol table.

View File

@ -3,7 +3,6 @@
// See "enum SpvBuiltIn_" in ./spirv.h
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=20) out int sk_SampleMask[1];
// 9999 is a sentinel value that causes us to ignore these declarations, beyond adding them to the
// symbol table.

View File

@ -1,32 +0,0 @@
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %sk_SampleMask %sk_Clockwise
OpExecutionMode %main OriginUpperLeft
OpName %sk_SampleMask "sk_SampleMask"
OpName %sk_Clockwise "sk_Clockwise"
OpName %main "main"
OpDecorate %_arr_int_int_1 ArrayStride 16
OpDecorate %sk_SampleMask BuiltIn SampleMask
OpDecorate %sk_Clockwise BuiltIn FrontFacing
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_arr_int_int_1 = OpTypeArray %int %int_1
%_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1
%sk_SampleMask = OpVariable %_ptr_Output__arr_int_int_1 Output
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%void = OpTypeVoid
%12 = OpTypeFunction %void
%int_0 = OpConstant %int 0
%_ptr_Output_int = OpTypePointer Output %int
%int_8 = OpConstant %int 8
%main = OpFunction %void None %12
%13 = OpLabel
%15 = OpAccessChain %_ptr_Output_int %sk_SampleMask %int_0
%17 = OpLoad %int %15
%19 = OpBitwiseOr %int %17 %int_8
OpStore %15 %19
OpReturn
OpFunctionEnd

View File

@ -1,4 +0,0 @@
void main() {
gl_SampleMask[0] |= 8;
}

View File

@ -1,14 +0,0 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
_out.sk_SampleMask[0] |= 8;
return _out;
}