From 900debdaaaa5800545c6532c4d62d172a023ed3d Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 3 Nov 2022 10:15:10 -0700 Subject: [PATCH 1/2] [Impeller] validate calls to texture in SkSL --- impeller/compiler/spirv_sksl.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/impeller/compiler/spirv_sksl.cc b/impeller/compiler/spirv_sksl.cc index c2bf67cc46a73..f5a396c4764ef 100644 --- a/impeller/compiler/spirv_sksl.cc +++ b/impeller/compiler/spirv_sksl.cc @@ -4,6 +4,8 @@ #include "impeller/compiler/spirv_sksl.h" +#include + using namespace spv; using namespace SPIRV_CROSS_NAMESPACE; @@ -431,6 +433,15 @@ std::string CompilerSkSL::to_function_args(const TextureFunctionArguments& args, std::string name = to_expression(args.base.img); std::string glsl_args = CompilerGLSL::to_function_args(args, p_forward); + // SkSL only supports coordinates. All other arguments to texture are + // unsupported and will generate invalid SkSL. + if (args.grad_x || args.grad_y || args.lod || args.coffset || args.offset || + args.sample || args.min_lod || args.sparse_texel || args.bias || + args.component) { + FLUTTER_CROSS_THROW( + "Only sampler and position arguments are supported in texture() " + "calls."); + } // GLSL puts the shader as the first argument, but in SkSL the shader is // implicitly passed as the reciever of the 'eval' method. Therefore, the From 2c0eac5d685d1627a6fb85b8d9717e47fcc29222 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 3 Nov 2022 10:16:53 -0700 Subject: [PATCH 2/2] Update spirv_sksl.cc --- impeller/compiler/spirv_sksl.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/impeller/compiler/spirv_sksl.cc b/impeller/compiler/spirv_sksl.cc index f5a396c4764ef..30756420683ce 100644 --- a/impeller/compiler/spirv_sksl.cc +++ b/impeller/compiler/spirv_sksl.cc @@ -4,8 +4,6 @@ #include "impeller/compiler/spirv_sksl.h" -#include - using namespace spv; using namespace SPIRV_CROSS_NAMESPACE;