зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465964 - Add translated source to MOZ_WEBGL_DUMP_SHADER spew. - r=kvark
MozReview-Commit-ID: BDb64RqX537
This commit is contained in:
Родитель
680ca035e7
Коммит
261d4ed101
|
@ -19,6 +19,27 @@
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
static void
|
||||||
|
PrintLongString(const char* const begin, const size_t len)
|
||||||
|
{
|
||||||
|
// Wow - Roll Your Own Foreach-Lines because printf_stderr has a hard-coded
|
||||||
|
// internal size, so long strings are truncated.
|
||||||
|
|
||||||
|
const size_t chunkSize = 1000;
|
||||||
|
const UniqueBuffer buf(moz_xmalloc(chunkSize+1)); // +1 for null-term
|
||||||
|
const auto bufBegin = (char*)buf.get();
|
||||||
|
bufBegin[chunkSize] = '\0';
|
||||||
|
|
||||||
|
auto chunkBegin = begin;
|
||||||
|
const auto end = begin + len;
|
||||||
|
while (chunkBegin + chunkSize < end) {
|
||||||
|
memcpy(bufBegin, chunkBegin, chunkSize);
|
||||||
|
printf_stderr("%s", bufBegin);
|
||||||
|
chunkBegin += chunkSize;
|
||||||
|
}
|
||||||
|
printf_stderr("%s", chunkBegin);
|
||||||
|
}
|
||||||
|
|
||||||
// On success, writes to out_validator and out_translatedSource.
|
// On success, writes to out_validator and out_translatedSource.
|
||||||
// On failure, writes to out_translationLog.
|
// On failure, writes to out_translationLog.
|
||||||
static bool
|
static bool
|
||||||
|
@ -166,33 +187,6 @@ WebGLShader::ShaderSource(const nsAString& source)
|
||||||
// 7-bit ASCII range, so we can skip the NS_IsAscii() check.
|
// 7-bit ASCII range, so we can skip the NS_IsAscii() check.
|
||||||
const NS_LossyConvertUTF16toASCII cleanSource(sourceWithoutComments);
|
const NS_LossyConvertUTF16toASCII cleanSource(sourceWithoutComments);
|
||||||
|
|
||||||
if (PR_GetEnv("MOZ_WEBGL_DUMP_SHADERS")) {
|
|
||||||
printf_stderr("////////////////////////////////////////\n");
|
|
||||||
printf_stderr("// MOZ_WEBGL_DUMP_SHADERS:\n");
|
|
||||||
|
|
||||||
// Wow - Roll Your Own Foreach-Lines because printf_stderr has a hard-coded
|
|
||||||
// internal size, so long strings are truncated.
|
|
||||||
|
|
||||||
const size_t maxChunkSize = 1024-1; // -1 for null-term.
|
|
||||||
const UniqueBuffer buf(moz_xmalloc(maxChunkSize+1)); // +1 for null-term
|
|
||||||
const auto bufBegin = (char*)buf.get();
|
|
||||||
|
|
||||||
size_t chunkStart = 0;
|
|
||||||
while (chunkStart != cleanSource.Length()) {
|
|
||||||
const auto chunkEnd = std::min(chunkStart + maxChunkSize,
|
|
||||||
size_t(cleanSource.Length()));
|
|
||||||
const auto chunkSize = chunkEnd - chunkStart;
|
|
||||||
|
|
||||||
memcpy(bufBegin, cleanSource.BeginReading() + chunkStart, chunkSize);
|
|
||||||
bufBegin[chunkSize + 1] = '\0';
|
|
||||||
|
|
||||||
printf_stderr("%s", bufBegin);
|
|
||||||
chunkStart += chunkSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf_stderr("////////////////////////////////////////\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
mSource = source;
|
mSource = source;
|
||||||
mCleanSource = cleanSource;
|
mCleanSource = cleanSource;
|
||||||
}
|
}
|
||||||
|
@ -208,6 +202,12 @@ WebGLShader::CompileShader()
|
||||||
|
|
||||||
mValidator.reset(mContext->CreateShaderValidator(mType));
|
mValidator.reset(mContext->CreateShaderValidator(mType));
|
||||||
|
|
||||||
|
static const bool kDumpShaders = PR_GetEnv("MOZ_WEBGL_DUMP_SHADERS");
|
||||||
|
if (MOZ_UNLIKELY(kDumpShaders)) {
|
||||||
|
printf_stderr("==== begin MOZ_WEBGL_DUMP_SHADERS ====\n");
|
||||||
|
PrintLongString(mCleanSource.BeginReading(), mCleanSource.Length());
|
||||||
|
}
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
if (mValidator) {
|
if (mValidator) {
|
||||||
success = Translate(mCleanSource, mValidator.get(), &mValidationLog,
|
success = Translate(mCleanSource, mValidator.get(), &mValidationLog,
|
||||||
|
@ -217,6 +217,16 @@ WebGLShader::CompileShader()
|
||||||
&mValidationLog, &mTranslatedSource);
|
&mValidationLog, &mTranslatedSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MOZ_UNLIKELY(kDumpShaders)) {
|
||||||
|
printf_stderr("\n==== \\/ \\/ \\/ ====\n");
|
||||||
|
if (success) {
|
||||||
|
PrintLongString(mTranslatedSource.BeginReading(), mTranslatedSource.Length());
|
||||||
|
} else {
|
||||||
|
printf_stderr("Validation failed:\n%s", mValidationLog.BeginReading());
|
||||||
|
}
|
||||||
|
printf_stderr("\n==== end ====\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче