From 62b09687857c923b1044be0aef4dd900f8379b22 Mon Sep 17 00:00:00 2001 From: "tomhudson@google.com" Date: Wed, 9 Nov 2011 16:39:17 +0000 Subject: Speed up GrDrawState handling. Compact GrDrawState and nested structs; dynamically only copy and compare the fields actually active on the structs in question. Yields 10-20% speedup of text benchmarks in GPU configuration. Could probably get additional marginal speedup by ignoring unused kernel fields. Has some fragile constructs: pointer math on members to compute sizes of portions of structs. Removes fields necessary for GrTesselatedPathRenderer. git-svn-id: http://skia.googlecode.com/svn/trunk@2644 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrStencil.cpp | 132 +++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'src/gpu/GrStencil.cpp') diff --git a/src/gpu/GrStencil.cpp b/src/gpu/GrStencil.cpp index 376e057754..a66fbfd01c 100644 --- a/src/gpu/GrStencil.cpp +++ b/src/gpu/GrStencil.cpp @@ -13,9 +13,9 @@ const GrStencilSettings GrStencilSettings::gDisabled = { kKeep_StencilOp, kKeep_StencilOp, kKeep_StencilOp, kKeep_StencilOp, kAlways_StencilFunc, kAlways_StencilFunc, - 0x0, 0x0, - 0x0, 0x0, - 0x0, 0x0 + 0x0000, 0x0000, + 0x0000, 0x0000, + 0x0000, 0x0000 }; GR_STATIC_ASSERT(0 == kKeep_StencilOp); GR_STATIC_ASSERT(0 == kAlways_StencilFunc); @@ -36,17 +36,17 @@ static const GrStencilSettings gUserToClipReplace = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x0, 0x0, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; static const GrStencilSettings gInvUserToClipReplace = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x0, 0x0, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; /////// @@ -55,17 +55,17 @@ static const GrStencilSettings gUserToClipIsect = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, - 0x0, 0x0, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; static const GrStencilSettings gInvUserToClipIsect = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0xffffffff, 0xffffffff, - 0x0, 0x0, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; /////// @@ -74,17 +74,17 @@ static const GrStencilSettings gUserToClipDiff = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0xffffffff, 0xffffffff, - 0x0, 0x0, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; static const GrStencilSettings gInvUserToClipDiff = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, - 0x0, 0x0, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; /////// @@ -95,9 +95,9 @@ static const GrStencilSettings gUserToClipUnionPass0 = { kReplace_StencilOp, kReplace_StencilOp, kKeep_StencilOp, kKeep_StencilOp, kLEqual_StencilFunc, kLEqual_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x00000001, 0x00000001, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0001, 0x0001, // set clip bit + 0xffff, 0xffff }; // second pass allows anything greater than just clip bit set to pass @@ -105,9 +105,9 @@ static const GrStencilSettings gUserToClipUnionPass1 = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kLEqual_StencilFunc, kLEqual_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; // for inverse first pass finds non-zerp user with clip bit set @@ -116,9 +116,9 @@ static const GrStencilSettings gInvUserToClipUnionPass0 = { kReplace_StencilOp, kReplace_StencilOp, kKeep_StencilOp, kKeep_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; // second pass lets anything through with a nonzero user portion @@ -127,9 +127,9 @@ static const GrStencilSettings gInvUserToClipUnionPass1 = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; /////// @@ -138,36 +138,36 @@ static const GrStencilSettings gUserToClipXorPass0 = { kInvert_StencilOp, kInvert_StencilOp, kKeep_StencilOp, kKeep_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x00000000, 0x00000000, - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0000, 0x0000, + 0xffff, 0xffff }; static const GrStencilSettings gUserToClipXorPass1 = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kGreater_StencilFunc, kGreater_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; static const GrStencilSettings gInvUserToClipXorPass0 = { kInvert_StencilOp, kInvert_StencilOp, kKeep_StencilOp, kKeep_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x00000000, 0x00000000, - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0000, 0x0000, + 0xffff, 0xffff }; static const GrStencilSettings gInvUserToClipXorPass1 = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; /////// @@ -176,27 +176,27 @@ static const GrStencilSettings gUserToClipRDiffPass0 = { kInvert_StencilOp, kInvert_StencilOp, kZero_StencilOp, kZero_StencilOp, kLess_StencilFunc, kLess_StencilFunc, - 0xffffffff, 0xffffffff, // unset clip bit - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0xffff, 0xffff, // unset clip bit + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; static const GrStencilSettings gUserToClipRDiffPass1 = { kReplace_StencilOp, kReplace_StencilOp, kZero_StencilOp, kZero_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0x00000000, 0x00000000, // set clip bit - 0x00000000, 0x00000000, // set clip bit - 0xffffffff, 0xffffffff + 0x0000, 0x0000, // set clip bit + 0x0000, 0x0000, // set clip bit + 0xffff, 0xffff }; static const GrStencilSettings gInvUserToClipRDiff = { kInvert_StencilOp, kInvert_StencilOp, kZero_StencilOp, kZero_StencilOp, kEqual_StencilFunc, kEqual_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, - 0x00000000, 0x00000000 // set clip bit + 0xffff, 0xffff, + 0x0000, 0x0000, + 0x0000, 0x0000 // set clip bit }; /////// // Direct to Stencil @@ -211,36 +211,36 @@ static const GrStencilSettings gReplaceClip = { kReplace_StencilOp, kReplace_StencilOp, kReplace_StencilOp, kReplace_StencilOp, kAlways_StencilFunc, kAlways_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, // set clip bit - 0x00000000, 0x00000000 // set clipBit + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0x0000, 0x0000 // set clipBit }; static const GrStencilSettings gUnionClip = { kReplace_StencilOp, kReplace_StencilOp, kReplace_StencilOp, kReplace_StencilOp, kAlways_StencilFunc, kAlways_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, // set clip bit - 0x00000000, 0x00000000 // set clip bit + 0xffff, 0xffff, + 0x0000, 0x0000, // set clip bit + 0x0000, 0x0000 // set clip bit }; static const GrStencilSettings gXorClip = { kInvert_StencilOp, kInvert_StencilOp, kInvert_StencilOp, kInvert_StencilOp, kAlways_StencilFunc, kAlways_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, - 0x00000000, 0x00000000 // set clip bit + 0xffff, 0xffff, + 0x0000, 0x0000, + 0x0000, 0x0000 // set clip bit }; static const GrStencilSettings gDiffClip = { kZero_StencilOp, kZero_StencilOp, kZero_StencilOp, kZero_StencilOp, kAlways_StencilFunc, kAlways_StencilFunc, - 0xffffffff, 0xffffffff, - 0x00000000, 0x00000000, - 0x00000000, 0x00000000 // set clip bit + 0xffff, 0xffff, + 0x0000, 0x0000, + 0x0000, 0x0000 // set clip bit }; bool GrStencilSettings::GetClipPasses(GrSetOp op, -- cgit v1.2.3