зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1686635 - Reformat SWGL C++ code. r=lsalzman
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D101319
This commit is contained in:
Родитель
8509639277
Коммит
74eab25fd6
|
@ -59,8 +59,7 @@ static NO_INLINE void scale_blit(Texture& srctex, const IntRect& srcReq,
|
|||
src += bpp * (fracX / dstWidth);
|
||||
fracY %= dstHeight;
|
||||
fracX %= dstWidth;
|
||||
for (int rows = clippedDest.height(); rows > 0;
|
||||
rows--) {
|
||||
for (int rows = clippedDest.height(); rows > 0; rows--) {
|
||||
if (srcWidth == dstWidth) {
|
||||
// No scaling, so just do a fast copy.
|
||||
memcpy(dest, src, span * bpp);
|
||||
|
@ -68,13 +67,16 @@ static NO_INLINE void scale_blit(Texture& srctex, const IntRect& srcReq,
|
|||
// Do scaling with different source and dest widths.
|
||||
switch (bpp) {
|
||||
case 1:
|
||||
scale_row((uint8_t*)dest, dstWidth, (uint8_t*)src, srcWidth, span, fracX);
|
||||
scale_row((uint8_t*)dest, dstWidth, (uint8_t*)src, srcWidth, span,
|
||||
fracX);
|
||||
break;
|
||||
case 2:
|
||||
scale_row((uint16_t*)dest, dstWidth, (uint16_t*)src, srcWidth, span, fracX);
|
||||
scale_row((uint16_t*)dest, dstWidth, (uint16_t*)src, srcWidth, span,
|
||||
fracX);
|
||||
break;
|
||||
case 4:
|
||||
scale_row((uint32_t*)dest, dstWidth, (uint32_t*)src, srcWidth, span, fracX);
|
||||
scale_row((uint32_t*)dest, dstWidth, (uint32_t*)src, srcWidth, span,
|
||||
fracX);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
@ -174,8 +176,7 @@ static NO_INLINE void linear_blit(Texture& srctex, const IntRect& srcReq,
|
|||
destStride = -destStride;
|
||||
}
|
||||
int span = dstBounds.width();
|
||||
for (int rows = dstBounds.height(); rows > 0;
|
||||
rows--) {
|
||||
for (int rows = dstBounds.height(); rows > 0; rows--) {
|
||||
switch (bpp) {
|
||||
case 1:
|
||||
linear_row_blit((uint8_t*)dest, span, srcUV, srcDUV.x, srcZOffset,
|
||||
|
@ -252,8 +253,7 @@ static NO_INLINE void linear_composite(Texture& srctex, const IntRect& srcReq,
|
|||
destStride = -destStride;
|
||||
}
|
||||
int span = dstBounds.width();
|
||||
for (int rows = dstBounds.height(); rows > 0;
|
||||
rows--) {
|
||||
for (int rows = dstBounds.height(); rows > 0; rows--) {
|
||||
linear_row_composite((uint32_t*)dest, span, srcUV, srcDUV.x, &sampler);
|
||||
dest += destStride;
|
||||
srcUV.y += srcDUV.y;
|
||||
|
@ -385,7 +385,8 @@ static void unscaled_row_composite(uint32_t* dest, const uint32_t* src,
|
|||
|
||||
static NO_INLINE void unscaled_composite(Texture& srctex, const IntRect& srcReq,
|
||||
Texture& dsttex, const IntRect& dstReq,
|
||||
bool invertY, const IntRect& clipRect) {
|
||||
bool invertY,
|
||||
const IntRect& clipRect) {
|
||||
IntRect bounds = dsttex.sample_bounds(dstReq, invertY);
|
||||
bounds.intersect(clipRect);
|
||||
bounds.intersect(srctex.sample_bounds(srcReq));
|
||||
|
@ -396,8 +397,7 @@ static NO_INLINE void unscaled_composite(Texture& srctex, const IntRect& srcReq,
|
|||
if (invertY) {
|
||||
destStride = -destStride;
|
||||
}
|
||||
for (int rows = bounds.height(); rows > 0;
|
||||
rows--) {
|
||||
for (int rows = bounds.height(); rows > 0; rows--) {
|
||||
unscaled_row_composite((uint32_t*)dest, (const uint32_t*)src,
|
||||
bounds.width());
|
||||
dest += destStride;
|
||||
|
@ -413,8 +413,8 @@ static NO_INLINE void unscaled_composite(Texture& srctex, const IntRect& srcReq,
|
|||
void Composite(LockedTexture* lockedDst, LockedTexture* lockedSrc, GLint srcX,
|
||||
GLint srcY, GLsizei srcWidth, GLsizei srcHeight, GLint dstX,
|
||||
GLint dstY, GLsizei dstWidth, GLsizei dstHeight,
|
||||
GLboolean opaque, GLboolean flip, GLenum filter,
|
||||
GLint clipX, GLint clipY, GLsizei clipWidth, GLsizei clipHeight) {
|
||||
GLboolean opaque, GLboolean flip, GLenum filter, GLint clipX,
|
||||
GLint clipY, GLsizei clipWidth, GLsizei clipHeight) {
|
||||
if (!lockedDst || !lockedSrc) {
|
||||
return;
|
||||
}
|
||||
|
@ -429,9 +429,7 @@ void Composite(LockedTexture* lockedDst, LockedTexture* lockedSrc, GLint srcX,
|
|||
IntRect{dstX, dstY, dstX + dstWidth, dstY + dstHeight} - dsttex.offset;
|
||||
// Compute clip rect as relative to the dstReq, as that's the same coords
|
||||
// as used for the sampling bounds.
|
||||
IntRect clipRect = {clipX - dstX,
|
||||
clipY - dstY,
|
||||
clipX - dstX + clipWidth,
|
||||
IntRect clipRect = {clipX - dstX, clipY - dstY, clipX - dstX + clipWidth,
|
||||
clipY - dstY + clipHeight};
|
||||
|
||||
if (opaque) {
|
||||
|
@ -845,8 +843,7 @@ static void linear_convert_yuv(Texture& ytex, Texture& utex, Texture& vtex,
|
|||
destStride = -destStride;
|
||||
}
|
||||
int span = dstBounds.width();
|
||||
for (int rows = dstBounds.height(); rows > 0;
|
||||
rows--) {
|
||||
for (int rows = dstBounds.height(); rows > 0; rows--) {
|
||||
switch (colorSpace) {
|
||||
case REC_601:
|
||||
linear_row_yuv<REC_601>((uint32_t*)dest, span, srcUV, srcDUV.x,
|
||||
|
@ -885,7 +882,8 @@ void CompositeYUV(LockedTexture* lockedDst, LockedTexture* lockedY,
|
|||
YUVColorSpace colorSpace, GLuint colorDepth, GLint srcX,
|
||||
GLint srcY, GLsizei srcWidth, GLsizei srcHeight, GLint dstX,
|
||||
GLint dstY, GLsizei dstWidth, GLsizei dstHeight,
|
||||
GLboolean flip, GLint clipX, GLint clipY, GLsizei clipWidth, GLsizei clipHeight) {
|
||||
GLboolean flip, GLint clipX, GLint clipY, GLsizei clipWidth,
|
||||
GLsizei clipHeight) {
|
||||
if (!lockedDst || !lockedY || !lockedU || !lockedV) {
|
||||
return;
|
||||
}
|
||||
|
@ -909,9 +907,7 @@ void CompositeYUV(LockedTexture* lockedDst, LockedTexture* lockedY,
|
|||
IntRect{dstX, dstY, dstX + dstWidth, dstY + dstHeight} - dsttex.offset;
|
||||
// Compute clip rect as relative to the dstReq, as that's the same coords
|
||||
// as used for the sampling bounds.
|
||||
IntRect clipRect = {clipX - dstX,
|
||||
clipY - dstY,
|
||||
clipX - dstX + clipWidth,
|
||||
IntRect clipRect = {clipX - dstX, clipY - dstY, clipX - dstX + clipWidth,
|
||||
clipY - dstY + clipHeight};
|
||||
// For now, always use a linear filter path that would be required for
|
||||
// scaling. Further fast-paths for non-scaled video might be desirable in the
|
||||
|
|
|
@ -28,35 +28,34 @@
|
|||
# define ALWAYS_INLINE __forceinline
|
||||
# define NO_INLINE __declspec(noinline)
|
||||
|
||||
// Including Windows.h brings a huge amount of namespace polution so just
|
||||
// define a couple of things manually
|
||||
typedef int BOOL;
|
||||
# define WINAPI __stdcall
|
||||
// Including Windows.h brings a huge amount of namespace polution so just
|
||||
// define a couple of things manually
|
||||
typedef int BOOL;
|
||||
# define WINAPI __stdcall
|
||||
# define DECLSPEC_IMPORT __declspec(dllimport)
|
||||
# define WINBASEAPI DECLSPEC_IMPORT
|
||||
typedef unsigned long DWORD;
|
||||
typedef long LONG;
|
||||
typedef __int64 LONGLONG;
|
||||
typedef unsigned long DWORD;
|
||||
typedef long LONG;
|
||||
typedef __int64 LONGLONG;
|
||||
# define DUMMYSTRUCTNAME
|
||||
|
||||
typedef union _LARGE_INTEGER {
|
||||
struct {
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
} DUMMYSTRUCTNAME;
|
||||
struct {
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
} u;
|
||||
LONGLONG QuadPart;
|
||||
} LARGE_INTEGER;
|
||||
extern "C" {
|
||||
WINBASEAPI BOOL WINAPI
|
||||
QueryPerformanceCounter(LARGE_INTEGER* lpPerformanceCount);
|
||||
typedef union _LARGE_INTEGER {
|
||||
struct {
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
} DUMMYSTRUCTNAME;
|
||||
struct {
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
} u;
|
||||
LONGLONG QuadPart;
|
||||
} LARGE_INTEGER;
|
||||
extern "C" {
|
||||
WINBASEAPI BOOL WINAPI
|
||||
QueryPerformanceCounter(LARGE_INTEGER* lpPerformanceCount);
|
||||
|
||||
WINBASEAPI BOOL WINAPI
|
||||
QueryPerformanceFrequency(LARGE_INTEGER* lpFrequency);
|
||||
}
|
||||
WINBASEAPI BOOL WINAPI QueryPerformanceFrequency(LARGE_INTEGER* lpFrequency);
|
||||
}
|
||||
|
||||
#else
|
||||
# define ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
|
@ -3844,8 +3843,8 @@ static int clip_side(int nump, Point3D* p, Interpolants* interp, Point3D* outP,
|
|||
float k = prevDist / (prevDist - curDist);
|
||||
Point3D clipped = prev + (cur - prev) * k;
|
||||
if (prevSide * clipped.select(AXIS) > clipped.w) {
|
||||
k = nextafterf(k, 1.0f);
|
||||
clipped = prev + (cur - prev) * k;
|
||||
k = nextafterf(k, 1.0f);
|
||||
clipped = prev + (cur - prev) * k;
|
||||
}
|
||||
outP[numClip] = clipped;
|
||||
outInterp[numClip] = prevInterp + (curInterp - prevInterp) * k;
|
||||
|
@ -3879,8 +3878,8 @@ static int clip_side(int nump, Point3D* p, Interpolants* interp, Point3D* outP,
|
|||
float k = prevDist / (prevDist - curDist);
|
||||
Point3D clipped = prev + (cur - prev) * k;
|
||||
if (curSide * clipped.select(AXIS) > clipped.w) {
|
||||
k = nextafterf(k, 0.0f);
|
||||
clipped = prev + (cur - prev) * k;
|
||||
k = nextafterf(k, 0.0f);
|
||||
clipped = prev + (cur - prev) * k;
|
||||
}
|
||||
outP[numClip] = clipped;
|
||||
outInterp[numClip] = prevInterp + (curInterp - prevInterp) * k;
|
||||
|
@ -4015,7 +4014,7 @@ static void draw_perspective(int nump, Interpolants interp_outs[4],
|
|||
// result in Inf/NaN, then just set the reciprocal itself to zero so that
|
||||
// the coordinates becomes zeroed out, as the only valid point that
|
||||
// satisfies -W <= X/Y/Z <= W is all zeroes.
|
||||
if(!isfinite(w)) w = 0.0f;
|
||||
if (!isfinite(w)) w = 0.0f;
|
||||
p_clip[i] = Point3D(p_clip[i].sel(X, Y, Z) * w * scale + offset, w);
|
||||
}
|
||||
draw_perspective_clipped(nump, p_clip, interp_clip, colortex, layer,
|
||||
|
@ -4044,7 +4043,7 @@ static void draw_quad(int nump, Texture& colortex, int layer,
|
|||
// result in Inf/NaN, then just set the reciprocal itself to zero so that
|
||||
// the coordinates becomes zeroed out, as the only valid point that
|
||||
// satisfies -W <= X/Y/Z <= W is all zeroes.
|
||||
if(!isfinite(w)) w = 0.0f;
|
||||
if (!isfinite(w)) w = 0.0f;
|
||||
vec2 screen = (pos.sel(X, Y) * w + 1) * 0.5f *
|
||||
vec2_scalar(ctx->viewport.width(), ctx->viewport.height()) +
|
||||
make_vec2(ctx->viewport.origin() - colortex.offset);
|
||||
|
@ -4262,13 +4261,14 @@ void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
|
|||
|
||||
#ifdef PRINT_TIMINGS
|
||||
uint64_t end = get_time_value();
|
||||
printf("%7.3fms draw(%s, %d): %d pixels in %d rows (avg %f pixels/row, %fns/pixel)\n",
|
||||
double(end - start)/(1000.*1000.),
|
||||
ctx->programs[ctx->current_program].impl->get_name(),
|
||||
instancecount,
|
||||
ctx->shaded_pixels, ctx->shaded_rows,
|
||||
double(ctx->shaded_pixels)/ctx->shaded_rows,
|
||||
double(end - start)/max(ctx->shaded_pixels, 1));
|
||||
printf(
|
||||
"%7.3fms draw(%s, %d): %d pixels in %d rows (avg %f pixels/row, "
|
||||
"%fns/pixel)\n",
|
||||
double(end - start) / (1000. * 1000.),
|
||||
ctx->programs[ctx->current_program].impl->get_name(), instancecount,
|
||||
ctx->shaded_pixels, ctx->shaded_rows,
|
||||
double(ctx->shaded_pixels) / ctx->shaded_rows,
|
||||
double(end - start) / max(ctx->shaded_pixels, 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -4317,4 +4317,3 @@ void DestroyContext(Context* c) {
|
|||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
|
@ -65,8 +65,12 @@ SI bool test_none(Bool cond) { return _mm_movemask_ps(cond) == 0; }
|
|||
SI bool test_all(Bool cond) {
|
||||
return bit_cast<uint32_t>(CONVERT(cond, U8)) == 0xFFFFFFFFU;
|
||||
}
|
||||
SI bool test_any(Bool cond) { return bit_cast<uint32_t>(CONVERT(cond, U8)) != 0; }
|
||||
SI bool test_none(Bool cond) { return bit_cast<uint32_t>(CONVERT(cond, U8)) == 0; }
|
||||
SI bool test_any(Bool cond) {
|
||||
return bit_cast<uint32_t>(CONVERT(cond, U8)) != 0;
|
||||
}
|
||||
SI bool test_none(Bool cond) {
|
||||
return bit_cast<uint32_t>(CONVERT(cond, U8)) == 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
float make_float(float n) { return n; }
|
||||
|
@ -125,7 +129,8 @@ SI int32_t if_then_else(int32_t c, int32_t t, int32_t e) { return c ? t : e; }
|
|||
SI float if_then_else(int32_t c, float t, float e) { return c ? t : e; }
|
||||
|
||||
SI Float if_then_else(I32 c, float t, float e) {
|
||||
return bit_cast<Float>((c & bit_cast<I32>(Float(t))) | (~c & bit_cast<I32>(Float(e))));
|
||||
return bit_cast<Float>((c & bit_cast<I32>(Float(t))) |
|
||||
(~c & bit_cast<I32>(Float(e))));
|
||||
}
|
||||
|
||||
SI I32 if_then_else(I32 c, int32_t t, int32_t e) {
|
||||
|
@ -148,7 +153,8 @@ SI Bool if_then_else(int32_t c, Bool t, Bool e) { return c ? t : e; }
|
|||
|
||||
SI I16 if_then_else(I16 c, I16 t, I16 e) { return (c & t) | (~c & e); }
|
||||
|
||||
template <typename T> SI void swap(T& a, T& b) {
|
||||
template <typename T>
|
||||
SI void swap(T& a, T& b) {
|
||||
T t(a);
|
||||
a = b;
|
||||
b = t;
|
||||
|
@ -641,7 +647,10 @@ SI I32 roundfast(Float v, Float scale) {
|
|||
#endif
|
||||
}
|
||||
|
||||
template <typename T> SI auto round_pixel(T v) { return roundfast(v, 255.0f); }
|
||||
template <typename T>
|
||||
SI auto round_pixel(T v) {
|
||||
return roundfast(v, 255.0f);
|
||||
}
|
||||
|
||||
#define round __glsl_round
|
||||
|
||||
|
@ -2398,7 +2407,8 @@ Float atan(Float v) { return {atanf(v.x), atanf(v.y), atanf(v.z), atanf(v.w)}; }
|
|||
float atan(float a, float b) { return atan2f(a, b); }
|
||||
|
||||
Float atan(Float a, Float b) {
|
||||
return {atan2f(a.x, b.x), atan2f(a.y, b.y), atan2f(a.z, b.z), atan2f(a.w, b.w)};
|
||||
return {atan2f(a.x, b.x), atan2f(a.y, b.y), atan2f(a.z, b.z),
|
||||
atan2f(a.w, b.w)};
|
||||
}
|
||||
|
||||
bvec4 notEqual(ivec4 a, ivec4 b) {
|
||||
|
|
|
@ -213,7 +213,8 @@ static ALWAYS_INLINE T swgl_linearQuantizeStep(S s, T p) {
|
|||
__VA_ARGS__)
|
||||
|
||||
// Convert and pack planar YUV samples to RGB output using a color space
|
||||
static ALWAYS_INLINE PackedRGBA8 convertYUV(int colorSpace, U16 y, U16 u, U16 v) {
|
||||
static ALWAYS_INLINE PackedRGBA8 convertYUV(int colorSpace, U16 y, U16 u,
|
||||
U16 v) {
|
||||
auto yy = V8<int16_t>(zip(y, y));
|
||||
auto uv = V8<int16_t>(zip(u, v));
|
||||
switch (colorSpace) {
|
||||
|
|
|
@ -114,7 +114,7 @@ struct VectorType {
|
|||
};
|
||||
};
|
||||
|
||||
VectorType() : data{0} { }
|
||||
VectorType() : data{0} {}
|
||||
|
||||
constexpr VectorType(const VectorType& rhs) : data(rhs.data) {}
|
||||
// GCC vector extensions only support broadcasting scalars on arithmetic ops,
|
||||
|
|
Загрузка…
Ссылка в новой задаче