summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorGeorge Kyriazis <[email protected]>2018-04-20 13:29:39 -0500
committerGeorge Kyriazis <[email protected]>2018-04-27 14:36:41 -0500
commitaeab9db50a1067836764ff2486412b04d2b3b3a2 (patch)
tree0604322b7f20ca202b7fcca1b1e87ab95bd345ca /src/gallium/drivers
parentb97bb0ea6ddbc0fdaa892ff3ca008223de0e20d8 (diff)
swr/rast: Package events.proto with core output
However only if the file exists in DEBUG_OUTPUT_DIR. The expectation is that AR rasterizerLauncher will start placing it there when launching a workload (which is in a subsequent checkin) Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp30
-rw-r--r--src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp4
2 files changed, 32 insertions, 2 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
index ff7bdc3ef73..502835ca801 100644
--- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
+++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp
@@ -93,7 +93,35 @@ namespace ArchRast
class EventHandlerApiStats : public EventHandlerFile
{
public:
- EventHandlerApiStats(uint32_t id) : EventHandlerFile(id) {}
+ EventHandlerApiStats(uint32_t id) : EventHandlerFile(id) {
+#if defined(_WIN32)
+ // Attempt to copy the events.proto file to the ArchRast output dir. It's common for tools to place the events.proto file
+ // in the DEBUG_OUTPUT_DIR when launching AR. If it exists, this will attempt to copy it the first time we get here to package
+ // it with the stats. Otherwise, the user would need to specify the events.proto location when parsing the stats in post.
+ std::stringstream eventsProtoSrcFilename, eventsProtoDstFilename;
+ eventsProtoSrcFilename << KNOB_DEBUG_OUTPUT_DIR << "\\events.proto" << std::ends;
+ eventsProtoDstFilename << mOutputDir.substr(0, mOutputDir.size() - 1) << "\\events.proto" << std::ends;
+
+ // If event.proto already exists, we're done; else do the copy
+ struct stat buf; // Use a Posix stat for file existence check
+ if (!stat(eventsProtoDstFilename.str().c_str(), &buf) == 0) {
+ // Now check to make sure the events.proto source exists
+ if (stat(eventsProtoSrcFilename.str().c_str(), &buf) == 0) {
+ std::ifstream srcFile;
+ srcFile.open(eventsProtoSrcFilename.str().c_str(), std::ios::binary);
+ if (srcFile.is_open())
+ {
+ // Just do a binary buffer copy
+ std::ofstream dstFile;
+ dstFile.open(eventsProtoDstFilename.str().c_str(), std::ios::binary);
+ dstFile << srcFile.rdbuf();
+ dstFile.close();
+ }
+ srcFile.close();
+ }
+ }
+#endif
+ }
virtual void Handle(const DrawInstancedEvent& event)
{
diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp
index d1852b35fde..54d24861de5 100644
--- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp
+++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp
@@ -56,7 +56,8 @@ namespace ArchRast
const char* pBaseName = strrchr(procname, '\\');
std::stringstream outDir;
outDir << KNOB_DEBUG_OUTPUT_DIR << pBaseName << "_" << pid << std::ends;
- CreateDirectory(outDir.str().c_str(), NULL);
+ mOutputDir = outDir.str();
+ CreateDirectory(mOutputDir.c_str(), NULL);
// There could be multiple threads creating thread pools. We
// want to make sure they are uniquly identified by adding in
@@ -152,6 +153,7 @@ namespace ArchRast
}
std::string mFilename;
+ std::string mOutputDir;
static const uint32_t mBufferSize = 1024;
uint8_t mBuffer[mBufferSize];