Adding --dump_shaders=path/.
This commit is contained in:
parent
8440c9059a
commit
7491058ffd
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <xenia/gpu/d3d11/d3d11_shader.h>
|
#include <xenia/gpu/d3d11/d3d11_shader.h>
|
||||||
|
|
||||||
|
#include <xenia/gpu/gpu-private.h>
|
||||||
#include <xenia/gpu/xenos/ucode.h>
|
#include <xenia/gpu/xenos/ucode.h>
|
||||||
|
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
@ -88,13 +89,26 @@ ID3D10Blob* D3D11Shader::Compile(const char* shader_source) {
|
||||||
uint32_t flags2 = 0;
|
uint32_t flags2 = 0;
|
||||||
|
|
||||||
// Create a name.
|
// Create a name.
|
||||||
char file_name[64];
|
const char* base_path = "";
|
||||||
|
if (FLAGS_dump_shaders.size()) {
|
||||||
|
base_path = FLAGS_dump_shaders.c_str();
|
||||||
|
}
|
||||||
|
char file_name[XE_MAX_PATH];
|
||||||
xesnprintfa(file_name, XECOUNT(file_name),
|
xesnprintfa(file_name, XECOUNT(file_name),
|
||||||
"gen_%.16XLL.%s",
|
"%s/gen_%.16XLL.%s",
|
||||||
|
base_path,
|
||||||
hash_,
|
hash_,
|
||||||
type_ == XE_GPU_SHADER_TYPE_VERTEX ? "vs" : "ps");
|
type_ == XE_GPU_SHADER_TYPE_VERTEX ? "vs" : "ps");
|
||||||
|
|
||||||
// TODO(benvanik): dump to disk so tools can find it.
|
if (FLAGS_dump_shaders.size()) {
|
||||||
|
FILE* f = fopen(file_name, "w");
|
||||||
|
fprintf(f, shader_source);
|
||||||
|
fprintf(f, "\n\n");
|
||||||
|
fprintf(f, "/*\n");
|
||||||
|
fprintf(f, disasm_src_);
|
||||||
|
fprintf(f, " */\n");
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
// Compile shader to bytecode blob.
|
// Compile shader to bytecode blob.
|
||||||
ID3D10Blob* shader_blob = 0;
|
ID3D10Blob* shader_blob = 0;
|
||||||
|
@ -1089,7 +1103,7 @@ int TranslateALU(
|
||||||
// Disassemble scalar op.
|
// Disassemble scalar op.
|
||||||
xe_gpu_translate_alu_info_t& is = scalar_alu_instrs[alu->scalar_opc];
|
xe_gpu_translate_alu_info_t& is = scalar_alu_instrs[alu->scalar_opc];
|
||||||
output->append(" // ");
|
output->append(" // ");
|
||||||
output->append(" \t");
|
output->append("\t");
|
||||||
if (is.name) {
|
if (is.name) {
|
||||||
output->append("\t \t%s\t", is.name);
|
output->append("\t \t%s\t", is.name);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
DECLARE_string(gpu);
|
DECLARE_string(gpu);
|
||||||
|
|
||||||
DECLARE_bool(trace_ring_buffer);
|
DECLARE_bool(trace_ring_buffer);
|
||||||
|
DECLARE_string(dump_shaders);
|
||||||
|
|
||||||
|
|
||||||
#endif // XENIA_GPU_PRIVATE_H_
|
#endif // XENIA_GPU_PRIVATE_H_
|
||||||
|
|
|
@ -22,6 +22,8 @@ DEFINE_string(gpu, "any",
|
||||||
|
|
||||||
DEFINE_bool(trace_ring_buffer, false,
|
DEFINE_bool(trace_ring_buffer, false,
|
||||||
"Trace GPU ring buffer packets.");
|
"Trace GPU ring buffer packets.");
|
||||||
|
DEFINE_string(dump_shaders, "",
|
||||||
|
"Path to write GPU shaders to as they are compiled.");
|
||||||
|
|
||||||
|
|
||||||
#include <xenia/gpu/nop/nop_gpu.h>
|
#include <xenia/gpu/nop/nop_gpu.h>
|
||||||
|
|
Loading…
Reference in New Issue