uv in x - fix iphone6
For some strange reason, bit 15 seems to create problems on iphone6 for gles. This works fine for mtl. Shift down to bits 13 and 14. Change-Id: Id8e39d46bf23decaf1bd1a6058dd3fc999fc31cb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313907 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
ae1672bdb5
commit
6fd391a016
@ -216,9 +216,10 @@ public:
|
||||
*/
|
||||
static std::pair<uint16_t, uint16_t> PackIndexInTexCoords(
|
||||
uint16_t u, uint16_t v, int pageIndex) {
|
||||
// Pack the two bits of page in bits 14 and 15 of u.
|
||||
// Pack the two bits of page in bits 13 and 14 of u.
|
||||
SkASSERT(0 <= pageIndex && pageIndex < 4);
|
||||
u |= pageIndex << 14;
|
||||
u &= 0x1FFF;
|
||||
u |= pageIndex << 13;
|
||||
return std::make_pair(u, v);
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,9 @@ static void append_index_uv_varyings(GrGLSLPrimitiveProcessor::EmitArgs& args,
|
||||
GrGLSLVarying* st) {
|
||||
using Interpolation = GrGLSLVaryingHandler::Interpolation;
|
||||
// This extracts the texture index and texel coordinates from the same variable
|
||||
// Packing structure: texel coordinates have the 2-bit texture page encoded in bits 14 & 15 of
|
||||
// the x coordinate.
|
||||
// Packing structure: texel coordinates have the 2-bit texture page encoded in bits 13 & 14 of
|
||||
// the x coordinate. It would be nice to use bits 14 and 15, but iphone6 has problem with those
|
||||
// bits when in gles. Iphone6 works fine with bits 14 and 15 in metal.
|
||||
if (args.fShaderCaps->integerSupport()) {
|
||||
if (numTextureSamplers <= 1) {
|
||||
args.fVertBuilder->codeAppendf(R"code(
|
||||
@ -35,8 +36,8 @@ static void append_index_uv_varyings(GrGLSLPrimitiveProcessor::EmitArgs& args,
|
||||
} else {
|
||||
args.fVertBuilder->codeAppendf(R"code(
|
||||
int2 coords = int2(%s.x, %s.y);
|
||||
int texIdx = coords.x >> 14;
|
||||
float2 unormTexCoords = float2(coords.x & 0x3FFF, coords.y);
|
||||
int texIdx = coords.x >> 13;
|
||||
float2 unormTexCoords = float2(coords.x & 0x1FFF, coords.y);
|
||||
)code", inTexCoordsName, inTexCoordsName);
|
||||
}
|
||||
} else {
|
||||
@ -48,8 +49,8 @@ static void append_index_uv_varyings(GrGLSLPrimitiveProcessor::EmitArgs& args,
|
||||
} else {
|
||||
args.fVertBuilder->codeAppendf(R"code(
|
||||
float2 coord = float2(%s.x, %s.y);
|
||||
float texIdx = floor(coord.x * exp2(-14));
|
||||
float2 unormTexCoords = float2(coord.x - texIdx * exp2(14), coord.y);
|
||||
float texIdx = floor(coord.x * exp2(-13));
|
||||
float2 unormTexCoords = float2(coord.x - texIdx * exp2(13), coord.y);
|
||||
)code", inTexCoordsName, inTexCoordsName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user