summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2015-05-28 00:31:26 +0200
committerTony Wasserka <NeoBrainX@gmail.com>2015-08-16 13:22:01 +0200
commit2e3601f4156e73f22fa30d6b6cb42831ec1f713e (patch)
tree62fbc98e323f230dcb2d16d0f2a0b0ded6b9e2d9
parentcitra-qt: Improve shader debugger. (diff)
downloadyuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar
yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.gz
yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.bz2
yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.lz
yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.xz
yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.tar.zst
yuzu-2e3601f4156e73f22fa30d6b6cb42831ec1f713e.zip
Diffstat (limited to '')
-rw-r--r--src/citra_qt/debugger/graphics_vertex_shader.cpp5
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp59
-rw-r--r--src/video_core/debug_utils/debug_utils.h3
3 files changed, 53 insertions, 14 deletions
diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cpp
index 92d3a8323..b1657620e 100644
--- a/src/citra_qt/debugger/graphics_vertex_shader.cpp
+++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp
@@ -272,10 +272,9 @@ void GraphicsVertexShaderModel::DumpShader() {
auto& setup = Pica::g_state.vs;
auto& config = Pica::g_state.regs.vs;
- Pica::DebugUtils::DumpShader(setup.program_code.data(), setup.program_code.size(),
- setup.swizzle_data.data(), setup.swizzle_data.size(),
- config.main_offset, Pica::g_state.regs.vs_output_attributes);
+ Pica::DebugUtils::DumpShader(config, setup, Pica::g_state.regs.vs_output_attributes);
}
+
GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context,
QWidget* parent)
: BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) {
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 7cb7a6ef4..a79d90ef1 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -14,6 +14,7 @@
#include <png.h>
#endif
+#include <nihstro/float24.h>
#include <nihstro/shader_binary.h>
#include "common/assert.h"
@@ -110,8 +111,7 @@ void GeometryDumper::Dump() {
}
-void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size,
- u32 main_offset, const Regs::VSOutputAttributes* output_attributes)
+void DumpShader(const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes)
{
struct StuffToWrite {
u8* pointer;
@@ -231,25 +231,66 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
// TODO: Reduce the amount of binary code written to relevant portions
dvlp.binary_offset = write_offset - dvlp_offset;
- dvlp.binary_size_words = binary_size;
- QueueForWriting((u8*)binary_data, binary_size * sizeof(u32));
+ dvlp.binary_size_words = setup.program_code.size();
+ QueueForWriting((u8*)setup.program_code.data(), setup.program_code.size() * sizeof(u32));
dvlp.swizzle_info_offset = write_offset - dvlp_offset;
- dvlp.swizzle_info_num_entries = swizzle_size;
+ dvlp.swizzle_info_num_entries = setup.swizzle_data.size();
u32 dummy = 0;
- for (unsigned int i = 0; i < swizzle_size; ++i) {
- QueueForWriting((u8*)&swizzle_data[i], sizeof(swizzle_data[i]));
+ for (unsigned int i = 0; i < setup.swizzle_data.size(); ++i) {
+ QueueForWriting((u8*)&setup.swizzle_data[i], sizeof(setup.swizzle_data[i]));
QueueForWriting((u8*)&dummy, sizeof(dummy));
}
- dvle.main_offset_words = main_offset;
+ dvle.main_offset_words = config.main_offset;
dvle.output_register_table_offset = write_offset - dvlb.dvle_offset;
dvle.output_register_table_size = static_cast<u32>(output_info_table.size());
QueueForWriting((u8*)output_info_table.data(), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo)));
// TODO: Create a label table for "main"
- // TODO: Write uniforms as constants
+ std::vector<nihstro::ConstantInfo> constant_table;
+ for (unsigned i = 0; i < setup.uniforms.b.size(); ++i) {
+ nihstro::ConstantInfo constant;
+ memset(&constant, 0, sizeof(constant));
+ constant.type = nihstro::ConstantInfo::Bool;
+ constant.regid = i;
+ constant.b = setup.uniforms.b[i];
+ constant_table.emplace_back(constant);
+ }
+ for (unsigned i = 0; i < setup.uniforms.i.size(); ++i) {
+ nihstro::ConstantInfo constant;
+ memset(&constant, 0, sizeof(constant));
+ constant.type = nihstro::ConstantInfo::Int;
+ constant.regid = i;
+ constant.i.x = setup.uniforms.i[i].x;
+ constant.i.y = setup.uniforms.i[i].y;
+ constant.i.z = setup.uniforms.i[i].z;
+ constant.i.w = setup.uniforms.i[i].w;
+ constant_table.emplace_back(constant);
+ }
+ for (unsigned i = 0; i < sizeof(setup.uniforms.f) / sizeof(setup.uniforms.f[0]); ++i) {
+ nihstro::ConstantInfo constant;
+ memset(&constant, 0, sizeof(constant));
+ constant.type = nihstro::ConstantInfo::Float;
+ constant.regid = i;
+ constant.f.x = nihstro::to_float24(setup.uniforms.f[i].x.ToFloat32());
+ constant.f.y = nihstro::to_float24(setup.uniforms.f[i].y.ToFloat32());
+ constant.f.z = nihstro::to_float24(setup.uniforms.f[i].z.ToFloat32());
+ constant.f.w = nihstro::to_float24(setup.uniforms.f[i].w.ToFloat32());
+
+ // Store constant if it's different from zero..
+ if (setup.uniforms.f[i].x.ToFloat32() != 0.0 ||
+ setup.uniforms.f[i].y.ToFloat32() != 0.0 ||
+ setup.uniforms.f[i].z.ToFloat32() != 0.0 ||
+ setup.uniforms.f[i].w.ToFloat32() != 0.0)
+ constant_table.emplace_back(constant);
+ }
+ dvle.constant_table_offset = write_offset - dvlb.dvle_offset;
+ dvle.constant_table_size = constant_table.size();
+ for (const auto& constant : constant_table) {
+ QueueForWriting((uint8_t*)&constant, sizeof(constant));
+ }
// Write data to file
static int dump_index = 0;
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
index 4939e6c06..1450e5bf3 100644
--- a/src/video_core/debug_utils/debug_utils.h
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -181,8 +181,7 @@ private:
std::vector<Face> faces;
};
-void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size,
- u32 main_offset, const Regs::VSOutputAttributes* output_attributes);
+void DumpShader(const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes);
// Utility class to log Pica commands.