fm: Make --writeShaders dump fragment, vertex, and key files
Bug: skia:11372 Change-Id: Ib764b8d995655317e8968e57b1ea0528339d430b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379060 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
dc41f59b3d
commit
9e1ef99d1e
@ -94,17 +94,35 @@ void MemoryCache::writeShadersToDisk(const char* path, GrBackendApi api) {
|
||||
SkSL::Program::Inputs inputsIgnored[kGrShaderTypeCount];
|
||||
SkSL::String shaders[kGrShaderTypeCount];
|
||||
const SkData* data = it->second.fData.get();
|
||||
// Even with the SPIR-V switches, it seems like we must use .spv, or malisc tries to
|
||||
// run glslang on the input.
|
||||
const char* ext = GrBackendApi::kOpenGL == api ? "frag" : "spv";
|
||||
const SkString& description = it->second.fDescription;
|
||||
SkReadBuffer reader(data->data(), data->size());
|
||||
GrPersistentCacheUtils::GetType(&reader); // Shader type tag
|
||||
GrPersistentCacheUtils::UnpackCachedShaders(&reader, shaders,
|
||||
inputsIgnored, kGrShaderTypeCount);
|
||||
|
||||
SkString filename = SkStringPrintf("%s/%s.%s", path, md5.c_str(), ext);
|
||||
SkFILEWStream file(filename.c_str());
|
||||
file.write(shaders[kFragment_GrShaderType].c_str(), shaders[kFragment_GrShaderType].size());
|
||||
// Even with the SPIR-V switches, it seems like we must use .spv, or malisc tries to
|
||||
// run glslang on the input.
|
||||
{
|
||||
const char* ext = GrBackendApi::kOpenGL == api ? "frag" : "frag.spv";
|
||||
SkString filename = SkStringPrintf("%s/%s.%s", path, md5.c_str(), ext);
|
||||
SkFILEWStream file(filename.c_str());
|
||||
file.write(shaders[kFragment_GrShaderType].c_str(),
|
||||
shaders[kFragment_GrShaderType].size());
|
||||
}
|
||||
{
|
||||
const char* ext = GrBackendApi::kOpenGL == api ? "vert" : "vert.spv";
|
||||
SkString filename = SkStringPrintf("%s/%s.%s", path, md5.c_str(), ext);
|
||||
SkFILEWStream file(filename.c_str());
|
||||
file.write(shaders[kVertex_GrShaderType].c_str(),
|
||||
shaders[kVertex_GrShaderType].size());
|
||||
}
|
||||
|
||||
if (!description.isEmpty()) {
|
||||
const char* ext = "key";
|
||||
SkString filename = SkStringPrintf("%s/%s.%s", path, md5.c_str(), ext);
|
||||
SkFILEWStream file(filename.c_str());
|
||||
file.write(description.c_str(), description.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user