Adding some GPU docs and creating output directories automatically.

This commit is contained in:
Ben Vanik
2015-06-10 19:19:55 -07:00
parent 6be12a61c1
commit cabf9d6261
10 changed files with 144 additions and 24 deletions

View File

@@ -9,6 +9,7 @@
#include "xenia/gpu/gl4/gl4_shader.h"
#include "xenia/base/fs.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/gpu/gl4/gl4_gpu-private.h"
@@ -357,7 +358,14 @@ bool GL4Shader::CompileProgram(std::string source) {
snprintf(file_name, xe::countof(file_name), "%s/gl4_gen_%.16llX.%s",
base_path, data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag");
if (FLAGS_dump_shaders.size()) {
if (!FLAGS_dump_shaders.empty()) {
// Ensure shader dump path exists.
auto dump_shaders_path = xe::to_wstring(FLAGS_dump_shaders);
if (!dump_shaders_path.empty()) {
dump_shaders_path = xe::to_absolute_path(dump_shaders_path);
xe::fs::CreateFolder(dump_shaders_path);
}
// Note that we put the translated source first so we get good line numbers.
FILE* f = fopen(file_name, "w");
fprintf(f, translated_disassembly_.c_str());
@@ -430,7 +438,7 @@ bool GL4Shader::CompileProgram(std::string source) {
}
// Append to shader dump.
if (FLAGS_dump_shaders.size()) {
if (!FLAGS_dump_shaders.empty()) {
if (disasm_start) {
FILE* f = fopen(file_name, "a");
fprintf(f, "\n\n/*\n");

49
src/xenia/gpu/tracing.cc Normal file
View File

@@ -0,0 +1,49 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/gpu/tracing.h"
#include "xenia/base/fs.h"
#include "xenia/base/string.h"
namespace xe {
namespace gpu {
TraceWriter::TraceWriter(uint8_t* membase)
: membase_(membase), file_(nullptr) {}
TraceWriter::~TraceWriter() = default;
bool TraceWriter::Open(const std::wstring& path) {
Close();
auto canonical_path = xe::to_absolute_path(path);
auto base_path = xe::find_base_path(canonical_path);
xe::fs::CreateFolder(base_path);
file_ = _wfopen(canonical_path.c_str(), L"wb");
return file_ != nullptr;
}
void TraceWriter::Flush() {
if (file_) {
fflush(file_);
}
}
void TraceWriter::Close() {
if (file_) {
fflush(file_);
fclose(file_);
file_ = nullptr;
}
}
} // namespace gpu
} // namespace xe

View File

@@ -82,30 +82,14 @@ struct EventCommand {
class TraceWriter {
public:
TraceWriter(uint8_t* membase) : membase_(membase), file_(nullptr) {}
~TraceWriter() = default;
TraceWriter(uint8_t* membase);
~TraceWriter();
bool is_open() const { return file_ != nullptr; }
bool Open(const std::wstring& path) {
Close();
file_ = _wfopen(path.c_str(), L"wb");
return file_ != nullptr;
}
void Flush() {
if (file_) {
fflush(file_);
}
}
void Close() {
if (file_) {
fflush(file_);
fclose(file_);
file_ = nullptr;
}
}
bool Open(const std::wstring& path);
void Flush();
void Close();
void WritePrimaryBufferStart(uint32_t base_ptr, uint32_t count) {
if (!file_) {