SkSL: Hide most integral types from runtime effects
'int' is the only integral type that exists in GLSL ES 1.0 (and it's not really guaranteed to be an integer). This enforces the same restriction on runtime effects - no unsigned integers, and no short or byte types. Bug: skia:11093 Change-Id: I938f1e0e125dc8347507f428b46b51c66033c752 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347046 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
0c3536c09a
commit
20fad32064
@ -103,11 +103,6 @@ Compiler::Compiler(const ShaderCapsClass* caps, Flags flags)
|
|||||||
TYPE( Float), TYPE( Float2), TYPE( Float3), TYPE( Float4),
|
TYPE( Float), TYPE( Float2), TYPE( Float3), TYPE( Float4),
|
||||||
TYPE( Half), TYPE( Half2), TYPE( Half3), TYPE( Half4),
|
TYPE( Half), TYPE( Half2), TYPE( Half3), TYPE( Half4),
|
||||||
TYPE( Int), TYPE( Int2), TYPE( Int3), TYPE( Int4),
|
TYPE( Int), TYPE( Int2), TYPE( Int3), TYPE( Int4),
|
||||||
TYPE( UInt), TYPE( UInt2), TYPE( UInt3), TYPE( UInt4),
|
|
||||||
TYPE( Short), TYPE( Short2), TYPE( Short3), TYPE( Short4),
|
|
||||||
TYPE(UShort), TYPE(UShort2), TYPE(UShort3), TYPE(UShort4),
|
|
||||||
TYPE( Byte), TYPE( Byte2), TYPE( Byte3), TYPE( Byte4),
|
|
||||||
TYPE( UByte), TYPE( UByte2), TYPE( UByte3), TYPE( UByte4),
|
|
||||||
TYPE( Bool), TYPE( Bool2), TYPE( Bool3), TYPE( Bool4),
|
TYPE( Bool), TYPE( Bool2), TYPE( Bool3), TYPE( Bool4),
|
||||||
|
|
||||||
TYPE(Float2x2), TYPE(Float3x3), TYPE(Float4x4),
|
TYPE(Float2x2), TYPE(Float3x3), TYPE(Float4x4),
|
||||||
@ -115,15 +110,22 @@ Compiler::Compiler(const ShaderCapsClass* caps, Flags flags)
|
|||||||
|
|
||||||
TYPE(SquareMat), TYPE(SquareHMat),
|
TYPE(SquareMat), TYPE(SquareHMat),
|
||||||
|
|
||||||
TYPE(GenType), TYPE(GenHType), TYPE(GenIType), TYPE(GenUType), TYPE(GenBType),
|
TYPE(GenType), TYPE(GenHType), TYPE(GenIType), TYPE(GenBType),
|
||||||
TYPE(Vec), TYPE(HVec), TYPE(IVec), TYPE(UVec), TYPE(BVec),
|
TYPE(Vec), TYPE(HVec), TYPE(IVec), TYPE(BVec),
|
||||||
|
|
||||||
TYPE(SVec), TYPE(USVec), TYPE(ByteVec), TYPE(UByteVec),
|
|
||||||
|
|
||||||
TYPE(FragmentProcessor),
|
TYPE(FragmentProcessor),
|
||||||
};
|
};
|
||||||
|
|
||||||
const SkSL::Symbol* privateTypes[] = {
|
const SkSL::Symbol* privateTypes[] = {
|
||||||
|
TYPE( UInt), TYPE( UInt2), TYPE( UInt3), TYPE( UInt4),
|
||||||
|
TYPE( Short), TYPE( Short2), TYPE( Short3), TYPE( Short4),
|
||||||
|
TYPE(UShort), TYPE(UShort2), TYPE(UShort3), TYPE(UShort4),
|
||||||
|
TYPE( Byte), TYPE( Byte2), TYPE( Byte3), TYPE( Byte4),
|
||||||
|
TYPE( UByte), TYPE( UByte2), TYPE( UByte3), TYPE( UByte4),
|
||||||
|
|
||||||
|
TYPE(GenUType), TYPE(UVec),
|
||||||
|
TYPE(SVec), TYPE(USVec), TYPE(ByteVec), TYPE(UByteVec),
|
||||||
|
|
||||||
TYPE(Float2x3), TYPE(Float2x4),
|
TYPE(Float2x3), TYPE(Float2x4),
|
||||||
TYPE(Float3x2), TYPE(Float3x4),
|
TYPE(Float3x2), TYPE(Float3x4),
|
||||||
TYPE(Float4x2), TYPE(Float4x3),
|
TYPE(Float4x2), TYPE(Float4x3),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
static uint8_t SKSL_INCLUDE_sksl_interp[] = {166,0,
|
static uint8_t SKSL_INCLUDE_sksl_interp[] = {160,0,
|
||||||
1,120,
|
1,120,
|
||||||
9,36,103,101,110,73,84,121,112,101,
|
9,36,103,101,110,73,84,121,112,101,
|
||||||
1,121,
|
1,121,
|
||||||
@ -16,13 +16,12 @@ static uint8_t SKSL_INCLUDE_sksl_interp[] = {166,0,
|
|||||||
5,36,105,118,101,99,
|
5,36,105,118,101,99,
|
||||||
8,108,101,115,115,84,104,97,110,
|
8,108,101,115,115,84,104,97,110,
|
||||||
5,36,98,118,101,99,
|
5,36,98,118,101,99,
|
||||||
5,36,117,118,101,99,
|
|
||||||
13,108,101,115,115,84,104,97,110,69,113,117,97,108,
|
13,108,101,115,115,84,104,97,110,69,113,117,97,108,
|
||||||
11,103,114,101,97,116,101,114,84,104,97,110,
|
11,103,114,101,97,116,101,114,84,104,97,110,
|
||||||
16,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,
|
16,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,
|
||||||
5,101,113,117,97,108,
|
5,101,113,117,97,108,
|
||||||
8,110,111,116,69,113,117,97,108,
|
8,110,111,116,69,113,117,97,108,
|
||||||
43,84,0,
|
43,60,0,
|
||||||
47,1,0,
|
47,1,0,
|
||||||
9,2,0,
|
9,2,0,
|
||||||
44,2,0,4,0,3,
|
44,2,0,4,0,3,
|
||||||
@ -163,37 +162,40 @@ static uint8_t SKSL_INCLUDE_sksl_interp[] = {166,0,
|
|||||||
44,52,0,98,0,
|
44,52,0,98,0,
|
||||||
47,53,0,
|
47,53,0,
|
||||||
9,2,0,
|
9,2,0,
|
||||||
44,54,0,104,0,3,
|
41,49,0,3,
|
||||||
47,55,0,
|
47,54,0,
|
||||||
9,14,0,
|
9,14,0,
|
||||||
41,54,0,3,
|
41,49,0,3,
|
||||||
46,56,0,2,
|
23,55,0,
|
||||||
41,51,0,
|
9,104,0,2,53,0,54,0,
|
||||||
23,57,0,
|
|
||||||
9,89,0,2,53,0,55,0,
|
|
||||||
41,52,0,
|
41,52,0,
|
||||||
41,57,0,
|
47,56,0,
|
||||||
47,58,0,
|
|
||||||
9,2,0,
|
9,2,0,
|
||||||
41,49,0,3,
|
41,49,0,3,
|
||||||
|
47,57,0,
|
||||||
|
9,14,0,
|
||||||
|
41,49,0,3,
|
||||||
|
23,58,0,
|
||||||
|
9,118,0,2,56,0,57,0,
|
||||||
|
41,52,0,
|
||||||
47,59,0,
|
47,59,0,
|
||||||
|
9,2,0,
|
||||||
|
41,49,0,3,
|
||||||
|
47,60,0,
|
||||||
9,14,0,
|
9,14,0,
|
||||||
41,49,0,3,
|
41,49,0,3,
|
||||||
23,60,0,
|
23,61,0,
|
||||||
9,110,0,2,58,0,59,0,
|
9,130,0,2,59,0,60,0,
|
||||||
41,52,0,
|
41,52,0,
|
||||||
47,61,0,
|
|
||||||
9,2,0,
|
|
||||||
41,54,0,3,
|
|
||||||
47,62,0,
|
47,62,0,
|
||||||
|
9,2,0,
|
||||||
|
41,49,0,3,
|
||||||
|
47,63,0,
|
||||||
9,14,0,
|
9,14,0,
|
||||||
41,54,0,3,
|
41,49,0,3,
|
||||||
46,63,0,2,
|
|
||||||
41,60,0,
|
|
||||||
23,64,0,
|
23,64,0,
|
||||||
9,110,0,2,61,0,62,0,
|
9,147,0,2,62,0,63,0,
|
||||||
41,52,0,
|
41,52,0,
|
||||||
41,64,0,
|
|
||||||
47,65,0,
|
47,65,0,
|
||||||
9,2,0,
|
9,2,0,
|
||||||
41,49,0,3,
|
41,49,0,3,
|
||||||
@ -201,93 +203,18 @@ static uint8_t SKSL_INCLUDE_sksl_interp[] = {166,0,
|
|||||||
9,14,0,
|
9,14,0,
|
||||||
41,49,0,3,
|
41,49,0,3,
|
||||||
23,67,0,
|
23,67,0,
|
||||||
9,124,0,2,65,0,66,0,
|
9,153,0,2,65,0,66,0,
|
||||||
41,52,0,
|
41,52,0,10,0,
|
||||||
47,68,0,
|
|
||||||
9,2,0,
|
|
||||||
41,54,0,3,
|
|
||||||
47,69,0,
|
|
||||||
9,14,0,
|
|
||||||
41,54,0,3,
|
|
||||||
46,70,0,2,
|
|
||||||
41,67,0,
|
|
||||||
23,71,0,
|
|
||||||
9,124,0,2,68,0,69,0,
|
|
||||||
41,52,0,
|
|
||||||
41,71,0,
|
|
||||||
47,72,0,
|
|
||||||
9,2,0,
|
|
||||||
41,49,0,3,
|
|
||||||
47,73,0,
|
|
||||||
9,14,0,
|
|
||||||
41,49,0,3,
|
|
||||||
23,74,0,
|
|
||||||
9,136,0,2,72,0,73,0,
|
|
||||||
41,52,0,
|
|
||||||
47,75,0,
|
|
||||||
9,2,0,
|
|
||||||
41,54,0,3,
|
|
||||||
47,76,0,
|
|
||||||
9,14,0,
|
|
||||||
41,54,0,3,
|
|
||||||
46,77,0,2,
|
|
||||||
41,74,0,
|
|
||||||
23,78,0,
|
|
||||||
9,136,0,2,75,0,76,0,
|
|
||||||
41,52,0,
|
|
||||||
41,78,0,
|
|
||||||
47,79,0,
|
|
||||||
9,2,0,
|
|
||||||
41,49,0,3,
|
|
||||||
47,80,0,
|
|
||||||
9,14,0,
|
|
||||||
41,49,0,3,
|
|
||||||
23,81,0,
|
|
||||||
9,153,0,2,79,0,80,0,
|
|
||||||
41,52,0,
|
|
||||||
47,82,0,
|
|
||||||
9,2,0,
|
|
||||||
41,54,0,3,
|
|
||||||
47,83,0,
|
|
||||||
9,14,0,
|
|
||||||
41,54,0,3,
|
|
||||||
46,84,0,2,
|
|
||||||
41,81,0,
|
|
||||||
23,85,0,
|
|
||||||
9,153,0,2,82,0,83,0,
|
|
||||||
41,52,0,
|
|
||||||
41,85,0,
|
|
||||||
47,86,0,
|
|
||||||
9,2,0,
|
|
||||||
41,49,0,3,
|
|
||||||
47,87,0,
|
|
||||||
9,14,0,
|
|
||||||
41,49,0,3,
|
|
||||||
23,88,0,
|
|
||||||
9,159,0,2,86,0,87,0,
|
|
||||||
41,52,0,
|
|
||||||
47,89,0,
|
|
||||||
9,2,0,
|
|
||||||
41,54,0,3,
|
|
||||||
47,90,0,
|
|
||||||
9,14,0,
|
|
||||||
41,54,0,3,
|
|
||||||
46,91,0,2,
|
|
||||||
41,88,0,
|
|
||||||
23,92,0,
|
|
||||||
9,159,0,2,89,0,90,0,
|
|
||||||
41,52,0,
|
|
||||||
41,92,0,10,0,
|
|
||||||
21,0,
|
21,0,
|
||||||
75,0,
|
56,0,
|
||||||
61,0,
|
50,0,
|
||||||
68,0,
|
53,0,
|
||||||
|
44,0,
|
||||||
47,0,
|
47,0,
|
||||||
54,0,
|
|
||||||
12,0,
|
12,0,
|
||||||
5,0,
|
5,0,
|
||||||
40,0,
|
40,0,
|
||||||
82,0,
|
59,0,
|
||||||
12,
|
12,
|
||||||
13,};
|
13,};
|
||||||
static constexpr size_t SKSL_INCLUDE_sksl_interp_LENGTH = sizeof(SKSL_INCLUDE_sksl_interp);
|
static constexpr size_t SKSL_INCLUDE_sksl_interp_LENGTH = sizeof(SKSL_INCLUDE_sksl_interp);
|
||||||
|
@ -14,14 +14,8 @@ $genIType mix($genIType x, $genIType y, $genBType a);
|
|||||||
$genBType mix($genBType x, $genBType y, $genBType a);
|
$genBType mix($genBType x, $genBType y, $genBType a);
|
||||||
|
|
||||||
$bvec lessThan($ivec x, $ivec y);
|
$bvec lessThan($ivec x, $ivec y);
|
||||||
$bvec lessThan($uvec x, $uvec y);
|
|
||||||
$bvec lessThanEqual($ivec x, $ivec y);
|
$bvec lessThanEqual($ivec x, $ivec y);
|
||||||
$bvec lessThanEqual($uvec x, $uvec y);
|
|
||||||
$bvec greaterThan($ivec x, $ivec y);
|
$bvec greaterThan($ivec x, $ivec y);
|
||||||
$bvec greaterThan($uvec x, $uvec y);
|
|
||||||
$bvec greaterThanEqual($ivec x, $ivec y);
|
$bvec greaterThanEqual($ivec x, $ivec y);
|
||||||
$bvec greaterThanEqual($uvec x, $uvec y);
|
|
||||||
$bvec equal($ivec x, $ivec y);
|
$bvec equal($ivec x, $ivec y);
|
||||||
$bvec equal($uvec x, $uvec y);
|
|
||||||
$bvec notEqual($ivec x, $ivec y);
|
$bvec notEqual($ivec x, $ivec y);
|
||||||
$bvec notEqual($uvec x, $uvec y);
|
|
||||||
|
@ -166,6 +166,7 @@ half3x3 inverse(half3x3 m);
|
|||||||
half4x4 inverse(half4x4 m);
|
half4x4 inverse(half4x4 m);
|
||||||
|
|
||||||
// 8.6 : Vector Relational Functions
|
// 8.6 : Vector Relational Functions
|
||||||
|
// TODO: Move ivec versions of these from sksl_interp.sksl to here, implement them in VM generator
|
||||||
$bvec lessThan($vec x, $vec y);
|
$bvec lessThan($vec x, $vec y);
|
||||||
$bvec lessThan($hvec x, $hvec y);
|
$bvec lessThan($hvec x, $hvec y);
|
||||||
$bvec lessThanEqual($vec x, $vec y);
|
$bvec lessThanEqual($vec x, $vec y);
|
||||||
|
@ -264,15 +264,6 @@ DEF_TEST(SkSLInterpreterBitwise, r) {
|
|||||||
test(r, "void main(inout half4 color) { color.r = half(~int(color.r) & 3); }",
|
test(r, "void main(inout half4 color) { color.r = half(~int(color.r) & 3); }",
|
||||||
6, 0, 0, 0, 1, 0, 0, 0);
|
6, 0, 0, 0, 1, 0, 0, 0);
|
||||||
|
|
||||||
test(r, "void main(inout half4 color) { color.r = half(uint(color.r) | 3); }",
|
|
||||||
5, 0, 0, 0, 7, 0, 0, 0);
|
|
||||||
test(r, "void main(inout half4 color) { color.r = half(uint(color.r) & 3); }",
|
|
||||||
6, 0, 0, 0, 2, 0, 0, 0);
|
|
||||||
test(r, "void main(inout half4 color) { color.r = half(uint(color.r) ^ 3); }",
|
|
||||||
5, 0, 0, 0, 6, 0, 0, 0);
|
|
||||||
test(r, "void main(inout half4 color) { color.r = half(~uint(color.r) & 3); }",
|
|
||||||
6, 0, 0, 0, 1, 0, 0, 0);
|
|
||||||
|
|
||||||
// Shift operators
|
// Shift operators
|
||||||
unsigned in = 0x80000011;
|
unsigned in = 0x80000011;
|
||||||
unsigned out;
|
unsigned out;
|
||||||
@ -282,9 +273,6 @@ DEF_TEST(SkSLInterpreterBitwise, r) {
|
|||||||
|
|
||||||
out = 0xF0000002;
|
out = 0xF0000002;
|
||||||
test(r, "int main(int x) { return x >> 3; }", (float*)&in, (float*)&out);
|
test(r, "int main(int x) { return x >> 3; }", (float*)&in, (float*)&out);
|
||||||
|
|
||||||
out = 0x10000002;
|
|
||||||
test(r, "uint main(uint x) { return x >> 3; }", (float*)&in, (float*)&out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_TEST(SkSLInterpreterMatrix, r) {
|
DEF_TEST(SkSLInterpreterMatrix, r) {
|
||||||
@ -389,7 +377,6 @@ DEF_TEST(SkSLInterpreterTernary, r) {
|
|||||||
DEF_TEST(SkSLInterpreterCast, r) {
|
DEF_TEST(SkSLInterpreterCast, r) {
|
||||||
union Val {
|
union Val {
|
||||||
float f;
|
float f;
|
||||||
uint32_t u;
|
|
||||||
int32_t s;
|
int32_t s;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -403,13 +390,6 @@ DEF_TEST(SkSLInterpreterCast, r) {
|
|||||||
test(r, "float main(int x) { return float (x); }", (float*)input, (float*)expected);
|
test(r, "float main(int x) { return float (x); }", (float*)input, (float*)expected);
|
||||||
test(r, "float2 main(int2 x) { return float2(x); }", (float*)input, (float*)expected);
|
test(r, "float2 main(int2 x) { return float2(x); }", (float*)input, (float*)expected);
|
||||||
|
|
||||||
input[0].u = 3;
|
|
||||||
input[1].u = 5;
|
|
||||||
expected[0].f = 3.0f;
|
|
||||||
expected[1].f = 5.0f;
|
|
||||||
test(r, "float main(uint x) { return float (x); }", (float*)input, (float*)expected);
|
|
||||||
test(r, "float2 main(uint2 x) { return float2(x); }", (float*)input, (float*)expected);
|
|
||||||
|
|
||||||
input[0].f = 3.0f;
|
input[0].f = 3.0f;
|
||||||
input[1].f = -5.0f;
|
input[1].f = -5.0f;
|
||||||
expected[0].s = 3;
|
expected[0].s = 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user