Hash :
47ca1b2f
Author :
Date :
2019-01-23T16:11:41
Revert "Vulkan: Adding custom pool allocator" This reverts commit 05459e06fde5047ae8f5f90fe091c3255e6bc88e. Reason for revert: Clusterfuzz bugs flagged this commit Original change's description: > Vulkan: Adding custom pool allocator > > Copied pool allocator used by compiler to common and hooking it up as > custom allocator for CommandPools. Modified it to support reallocation. > > RendererVk now has a private poolAllocator and VkAllocationCallbacks > struct. The allocation callbacks are initialized to static functions > in RendererVk::initializeDevice() and then passed to CommandPool init() > and destroy() functions. > > Using the pool allocator saves Command Pool/Buffer clean-up time which > was showing us as a bottleneck is some cases. > > Bug: angleproject:2951 > Change-Id: I81aa8a7ec60397676fa722d6435029db27947ef4 > Reviewed-on: https://chromium-review.googlesource.com/c/1409867 > Commit-Queue: Tobin Ehlis <tobine@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> TBR=jmadill@chromium.org,tobine@google.com,ianelliott@google.com,syoussefi@chromium.org Change-Id: I363a351667c4dddef79833061790da90de477e70 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:2951 Reviewed-on: https://chromium-review.googlesource.com/c/1430679 Reviewed-by: Tobin Ehlis <tobine@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RemovePow_test.cpp:
// Tests for removing pow() function calls from the AST.
//
#include "GLSLANG/ShaderLang.h"
#include "angle_gl.h"
#include "compiler/translator/TranslatorGLSL.h"
#include "compiler/translator/tree_util/NodeSearch.h"
#include "gtest/gtest.h"
using namespace sh;
class RemovePowTest : public testing::Test
{
public:
RemovePowTest() {}
protected:
void SetUp() override
{
allocator.push();
SetGlobalPoolAllocator(&allocator);
ShBuiltInResources resources;
sh::InitBuiltInResources(&resources);
mTranslatorGLSL =
new sh::TranslatorGLSL(GL_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_GLSL_COMPATIBILITY_OUTPUT);
ASSERT_TRUE(mTranslatorGLSL->Init(resources));
}
void TearDown() override
{
SafeDelete(mTranslatorGLSL);
SetGlobalPoolAllocator(nullptr);
allocator.pop();
}
void compile(const std::string &shaderString)
{
const char *shaderStrings[] = {shaderString.c_str()};
mASTRoot = mTranslatorGLSL->compileTreeForTesting(
shaderStrings, 1, SH_OBJECT_CODE | SH_REMOVE_POW_WITH_CONSTANT_EXPONENT);
if (!mASTRoot)
{
TInfoSink &infoSink = mTranslatorGLSL->getInfoSink();
FAIL() << "Shader compilation into ESSL failed " << infoSink.info.c_str();
}
}
template <class T>
bool foundInAST()
{
return T::search(mASTRoot);
}
private:
sh::TranslatorGLSL *mTranslatorGLSL;
TIntermNode *mASTRoot;
TPoolAllocator allocator;
};
// Check if there's a pow() node anywhere in the tree.
class FindPow : public sh::NodeSearchTraverser<FindPow>
{
public:
bool visitBinary(Visit visit, TIntermBinary *node) override
{
if (node->getOp() == EOpPow)
{
mFound = true;
}
return !mFound;
}
};
// Check if the tree starting at node corresponds to exp2(y * log2(x))
// If the tree matches, set base to the node corresponding to x.
bool IsPowWorkaround(TIntermNode *node, TIntermNode **base)
{
TIntermUnary *exp = node->getAsUnaryNode();
if (exp != nullptr && exp->getOp() == EOpExp2)
{
TIntermBinary *mul = exp->getOperand()->getAsBinaryNode();
if (mul != nullptr && mul->isMultiplication())
{
TIntermUnary *log = mul->getRight()->getAsUnaryNode();
if (mul->getLeft()->getAsConstantUnion() && log != nullptr)
{
if (log->getOp() == EOpLog2)
{
if (base)
*base = log->getOperand();
return true;
}
}
}
}
return false;
}
// Check if there's a node with the correct workaround to pow anywhere in the tree.
class FindPowWorkaround : public sh::NodeSearchTraverser<FindPowWorkaround>
{
public:
bool visitUnary(Visit visit, TIntermUnary *node) override
{
mFound = IsPowWorkaround(node, nullptr);
return !mFound;
}
};
// Check if there's a node with the correct workaround to pow with another workaround to pow
// nested within it anywhere in the tree.
class FindNestedPowWorkaround : public sh::NodeSearchTraverser<FindNestedPowWorkaround>
{
public:
bool visitUnary(Visit visit, TIntermUnary *node) override
{
TIntermNode *base = nullptr;
bool oneFound = IsPowWorkaround(node, &base);
if (oneFound && base)
mFound = IsPowWorkaround(base, nullptr);
return !mFound;
}
};
TEST_F(RemovePowTest, PowWithConstantExponent)
{
const std::string &shaderString =
"precision mediump float;\n"
"uniform float u;\n"
"void main() {\n"
" gl_FragColor = pow(vec4(u), vec4(0.5));\n"
"}\n";
compile(shaderString);
ASSERT_FALSE(foundInAST<FindPow>());
ASSERT_TRUE(foundInAST<FindPowWorkaround>());
ASSERT_FALSE(foundInAST<FindNestedPowWorkaround>());
}
TEST_F(RemovePowTest, NestedPowWithConstantExponent)
{
const std::string &shaderString =
"precision mediump float;\n"
"uniform float u;\n"
"void main() {\n"
" gl_FragColor = pow(pow(vec4(u), vec4(2.0)), vec4(0.5));\n"
"}\n";
compile(shaderString);
ASSERT_FALSE(foundInAST<FindPow>());
ASSERT_TRUE(foundInAST<FindNestedPowWorkaround>());
}