Commit 34120d07 by Cody Northrop Committed by Commit Bot

Capture/Replay: Track groups of strings

When string counters were added, it accidentally broke transform feedback varyings. All the strings were combined, resulting in: const char *glTransformFeedbackVaryings_varyings_0[] = { R"(out_Posout_Aout_Bout_C)" }; Instead, generate the counter for the entire group. This CL results in: const char *glTransformFeedbackVaryings_varyings_0[] = { R"(out_Pos)", R"(out_A)", R"(out_B)", R"(out_C)", }; Test: Manhattan MEC works again Bug: angleproject:4941 Change-Id: Ie605395942c9105ba234009989f41a2a1cd8c53e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2381565Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent 91004654
......@@ -366,33 +366,47 @@ void WriteStringPointerParamReplay(DataTracker *dataTracker,
const ParamCapture &param)
{
// Concatenate the strings to ensure we get an accurate counter
// TODO (anglebug.com/4941): Explore a way to avoid lumping the strings together
std::string str;
std::vector<std::string> strings;
for (const std::vector<uint8_t> &data : param.data)
{
// null terminate C style string
ASSERT(data.size() > 0 && data.back() == '\0');
str += std::string(data.begin(), data.end() - 1);
strings.push_back(std::string(data.begin(), data.end() - 1));
}
int counter = dataTracker->getStringCounters().getStringCounter(str);
if (counter == kStringNotFound)
int counter = dataTracker->getStringCounters().getStringCounter(strings);
if (counter == kStringsNotFound)
{
// This is a unique string, so set up its declaration and update its counter
// This is a unique set of strings, so set up their declaration and update the counter
counter = dataTracker->getCounters().getAndIncrement(call.entryPoint, param.name);
dataTracker->getStringCounters().setStringCounter(str, counter);
dataTracker->getStringCounters().setStringCounter(strings, counter);
header << "const char *";
WriteParamStaticVarName(call, param, counter, header);
header << "[] = { \n";
// Break up long strings for MSVC
for (size_t i = 0; i < str.length(); i += kStringLengthLimit)
for (const std::string &str : strings)
{
size_t copyLength = ((str.length() - i) >= kStringLengthLimit) ? kStringLengthLimit
: (str.length() - i);
header << " R\"(" << str.substr(i, copyLength) << ")\"\n";
// Break up long strings for MSVC
size_t copyLength = 0;
std::string separator;
for (size_t i = 0; i < str.length(); i += kStringLengthLimit)
{
if ((str.length() - i) <= kStringLengthLimit)
{
copyLength = str.length() - i;
separator = ",";
}
else
{
copyLength = kStringLengthLimit;
separator = "";
}
header << " R\"(" << str.substr(i, copyLength) << ")\"" << separator << "\n";
}
}
header << " };\n";
}
......@@ -4307,23 +4321,23 @@ StringCounters::StringCounters() = default;
StringCounters::~StringCounters() = default;
int StringCounters::getStringCounter(std::string &str)
int StringCounters::getStringCounter(std::vector<std::string> &strings)
{
const auto &id = mStringCounterMap.find(str);
const auto &id = mStringCounterMap.find(strings);
if (id == mStringCounterMap.end())
{
return kStringNotFound;
return kStringsNotFound;
}
else
{
return mStringCounterMap[str];
return mStringCounterMap[strings];
}
}
void StringCounters::setStringCounter(std::string &str, int &counter)
void StringCounters::setStringCounter(std::vector<std::string> &strings, int &counter)
{
ASSERT(counter >= 0);
mStringCounterMap[str] = counter;
mStringCounterMap[strings] = counter;
}
ResourceTracker::ResourceTracker() = default;
......
......@@ -179,18 +179,18 @@ class DataCounters final : angle::NonCopyable
std::map<Counter, int> mData;
};
constexpr int kStringNotFound = -1;
constexpr int kStringsNotFound = -1;
class StringCounters final : angle::NonCopyable
{
public:
StringCounters();
~StringCounters();
int getStringCounter(std::string &str);
void setStringCounter(std::string &str, int &counter);
int getStringCounter(std::vector<std::string> &str);
void setStringCounter(std::vector<std::string> &str, int &counter);
private:
std::map<std::string, int> mStringCounterMap;
std::map<std::vector<std::string>, int> mStringCounterMap;
};
class DataTracker final : angle::NonCopyable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment