Add bool2/bool3/bool4 to GrSLType.
These are basic vector types, required by GLSL ES2, but we could not create helper functions using them because they were missing from our GrSLType enum. (This also prevented Runtime Effects from using these types in helper functions.) Change-Id: I78c328499e8ed90cb29c641b90ee59460a5a45de Bug: skia:11246 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364036 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
a6c692b884
commit
9fc9b87540
@ -32,6 +32,8 @@ sksl_fp_tests = [
|
||||
"/sksl/fp/GrChildProcessorsWithInput.fp",
|
||||
"/sksl/fp/GrConditionalInUniform.fp",
|
||||
"/sksl/fp/GrFunction.fp",
|
||||
"/sksl/fp/GrFunctionArgTypes.fp",
|
||||
"/sksl/fp/GrFunctionReturnTypes.fp",
|
||||
"/sksl/fp/GrGrSLTypesAreSupported.fp",
|
||||
"/sksl/fp/GrHelloWorld.fp",
|
||||
"/sksl/fp/GrInUniform.fp",
|
||||
|
@ -304,6 +304,9 @@ static inline GrQuadAAFlags SkToGrQuadAAFlags(unsigned flags) {
|
||||
enum GrSLType {
|
||||
kVoid_GrSLType,
|
||||
kBool_GrSLType,
|
||||
kBool2_GrSLType,
|
||||
kBool3_GrSLType,
|
||||
kBool4_GrSLType,
|
||||
kByte_GrSLType,
|
||||
kByte2_GrSLType,
|
||||
kByte3_GrSLType,
|
||||
@ -409,6 +412,9 @@ static constexpr bool GrSLTypeIsFloatType(GrSLType type) {
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kByte_GrSLType:
|
||||
case kByte2_GrSLType:
|
||||
case kByte3_GrSLType:
|
||||
@ -457,6 +463,7 @@ static constexpr int GrSLTypeVecLength(GrSLType type) {
|
||||
|
||||
case kFloat2_GrSLType:
|
||||
case kHalf2_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kByte2_GrSLType:
|
||||
case kUByte2_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
@ -467,6 +474,7 @@ static constexpr int GrSLTypeVecLength(GrSLType type) {
|
||||
|
||||
case kFloat3_GrSLType:
|
||||
case kHalf3_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kByte3_GrSLType:
|
||||
case kUByte3_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
@ -477,6 +485,7 @@ static constexpr int GrSLTypeVecLength(GrSLType type) {
|
||||
|
||||
case kFloat4_GrSLType:
|
||||
case kHalf4_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kByte4_GrSLType:
|
||||
case kUByte4_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
@ -563,6 +572,9 @@ static constexpr bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
|
||||
case kUint3_GrSLType:
|
||||
case kUint4_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kByte_GrSLType:
|
||||
case kByte2_GrSLType:
|
||||
case kByte3_GrSLType:
|
||||
|
19
resources/sksl/fp/GrFunctionArgTypes.fp
Normal file
19
resources/sksl/fp/GrFunctionArgTypes.fp
Normal file
@ -0,0 +1,19 @@
|
||||
/*#pragma settings NoInline*/
|
||||
|
||||
// Verify that all the basic ES2 types are supported as FP helper function arguments.
|
||||
bool takes_float (float f1, float2 f2, float3 f3, float4 f4) { return true; }
|
||||
bool takes_float_matrix(float2x2 m2, float3x3 m3, float4x4 m4) { return true; }
|
||||
bool takes_half (half h1, half2 h2, half3 h3, half4 h4) { return true; }
|
||||
bool takes_half_matrix (half2x2 m2, half3x3 m3, half4x4 m4) { return true; }
|
||||
bool takes_bool (bool b, bool2 b2, bool3 b3, bool4 b4) { return true; }
|
||||
bool takes_int (int i, int2 i2, int3 i3, int4 i4) { return true; }
|
||||
|
||||
half4 main() {
|
||||
return takes_float(float(1), float2(2), float3(3), float4(4)) &&
|
||||
takes_float_matrix(float2x2(2), float3x3(3), float4x4(4)) &&
|
||||
takes_half(half(1), half2(2), half3(3), half4(4)) &&
|
||||
takes_half_matrix(half2x2(2), half3x3(3), half4x4(4)) &&
|
||||
takes_bool(true, bool2(true), bool3(true), bool4(true)) &&
|
||||
takes_int(1, int2(2), int3(3), int4(4))
|
||||
? half4(1) : half4(0);
|
||||
}
|
51
resources/sksl/fp/GrFunctionReturnTypes.fp
Normal file
51
resources/sksl/fp/GrFunctionReturnTypes.fp
Normal file
@ -0,0 +1,51 @@
|
||||
/*#pragma settings NoInline*/
|
||||
|
||||
// Verify that all the basic ES2 types are supported as FP helper function return types.
|
||||
float returns_float() { return float(1); }
|
||||
float2 returns_float2() { return float2(2); }
|
||||
float3 returns_float3() { return float3(3); }
|
||||
float4 returns_float4() { return float4(4); }
|
||||
float2x2 returns_float2x2() { return float2x2(2); }
|
||||
float3x3 returns_float3x3() { return float3x3(3); }
|
||||
float4x4 returns_float4x4() { return float4x4(4); }
|
||||
half returns_half() { return half(1); }
|
||||
half2 returns_half2() { return half2(2); }
|
||||
half3 returns_half3() { return half3(3); }
|
||||
half4 returns_half4() { return half4(4); }
|
||||
half2x2 returns_half2x2() { return half2x2(2); }
|
||||
half3x3 returns_half3x3() { return half3x3(3); }
|
||||
half4x4 returns_half4x4() { return half4x4(4); }
|
||||
bool returns_bool() { return bool(true); }
|
||||
bool2 returns_bool2() { return bool2(true); }
|
||||
bool3 returns_bool3() { return bool3(true); }
|
||||
bool4 returns_bool4() { return bool4(true); }
|
||||
int returns_int() { return int(1); }
|
||||
int2 returns_int2() { return int2(2); }
|
||||
int3 returns_int3() { return int3(3); }
|
||||
int4 returns_int4() { return int4(4); }
|
||||
|
||||
half4 main() {
|
||||
returns_float();
|
||||
returns_float2();
|
||||
returns_float3();
|
||||
returns_float4();
|
||||
returns_float2x2();
|
||||
returns_float3x3();
|
||||
returns_float4x4();
|
||||
returns_half();
|
||||
returns_half2();
|
||||
returns_half3();
|
||||
returns_half4();
|
||||
returns_half2x2();
|
||||
returns_half3x3();
|
||||
returns_half4x4();
|
||||
returns_bool();
|
||||
returns_bool2();
|
||||
returns_bool3();
|
||||
returns_bool4();
|
||||
returns_int();
|
||||
returns_int2();
|
||||
returns_int3();
|
||||
returns_int4();
|
||||
return half4(1);
|
||||
}
|
@ -88,6 +88,9 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
// This query is only valid for certain types.
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
@ -167,6 +170,9 @@ static inline uint32_t grsltype_to_size(GrSLType type) {
|
||||
// This query is only valid for certain types.
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
|
@ -10,6 +10,9 @@
|
||||
/** Returns the number of locations take up by a given GrSLType. We assume that all
|
||||
scalar values are 32 bits. */
|
||||
static inline int grsltype_to_location_size(GrSLType type) {
|
||||
// If a new GrSL type is added, this function will need to be updated.
|
||||
static_assert(kGrSLTypeCount == 49);
|
||||
|
||||
switch(type) {
|
||||
case kVoid_GrSLType:
|
||||
return 0;
|
||||
@ -62,6 +65,9 @@ static inline int grsltype_to_location_size(GrSLType type) {
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
return 0;
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
return 1;
|
||||
case kInt_GrSLType: // fall through
|
||||
case kShort_GrSLType:
|
||||
|
@ -12,6 +12,9 @@ const char* GrGLSLTypeString(GrSLType t) {
|
||||
switch (t) {
|
||||
case kVoid_GrSLType: return "void";
|
||||
case kBool_GrSLType: return "bool";
|
||||
case kBool2_GrSLType: return "bool2";
|
||||
case kBool3_GrSLType: return "bool3";
|
||||
case kBool4_GrSLType: return "bool4";
|
||||
case kByte_GrSLType: return "byte";
|
||||
case kByte2_GrSLType: return "byte2";
|
||||
case kByte3_GrSLType: return "byte3";
|
||||
|
@ -81,6 +81,9 @@ static uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
// This query is only valid for certain types.
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
@ -162,6 +165,9 @@ static inline uint32_t grsltype_to_mtl_size(GrSLType type) {
|
||||
// This query is only valid for certain types.
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
|
@ -81,6 +81,9 @@ static uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
// This query is only valid for certain types.
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
@ -165,6 +168,9 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
|
||||
// This query is only valid for certain types.
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
case kTextureExternalSampler_GrSLType:
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
|
@ -65,6 +65,9 @@ static inline int grsltype_to_location_size(GrSLType type) {
|
||||
case kTexture2DRectSampler_GrSLType:
|
||||
return 0;
|
||||
case kBool_GrSLType:
|
||||
case kBool2_GrSLType:
|
||||
case kBool3_GrSLType:
|
||||
case kBool4_GrSLType:
|
||||
return 1;
|
||||
case kInt_GrSLType: // fall through
|
||||
case kShort_GrSLType:
|
||||
|
@ -488,10 +488,13 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
|
||||
static const char* glsltype_string(const Context& context, const Type& type) {
|
||||
// If a new GrSL type is added, this function will need to be updated.
|
||||
static_assert(kGrSLTypeCount == 46);
|
||||
static_assert(kGrSLTypeCount == 49);
|
||||
|
||||
if (type == *context.fTypes.fVoid ) { return "kVoid_GrSLType"; }
|
||||
if (type == *context.fTypes.fBool ) { return "kBool_GrSLType"; }
|
||||
if (type == *context.fTypes.fBool2 ) { return "kBool2_GrSLType"; }
|
||||
if (type == *context.fTypes.fBool3 ) { return "kBool3_GrSLType"; }
|
||||
if (type == *context.fTypes.fBool4 ) { return "kBool4_GrSLType"; }
|
||||
if (type == *context.fTypes.fByte ) { return "kByte_GrSLType"; }
|
||||
if (type == *context.fTypes.fByte2 ) { return "kByte2_GrSLType"; }
|
||||
if (type == *context.fTypes.fByte3 ) { return "kByte3_GrSLType"; }
|
||||
|
@ -45,10 +45,13 @@ void write_stringstream(const StringStream& s, OutputStream& out) {
|
||||
#if !defined(SKSL_STANDALONE)
|
||||
bool type_to_grsltype(const Context& context, const Type& type, GrSLType* outType) {
|
||||
// If a new GrSL type is added, this function will need to be updated.
|
||||
static_assert(kGrSLTypeCount == 46);
|
||||
static_assert(kGrSLTypeCount == 49);
|
||||
|
||||
if (type == *context.fTypes.fVoid ) { *outType = kVoid_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fBool ) { *outType = kBool_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fBool2 ) { *outType = kBool2_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fBool3 ) { *outType = kBool3_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fBool4 ) { *outType = kBool4_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fByte ) { *outType = kByte_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fByte2 ) { *outType = kByte2_GrSLType; return true; }
|
||||
if (type == *context.fTypes.fByte3 ) { *outType = kByte3_GrSLType; return true; }
|
||||
|
82
tests/sksl/fp/GrFunctionArgTypes.cpp
Normal file
82
tests/sksl/fp/GrFunctionArgTypes.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*#pragma settings NoInline*/
|
||||
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from GrFunctionArgTypes.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
#include "GrFunctionArgTypes.h"
|
||||
|
||||
#include "src/core/SkUtils.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
|
||||
#include "src/sksl/SkSLCPP.h"
|
||||
#include "src/sksl/SkSLUtil.h"
|
||||
class GrGLSLFunctionArgTypes : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
GrGLSLFunctionArgTypes() {}
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrFunctionArgTypes& _outer = args.fFp.cast<GrFunctionArgTypes>();
|
||||
(void) _outer;
|
||||
SkString takes_float_name = fragBuilder->getMangledFunctionName("takes_float");
|
||||
const GrShaderVar takes_float_args[] = { GrShaderVar("f1", kFloat_GrSLType), GrShaderVar("f2", kFloat2_GrSLType), GrShaderVar("f3", kFloat3_GrSLType), GrShaderVar("f4", kFloat4_GrSLType) };
|
||||
SkString takes_float_matrix_name = fragBuilder->getMangledFunctionName("takes_float_matrix");
|
||||
const GrShaderVar takes_float_matrix_args[] = { GrShaderVar("m2", kFloat2x2_GrSLType), GrShaderVar("m3", kFloat3x3_GrSLType), GrShaderVar("m4", kFloat4x4_GrSLType) };
|
||||
SkString takes_half_name = fragBuilder->getMangledFunctionName("takes_half");
|
||||
const GrShaderVar takes_half_args[] = { GrShaderVar("h1", kHalf_GrSLType), GrShaderVar("h2", kHalf2_GrSLType), GrShaderVar("h3", kHalf3_GrSLType), GrShaderVar("h4", kHalf4_GrSLType) };
|
||||
SkString takes_half_matrix_name = fragBuilder->getMangledFunctionName("takes_half_matrix");
|
||||
const GrShaderVar takes_half_matrix_args[] = { GrShaderVar("m2", kHalf2x2_GrSLType), GrShaderVar("m3", kHalf3x3_GrSLType), GrShaderVar("m4", kHalf4x4_GrSLType) };
|
||||
SkString takes_bool_name = fragBuilder->getMangledFunctionName("takes_bool");
|
||||
const GrShaderVar takes_bool_args[] = { GrShaderVar("b", kBool_GrSLType), GrShaderVar("b2", kBool2_GrSLType), GrShaderVar("b3", kBool3_GrSLType), GrShaderVar("b4", kBool4_GrSLType) };
|
||||
SkString takes_int_name = fragBuilder->getMangledFunctionName("takes_int");
|
||||
const GrShaderVar takes_int_args[] = { GrShaderVar("i", kInt_GrSLType), GrShaderVar("i2", kInt2_GrSLType), GrShaderVar("i3", kInt3_GrSLType), GrShaderVar("i4", kInt4_GrSLType) };
|
||||
fragBuilder->emitFunction(kBool_GrSLType, takes_float_name.c_str(), {takes_float_args, 4},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool_GrSLType, takes_float_matrix_name.c_str(), {takes_float_matrix_args, 3},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool_GrSLType, takes_half_name.c_str(), {takes_half_args, 4},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool_GrSLType, takes_half_matrix_name.c_str(), {takes_half_matrix_args, 3},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool_GrSLType, takes_bool_name.c_str(), {takes_bool_args, 4},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool_GrSLType, takes_int_name.c_str(), {takes_int_args, 4},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(return ((((%s(1.0, float2(2.0), float3(3.0), float4(4.0)) && %s(float2x2(2.0), float3x3(3.0), float4x4(4.0))) && %s(1.0, half2(2.0), half3(3.0), half4(4.0))) && %s(half2x2(2.0), half3x3(3.0), half4x4(4.0))) && %s(true, bool2(true), bool3(true), bool4(true))) && %s(1, int2(2), int3(3), int4(4)) ? half4(1.0) : half4(0.0);
|
||||
)SkSL"
|
||||
, takes_float_name.c_str(), takes_float_matrix_name.c_str(), takes_half_name.c_str(), takes_half_matrix_name.c_str(), takes_bool_name.c_str(), takes_int_name.c_str());
|
||||
}
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
|
||||
}
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrFunctionArgTypes::onCreateGLSLInstance() const {
|
||||
return new GrGLSLFunctionArgTypes();
|
||||
}
|
||||
void GrFunctionArgTypes::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
|
||||
}
|
||||
bool GrFunctionArgTypes::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrFunctionArgTypes& that = other.cast<GrFunctionArgTypes>();
|
||||
(void) that;
|
||||
return true;
|
||||
}
|
||||
GrFunctionArgTypes::GrFunctionArgTypes(const GrFunctionArgTypes& src)
|
||||
: INHERITED(kGrFunctionArgTypes_ClassID, src.optimizationFlags()) {
|
||||
this->cloneAndRegisterAllChildProcessors(src);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrFunctionArgTypes::clone() const {
|
||||
return std::make_unique<GrFunctionArgTypes>(*this);
|
||||
}
|
||||
#if GR_TEST_UTILS
|
||||
SkString GrFunctionArgTypes::onDumpInfo() const {
|
||||
return SkString();
|
||||
}
|
||||
#endif
|
36
tests/sksl/fp/GrFunctionArgTypes.h
Normal file
36
tests/sksl/fp/GrFunctionArgTypes.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*#pragma settings NoInline*/
|
||||
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from GrFunctionArgTypes.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
#ifndef GrFunctionArgTypes_DEFINED
|
||||
#define GrFunctionArgTypes_DEFINED
|
||||
|
||||
#include "include/core/SkM44.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
||||
class GrFunctionArgTypes : public GrFragmentProcessor {
|
||||
public:
|
||||
static std::unique_ptr<GrFragmentProcessor> Make() {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrFunctionArgTypes());
|
||||
}
|
||||
GrFunctionArgTypes(const GrFunctionArgTypes& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "FunctionArgTypes"; }
|
||||
private:
|
||||
GrFunctionArgTypes()
|
||||
: INHERITED(kGrFunctionArgTypes_ClassID, kNone_OptimizationFlags) {
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
#if GR_TEST_UTILS
|
||||
SkString onDumpInfo() const override;
|
||||
#endif
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
using INHERITED = GrFragmentProcessor;
|
||||
};
|
||||
#endif
|
184
tests/sksl/fp/GrFunctionReturnTypes.cpp
Normal file
184
tests/sksl/fp/GrFunctionReturnTypes.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
/*#pragma settings NoInline*/
|
||||
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from GrFunctionReturnTypes.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
#include "GrFunctionReturnTypes.h"
|
||||
|
||||
#include "src/core/SkUtils.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
|
||||
#include "src/sksl/SkSLCPP.h"
|
||||
#include "src/sksl/SkSLUtil.h"
|
||||
class GrGLSLFunctionReturnTypes : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
GrGLSLFunctionReturnTypes() {}
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrFunctionReturnTypes& _outer = args.fFp.cast<GrFunctionReturnTypes>();
|
||||
(void) _outer;
|
||||
SkString returns_float_name = fragBuilder->getMangledFunctionName("returns_float");
|
||||
const GrShaderVar returns_float_args[] = { };
|
||||
SkString returns_float2_name = fragBuilder->getMangledFunctionName("returns_float2");
|
||||
const GrShaderVar returns_float2_args[] = { };
|
||||
SkString returns_float3_name = fragBuilder->getMangledFunctionName("returns_float3");
|
||||
const GrShaderVar returns_float3_args[] = { };
|
||||
SkString returns_float4_name = fragBuilder->getMangledFunctionName("returns_float4");
|
||||
const GrShaderVar returns_float4_args[] = { };
|
||||
SkString returns_float2x2_name = fragBuilder->getMangledFunctionName("returns_float2x2");
|
||||
const GrShaderVar returns_float2x2_args[] = { };
|
||||
SkString returns_float3x3_name = fragBuilder->getMangledFunctionName("returns_float3x3");
|
||||
const GrShaderVar returns_float3x3_args[] = { };
|
||||
SkString returns_float4x4_name = fragBuilder->getMangledFunctionName("returns_float4x4");
|
||||
const GrShaderVar returns_float4x4_args[] = { };
|
||||
SkString returns_half_name = fragBuilder->getMangledFunctionName("returns_half");
|
||||
const GrShaderVar returns_half_args[] = { };
|
||||
SkString returns_half2_name = fragBuilder->getMangledFunctionName("returns_half2");
|
||||
const GrShaderVar returns_half2_args[] = { };
|
||||
SkString returns_half3_name = fragBuilder->getMangledFunctionName("returns_half3");
|
||||
const GrShaderVar returns_half3_args[] = { };
|
||||
SkString returns_half4_name = fragBuilder->getMangledFunctionName("returns_half4");
|
||||
const GrShaderVar returns_half4_args[] = { };
|
||||
SkString returns_half2x2_name = fragBuilder->getMangledFunctionName("returns_half2x2");
|
||||
const GrShaderVar returns_half2x2_args[] = { };
|
||||
SkString returns_half3x3_name = fragBuilder->getMangledFunctionName("returns_half3x3");
|
||||
const GrShaderVar returns_half3x3_args[] = { };
|
||||
SkString returns_half4x4_name = fragBuilder->getMangledFunctionName("returns_half4x4");
|
||||
const GrShaderVar returns_half4x4_args[] = { };
|
||||
SkString returns_bool_name = fragBuilder->getMangledFunctionName("returns_bool");
|
||||
const GrShaderVar returns_bool_args[] = { };
|
||||
SkString returns_bool2_name = fragBuilder->getMangledFunctionName("returns_bool2");
|
||||
const GrShaderVar returns_bool2_args[] = { };
|
||||
SkString returns_bool3_name = fragBuilder->getMangledFunctionName("returns_bool3");
|
||||
const GrShaderVar returns_bool3_args[] = { };
|
||||
SkString returns_bool4_name = fragBuilder->getMangledFunctionName("returns_bool4");
|
||||
const GrShaderVar returns_bool4_args[] = { };
|
||||
SkString returns_int_name = fragBuilder->getMangledFunctionName("returns_int");
|
||||
const GrShaderVar returns_int_args[] = { };
|
||||
SkString returns_int2_name = fragBuilder->getMangledFunctionName("returns_int2");
|
||||
const GrShaderVar returns_int2_args[] = { };
|
||||
SkString returns_int3_name = fragBuilder->getMangledFunctionName("returns_int3");
|
||||
const GrShaderVar returns_int3_args[] = { };
|
||||
SkString returns_int4_name = fragBuilder->getMangledFunctionName("returns_int4");
|
||||
const GrShaderVar returns_int4_args[] = { };
|
||||
fragBuilder->emitFunction(kFloat_GrSLType, returns_float_name.c_str(), {returns_float_args, 0},
|
||||
R"SkSL(return 1.0;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kFloat2_GrSLType, returns_float2_name.c_str(), {returns_float2_args, 0},
|
||||
R"SkSL(return float2(2.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kFloat3_GrSLType, returns_float3_name.c_str(), {returns_float3_args, 0},
|
||||
R"SkSL(return float3(3.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kFloat4_GrSLType, returns_float4_name.c_str(), {returns_float4_args, 0},
|
||||
R"SkSL(return float4(4.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kFloat2x2_GrSLType, returns_float2x2_name.c_str(), {returns_float2x2_args, 0},
|
||||
R"SkSL(return float2x2(2.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kFloat3x3_GrSLType, returns_float3x3_name.c_str(), {returns_float3x3_args, 0},
|
||||
R"SkSL(return float3x3(3.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kFloat4x4_GrSLType, returns_float4x4_name.c_str(), {returns_float4x4_args, 0},
|
||||
R"SkSL(return float4x4(4.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf_GrSLType, returns_half_name.c_str(), {returns_half_args, 0},
|
||||
R"SkSL(return 1.0;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf2_GrSLType, returns_half2_name.c_str(), {returns_half2_args, 0},
|
||||
R"SkSL(return half2(2.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf3_GrSLType, returns_half3_name.c_str(), {returns_half3_args, 0},
|
||||
R"SkSL(return half3(3.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf4_GrSLType, returns_half4_name.c_str(), {returns_half4_args, 0},
|
||||
R"SkSL(return half4(4.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf2x2_GrSLType, returns_half2x2_name.c_str(), {returns_half2x2_args, 0},
|
||||
R"SkSL(return half2x2(2.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf3x3_GrSLType, returns_half3x3_name.c_str(), {returns_half3x3_args, 0},
|
||||
R"SkSL(return half3x3(3.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kHalf4x4_GrSLType, returns_half4x4_name.c_str(), {returns_half4x4_args, 0},
|
||||
R"SkSL(return half4x4(4.0);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool_GrSLType, returns_bool_name.c_str(), {returns_bool_args, 0},
|
||||
R"SkSL(return true;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool2_GrSLType, returns_bool2_name.c_str(), {returns_bool2_args, 0},
|
||||
R"SkSL(return bool2(true);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool3_GrSLType, returns_bool3_name.c_str(), {returns_bool3_args, 0},
|
||||
R"SkSL(return bool3(true);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kBool4_GrSLType, returns_bool4_name.c_str(), {returns_bool4_args, 0},
|
||||
R"SkSL(return bool4(true);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kInt_GrSLType, returns_int_name.c_str(), {returns_int_args, 0},
|
||||
R"SkSL(return 1;
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kInt2_GrSLType, returns_int2_name.c_str(), {returns_int2_args, 0},
|
||||
R"SkSL(return int2(2);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kInt3_GrSLType, returns_int3_name.c_str(), {returns_int3_args, 0},
|
||||
R"SkSL(return int3(3);
|
||||
)SkSL");
|
||||
fragBuilder->emitFunction(kInt4_GrSLType, returns_int4_name.c_str(), {returns_int4_args, 0},
|
||||
R"SkSL(return int4(4);
|
||||
)SkSL");
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
%s();
|
||||
return half4(1.0);
|
||||
)SkSL"
|
||||
, returns_float_name.c_str(), returns_float2_name.c_str(), returns_float3_name.c_str(), returns_float4_name.c_str(), returns_float2x2_name.c_str(), returns_float3x3_name.c_str(), returns_float4x4_name.c_str(), returns_half_name.c_str(), returns_half2_name.c_str(), returns_half3_name.c_str(), returns_half4_name.c_str(), returns_half2x2_name.c_str(), returns_half3x3_name.c_str(), returns_half4x4_name.c_str(), returns_bool_name.c_str(), returns_bool2_name.c_str(), returns_bool3_name.c_str(), returns_bool4_name.c_str(), returns_int_name.c_str(), returns_int2_name.c_str(), returns_int3_name.c_str(), returns_int4_name.c_str());
|
||||
}
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
|
||||
}
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrFunctionReturnTypes::onCreateGLSLInstance() const {
|
||||
return new GrGLSLFunctionReturnTypes();
|
||||
}
|
||||
void GrFunctionReturnTypes::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
|
||||
}
|
||||
bool GrFunctionReturnTypes::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrFunctionReturnTypes& that = other.cast<GrFunctionReturnTypes>();
|
||||
(void) that;
|
||||
return true;
|
||||
}
|
||||
GrFunctionReturnTypes::GrFunctionReturnTypes(const GrFunctionReturnTypes& src)
|
||||
: INHERITED(kGrFunctionReturnTypes_ClassID, src.optimizationFlags()) {
|
||||
this->cloneAndRegisterAllChildProcessors(src);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrFunctionReturnTypes::clone() const {
|
||||
return std::make_unique<GrFunctionReturnTypes>(*this);
|
||||
}
|
||||
#if GR_TEST_UTILS
|
||||
SkString GrFunctionReturnTypes::onDumpInfo() const {
|
||||
return SkString();
|
||||
}
|
||||
#endif
|
36
tests/sksl/fp/GrFunctionReturnTypes.h
Normal file
36
tests/sksl/fp/GrFunctionReturnTypes.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*#pragma settings NoInline*/
|
||||
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from GrFunctionReturnTypes.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
#ifndef GrFunctionReturnTypes_DEFINED
|
||||
#define GrFunctionReturnTypes_DEFINED
|
||||
|
||||
#include "include/core/SkM44.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
||||
class GrFunctionReturnTypes : public GrFragmentProcessor {
|
||||
public:
|
||||
static std::unique_ptr<GrFragmentProcessor> Make() {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrFunctionReturnTypes());
|
||||
}
|
||||
GrFunctionReturnTypes(const GrFunctionReturnTypes& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "FunctionReturnTypes"; }
|
||||
private:
|
||||
GrFunctionReturnTypes()
|
||||
: INHERITED(kGrFunctionReturnTypes_ClassID, kNone_OptimizationFlags) {
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
#if GR_TEST_UTILS
|
||||
SkString onDumpInfo() const override;
|
||||
#endif
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
using INHERITED = GrFragmentProcessor;
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user