Merge GrGLSLShaderVar and GrShaderVar
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5087 Change-Id: Ib8943a1da1ea495554feaf5b0992b94fbb9539ab Reviewed-on: https://skia-review.googlesource.com/5087 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
d728f0c1a9
commit
99938a8ef2
@ -11,12 +11,12 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GLBench.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
/*
|
||||
* This is a native GL benchmark for instanced arrays vs vertex buffer objects. To benchmark this
|
||||
@ -111,9 +111,9 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
const char* version = glslCaps->versionDeclString();
|
||||
|
||||
// setup vertex shader
|
||||
GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(glslCaps, &vshaderTxt);
|
||||
@ -131,7 +131,7 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
"}\n");
|
||||
|
||||
// setup fragment shader
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
SkString fshaderTxt(version);
|
||||
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
|
||||
oColor.setTypeModifier(GrShaderVar::kIn_TypeModifier);
|
||||
|
@ -11,12 +11,12 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GLBench.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -101,10 +101,10 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
// corner of the screen than the previous circle.
|
||||
|
||||
// set up vertex shader; this is a trivial vertex shader that passes through position and color
|
||||
GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar oPosition("o_position", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrGLSLShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar oPosition("o_position", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar aColor("a_color", kVec3f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(glslCaps, &vshaderTxt);
|
||||
@ -129,7 +129,7 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
// coded center and compare that to some hard-coded circle radius to compute a coverage.
|
||||
// Then, this coverage is mixed with the coverage from the previous stage and passed to the
|
||||
// next stage.
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
SkString fshaderTxt(version);
|
||||
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
|
||||
oPosition.setTypeModifier(GrShaderVar::kIn_TypeModifier);
|
||||
|
@ -11,12 +11,12 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GLBench.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
@ -69,9 +69,9 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
const char* version = glslCaps->versionDeclString();
|
||||
|
||||
// setup vertex shader
|
||||
GrGLSLShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
SkTArray<GrGLSLShaderVar> aVars;
|
||||
SkTArray<GrGLSLShaderVar> oVars;
|
||||
GrShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
SkTArray<GrShaderVar> aVars;
|
||||
SkTArray<GrShaderVar> oVars;
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(glslCaps, &vshaderTxt);
|
||||
@ -80,9 +80,9 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
for (uint32_t i = 0; i < attribs; i++) {
|
||||
SkString aname;
|
||||
aname.appendf("a_color_%d", i);
|
||||
aVars.push_back(GrGLSLShaderVar(aname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kIn_TypeModifier));
|
||||
aVars.push_back(GrShaderVar(aname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kIn_TypeModifier));
|
||||
aVars.back().appendDecl(glslCaps, &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
|
||||
@ -91,9 +91,9 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
for (uint32_t i = 0; i < maxAttribs; i++) {
|
||||
SkString oname;
|
||||
oname.appendf("o_color_%d", i);
|
||||
oVars.push_back(GrGLSLShaderVar(oname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kOut_TypeModifier));
|
||||
oVars.push_back(GrShaderVar(oname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kOut_TypeModifier));
|
||||
oVars.back().appendDecl(glslCaps, &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
}
|
||||
@ -115,7 +115,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
vshaderTxt.append("}\n");
|
||||
|
||||
// setup fragment shader
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
SkString fshaderTxt(version);
|
||||
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
|
||||
|
||||
|
@ -774,15 +774,15 @@ void GrGLPerlinNoise2::emitCode(EmitArgs& args) {
|
||||
const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec2(1.0)), %s);";
|
||||
|
||||
// Add noise function
|
||||
static const GrGLSLShaderVar gPerlinNoiseArgs[] = {
|
||||
GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLSLShaderVar(noiseVec, kVec2f_GrSLType)
|
||||
static const GrShaderVar gPerlinNoiseArgs[] = {
|
||||
GrShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrShaderVar(noiseVec, kVec2f_GrSLType)
|
||||
};
|
||||
|
||||
static const GrGLSLShaderVar gPerlinNoiseStitchArgs[] = {
|
||||
GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLSLShaderVar(noiseVec, kVec2f_GrSLType),
|
||||
GrGLSLShaderVar(stitchData, kVec2f_GrSLType)
|
||||
static const GrShaderVar gPerlinNoiseStitchArgs[] = {
|
||||
GrShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrShaderVar(noiseVec, kVec2f_GrSLType),
|
||||
GrShaderVar(stitchData, kVec2f_GrSLType)
|
||||
};
|
||||
|
||||
SkString noiseCode;
|
||||
@ -1157,8 +1157,8 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
const char* zUni = uniformHandler->getUniformCStr(fZUni);
|
||||
|
||||
// fade function
|
||||
static const GrGLSLShaderVar fadeArgs[] = {
|
||||
GrGLSLShaderVar("t", kVec3f_GrSLType)
|
||||
static const GrShaderVar fadeArgs[] = {
|
||||
GrShaderVar("t", kVec3f_GrSLType)
|
||||
};
|
||||
SkString fadeFuncName;
|
||||
fsBuilder->emitFunction(kVec3f_GrSLType, "fade", SK_ARRAY_COUNT(fadeArgs),
|
||||
@ -1167,8 +1167,8 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
&fadeFuncName);
|
||||
|
||||
// perm function
|
||||
static const GrGLSLShaderVar permArgs[] = {
|
||||
GrGLSLShaderVar("x", kFloat_GrSLType)
|
||||
static const GrShaderVar permArgs[] = {
|
||||
GrShaderVar("x", kFloat_GrSLType)
|
||||
};
|
||||
SkString permFuncName;
|
||||
SkString permCode("return ");
|
||||
@ -1181,9 +1181,9 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
permCode.c_str(), &permFuncName);
|
||||
|
||||
// grad function
|
||||
static const GrGLSLShaderVar gradArgs[] = {
|
||||
GrGLSLShaderVar("x", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("p", kVec3f_GrSLType)
|
||||
static const GrShaderVar gradArgs[] = {
|
||||
GrShaderVar("x", kFloat_GrSLType),
|
||||
GrShaderVar("p", kVec3f_GrSLType)
|
||||
};
|
||||
SkString gradFuncName;
|
||||
SkString gradCode("return dot(");
|
||||
@ -1194,18 +1194,18 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
gradCode.c_str(), &gradFuncName);
|
||||
|
||||
// lerp function
|
||||
static const GrGLSLShaderVar lerpArgs[] = {
|
||||
GrGLSLShaderVar("a", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("b", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("w", kFloat_GrSLType)
|
||||
static const GrShaderVar lerpArgs[] = {
|
||||
GrShaderVar("a", kFloat_GrSLType),
|
||||
GrShaderVar("b", kFloat_GrSLType),
|
||||
GrShaderVar("w", kFloat_GrSLType)
|
||||
};
|
||||
SkString lerpFuncName;
|
||||
fsBuilder->emitFunction(kFloat_GrSLType, "lerp", SK_ARRAY_COUNT(lerpArgs), lerpArgs,
|
||||
"return a + w * (b - a);", &lerpFuncName);
|
||||
|
||||
// noise function
|
||||
static const GrGLSLShaderVar noiseArgs[] = {
|
||||
GrGLSLShaderVar("p", kVec3f_GrSLType),
|
||||
static const GrShaderVar noiseArgs[] = {
|
||||
GrShaderVar("p", kVec3f_GrSLType),
|
||||
};
|
||||
SkString noiseFuncName;
|
||||
SkString noiseCode;
|
||||
@ -1241,9 +1241,9 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
noiseCode.c_str(), &noiseFuncName);
|
||||
|
||||
// noiseOctaves function
|
||||
static const GrGLSLShaderVar noiseOctavesArgs[] = {
|
||||
GrGLSLShaderVar("p", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("octaves", kFloat_GrSLType),
|
||||
static const GrShaderVar noiseOctavesArgs[] = {
|
||||
GrShaderVar("p", kVec3f_GrSLType),
|
||||
GrShaderVar("octaves", kFloat_GrSLType),
|
||||
};
|
||||
SkString noiseOctavesFuncName;
|
||||
SkString noiseOctavesCode;
|
||||
|
@ -185,6 +185,7 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrTraceMarker.h",
|
||||
"$_src/gpu/GrTracing.h",
|
||||
"$_src/gpu/GrTestUtils.cpp",
|
||||
"$_src/gpu/GrShaderVar.cpp",
|
||||
"$_src/gpu/GrSWMaskHelper.cpp",
|
||||
"$_src/gpu/GrSWMaskHelper.h",
|
||||
"$_src/gpu/GrSoftwarePathRenderer.cpp",
|
||||
@ -421,7 +422,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/glsl/GrGLSLProgramDataManager.h",
|
||||
"$_src/gpu/glsl/GrGLSLShaderBuilder.cpp",
|
||||
"$_src/gpu/glsl/GrGLSLShaderBuilder.h",
|
||||
"$_src/gpu/glsl/GrGLSLShaderVar.h",
|
||||
"$_src/gpu/glsl/GrGLSLUniformHandler.h",
|
||||
"$_src/gpu/glsl/GrGLSLUtil.cpp",
|
||||
"$_src/gpu/glsl/GrGLSLUtil.h",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
@ -8,20 +8,18 @@
|
||||
#ifndef GrShaderVar_DEFINED
|
||||
#define GrShaderVar_DEFINED
|
||||
|
||||
#include "GrTypesPriv.h"
|
||||
#include "SkString.h"
|
||||
#include "GrTypesPriv.h"
|
||||
|
||||
class GrGLSLCaps;
|
||||
|
||||
#define USE_UNIFORM_FLOAT_ARRAYS true
|
||||
|
||||
/**
|
||||
* Represents a variable in a shader
|
||||
*/
|
||||
class GrShaderVar {
|
||||
public:
|
||||
/**
|
||||
* Early versions of GLSL have Varying and Attribute; those are later
|
||||
* deprecated, but we still need to know whether a Varying variable
|
||||
* should be treated as In or Out.
|
||||
*
|
||||
* TODO This really shouldn't live here, but until we have c++11, there is really no good way
|
||||
* to write extensible enums. In reality, only none, out, in, inout, and uniform really
|
||||
* make sense on this base class
|
||||
*/
|
||||
enum TypeModifier {
|
||||
kNone_TypeModifier,
|
||||
kOut_TypeModifier,
|
||||
@ -31,77 +29,178 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Defaults to a float with no precision specifier
|
||||
*/
|
||||
GrShaderVar()
|
||||
: fType(kFloat_GrSLType)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fCount(kNonArray)
|
||||
, fPrecision(kDefault_GrSLPrecision) {
|
||||
}
|
||||
|
||||
GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fName(name)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fName(name)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(typeModifier)
|
||||
, fName(name)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Values for array count that have special meaning. We allow 1-sized arrays.
|
||||
* Values for array count that have special meaning. We allow 1-sized arrays.git
|
||||
*/
|
||||
enum {
|
||||
kNonArray = 0, // not an array
|
||||
kUnsizedArray = -1, // an unsized array (declared with [])
|
||||
};
|
||||
|
||||
/**
|
||||
* Defaults to a non-arry float with no precision specifier, type modifier, or layout qualifier.
|
||||
*/
|
||||
GrShaderVar()
|
||||
: fType(kFloat_GrSLType)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fCount(kNonArray)
|
||||
, fPrecision(kDefault_GrSLPrecision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
}
|
||||
|
||||
GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(kNone_TypeModifier)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(typeModifier)
|
||||
, fCount(kNonArray)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: fType(type)
|
||||
, fTypeModifier(typeModifier)
|
||||
, fCount(arrayCount)
|
||||
, fPrecision(precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(name) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrShaderVar(const GrShaderVar& that)
|
||||
: fType(that.fType)
|
||||
, fTypeModifier(that.fTypeModifier)
|
||||
, fCount(that.fCount)
|
||||
, fPrecision(that.fPrecision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS)
|
||||
, fName(that.fName)
|
||||
, fLayoutQualifier(that.fLayoutQualifier)
|
||||
, fExtraModifiers(that.fExtraModifiers) {
|
||||
SkASSERT(kVoid_GrSLType != that.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets as a non-array.
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
const SkString& name,
|
||||
TypeModifier typeModifier = kNone_TypeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
int count = kNonArray) {
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets as a non-array.
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
const char* name,
|
||||
TypeModifier typeModifier = kNone_TypeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
int count = kNonArray) {
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = kNonArray;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all var options
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
const SkString& name,
|
||||
int count,
|
||||
TypeModifier typeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all var options
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
const char* name,
|
||||
int count,
|
||||
TypeModifier typeModifier,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
fType = type;
|
||||
fTypeModifier = typeModifier;
|
||||
fName = name;
|
||||
fCount = count;
|
||||
fPrecision = precision;
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,12 +270,67 @@ public:
|
||||
*/
|
||||
void setPrecision(GrSLPrecision p) { fPrecision = p; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Set the layout qualifier
|
||||
*/
|
||||
void setLayoutQualifier(const char* layoutQualifier) {
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
}
|
||||
|
||||
void addModifier(const char* modifier) {
|
||||
if (modifier) {
|
||||
fExtraModifiers.appendf("%s ", modifier);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a declaration of this variable to out.
|
||||
*/
|
||||
void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const;
|
||||
|
||||
void appendArrayAccess(int index, SkString* out) const {
|
||||
out->appendf("%s[%d]%s",
|
||||
this->getName().c_str(),
|
||||
index,
|
||||
fUseUniformFloatArrays ? "" : ".x");
|
||||
}
|
||||
|
||||
void appendArrayAccess(const char* indexName, SkString* out) const {
|
||||
out->appendf("%s[%s]%s",
|
||||
this->getName().c_str(),
|
||||
indexName,
|
||||
fUseUniformFloatArrays ? "" : ".x");
|
||||
}
|
||||
|
||||
private:
|
||||
static const char* TypeModifierString(TypeModifier t) {
|
||||
switch (t) {
|
||||
case kNone_TypeModifier:
|
||||
return "";
|
||||
case kIn_TypeModifier:
|
||||
return "in";
|
||||
case kInOut_TypeModifier:
|
||||
return "inout";
|
||||
case kOut_TypeModifier:
|
||||
return "out";
|
||||
case kUniform_TypeModifier:
|
||||
return "uniform";
|
||||
}
|
||||
SkFAIL("Unknown shader variable type modifier.");
|
||||
return ""; // suppress warning
|
||||
}
|
||||
|
||||
GrSLType fType;
|
||||
TypeModifier fTypeModifier;
|
||||
SkString fName;
|
||||
int fCount;
|
||||
GrSLPrecision fPrecision;
|
||||
/// Work around driver bugs on some hardware that don't correctly
|
||||
/// support uniform float []
|
||||
bool fUseUniformFloatArrays;
|
||||
|
||||
SkString fName;
|
||||
SkString fLayoutQualifier;
|
||||
SkString fExtraModifiers;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrStyle.h"
|
||||
#include "effects/GrSimpleTextureEffect.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "SkGrPriv.h"
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "effects/GrTextureDomain.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
@ -1801,14 +1802,14 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString lightFunc;
|
||||
this->emitLightFunc(uniformHandler, fragBuilder, &lightFunc);
|
||||
static const GrGLSLShaderVar gSobelArgs[] = {
|
||||
GrGLSLShaderVar("a", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("b", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("c", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("d", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("e", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("f", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("scale", kFloat_GrSLType),
|
||||
static const GrShaderVar gSobelArgs[] = {
|
||||
GrShaderVar("a", kFloat_GrSLType),
|
||||
GrShaderVar("b", kFloat_GrSLType),
|
||||
GrShaderVar("c", kFloat_GrSLType),
|
||||
GrShaderVar("d", kFloat_GrSLType),
|
||||
GrShaderVar("e", kFloat_GrSLType),
|
||||
GrShaderVar("f", kFloat_GrSLType),
|
||||
GrShaderVar("scale", kFloat_GrSLType),
|
||||
};
|
||||
SkString sobelFuncName;
|
||||
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
@ -1819,10 +1820,10 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
gSobelArgs,
|
||||
"\treturn (-a + b - 2.0 * c + 2.0 * d -e + f) * scale;\n",
|
||||
&sobelFuncName);
|
||||
static const GrGLSLShaderVar gPointToNormalArgs[] = {
|
||||
GrGLSLShaderVar("x", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("y", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("scale", kFloat_GrSLType),
|
||||
static const GrShaderVar gPointToNormalArgs[] = {
|
||||
GrShaderVar("x", kFloat_GrSLType),
|
||||
GrShaderVar("y", kFloat_GrSLType),
|
||||
GrShaderVar("scale", kFloat_GrSLType),
|
||||
};
|
||||
SkString pointToNormalName;
|
||||
fragBuilder->emitFunction(kVec3f_GrSLType,
|
||||
@ -1832,9 +1833,9 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
"\treturn normalize(vec3(-x * scale, -y * scale, 1));\n",
|
||||
&pointToNormalName);
|
||||
|
||||
static const GrGLSLShaderVar gInteriorNormalArgs[] = {
|
||||
GrGLSLShaderVar("m", kFloat_GrSLType, 9),
|
||||
GrGLSLShaderVar("surfaceScale", kFloat_GrSLType),
|
||||
static const GrShaderVar gInteriorNormalArgs[] = {
|
||||
GrShaderVar("m", kFloat_GrSLType, 9),
|
||||
GrShaderVar("surfaceScale", kFloat_GrSLType),
|
||||
};
|
||||
SkString normalBody = emitNormalFunc(le.boundaryMode(),
|
||||
pointToNormalName.c_str(),
|
||||
@ -1922,10 +1923,10 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandl
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"KD", &kd);
|
||||
|
||||
static const GrGLSLShaderVar gLightArgs[] = {
|
||||
GrGLSLShaderVar("normal", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
|
||||
static const GrShaderVar gLightArgs[] = {
|
||||
GrShaderVar("normal", kVec3f_GrSLType),
|
||||
GrShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrShaderVar("lightColor", kVec3f_GrSLType)
|
||||
};
|
||||
SkString lightBody;
|
||||
lightBody.appendf("\tfloat colorScale = %s * dot(normal, surfaceToLight);\n", kd);
|
||||
@ -2017,10 +2018,10 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHand
|
||||
"Shininess",
|
||||
&shininess);
|
||||
|
||||
static const GrGLSLShaderVar gLightArgs[] = {
|
||||
GrGLSLShaderVar("normal", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
|
||||
static const GrShaderVar gLightArgs[] = {
|
||||
GrShaderVar("normal", kVec3f_GrSLType),
|
||||
GrShaderVar("surfaceToLight", kVec3f_GrSLType),
|
||||
GrShaderVar("lightColor", kVec3f_GrSLType)
|
||||
};
|
||||
SkString lightBody;
|
||||
lightBody.appendf("\tvec3 halfDir = vec3(normalize(surfaceToLight + vec3(0, 0, 1)));\n");
|
||||
@ -2156,8 +2157,8 @@ void GrGLSpotLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
|
||||
fSUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
|
||||
|
||||
static const GrGLSLShaderVar gLightColorArgs[] = {
|
||||
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType)
|
||||
static const GrShaderVar gLightColorArgs[] = {
|
||||
GrShaderVar("surfaceToLight", kVec3f_GrSLType)
|
||||
};
|
||||
SkString lightColorBody;
|
||||
lightColorBody.appendf("\tfloat cosAngle = -dot(surfaceToLight, %s);\n", s);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "SkGr.h"
|
||||
#include "SkGrPriv.h"
|
||||
#include "effects/Gr1DKernelEffect.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -639,15 +639,15 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
|
||||
const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec2(1.0)), %s);";
|
||||
|
||||
// Add noise function
|
||||
static const GrGLSLShaderVar gPerlinNoiseArgs[] = {
|
||||
GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLSLShaderVar(noiseVec, kVec2f_GrSLType)
|
||||
static const GrShaderVar gPerlinNoiseArgs[] = {
|
||||
GrShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrShaderVar(noiseVec, kVec2f_GrSLType)
|
||||
};
|
||||
|
||||
static const GrGLSLShaderVar gPerlinNoiseStitchArgs[] = {
|
||||
GrGLSLShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrGLSLShaderVar(noiseVec, kVec2f_GrSLType),
|
||||
GrGLSLShaderVar(stitchData, kVec2f_GrSLType)
|
||||
static const GrShaderVar gPerlinNoiseStitchArgs[] = {
|
||||
GrShaderVar(chanCoord, kFloat_GrSLType),
|
||||
GrShaderVar(noiseVec, kVec2f_GrSLType),
|
||||
GrShaderVar(stitchData, kVec2f_GrSLType)
|
||||
};
|
||||
|
||||
SkString noiseCode;
|
||||
|
@ -5,6 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "Sk4fLinearGradient.h"
|
||||
#include "SkColorSpace_XYZ.h"
|
||||
#include "SkGradientShaderPriv.h"
|
||||
|
@ -708,7 +708,7 @@ void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(E
|
||||
|
||||
// this is the distance along x-axis from the end center to focal point in
|
||||
// transformed coordinates
|
||||
GrGLSLShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
|
||||
GrShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -958,11 +958,11 @@ void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
|
||||
GrShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
|
||||
// params.x = A
|
||||
// params.y = B
|
||||
// params.z = C
|
||||
GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
|
||||
GrShaderVar params = uniformHandler->getUniformVariable(fParamUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -1194,11 +1194,11 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCo
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
|
||||
GrShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
|
||||
// params.x = A
|
||||
// params.y = B
|
||||
// params.z = C
|
||||
GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
|
||||
GrShaderVar params = uniformHandler->getUniformVariable(fParamUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "SkRRect.h"
|
||||
#include "SkStrokeRec.h"
|
||||
#include "batches/GrVertexBatch.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
44
src/gpu/GrShaderVar.cpp
Normal file
44
src/gpu/GrShaderVar.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "GrShaderVar.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
|
||||
void GrShaderVar::appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
|
||||
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
|
||||
if (!fLayoutQualifier.isEmpty()) {
|
||||
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
|
||||
}
|
||||
out->append(fExtraModifiers);
|
||||
if (this->getTypeModifier() != kNone_TypeModifier) {
|
||||
out->append(TypeModifierString(this->getTypeModifier()));
|
||||
out->append(" ");
|
||||
}
|
||||
GrSLType effectiveType = this->getType();
|
||||
if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
|
||||
// Desktop GLSL has added precision qualifiers but they don't do anything.
|
||||
out->appendf("%s ", GrGLSLPrecisionString(fPrecision));
|
||||
}
|
||||
if (this->isArray()) {
|
||||
if (this->isUnsizedArray()) {
|
||||
out->appendf("%s %s[]",
|
||||
GrGLSLTypeString(effectiveType),
|
||||
this->getName().c_str());
|
||||
} else {
|
||||
SkASSERT(this->getArrayCount() > 0);
|
||||
out->appendf("%s %s[%d]",
|
||||
GrGLSLTypeString(effectiveType),
|
||||
this->getName().c_str(),
|
||||
this->getArrayCount());
|
||||
}
|
||||
} else {
|
||||
out->appendf("%s %s",
|
||||
GrGLSLTypeString(effectiveType),
|
||||
this->getName().c_str());
|
||||
}
|
||||
}
|
@ -521,9 +521,9 @@ public:
|
||||
SkAssertResult(fsBuilder->enableFeature(
|
||||
GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature));
|
||||
static const int QUAD_ARGS = 2;
|
||||
GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = {
|
||||
GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision),
|
||||
GrGLSLShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision)
|
||||
GrShaderVar inQuadArgs[QUAD_ARGS] = {
|
||||
GrShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision),
|
||||
GrShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision)
|
||||
};
|
||||
SkString inQuadName;
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "GrBezierEffect.h"
|
||||
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
@ -116,14 +117,14 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
precision = kMedium_GrSLPrecision;
|
||||
}
|
||||
|
||||
GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar gF("gF", kVec2f_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar gFM("gFM", kFloat_GrSLType, 0, precision);
|
||||
GrGLSLShaderVar func("func", kFloat_GrSLType, 0, precision);
|
||||
GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, precision);
|
||||
GrShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, precision);
|
||||
GrShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, precision);
|
||||
GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0, precision);
|
||||
GrShaderVar dfdy("dfdy", kFloat_GrSLType, 0, precision);
|
||||
GrShaderVar gF("gF", kVec2f_GrSLType, 0, precision);
|
||||
GrShaderVar gFM("gFM", kFloat_GrSLType, 0, precision);
|
||||
GrShaderVar func("func", kFloat_GrSLType, 0, precision);
|
||||
|
||||
fragBuilder->declAppend(edgeAlpha);
|
||||
fragBuilder->declAppend(dklmdx);
|
||||
@ -564,14 +565,14 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
args.fFPCoordTransformHandler);
|
||||
|
||||
|
||||
GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrGLSLShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
|
||||
fragBuilder->declAppend(edgeAlpha);
|
||||
fragBuilder->declAppend(dklmdx);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "GrBicubicEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
@ -66,13 +67,13 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
|
||||
SkString cubicBlendName;
|
||||
|
||||
static const GrGLSLShaderVar gCubicBlendArgs[] = {
|
||||
GrGLSLShaderVar("coefficients", kMat44f_GrSLType),
|
||||
GrGLSLShaderVar("t", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("c0", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("c1", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("c2", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("c3", kVec4f_GrSLType),
|
||||
static const GrShaderVar gCubicBlendArgs[] = {
|
||||
GrShaderVar("coefficients", kMat44f_GrSLType),
|
||||
GrShaderVar("t", kFloat_GrSLType),
|
||||
GrShaderVar("c0", kVec4f_GrSLType),
|
||||
GrShaderVar("c1", kVec4f_GrSLType),
|
||||
GrShaderVar("c2", kVec4f_GrSLType),
|
||||
GrShaderVar("c3", kVec4f_GrSLType),
|
||||
};
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
|
||||
@ -22,7 +23,7 @@ public:
|
||||
GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion();
|
||||
|
||||
// Using highp for GLES here in order to avoid some precision issues on specific GPUs.
|
||||
GrGLSLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
GrShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
SkString tmpDecl;
|
||||
tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl);
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkPathPriv.h"
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "GrConvolutionEffect.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
@ -58,7 +59,7 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
|
||||
fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);
|
||||
|
||||
const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
|
||||
const GrShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
|
||||
fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkRect.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
|
||||
|
@ -29,8 +29,8 @@ public:
|
||||
}
|
||||
|
||||
SkString srgbFuncName;
|
||||
static const GrGLSLShaderVar gSrgbArgs[] = {
|
||||
GrGLSLShaderVar("x", kFloat_GrSLType),
|
||||
static const GrShaderVar gSrgbArgs[] = {
|
||||
GrShaderVar("x", kFloat_GrSLType),
|
||||
};
|
||||
switch (ge.mode()) {
|
||||
case GrGammaEffect::Mode::kLinearToSRGB:
|
||||
|
@ -5,6 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "GrMatrixConvolutionEffect.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkRect.h"
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "GrOvalEffect.h"
|
||||
#include "SkRRect.h"
|
||||
#include "SkTLazy.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
@ -334,13 +334,13 @@ bool GrGLGpu::createPLSSetupProgram() {
|
||||
const GrGLSLCaps* glslCaps = this->glCaps().glslCaps();
|
||||
const char* version = glslCaps->versionDeclString();
|
||||
|
||||
GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
if (glslCaps->noperspectiveInterpolationSupport()) {
|
||||
@ -3753,13 +3753,13 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
|
||||
}
|
||||
|
||||
const char* version = glslCaps->versionDeclString();
|
||||
GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uTexture("u_texture", samplerType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar uTexture("u_texture", samplerType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
if (glslCaps->noperspectiveInterpolationSupport()) {
|
||||
@ -3858,20 +3858,19 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
|
||||
}
|
||||
|
||||
const char* version = glslCaps->versionDeclString();
|
||||
GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
|
||||
GrShaderVar::kUniform_TypeModifier);
|
||||
// We need 1, 2, or 4 texture coordinates (depending on parity of each dimension):
|
||||
GrGLSLShaderVar vTexCoords[] = {
|
||||
GrGLSLShaderVar("v_texCoord0", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrGLSLShaderVar("v_texCoord1", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrGLSLShaderVar("v_texCoord2", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrGLSLShaderVar("v_texCoord3", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrShaderVar vTexCoords[] = {
|
||||
GrShaderVar("v_texCoord0", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrShaderVar("v_texCoord1", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrShaderVar("v_texCoord2", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
GrShaderVar("v_texCoord3", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
|
||||
};
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,
|
||||
GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
if (glslCaps->noperspectiveInterpolationSupport()) {
|
||||
@ -4020,9 +4019,9 @@ bool GrGLGpu::createWireRectProgram() {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrGLSLShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
GrShaderVar uColor("u_color", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar uRect("u_rect", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
|
||||
GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
|
||||
const char* version = this->glCaps().glslCaps()->versionDeclString();
|
||||
|
||||
// The rect uniform specifies the rectangle in NDC space as a vec4 (left,top,right,bottom). The
|
||||
@ -4042,7 +4041,7 @@ bool GrGLGpu::createWireRectProgram() {
|
||||
"}"
|
||||
);
|
||||
|
||||
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString fshaderTxt(version);
|
||||
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
|
||||
SkASSERT((COUNT) <= (UNI).fArrayCount || \
|
||||
(1 == (COUNT) && GrGLSLShaderVar::kNonArray == (UNI).fArrayCount))
|
||||
(1 == (COUNT) && GrShaderVar::kNonArray == (UNI).fArrayCount))
|
||||
|
||||
GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
const UniformInfoArray& uniforms,
|
||||
@ -24,7 +24,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
for (int i = 0; i < count; i++) {
|
||||
Uniform& uniform = fUniforms[i];
|
||||
const UniformInfo& builderUniform = uniforms[i];
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
|
||||
SkASSERT(GrShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
|
||||
builderUniform.fVariable.getArrayCount() > 0);
|
||||
SkDEBUGCODE(
|
||||
uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
|
||||
@ -40,7 +40,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
|
||||
PathProcVarying& pathProcVarying = fPathProcVaryings[i];
|
||||
const VaryingInfo& builderPathProcVarying = pathProcVaryings[i];
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == builderPathProcVarying.fVariable.getArrayCount() ||
|
||||
SkASSERT(GrShaderVar::kNonArray == builderPathProcVarying.fVariable.getArrayCount() ||
|
||||
builderPathProcVarying.fVariable.getArrayCount() > 0);
|
||||
SkDEBUGCODE(
|
||||
pathProcVarying.fArrayCount = builderPathProcVarying.fVariable.getArrayCount();
|
||||
@ -68,7 +68,7 @@ void GrGLProgramDataManager::setSamplers(const UniformInfoArray& samplers) const
|
||||
void GrGLProgramDataManager::set1i(UniformHandle u, int32_t i) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kInt_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni));
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fLocation, i));
|
||||
@ -90,7 +90,7 @@ void GrGLProgramDataManager::set1iv(UniformHandle u,
|
||||
void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kFloat_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fLocation, v0));
|
||||
@ -116,7 +116,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
|
||||
void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec2f_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fLocation, v0, v1));
|
||||
@ -139,7 +139,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
|
||||
void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec3f_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fLocation, v0, v1, v2));
|
||||
@ -166,7 +166,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
|
||||
float v3) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec4f_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkDEBUGCODE(this->printUnused(uni);)
|
||||
if (kUnusedUniform != uni.fLocation) {
|
||||
GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fLocation, v0, v1, v2, v3));
|
||||
|
@ -8,11 +8,10 @@
|
||||
#ifndef GrGLProgramDataManager_DEFINED
|
||||
#define GrGLProgramDataManager_DEFINED
|
||||
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
||||
#include "GrAllocator.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "gl/GrGLTypes.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
||||
#include "SkTArray.h"
|
||||
|
||||
@ -27,18 +26,17 @@ class GrGLProgram;
|
||||
class GrGLProgramDataManager : public GrGLSLProgramDataManager {
|
||||
public:
|
||||
struct UniformInfo {
|
||||
GrGLSLShaderVar fVariable;
|
||||
GrShaderVar fVariable;
|
||||
uint32_t fVisibility;
|
||||
GrGLint fLocation;
|
||||
};
|
||||
|
||||
struct VaryingInfo {
|
||||
GrGLSLShaderVar fVariable;
|
||||
GrShaderVar fVariable;
|
||||
GrGLint fLocation;
|
||||
};
|
||||
|
||||
|
||||
// This uses an allocator rather than array so that the GrGLSLShaderVars don't move in memory
|
||||
// This uses an allocator rather than array so that the GrShaderVars don't move in memory
|
||||
// after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
|
||||
// name strings. Otherwise, we'd have to hand out copies.
|
||||
typedef GrTAllocator<UniformInfo> UniformInfoArray;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "GrGLTexture.h"
|
||||
#include "GrGLGpu.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "SkTraceMemoryDump.h"
|
||||
|
||||
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
|
||||
|
@ -30,7 +30,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
uni.fVariable.setType(type);
|
||||
uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
|
||||
uni.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
|
||||
// TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
|
||||
// the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
|
||||
// exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
|
||||
@ -70,7 +70,7 @@ GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(uint32_t visi
|
||||
UniformInfo& sampler = fSamplers.push_back();
|
||||
SkASSERT(GrSLTypeIsCombinedSamplerType(type));
|
||||
sampler.fVariable.setType(type);
|
||||
sampler.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
|
||||
sampler.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
|
||||
sampler.fVariable.setPrecision(precision);
|
||||
sampler.fVariable.setName(mangleName);
|
||||
sampler.fLocation = -1;
|
||||
|
@ -18,7 +18,7 @@ class GrGLUniformHandler : public GrGLSLUniformHandler {
|
||||
public:
|
||||
static const int kUniformsPerBlock = 8;
|
||||
|
||||
const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
const GrShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
return fUniforms[u.toIndex()].fVariable;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ private:
|
||||
SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
|
||||
const char* name) override;
|
||||
|
||||
const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const override {
|
||||
const GrShaderVar& samplerVariable(SamplerHandle handle) const override {
|
||||
return fSamplers[handle.toIndex()].fVariable;
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,8 @@ static void soft_light_component_pos_dst_alpha(GrGLSLFragmentBuilder* fsBuilder,
|
||||
static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
|
||||
// Emit a helper that gets the luminance of a color.
|
||||
SkString getFunction;
|
||||
GrGLSLShaderVar getLumArgs[] = {
|
||||
GrGLSLShaderVar("color", kVec3f_GrSLType),
|
||||
GrShaderVar getLumArgs[] = {
|
||||
GrShaderVar("color", kVec3f_GrSLType),
|
||||
};
|
||||
SkString getLumBody("return dot(vec3(0.3, 0.59, 0.11), color);");
|
||||
fsBuilder->emitFunction(kFloat_GrSLType,
|
||||
@ -135,10 +135,10 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
|
||||
&getFunction);
|
||||
|
||||
// Emit the set luminance function.
|
||||
GrGLSLShaderVar setLumArgs[] = {
|
||||
GrGLSLShaderVar("hueSat", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("alpha", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("lumColor", kVec3f_GrSLType),
|
||||
GrShaderVar setLumArgs[] = {
|
||||
GrShaderVar("hueSat", kVec3f_GrSLType),
|
||||
GrShaderVar("alpha", kFloat_GrSLType),
|
||||
GrShaderVar("lumColor", kVec3f_GrSLType),
|
||||
};
|
||||
SkString setLumBody;
|
||||
setLumBody.printf("float diff = %s(lumColor - hueSat);", getFunction.c_str());
|
||||
@ -169,7 +169,7 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
|
||||
static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
|
||||
// Emit a helper that gets the saturation of a color
|
||||
SkString getFunction;
|
||||
GrGLSLShaderVar getSatArgs[] = { GrGLSLShaderVar("color", kVec3f_GrSLType) };
|
||||
GrShaderVar getSatArgs[] = { GrShaderVar("color", kVec3f_GrSLType) };
|
||||
SkString getSatBody;
|
||||
getSatBody.printf("return max(max(color.r, color.g), color.b) - "
|
||||
"min(min(color.r, color.g), color.b);");
|
||||
@ -184,11 +184,11 @@ static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatF
|
||||
// problems on PowerVR drivers. So instead it returns a vec3 where r, g ,b are the
|
||||
// adjusted min, mid, and max inputs, respectively.
|
||||
SkString helperFunction;
|
||||
GrGLSLShaderVar helperArgs[] = {
|
||||
GrGLSLShaderVar("minComp", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("midComp", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("maxComp", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("sat", kFloat_GrSLType),
|
||||
GrShaderVar helperArgs[] = {
|
||||
GrShaderVar("minComp", kFloat_GrSLType),
|
||||
GrShaderVar("midComp", kFloat_GrSLType),
|
||||
GrShaderVar("maxComp", kFloat_GrSLType),
|
||||
GrShaderVar("sat", kFloat_GrSLType),
|
||||
};
|
||||
static const char kHelperBody[] = "if (minComp < maxComp) {"
|
||||
"vec3 result;"
|
||||
@ -205,9 +205,9 @@ static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatF
|
||||
kHelperBody,
|
||||
&helperFunction);
|
||||
|
||||
GrGLSLShaderVar setSatArgs[] = {
|
||||
GrGLSLShaderVar("hueLumColor", kVec3f_GrSLType),
|
||||
GrGLSLShaderVar("satColor", kVec3f_GrSLType),
|
||||
GrShaderVar setSatArgs[] = {
|
||||
GrShaderVar("hueLumColor", kVec3f_GrSLType),
|
||||
GrShaderVar("satColor", kVec3f_GrSLType),
|
||||
};
|
||||
const char* helpFunc = helperFunction.c_str();
|
||||
SkString setSatBody;
|
||||
|
@ -147,8 +147,8 @@ const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
|
||||
extension);
|
||||
}
|
||||
fInputs.push_back().set(kVec4f_GrSLType,
|
||||
GrGLSLShaderVar::kIn_TypeModifier,
|
||||
"gl_FragCoord",
|
||||
GrShaderVar::kIn_TypeModifier,
|
||||
kDefault_GrSLPrecision,
|
||||
"origin_upper_left");
|
||||
fSetupFragPosition = true;
|
||||
@ -226,9 +226,8 @@ void GrGLSLFragmentShaderBuilder::overrideSampleCoverage(const char* mask) {
|
||||
if (this->addFeature(1 << kSampleMaskOverrideCoverage_GLSLPrivateFeature,
|
||||
"GL_NV_sample_mask_override_coverage")) {
|
||||
// Redeclare gl_SampleMask with layout(override_coverage) if we haven't already.
|
||||
fOutputs.push_back().set(kInt_GrSLType, GrShaderVar::kOut_TypeModifier,
|
||||
"gl_SampleMask", 1, kHigh_GrSLPrecision,
|
||||
"override_coverage");
|
||||
fOutputs.push_back().set(kInt_GrSLType, "gl_SampleMask", 1, GrShaderVar::kOut_TypeModifier,
|
||||
kHigh_GrSLPrecision, "override_coverage");
|
||||
}
|
||||
this->codeAppendf("gl_SampleMask[0] = %s;", mask);
|
||||
fHasInitializedSampleMask = true;
|
||||
@ -283,9 +282,8 @@ void GrGLSLFragmentShaderBuilder::enableCustomOutput() {
|
||||
if (!fHasCustomColorOutput) {
|
||||
fHasCustomColorOutput = true;
|
||||
fCustomColorOutputIndex = fOutputs.count();
|
||||
fOutputs.push_back().set(kVec4f_GrSLType,
|
||||
GrGLSLShaderVar::kOut_TypeModifier,
|
||||
DeclaredColorOutputName());
|
||||
fOutputs.push_back().set(kVec4f_GrSLType, DeclaredColorOutputName(),
|
||||
GrShaderVar::kOut_TypeModifier);
|
||||
fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back());
|
||||
}
|
||||
}
|
||||
@ -303,8 +301,8 @@ void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
|
||||
// output. The condition also co-incides with the condition in whici GLES SL 2.0
|
||||
// requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
|
||||
if (caps.mustDeclareFragmentShaderOutput()) {
|
||||
fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModifier,
|
||||
DeclaredSecondaryColorOutputName());
|
||||
fOutputs.push_back().set(kVec4f_GrSLType, DeclaredSecondaryColorOutputName(),
|
||||
GrShaderVar::kOut_TypeModifier);
|
||||
fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back());
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
#ifndef GrGLSLFragmentShaderBuilder_DEFINED
|
||||
#define GrGLSLFragmentShaderBuilder_DEFINED
|
||||
|
||||
#include "GrBlend.h"
|
||||
#include "GrGLSLShaderBuilder.h"
|
||||
|
||||
#include "GrProcessor.h"
|
||||
|
||||
class GrRenderTarget;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "GrPipeline.h"
|
||||
#include "GrTexturePriv.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
|
@ -20,8 +20,9 @@
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
class GrGLSLCaps;
|
||||
class GrGLSLShaderVar;
|
||||
class GrShaderVar;
|
||||
class GrGLSLVaryingHandler;
|
||||
class GrGLSLExpr4;
|
||||
|
||||
typedef SkSTArray<8, GrGLSLFragmentProcessor*, true> GrGLSLFragProcs;
|
||||
|
||||
@ -43,7 +44,7 @@ public:
|
||||
|
||||
typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle;
|
||||
|
||||
const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const {
|
||||
const GrShaderVar& samplerVariable(SamplerHandle handle) const {
|
||||
return this->uniformHandler()->samplerVariable(handle);
|
||||
}
|
||||
|
||||
@ -79,8 +80,8 @@ public:
|
||||
|
||||
// Used for backend customization of the output color and secondary color variables from the
|
||||
// fragment processor. Only used if the outputs are explicitly declared in the shaders
|
||||
virtual void finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) {}
|
||||
virtual void finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) {}
|
||||
virtual void finalizeFragmentOutputColor(GrShaderVar& outputColor) {}
|
||||
virtual void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) {}
|
||||
|
||||
// number of each input/output type in a single allocation block, used by many builders
|
||||
static const int kVarsPerBlock;
|
||||
|
@ -5,11 +5,11 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GrShaderVar.h"
|
||||
#include "GrSwizzle.h"
|
||||
#include "glsl/GrGLSLShaderBuilder.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
|
||||
GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
|
||||
@ -29,7 +29,7 @@ GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
|
||||
this->main() = "void main() {";
|
||||
}
|
||||
|
||||
void GrGLSLShaderBuilder::declAppend(const GrGLSLShaderVar& var) {
|
||||
void GrGLSLShaderBuilder::declAppend(const GrShaderVar& var) {
|
||||
SkString tempDecl;
|
||||
var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
|
||||
this->codeAppendf("%s;", tempDecl.c_str());
|
||||
@ -44,7 +44,7 @@ void GrGLSLShaderBuilder::appendPrecisionModifier(GrSLPrecision precision) {
|
||||
void GrGLSLShaderBuilder::emitFunction(GrSLType returnType,
|
||||
const char* name,
|
||||
int argCnt,
|
||||
const GrGLSLShaderVar* args,
|
||||
const GrShaderVar* args,
|
||||
const char* body,
|
||||
SkString* outName) {
|
||||
this->functions().append(GrGLSLTypeString(returnType));
|
||||
@ -73,7 +73,7 @@ void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
|
||||
const char* coordName,
|
||||
GrSLType varyingType) const {
|
||||
const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
|
||||
const GrGLSLShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
|
||||
const GrShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
|
||||
GrSLType samplerType = sampler.getType();
|
||||
if (samplerType == kTexture2DRectSampler_GrSLType) {
|
||||
if (varyingType == kVec2f_GrSLType) {
|
||||
@ -132,9 +132,9 @@ void GrGLSLShaderBuilder::appendColorGamutXform(SkString* out,
|
||||
// Our color is (r, g, b, a), but we want to multiply (r, g, b, 1) by our matrix, then
|
||||
// re-insert the original alpha. The supplied srcColor is likely to be of the form
|
||||
// "texture(...)", and we don't want to evaluate that twice, so wrap everything in a function.
|
||||
static const GrGLSLShaderVar gColorGamutXformArgs[] = {
|
||||
GrGLSLShaderVar("color", kVec4f_GrSLType),
|
||||
GrGLSLShaderVar("xform", kMat44f_GrSLType),
|
||||
static const GrShaderVar gColorGamutXformArgs[] = {
|
||||
GrShaderVar("color", kVec4f_GrSLType),
|
||||
GrShaderVar("xform", kMat44f_GrSLType),
|
||||
};
|
||||
SkString functionBody;
|
||||
// Gamut xform, clamp to destination gamut
|
||||
@ -162,7 +162,7 @@ void GrGLSLShaderBuilder::appendColorGamutXform(const char* srcColor,
|
||||
void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
|
||||
SamplerHandle samplerHandle,
|
||||
const char* coordExpr) const {
|
||||
const GrGLSLShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
|
||||
const GrShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
|
||||
SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
|
||||
SkASSERT(GrSLTypeIsCombinedSamplerType(sampler.getType()));
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
#define GrGLSLShaderBuilder_DEFINED
|
||||
|
||||
#include "GrAllocator.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
#include "SkTDArray.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
@ -118,7 +118,7 @@ public:
|
||||
/**
|
||||
* Appends a variable declaration to one of the shaders
|
||||
*/
|
||||
void declAppend(const GrGLSLShaderVar& var);
|
||||
void declAppend(const GrShaderVar& var);
|
||||
|
||||
/**
|
||||
* Appends a precision qualifier followed by a space, if relevant for the GLSL version.
|
||||
@ -129,7 +129,7 @@ public:
|
||||
void emitFunction(GrSLType returnType,
|
||||
const char* name,
|
||||
int argCnt,
|
||||
const GrGLSLShaderVar* args,
|
||||
const GrShaderVar* args,
|
||||
const char* body,
|
||||
SkString* outName);
|
||||
|
||||
@ -161,7 +161,7 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
typedef GrTAllocator<GrGLSLShaderVar> VarArray;
|
||||
typedef GrTAllocator<GrShaderVar> VarArray;
|
||||
void appendDecls(const VarArray& vars, SkString* out) const;
|
||||
|
||||
/**
|
||||
|
@ -1,242 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrGLSLShaderVar_DEFINED
|
||||
#define GrGLSLShaderVar_DEFINED
|
||||
|
||||
#include "GrShaderVar.h"
|
||||
#include "../glsl/GrGLSL.h"
|
||||
#include "../glsl/GrGLSLCaps.h"
|
||||
|
||||
#define USE_UNIFORM_FLOAT_ARRAYS true
|
||||
|
||||
/**
|
||||
* Represents a variable in a shader
|
||||
*/
|
||||
class GrGLSLShaderVar : public GrShaderVar {
|
||||
public:
|
||||
/**
|
||||
* Defaults to a float with no precision specifier
|
||||
*/
|
||||
GrGLSLShaderVar()
|
||||
: GrShaderVar()
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
}
|
||||
|
||||
GrGLSLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: GrShaderVar(name, type, arrayCount, precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
||||
}
|
||||
|
||||
GrGLSLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
||||
int arrayCount = kNonArray, GrSLPrecision precision = kDefault_GrSLPrecision)
|
||||
: GrShaderVar(name, type, typeModifier, arrayCount, precision)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
}
|
||||
|
||||
GrGLSLShaderVar(const GrShaderVar& var)
|
||||
: GrShaderVar(var)
|
||||
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != var.getType());
|
||||
}
|
||||
|
||||
GrGLSLShaderVar(const GrGLSLShaderVar& var)
|
||||
: GrShaderVar(var.c_str(), var.getType(), var.getTypeModifier(),
|
||||
var.getArrayCount(), var.getPrecision())
|
||||
, fUseUniformFloatArrays(var.fUseUniformFloatArrays)
|
||||
, fLayoutQualifier(var.fLayoutQualifier)
|
||||
, fExtraModifiers(var.fExtraModifiers) {
|
||||
SkASSERT(kVoid_GrSLType != var.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Values for array count that have special meaning. We allow 1-sized arrays.
|
||||
*/
|
||||
enum {
|
||||
kNonArray = 0, // not an array
|
||||
kUnsizedArray = -1, // an unsized array (declared with [])
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets as a non-array.
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const SkString& name,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
INHERITED::set(type, name, typeModifier, precision);
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets as a non-array.
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const char* name,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
INHERITED::set(type, name, typeModifier, precision);
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all var options
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const SkString& name,
|
||||
int count,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
INHERITED::set(type, name, typeModifier, precision, count);
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all var options
|
||||
*/
|
||||
void set(GrSLType type,
|
||||
TypeModifier typeModifier,
|
||||
const char* name,
|
||||
int count,
|
||||
GrSLPrecision precision = kDefault_GrSLPrecision,
|
||||
const char* layoutQualifier = nullptr,
|
||||
const char* extraModifiers = nullptr,
|
||||
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
||||
SkASSERT(kVoid_GrSLType != type);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
|
||||
INHERITED::set(type, name, typeModifier, precision, count);
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
if (extraModifiers) {
|
||||
fExtraModifiers.printf("%s ", extraModifiers);
|
||||
}
|
||||
fUseUniformFloatArrays = useUniformFloatArrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the layout qualifier
|
||||
*/
|
||||
void setLayoutQualifier(const char* layoutQualifier) {
|
||||
fLayoutQualifier = layoutQualifier;
|
||||
}
|
||||
|
||||
void addModifier(const char* modifier) {
|
||||
if (modifier) {
|
||||
fExtraModifiers.appendf("%s ", modifier);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a declaration of this variable to out.
|
||||
*/
|
||||
void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
|
||||
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
|
||||
if (!fLayoutQualifier.isEmpty()) {
|
||||
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
|
||||
}
|
||||
out->append(fExtraModifiers);
|
||||
if (this->getTypeModifier() != kNone_TypeModifier) {
|
||||
out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
|
||||
out->append(" ");
|
||||
}
|
||||
GrSLType effectiveType = this->getType();
|
||||
if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
|
||||
// Desktop GLSL has added precision qualifiers but they don't do anything.
|
||||
out->appendf("%s ", GrGLSLPrecisionString(fPrecision));
|
||||
}
|
||||
if (this->isArray()) {
|
||||
if (this->isUnsizedArray()) {
|
||||
out->appendf("%s %s[]",
|
||||
GrGLSLTypeString(effectiveType),
|
||||
this->getName().c_str());
|
||||
} else {
|
||||
SkASSERT(this->getArrayCount() > 0);
|
||||
out->appendf("%s %s[%d]",
|
||||
GrGLSLTypeString(effectiveType),
|
||||
this->getName().c_str(),
|
||||
this->getArrayCount());
|
||||
}
|
||||
} else {
|
||||
out->appendf("%s %s",
|
||||
GrGLSLTypeString(effectiveType),
|
||||
this->getName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void appendArrayAccess(int index, SkString* out) const {
|
||||
out->appendf("%s[%d]%s",
|
||||
this->getName().c_str(),
|
||||
index,
|
||||
fUseUniformFloatArrays ? "" : ".x");
|
||||
}
|
||||
|
||||
void appendArrayAccess(const char* indexName, SkString* out) const {
|
||||
out->appendf("%s[%s]%s",
|
||||
this->getName().c_str(),
|
||||
indexName,
|
||||
fUseUniformFloatArrays ? "" : ".x");
|
||||
}
|
||||
|
||||
private:
|
||||
static const char* TypeModifierString(const GrGLSLCaps* glslCaps, TypeModifier t) {
|
||||
switch (t) {
|
||||
case kNone_TypeModifier:
|
||||
return "";
|
||||
case kIn_TypeModifier:
|
||||
return "in";
|
||||
case kInOut_TypeModifier:
|
||||
return "inout";
|
||||
case kOut_TypeModifier:
|
||||
return "out";
|
||||
case kUniform_TypeModifier:
|
||||
return "uniform";
|
||||
}
|
||||
SkFAIL("Unknown shader variable type modifier.");
|
||||
return ""; // suppress warning
|
||||
}
|
||||
|
||||
/// Work around driver bugs on some hardware that don't correctly
|
||||
/// support uniform float []
|
||||
bool fUseUniformFloatArrays;
|
||||
|
||||
SkString fLayoutQualifier;
|
||||
SkString fExtraModifiers;
|
||||
|
||||
typedef GrShaderVar INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
@ -9,7 +9,8 @@
|
||||
#define GrGLSLUniformHandler_DEFINED
|
||||
|
||||
#include "GrGLSLProgramDataManager.h"
|
||||
#include "GrGLSLShaderVar.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "GrSwizzle.h"
|
||||
|
||||
class GrGLSLProgramBuilder;
|
||||
|
||||
@ -46,7 +47,7 @@ public:
|
||||
outName);
|
||||
}
|
||||
|
||||
virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
virtual const GrShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
|
||||
/**
|
||||
* Shortcut for getUniformVariable(u).c_str()
|
||||
@ -60,7 +61,7 @@ protected:
|
||||
GrGLSLProgramBuilder* fProgramBuilder;
|
||||
|
||||
private:
|
||||
virtual const GrGLSLShaderVar& samplerVariable(SamplerHandle) const = 0;
|
||||
virtual const GrShaderVar& samplerVariable(SamplerHandle) const = 0;
|
||||
virtual GrSwizzle samplerSwizzle(SamplerHandle) const = 0;
|
||||
|
||||
virtual SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
|
||||
void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute* input,
|
||||
@ -81,7 +81,7 @@ void GrGLSLVaryingHandler::emitAttributes(const GrGeometryProcessor& gp) {
|
||||
void GrGLSLVaryingHandler::addAttribute(const GrShaderVar& var) {
|
||||
SkASSERT(GrShaderVar::kIn_TypeModifier == var.getTypeModifier());
|
||||
for (int j = 0; j < fVertexInputs.count(); ++j) {
|
||||
const GrGLSLShaderVar& attr = fVertexInputs[j];
|
||||
const GrShaderVar& attr = fVertexInputs[j];
|
||||
// if attribute already added, don't add it again
|
||||
if (attr.getName().equals(var.getName())) {
|
||||
return;
|
||||
@ -111,23 +111,23 @@ void GrGLSLVaryingHandler::finalize() {
|
||||
const VaryingInfo& v = this->fVaryings[i];
|
||||
const char* modifier = v.fIsFlat ? "flat" : fDefaultInterpolationModifier;
|
||||
if (v.fVisibility & kVertex_GrShaderFlag) {
|
||||
fVertexOutputs.push_back().set(v.fType, GrShaderVar::kOut_TypeModifier, v.fVsOut,
|
||||
fVertexOutputs.push_back().set(v.fType, v.fVsOut, GrShaderVar::kOut_TypeModifier,
|
||||
v.fPrecision, nullptr, modifier);
|
||||
if (v.fVisibility & kGeometry_GrShaderFlag) {
|
||||
fGeomInputs.push_back().set(v.fType, GrShaderVar::kIn_TypeModifier, v.fVsOut,
|
||||
GrShaderVar::kUnsizedArray, v.fPrecision, nullptr,
|
||||
fGeomInputs.push_back().set(v.fType, v.fVsOut, GrShaderVar::kUnsizedArray,
|
||||
GrShaderVar::kIn_TypeModifier, v.fPrecision, nullptr,
|
||||
modifier);
|
||||
}
|
||||
}
|
||||
if (v.fVisibility & kFragment_GrShaderFlag) {
|
||||
const char* fsIn = v.fVsOut.c_str();
|
||||
if (v.fVisibility & kGeometry_GrShaderFlag) {
|
||||
fGeomOutputs.push_back().set(v.fType, GrGLSLShaderVar::kOut_TypeModifier,
|
||||
v.fGsOut, v.fPrecision, nullptr, modifier);
|
||||
fGeomOutputs.push_back().set(v.fType, v.fGsOut, GrShaderVar::kOut_TypeModifier,
|
||||
v.fPrecision, nullptr, modifier);
|
||||
fsIn = v.fGsOut.c_str();
|
||||
}
|
||||
fFragInputs.push_back().set(v.fType, GrShaderVar::kIn_TypeModifier, fsIn,
|
||||
v.fPrecision, nullptr, modifier);
|
||||
fFragInputs.push_back().set(v.fType, fsIn, GrShaderVar::kIn_TypeModifier, v.fPrecision,
|
||||
nullptr, modifier);
|
||||
}
|
||||
}
|
||||
this->onFinalize();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include "GrAllocator.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "GrTypesPriv.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
|
||||
class GrGLSLProgramBuilder;
|
||||
|
||||
@ -152,7 +152,7 @@ protected:
|
||||
};
|
||||
|
||||
typedef GrTAllocator<VaryingInfo> VaryingList;
|
||||
typedef GrTAllocator<GrGLSLShaderVar> VarArray;
|
||||
typedef GrTAllocator<GrShaderVar> VarArray;
|
||||
typedef GrGLSLProgramDataManager::VaryingHandle VaryingHandle;
|
||||
|
||||
VaryingList fVaryings;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
#include "GrXferProcessor.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "GrRenderTargetPriv.h"
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
@ -1367,7 +1368,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
|
||||
}
|
||||
|
||||
if (kRect_ShapeFlag != (fBatchInfo.fShapeTypes | fBatchInfo.fInnerShapeTypes)) {
|
||||
GrGLSLShaderVar x("x", kVec2f_GrSLType, GrGLSLShaderVar::kNonArray, kHigh_GrSLPrecision);
|
||||
GrShaderVar x("x", kVec2f_GrSLType, GrShaderVar::kNonArray, kHigh_GrSLPrecision);
|
||||
f->emitFunction(kFloat_GrSLType, "square", 1, &x, "return dot(x, x);", &fSquareFun);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "GrVkTexture.h"
|
||||
#include "GrVkUniformBuffer.h"
|
||||
#include "GrVkVertexBuffer.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "SkPoint.h"
|
||||
#include "SkRect.h"
|
||||
|
||||
|
@ -7,10 +7,12 @@
|
||||
|
||||
#include "vk/GrVkPipelineStateBuilder.h"
|
||||
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "vk/GrVkDescriptorSetManager.h"
|
||||
#include "vk/GrVkGpu.h"
|
||||
#include "vk/GrVkRenderPass.h"
|
||||
|
||||
|
||||
GrVkPipelineState* GrVkPipelineStateBuilder::CreatePipelineState(
|
||||
GrVkGpu* gpu,
|
||||
const GrPipeline& pipeline,
|
||||
@ -51,11 +53,11 @@ const GrGLSLCaps* GrVkPipelineStateBuilder::glslCaps() const {
|
||||
return fGpu->vkCaps().glslCaps();
|
||||
}
|
||||
|
||||
void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) {
|
||||
void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrShaderVar& outputColor) {
|
||||
outputColor.setLayoutQualifier("location = 0, index = 0");
|
||||
}
|
||||
|
||||
void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) {
|
||||
void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrShaderVar& outputColor) {
|
||||
outputColor.setLayoutQualifier("location = 0, index = 1");
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
|
||||
GrVkGpu* gpu() const { return fGpu; }
|
||||
|
||||
void finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) override;
|
||||
void finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) override;
|
||||
void finalizeFragmentOutputColor(GrShaderVar& outputColor) override;
|
||||
void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override;
|
||||
|
||||
private:
|
||||
GrVkPipelineStateBuilder(GrVkGpu*,
|
||||
|
@ -26,7 +26,7 @@ GrVkPipelineStateDataManager::GrVkPipelineStateDataManager(const UniformInfoArra
|
||||
for (int i = 0; i < count; i++) {
|
||||
Uniform& uniform = fUniforms[i];
|
||||
const GrVkUniformHandler::UniformInfo uniformInfo = uniforms[i];
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uniformInfo.fVariable.getArrayCount() ||
|
||||
SkASSERT(GrShaderVar::kNonArray == uniformInfo.fVariable.getArrayCount() ||
|
||||
uniformInfo.fVariable.getArrayCount() > 0);
|
||||
SkDEBUGCODE(
|
||||
uniform.fArrayCount = uniformInfo.fVariable.getArrayCount();
|
||||
@ -57,7 +57,7 @@ void* GrVkPipelineStateDataManager::getBufferPtrAndMarkDirty(const Uniform& uni)
|
||||
void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kInt_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
memcpy(buffer, &i, sizeof(int32_t));
|
||||
}
|
||||
@ -69,7 +69,7 @@ void GrVkPipelineStateDataManager::set1iv(UniformHandle u,
|
||||
SkASSERT(uni.fType == kInt_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(int32_t) == 4);
|
||||
@ -83,7 +83,7 @@ void GrVkPipelineStateDataManager::set1iv(UniformHandle u,
|
||||
void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kFloat_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
memcpy(buffer, &v0, sizeof(float));
|
||||
@ -96,7 +96,7 @@ void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
|
||||
SkASSERT(uni.fType == kFloat_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -110,7 +110,7 @@ void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
|
||||
void GrVkPipelineStateDataManager::set2f(UniformHandle u, float v0, float v1) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec2f_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
float v[2] = { v0, v1 };
|
||||
@ -124,7 +124,7 @@ void GrVkPipelineStateDataManager::set2fv(UniformHandle u,
|
||||
SkASSERT(uni.fType == kVec2f_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -138,7 +138,7 @@ void GrVkPipelineStateDataManager::set2fv(UniformHandle u,
|
||||
void GrVkPipelineStateDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec3f_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
float v[3] = { v0, v1, v2 };
|
||||
@ -152,7 +152,7 @@ void GrVkPipelineStateDataManager::set3fv(UniformHandle u,
|
||||
SkASSERT(uni.fType == kVec3f_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -170,7 +170,7 @@ void GrVkPipelineStateDataManager::set4f(UniformHandle u,
|
||||
float v3) const {
|
||||
const Uniform& uni = fUniforms[u.toIndex()];
|
||||
SkASSERT(uni.fType == kVec4f_GrSLType);
|
||||
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
|
||||
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
float v[4] = { v0, v1, v2, v3 };
|
||||
@ -184,7 +184,7 @@ void GrVkPipelineStateDataManager::set4fv(UniformHandle u,
|
||||
SkASSERT(uni.fType == kVec4f_GrSLType);
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
|
||||
void* buffer = this->getBufferPtrAndMarkDirty(uni);
|
||||
SkASSERT(sizeof(float) == 4);
|
||||
@ -230,7 +230,7 @@ template<int N> inline void GrVkPipelineStateDataManager::setMatrices(UniformHan
|
||||
SkASSERT(uni.fType == kMat22f_GrSLType + (N - 2));
|
||||
SkASSERT(arrayCount > 0);
|
||||
SkASSERT(arrayCount <= uni.fArrayCount ||
|
||||
(1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCount));
|
||||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
|
||||
|
||||
void* buffer;
|
||||
if (GrVkUniformHandler::kVertexBinding == uni.fBinding) {
|
||||
|
@ -155,7 +155,7 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
||||
uni.fVariable.setPrecision(precision);
|
||||
// When outputing the GLSL, only the outer uniform block will get the Uniform modifier. Thus
|
||||
// we set the modifier to none for all uniforms declared inside the block.
|
||||
uni.fVariable.setTypeModifier(GrGLSLShaderVar::kNone_TypeModifier);
|
||||
uni.fVariable.setTypeModifier(GrShaderVar::kNone_TypeModifier);
|
||||
|
||||
uint32_t* currentOffset = kVertex_GrShaderFlag == visibility ? &fCurrentVertexUBOOffset
|
||||
: &fCurrentFragmentUBOOffset;
|
||||
@ -184,7 +184,7 @@ GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(uint32_t visi
|
||||
UniformInfo& info = fSamplers.push_back();
|
||||
SkASSERT(GrSLTypeIsCombinedSamplerType(type));
|
||||
info.fVariable.setType(type);
|
||||
info.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
|
||||
info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
|
||||
info.fVariable.setPrecision(precision);
|
||||
info.fVariable.setName(mangleName);
|
||||
SkString layoutQualifier;
|
||||
|
@ -8,10 +8,9 @@
|
||||
#ifndef GrVkUniformHandler_DEFINED
|
||||
#define GrVkUniformHandler_DEFINED
|
||||
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
#include "GrAllocator.h"
|
||||
#include "glsl/GrGLSLShaderVar.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class GrVkUniformHandler : public GrGLSLUniformHandler {
|
||||
public:
|
||||
@ -28,13 +27,13 @@ public:
|
||||
|
||||
// fUBOffset is only valid if the GrSLType of the fVariable is not a sampler
|
||||
struct UniformInfo {
|
||||
GrGLSLShaderVar fVariable;
|
||||
GrShaderVar fVariable;
|
||||
uint32_t fVisibility;
|
||||
uint32_t fUBOffset;
|
||||
};
|
||||
typedef GrTAllocator<UniformInfo> UniformInfoArray;
|
||||
|
||||
const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
const GrShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
return fUniforms[u.toIndex()].fVariable;
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ private:
|
||||
const char* name) override;
|
||||
|
||||
int numSamplers() const { return fSamplers.count(); }
|
||||
const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const override {
|
||||
const GrShaderVar& samplerVariable(SamplerHandle handle) const override {
|
||||
return fSamplers[handle.toIndex()].fVariable;
|
||||
}
|
||||
GrSwizzle samplerSwizzle(SamplerHandle handle) const override {
|
||||
|
@ -55,7 +55,7 @@ static inline int grsltype_to_location_size(GrSLType type) {
|
||||
void finalize_helper(GrVkVaryingHandler::VarArray& vars) {
|
||||
int locationIndex = 0;
|
||||
for (int i = 0; i < vars.count(); ++i) {
|
||||
GrGLSLShaderVar& var = vars[i];
|
||||
GrShaderVar& var = vars[i];
|
||||
SkString location;
|
||||
location.appendf("location = %d", locationIndex);
|
||||
var.setLayoutQualifier(location.c_str());
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/GLTestContext.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
|
||||
using sk_gpu_test::GLTestContext;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user