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, ...@@ -366,33 +366,47 @@ void WriteStringPointerParamReplay(DataTracker *dataTracker,
const ParamCapture &param) const ParamCapture &param)
{ {
// Concatenate the strings to ensure we get an accurate counter // Concatenate the strings to ensure we get an accurate counter
// TODO (anglebug.com/4941): Explore a way to avoid lumping the strings together std::vector<std::string> strings;
std::string str;
for (const std::vector<uint8_t> &data : param.data) for (const std::vector<uint8_t> &data : param.data)
{ {
// null terminate C style string // null terminate C style string
ASSERT(data.size() > 0 && data.back() == '\0'); 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); int counter = dataTracker->getStringCounters().getStringCounter(strings);
if (counter == kStringNotFound) 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); counter = dataTracker->getCounters().getAndIncrement(call.entryPoint, param.name);
dataTracker->getStringCounters().setStringCounter(str, counter); dataTracker->getStringCounters().setStringCounter(strings, counter);
header << "const char *"; header << "const char *";
WriteParamStaticVarName(call, param, counter, header); WriteParamStaticVarName(call, param, counter, header);
header << "[] = { \n"; header << "[] = { \n";
// Break up long strings for MSVC for (const std::string &str : strings)
for (size_t i = 0; i < str.length(); i += kStringLengthLimit)
{ {
size_t copyLength = ((str.length() - i) >= kStringLengthLimit) ? kStringLengthLimit // Break up long strings for MSVC
: (str.length() - i); size_t copyLength = 0;
header << " R\"(" << str.substr(i, copyLength) << ")\"\n"; 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"; header << " };\n";
} }
...@@ -4307,23 +4321,23 @@ StringCounters::StringCounters() = default; ...@@ -4307,23 +4321,23 @@ StringCounters::StringCounters() = default;
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()) if (id == mStringCounterMap.end())
{ {
return kStringNotFound; return kStringsNotFound;
} }
else 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); ASSERT(counter >= 0);
mStringCounterMap[str] = counter; mStringCounterMap[strings] = counter;
} }
ResourceTracker::ResourceTracker() = default; ResourceTracker::ResourceTracker() = default;
......
...@@ -179,18 +179,18 @@ class DataCounters final : angle::NonCopyable ...@@ -179,18 +179,18 @@ class DataCounters final : angle::NonCopyable
std::map<Counter, int> mData; std::map<Counter, int> mData;
}; };
constexpr int kStringNotFound = -1; constexpr int kStringsNotFound = -1;
class StringCounters final : angle::NonCopyable class StringCounters final : angle::NonCopyable
{ {
public: public:
StringCounters(); StringCounters();
~StringCounters(); ~StringCounters();
int getStringCounter(std::string &str); int getStringCounter(std::vector<std::string> &str);
void setStringCounter(std::string &str, int &counter); void setStringCounter(std::vector<std::string> &str, int &counter);
private: private:
std::map<std::string, int> mStringCounterMap; std::map<std::vector<std::string>, int> mStringCounterMap;
}; };
class DataTracker final : angle::NonCopyable 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