SkSL GLSL generator writes default precision for sampler2D/samplerExternalOS/sampler2DRect
This is a stop gap. We should probably base the precision decision on the texture format. Also removes all code used to add sampler precision to program keys. The precision that was added to the key did not affect the generated GLSL. Bug: skia:8863 Bug: skia:6718 Change-Id: Ibdb702e1aca5d48d83e2f24cb24010a0b7270871 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234322 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
5f5a481ae1
commit
67529b2543
include/private
src
tests
@ -408,28 +408,6 @@ enum GrShaderFlags {
|
||||
};
|
||||
GR_MAKE_BITFIELD_OPS(GrShaderFlags)
|
||||
|
||||
/**
|
||||
* Precisions of shader language variables. Not all shading languages support precisions or actually
|
||||
* vary the internal precision based on the qualifiers. These currently only apply to float types (
|
||||
* including float vectors and matrices).
|
||||
*/
|
||||
enum GrSLPrecision : int {
|
||||
kLow_GrSLPrecision,
|
||||
kMedium_GrSLPrecision,
|
||||
kHigh_GrSLPrecision,
|
||||
|
||||
// Default precision is a special tag that means "whatever the default for the program/type
|
||||
// combination is". In other words, it maps to the empty string in shader code. There are some
|
||||
// scenarios where kDefault is not allowed (as the default precision for a program, or for
|
||||
// varyings, for example).
|
||||
kDefault_GrSLPrecision,
|
||||
|
||||
// We only consider the "real" precisions here
|
||||
kLast_GrSLPrecision = kHigh_GrSLPrecision,
|
||||
};
|
||||
|
||||
static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
|
||||
|
||||
/** Is the shading language type float (including vectors/matrices)? */
|
||||
static constexpr bool GrSLTypeIsFloatType(GrSLType type) {
|
||||
switch (type) {
|
||||
@ -1080,46 +1058,6 @@ static inline size_t GrCompressedFormatDataSize(GrPixelConfig config,
|
||||
SK_ABORT("Invalid pixel config");
|
||||
}
|
||||
|
||||
/**
|
||||
* Precision qualifier that should be used with a sampler.
|
||||
*/
|
||||
static constexpr GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) {
|
||||
switch (config) {
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kAlpha_8_GrPixelConfig:
|
||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_8_as_Red_GrPixelConfig:
|
||||
case kGray_8_GrPixelConfig:
|
||||
case kGray_8_as_Lum_GrPixelConfig:
|
||||
case kGray_8_as_Red_GrPixelConfig:
|
||||
case kRGB_565_GrPixelConfig:
|
||||
case kRGBA_4444_GrPixelConfig:
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
case kRGB_888_GrPixelConfig:
|
||||
case kRGB_888X_GrPixelConfig:
|
||||
case kRG_88_GrPixelConfig:
|
||||
case kBGRA_8888_GrPixelConfig:
|
||||
case kSRGBA_8888_GrPixelConfig:
|
||||
case kRGB_ETC1_GrPixelConfig:
|
||||
return kLow_GrSLPrecision;
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
return kHigh_GrSLPrecision;
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
case kRGBA_1010102_GrPixelConfig:
|
||||
case kR_16_GrPixelConfig:
|
||||
case kRG_1616_GrPixelConfig:
|
||||
// Experimental (for Y416 and mutant P016/P010)
|
||||
case kRGBA_16161616_GrPixelConfig:
|
||||
case kRG_half_GrPixelConfig:
|
||||
return kMedium_GrSLPrecision;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like SkColorType this describes a layout of pixel data in CPU memory. It specifies the channels,
|
||||
* their type, and width. This exists so that the GPU backend can have private types that have no
|
||||
|
@ -54,44 +54,38 @@ static inline GrSamplerState::Filter clamp_filter(GrTextureType type,
|
||||
}
|
||||
|
||||
GrPrimitiveProcessor::TextureSampler::TextureSampler(GrTextureType textureType,
|
||||
GrPixelConfig config,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
uint32_t extraSamplerKey) {
|
||||
this->reset(textureType, config, samplerState, swizzle, extraSamplerKey);
|
||||
this->reset(textureType, samplerState, swizzle, extraSamplerKey);
|
||||
}
|
||||
|
||||
GrPrimitiveProcessor::TextureSampler::TextureSampler(GrTextureType textureType,
|
||||
GrPixelConfig config,
|
||||
GrSamplerState::Filter filterMode,
|
||||
GrSamplerState::WrapMode wrapXAndY,
|
||||
const GrSwizzle& swizzle) {
|
||||
this->reset(textureType, config, filterMode, wrapXAndY, swizzle);
|
||||
this->reset(textureType, filterMode, wrapXAndY, swizzle);
|
||||
}
|
||||
|
||||
void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
|
||||
GrPixelConfig config,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
uint32_t extraSamplerKey) {
|
||||
SkASSERT(kUnknown_GrPixelConfig != config);
|
||||
fSamplerState = samplerState;
|
||||
fSamplerState.setFilterMode(clamp_filter(textureType, samplerState.filter()));
|
||||
fSwizzle = swizzle;
|
||||
fTextureType = textureType;
|
||||
fConfig = config;
|
||||
fExtraSamplerKey = extraSamplerKey;
|
||||
fIsInitialized = true;
|
||||
}
|
||||
|
||||
void GrPrimitiveProcessor::TextureSampler::reset(GrTextureType textureType,
|
||||
GrPixelConfig config,
|
||||
GrSamplerState::Filter filterMode,
|
||||
GrSamplerState::WrapMode wrapXAndY,
|
||||
const GrSwizzle& swizzle) {
|
||||
SkASSERT(kUnknown_GrPixelConfig != config);
|
||||
filterMode = clamp_filter(textureType, filterMode);
|
||||
fSamplerState = GrSamplerState(wrapXAndY, filterMode);
|
||||
fSwizzle = swizzle;
|
||||
fTextureType = textureType;
|
||||
fConfig = config;
|
||||
fIsInitialized = true;
|
||||
}
|
||||
|
@ -254,38 +254,37 @@ class GrPrimitiveProcessor::TextureSampler {
|
||||
public:
|
||||
TextureSampler() = default;
|
||||
|
||||
TextureSampler(GrTextureType, GrPixelConfig, const GrSamplerState&, const GrSwizzle&,
|
||||
TextureSampler(GrTextureType, const GrSamplerState&, const GrSwizzle&,
|
||||
uint32_t extraSamplerKey);
|
||||
|
||||
explicit TextureSampler(GrTextureType, GrPixelConfig, GrSamplerState::Filter,
|
||||
explicit TextureSampler(GrTextureType, GrSamplerState::Filter,
|
||||
GrSamplerState::WrapMode wrapXAndY, const GrSwizzle&);
|
||||
|
||||
TextureSampler(const TextureSampler&) = delete;
|
||||
TextureSampler& operator=(const TextureSampler&) = delete;
|
||||
|
||||
void reset(GrTextureType, GrPixelConfig, const GrSamplerState&, const GrSwizzle&,
|
||||
void reset(GrTextureType, const GrSamplerState&, const GrSwizzle&,
|
||||
uint32_t extraSamplerKey = 0);
|
||||
void reset(GrTextureType, GrPixelConfig,
|
||||
void reset(GrTextureType,
|
||||
GrSamplerState::Filter,
|
||||
GrSamplerState::WrapMode wrapXAndY,
|
||||
const GrSwizzle& swizzle);
|
||||
|
||||
GrTextureType textureType() const { return fTextureType; }
|
||||
GrPixelConfig config() const { return fConfig; }
|
||||
|
||||
const GrSamplerState& samplerState() const { return fSamplerState; }
|
||||
const GrSwizzle& swizzle() const { return fSwizzle; }
|
||||
|
||||
uint32_t extraSamplerKey() const { return fExtraSamplerKey; }
|
||||
|
||||
bool isInitialized() const { return fConfig != kUnknown_GrPixelConfig; }
|
||||
bool isInitialized() const { return fIsInitialized; }
|
||||
|
||||
private:
|
||||
GrSamplerState fSamplerState;
|
||||
GrSwizzle fSwizzle;
|
||||
GrTextureType fTextureType = GrTextureType::k2D;
|
||||
GrPixelConfig fConfig = kUnknown_GrPixelConfig;
|
||||
uint32_t fExtraSamplerKey = 0;
|
||||
bool fIsInitialized = false;
|
||||
};
|
||||
|
||||
const GrPrimitiveProcessor::TextureSampler& GrPrimitiveProcessor::IthTextureSampler(int i) {
|
||||
|
@ -44,7 +44,7 @@ static inline uint16_t texture_type_key(GrTextureType type) {
|
||||
}
|
||||
|
||||
static uint32_t sampler_key(GrTextureType textureType, const GrSwizzle& swizzle,
|
||||
GrPixelConfig config, const GrShaderCaps& caps) {
|
||||
const GrShaderCaps& caps) {
|
||||
int samplerTypeKey = texture_type_key(textureType);
|
||||
|
||||
GR_STATIC_ASSERT(2 == sizeof(swizzle.asKey()));
|
||||
@ -52,9 +52,7 @@ static uint32_t sampler_key(GrTextureType textureType, const GrSwizzle& swizzle,
|
||||
if (caps.textureSwizzleAppliedInShader()) {
|
||||
swizzleKey = swizzle.asKey();
|
||||
}
|
||||
return SkToU32(samplerTypeKey |
|
||||
swizzleKey << kSamplerOrImageTypeKeyBits |
|
||||
(GrSLSamplerPrecision(config) << (16 + kSamplerOrImageTypeKeyBits)));
|
||||
return SkToU32(samplerTypeKey | swizzleKey << kSamplerOrImageTypeKeyBits);
|
||||
}
|
||||
|
||||
static void add_sampler_keys(GrProcessorKeyBuilder* b, const GrFragmentProcessor& fp,
|
||||
@ -67,7 +65,7 @@ static void add_sampler_keys(GrProcessorKeyBuilder* b, const GrFragmentProcessor
|
||||
const GrFragmentProcessor::TextureSampler& sampler = fp.textureSampler(i);
|
||||
const GrTexture* tex = sampler.peekTexture();
|
||||
uint32_t samplerKey = sampler_key(
|
||||
tex->texturePriv().textureType(), sampler.swizzle(), tex->config(), caps);
|
||||
tex->texturePriv().textureType(), sampler.swizzle(), caps);
|
||||
uint32_t extraSamplerKey = gpu->getExtraSamplerKeyForProgram(
|
||||
sampler.samplerState(), sampler.proxy()->backendFormat());
|
||||
if (extraSamplerKey) {
|
||||
@ -91,7 +89,7 @@ static void add_sampler_keys(GrProcessorKeyBuilder* b, const GrPrimitiveProcesso
|
||||
for (int i = 0; i < numTextureSamplers; ++i) {
|
||||
const GrPrimitiveProcessor::TextureSampler& sampler = pp.textureSampler(i);
|
||||
uint32_t samplerKey = sampler_key(
|
||||
sampler.textureType(), sampler.swizzle(), sampler.config(), caps);
|
||||
sampler.textureType(), sampler.swizzle(), caps);
|
||||
uint32_t extraSamplerKey = sampler.extraSamplerKey();
|
||||
if (extraSamplerKey) {
|
||||
// We first mark the normal sampler key with last bit to flag that it has an extra
|
||||
|
@ -84,8 +84,8 @@ GrCCPathProcessor::GrCCPathProcessor(CoverageMode coverageMode, const GrTexture*
|
||||
const SkMatrix& viewMatrixIfUsingLocalCoords)
|
||||
: INHERITED(kGrCCPathProcessor_ClassID)
|
||||
, fCoverageMode(coverageMode)
|
||||
, fAtlasAccess(atlasTexture->texturePriv().textureType(), atlasTexture->config(),
|
||||
GrSamplerState::Filter::kNearest, GrSamplerState::WrapMode::kClamp, swizzle)
|
||||
, fAtlasAccess(atlasTexture->texturePriv().textureType(), GrSamplerState::Filter::kNearest,
|
||||
GrSamplerState::WrapMode::kClamp, swizzle)
|
||||
, fAtlasSize(SkISize::Make(atlasTexture->width(), atlasTexture->height()))
|
||||
, fAtlasOrigin(atlasOrigin) {
|
||||
// TODO: Can we just assert that atlas has GrCCAtlas::kTextureOrigin and remove fAtlasOrigin?
|
||||
|
@ -154,8 +154,7 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps,
|
||||
for (int i = 0; i < numActiveProxies; ++i) {
|
||||
SkASSERT(proxies[i]);
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params, proxies[i]->textureSwizzle());
|
||||
}
|
||||
this->setTextureSamplerCnt(numActiveProxies);
|
||||
}
|
||||
@ -174,7 +173,7 @@ void GrBitmapTextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* proxies,
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
|
||||
if (!fTextureSamplers[i].isInitialized()) {
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
}
|
||||
}
|
||||
|
@ -241,8 +241,7 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const GrShaderCaps& c
|
||||
for (int i = 0; i < numProxies; ++i) {
|
||||
SkASSERT(proxies[i]);
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params, proxies[i]->textureSwizzle());
|
||||
}
|
||||
this->setTextureSamplerCnt(numProxies);
|
||||
}
|
||||
@ -260,7 +259,7 @@ void GrDistanceFieldA8TextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* pr
|
||||
SkASSERT(proxies[i]);
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
if (!fTextureSamplers[i].isInitialized()) {
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
}
|
||||
}
|
||||
@ -537,8 +536,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
|
||||
for (int i = 0; i < numProxies; ++i) {
|
||||
SkASSERT(proxies[i]);
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params, proxies[i]->textureSwizzle());
|
||||
}
|
||||
this->setTextureSamplerCnt(numProxies);
|
||||
}
|
||||
@ -557,7 +555,7 @@ void GrDistanceFieldPathGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* prox
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
|
||||
if (!fTextureSamplers[i].isInitialized()) {
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
}
|
||||
}
|
||||
@ -861,8 +859,7 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const GrShaderCaps&
|
||||
for (int i = 0; i < numProxies; ++i) {
|
||||
SkASSERT(proxies[i]);
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params, proxies[i]->textureSwizzle());
|
||||
}
|
||||
this->setTextureSamplerCnt(numProxies);
|
||||
}
|
||||
@ -881,7 +878,7 @@ void GrDistanceFieldLCDTextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* p
|
||||
SkASSERT(proxies[i]->isize() == fAtlasSize);
|
||||
|
||||
if (!fTextureSamplers[i].isInitialized()) {
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params,
|
||||
fTextureSamplers[i].reset(proxies[i]->textureType(), params,
|
||||
proxies[i]->textureSwizzle());
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,6 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(SkString* outputColor,
|
||||
const auto& sampler = proc.textureSampler(i);
|
||||
const GrTexture* texture = primProcProxies[i]->peekTexture();
|
||||
SkASSERT(sampler.textureType() == texture->texturePriv().textureType());
|
||||
SkASSERT(sampler.config() == texture->config());
|
||||
texSamplers[i] = this->emitSampler(texture,
|
||||
sampler.samplerState(),
|
||||
sampler.swizzle(),
|
||||
|
@ -101,7 +101,7 @@ private:
|
||||
uint32_t extraSamplerKey = gpu->getExtraSamplerKeyForProgram(samplerState,
|
||||
proxy->backendFormat());
|
||||
|
||||
fSampler.reset(proxy->textureType(), proxy->config(), samplerState, proxy->textureSwizzle(),
|
||||
fSampler.reset(proxy->textureType(), samplerState, proxy->textureSwizzle(),
|
||||
extraSamplerKey);
|
||||
this->setTextureSamplerCnt(1);
|
||||
fInPosition = {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
|
@ -856,13 +856,13 @@ public:
|
||||
}
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const VertexSpec& vertexSpec, const GrShaderCaps& caps,
|
||||
GrTextureType textureType, GrPixelConfig textureConfig,
|
||||
GrTextureType textureType,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle, uint32_t extraSamplerKey,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
|
||||
return sk_sp<QuadPerEdgeAAGeometryProcessor>(new QuadPerEdgeAAGeometryProcessor(
|
||||
vertexSpec, caps, textureType, textureConfig, samplerState, swizzle,
|
||||
extraSamplerKey, std::move(textureColorSpaceXform)));
|
||||
vertexSpec, caps, textureType, samplerState, swizzle, extraSamplerKey,
|
||||
std::move(textureColorSpaceXform)));
|
||||
}
|
||||
|
||||
const char* name() const override { return "QuadPerEdgeAAGeometryProcessor"; }
|
||||
@ -1050,15 +1050,16 @@ private:
|
||||
this->setTextureSamplerCnt(0);
|
||||
}
|
||||
|
||||
QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec, const GrShaderCaps& caps,
|
||||
GrTextureType textureType, GrPixelConfig textureConfig,
|
||||
QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec,
|
||||
const GrShaderCaps& caps,
|
||||
GrTextureType textureType,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
uint32_t extraSamplerKey,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform)
|
||||
: INHERITED(kQuadPerEdgeAAGeometryProcessor_ClassID)
|
||||
, fTextureColorSpaceXform(std::move(textureColorSpaceXform))
|
||||
, fSampler(textureType, textureConfig, samplerState, swizzle, extraSamplerKey) {
|
||||
, fSampler(textureType, samplerState, swizzle, extraSamplerKey) {
|
||||
SkASSERT(spec.hasLocalCoords());
|
||||
this->initializeAttrs(spec);
|
||||
this->setTextureSamplerCnt(1);
|
||||
@ -1136,12 +1137,12 @@ sk_sp<GrGeometryProcessor> MakeProcessor(const VertexSpec& spec) {
|
||||
}
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeTexturedProcessor(const VertexSpec& spec, const GrShaderCaps& caps,
|
||||
GrTextureType textureType, GrPixelConfig textureConfig,
|
||||
const GrSamplerState& samplerState, const GrSwizzle& swizzle, uint32_t extraSamplerKey,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(spec, caps, textureType, textureConfig,
|
||||
samplerState, swizzle, extraSamplerKey,
|
||||
std::move(textureColorSpaceXform));
|
||||
GrTextureType textureType,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle, uint32_t extraSamplerKey,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(spec, caps, textureType, samplerState, swizzle,
|
||||
extraSamplerKey, std::move(textureColorSpaceXform));
|
||||
}
|
||||
|
||||
} // namespace GrQuadPerEdgeAA
|
||||
|
@ -81,8 +81,8 @@ namespace GrQuadPerEdgeAA {
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeProcessor(const VertexSpec& spec);
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeTexturedProcessor(const VertexSpec& spec,
|
||||
const GrShaderCaps& caps, GrTextureType textureType, GrPixelConfig textureConfig,
|
||||
sk_sp<GrGeometryProcessor> MakeTexturedProcessor(
|
||||
const VertexSpec& spec, const GrShaderCaps& caps, GrTextureType textureType,
|
||||
const GrSamplerState& samplerState, const GrSwizzle& swizzle, uint32_t extraSamplerKey,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform);
|
||||
|
||||
|
@ -416,7 +416,6 @@ private:
|
||||
int numProxies = 0;
|
||||
int numTotalQuads = 0;
|
||||
auto textureType = fProxies[0].fProxy->textureType();
|
||||
auto config = fProxies[0].fProxy->config();
|
||||
const GrSwizzle& swizzle = fProxies[0].fProxy->textureSwizzle();
|
||||
GrAAType aaType = this->aaType();
|
||||
for (const auto& op : ChainRange<TextureOp>(this)) {
|
||||
@ -437,7 +436,6 @@ private:
|
||||
if (!proxy->isInstantiated()) {
|
||||
return;
|
||||
}
|
||||
SkASSERT(proxy->config() == config);
|
||||
SkASSERT(proxy->textureType() == textureType);
|
||||
SkASSERT(proxy->textureSwizzle() == swizzle);
|
||||
}
|
||||
@ -457,9 +455,8 @@ private:
|
||||
samplerState, fProxies[0].fProxy->backendFormat());
|
||||
|
||||
sk_sp<GrGeometryProcessor> gp = GrQuadPerEdgeAA::MakeTexturedProcessor(
|
||||
vertexSpec, *target->caps().shaderCaps(),
|
||||
textureType, config, samplerState, swizzle, extraSamplerKey,
|
||||
std::move(fTextureColorSpaceXform));
|
||||
vertexSpec, *target->caps().shaderCaps(), textureType, samplerState, swizzle,
|
||||
extraSamplerKey, std::move(fTextureColorSpaceXform));
|
||||
|
||||
// We'll use a dynamic state array for the GP textures when there are multiple ops.
|
||||
// Otherwise, we use fixed dynamic state to specify the single op's proxy.
|
||||
|
@ -1277,6 +1277,9 @@ void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool g
|
||||
}
|
||||
fFoundExternalSamplerDecl = true;
|
||||
}
|
||||
if (!fFoundRectSamplerDecl && var.fVar->fType == *fContext.fSampler2DRect_Type) {
|
||||
fFoundRectSamplerDecl = true;
|
||||
}
|
||||
}
|
||||
if (wroteType) {
|
||||
this->write(";");
|
||||
@ -1601,6 +1604,13 @@ bool GLSLCodeGenerator::generateCode() {
|
||||
|
||||
if (this->usesPrecisionModifiers()) {
|
||||
this->writeLine("precision mediump float;");
|
||||
this->writeLine("precision mediump sampler2D;");
|
||||
if (fFoundExternalSamplerDecl) {
|
||||
this->writeLine("precision mediump samplerExternalOES;");
|
||||
}
|
||||
if (fFoundRectSamplerDecl) {
|
||||
this->writeLine("precision mediump sampler2DRect;");
|
||||
}
|
||||
}
|
||||
write_stringstream(fExtraFunctions, *rawOut);
|
||||
write_stringstream(body, *rawOut);
|
||||
|
@ -215,6 +215,7 @@ protected:
|
||||
// true if we have run into usages of dFdx / dFdy
|
||||
bool fFoundDerivatives = false;
|
||||
bool fFoundExternalSamplerDecl = false;
|
||||
bool fFoundRectSamplerDecl = false;
|
||||
bool fFoundGSInvocations = false;
|
||||
bool fSetupFragPositionGlobal = false;
|
||||
bool fSetupFragPositionLocal = false;
|
||||
|
@ -326,6 +326,7 @@ DEF_TEST(SkSLUsesPrecisionModifiers, r) {
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" mediump float x = 0.75;\n"
|
||||
@ -578,6 +579,7 @@ DEF_TEST(SkSLDerivatives, r) {
|
||||
*SkSL::ShaderCapsFactory::ShaderDerivativeExtensionString(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = 1.0;\n"
|
||||
@ -588,6 +590,7 @@ DEF_TEST(SkSLDerivatives, r) {
|
||||
"#version 400\n"
|
||||
"#extension GL_OES_standard_derivatives : require\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = dFdx(1.0);\n"
|
||||
@ -1857,6 +1860,7 @@ DEF_TEST(SkSLTypePrecision, r) {
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"highp float f = 1.0;\n"
|
||||
"mediump float h = 2.0;\n"
|
||||
@ -1970,6 +1974,7 @@ DEF_TEST(SkSLForceHighPrecision, r) {
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" mediump float x = sqrt(1.0);\n"
|
||||
@ -1986,6 +1991,7 @@ DEF_TEST(SkSLForceHighPrecision, r) {
|
||||
settings,
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" highp float x = sqrt(1.0);\n"
|
||||
@ -2095,6 +2101,7 @@ DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
"in highp vec2 texcoord;\n"
|
||||
@ -2115,6 +2122,7 @@ DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
|
||||
*SkSL::ShaderCapsFactory::IncompleteShortIntPrecision(),
|
||||
"#version 310es\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
"in highp vec2 texcoord;\n"
|
||||
|
Loading…
Reference in New Issue
Block a user