summaryrefslogtreecommitdiff
path: root/src/video_core/debug_utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/debug_utils')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp43
-rw-r--r--src/video_core/debug_utils/debug_utils.h14
2 files changed, 31 insertions, 26 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 2d40f7d4f..e164e83a1 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -29,10 +29,10 @@
29#include "common/math_util.h" 29#include "common/math_util.h"
30#include "common/vector_math.h" 30#include "common/vector_math.h"
31#include "video_core/debug_utils/debug_utils.h" 31#include "video_core/debug_utils/debug_utils.h"
32#include "video_core/pica.h"
33#include "video_core/pica_state.h" 32#include "video_core/pica_state.h"
34#include "video_core/pica_types.h" 33#include "video_core/pica_types.h"
35#include "video_core/rasterizer_interface.h" 34#include "video_core/rasterizer_interface.h"
35#include "video_core/regs.h"
36#include "video_core/renderer_base.h" 36#include "video_core/renderer_base.h"
37#include "video_core/shader/shader.h" 37#include "video_core/shader/shader.h"
38#include "video_core/texture/texture_decode.h" 38#include "video_core/texture/texture_decode.h"
@@ -88,9 +88,9 @@ std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this global
88 88
89namespace DebugUtils { 89namespace DebugUtils {
90 90
91void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, 91void DumpShader(const std::string& filename, const ShaderRegs& config,
92 const Shader::ShaderSetup& setup, 92 const Shader::ShaderSetup& setup,
93 const Regs::VSOutputAttributes* output_attributes) { 93 const RasterizerRegs::VSOutputAttributes* output_attributes) {
94 struct StuffToWrite { 94 struct StuffToWrite {
95 const u8* pointer; 95 const u8* pointer;
96 u32 size; 96 u32 size;
@@ -129,7 +129,7 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config,
129 // This is put into a try-catch block to make sure we notice unknown configurations. 129 // This is put into a try-catch block to make sure we notice unknown configurations.
130 std::vector<OutputRegisterInfo> output_info_table; 130 std::vector<OutputRegisterInfo> output_info_table;
131 for (unsigned i = 0; i < 7; ++i) { 131 for (unsigned i = 0; i < 7; ++i) {
132 using OutputAttributes = Pica::Regs::VSOutputAttributes; 132 using OutputAttributes = Pica::RasterizerRegs::VSOutputAttributes;
133 133
134 // TODO: It's still unclear how the attribute components map to the register! 134 // TODO: It's still unclear how the attribute components map to the register!
135 // Once we know that, this code probably will not make much sense anymore. 135 // Once we know that, this code probably will not make much sense anymore.
@@ -331,7 +331,7 @@ static void FlushIOFile(png_structp png_ptr) {
331} 331}
332#endif 332#endif
333 333
334void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { 334void DumpTexture(const TexturingRegs::TextureConfig& texture_config, u8* data) {
335#ifndef HAVE_PNG 335#ifndef HAVE_PNG
336 return; 336 return;
337#else 337#else
@@ -396,7 +396,7 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
396 info.width = texture_config.width; 396 info.width = texture_config.width;
397 info.height = texture_config.height; 397 info.height = texture_config.height;
398 info.stride = row_stride; 398 info.stride = row_stride;
399 info.format = g_state.regs.texture0_format; 399 info.format = g_state.regs.texturing.texture0_format;
400 Math::Vec4<u8> texture_color = Pica::Texture::LookupTexture(data, x, y, info); 400 Math::Vec4<u8> texture_color = Pica::Texture::LookupTexture(data, x, y, info);
401 buf[3 * x + y * row_stride] = texture_color.r(); 401 buf[3 * x + y * row_stride] = texture_color.r();
402 buf[3 * x + y * row_stride + 1] = texture_color.g(); 402 buf[3 * x + y * row_stride + 1] = texture_color.g();
@@ -434,8 +434,10 @@ static std::string ReplacePattern(const std::string& input, const std::string& p
434 return ret; 434 return ret;
435} 435}
436 436
437static std::string GetTevStageConfigSourceString(const Pica::Regs::TevStageConfig::Source& source) { 437static std::string GetTevStageConfigSourceString(
438 using Source = Pica::Regs::TevStageConfig::Source; 438 const TexturingRegs::TevStageConfig::Source& source) {
439
440 using Source = TexturingRegs::TevStageConfig::Source;
439 static const std::map<Source, std::string> source_map = { 441 static const std::map<Source, std::string> source_map = {
440 {Source::PrimaryColor, "PrimaryColor"}, 442 {Source::PrimaryColor, "PrimaryColor"},
441 {Source::PrimaryFragmentColor, "PrimaryFragmentColor"}, 443 {Source::PrimaryFragmentColor, "PrimaryFragmentColor"},
@@ -457,9 +459,10 @@ static std::string GetTevStageConfigSourceString(const Pica::Regs::TevStageConfi
457} 459}
458 460
459static std::string GetTevStageConfigColorSourceString( 461static std::string GetTevStageConfigColorSourceString(
460 const Pica::Regs::TevStageConfig::Source& source, 462 const TexturingRegs::TevStageConfig::Source& source,
461 const Pica::Regs::TevStageConfig::ColorModifier modifier) { 463 const TexturingRegs::TevStageConfig::ColorModifier modifier) {
462 using ColorModifier = Pica::Regs::TevStageConfig::ColorModifier; 464
465 using ColorModifier = TexturingRegs::TevStageConfig::ColorModifier;
463 static const std::map<ColorModifier, std::string> color_modifier_map = { 466 static const std::map<ColorModifier, std::string> color_modifier_map = {
464 {ColorModifier::SourceColor, "%source.rgb"}, 467 {ColorModifier::SourceColor, "%source.rgb"},
465 {ColorModifier::OneMinusSourceColor, "(1.0 - %source.rgb)"}, 468 {ColorModifier::OneMinusSourceColor, "(1.0 - %source.rgb)"},
@@ -483,9 +486,10 @@ static std::string GetTevStageConfigColorSourceString(
483} 486}
484 487
485static std::string GetTevStageConfigAlphaSourceString( 488static std::string GetTevStageConfigAlphaSourceString(
486 const Pica::Regs::TevStageConfig::Source& source, 489 const TexturingRegs::TevStageConfig::Source& source,
487 const Pica::Regs::TevStageConfig::AlphaModifier modifier) { 490 const TexturingRegs::TevStageConfig::AlphaModifier modifier) {
488 using AlphaModifier = Pica::Regs::TevStageConfig::AlphaModifier; 491
492 using AlphaModifier = TexturingRegs::TevStageConfig::AlphaModifier;
489 static const std::map<AlphaModifier, std::string> alpha_modifier_map = { 493 static const std::map<AlphaModifier, std::string> alpha_modifier_map = {
490 {AlphaModifier::SourceAlpha, "%source.a"}, 494 {AlphaModifier::SourceAlpha, "%source.a"},
491 {AlphaModifier::OneMinusSourceAlpha, "(1.0 - %source.a)"}, 495 {AlphaModifier::OneMinusSourceAlpha, "(1.0 - %source.a)"},
@@ -507,8 +511,9 @@ static std::string GetTevStageConfigAlphaSourceString(
507} 511}
508 512
509static std::string GetTevStageConfigOperationString( 513static std::string GetTevStageConfigOperationString(
510 const Pica::Regs::TevStageConfig::Operation& operation) { 514 const TexturingRegs::TevStageConfig::Operation& operation) {
511 using Operation = Pica::Regs::TevStageConfig::Operation; 515
516 using Operation = TexturingRegs::TevStageConfig::Operation;
512 static const std::map<Operation, std::string> combiner_map = { 517 static const std::map<Operation, std::string> combiner_map = {
513 {Operation::Replace, "%source1"}, 518 {Operation::Replace, "%source1"},
514 {Operation::Modulate, "(%source1 * %source2)"}, 519 {Operation::Modulate, "(%source1 * %source2)"},
@@ -528,7 +533,7 @@ static std::string GetTevStageConfigOperationString(
528 return op_it->second; 533 return op_it->second;
529} 534}
530 535
531std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage) { 536std::string GetTevStageConfigColorCombinerString(const TexturingRegs::TevStageConfig& tev_stage) {
532 auto op_str = GetTevStageConfigOperationString(tev_stage.color_op); 537 auto op_str = GetTevStageConfigOperationString(tev_stage.color_op);
533 op_str = ReplacePattern( 538 op_str = ReplacePattern(
534 op_str, "%source1", 539 op_str, "%source1",
@@ -541,7 +546,7 @@ std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfi
541 GetTevStageConfigColorSourceString(tev_stage.color_source3, tev_stage.color_modifier3)); 546 GetTevStageConfigColorSourceString(tev_stage.color_source3, tev_stage.color_modifier3));
542} 547}
543 548
544std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage) { 549std::string GetTevStageConfigAlphaCombinerString(const TexturingRegs::TevStageConfig& tev_stage) {
545 auto op_str = GetTevStageConfigOperationString(tev_stage.alpha_op); 550 auto op_str = GetTevStageConfigOperationString(tev_stage.alpha_op);
546 op_str = ReplacePattern( 551 op_str = ReplacePattern(
547 op_str, "%source1", 552 op_str, "%source1",
@@ -554,7 +559,7 @@ std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfi
554 GetTevStageConfigAlphaSourceString(tev_stage.alpha_source3, tev_stage.alpha_modifier3)); 559 GetTevStageConfigAlphaSourceString(tev_stage.alpha_source3, tev_stage.alpha_modifier3));
555} 560}
556 561
557void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages) { 562void DumpTevStageConfig(const std::array<TexturingRegs::TevStageConfig, 6>& stages) {
558 std::string stage_info = "Tev setup:\n"; 563 std::string stage_info = "Tev setup:\n";
559 for (size_t index = 0; index < stages.size(); ++index) { 564 for (size_t index = 0; index < stages.size(); ++index) {
560 const auto& tev_stage = stages[index]; 565 const auto& tev_stage = stages[index];
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
index 938a2e1b5..fd94bdbb8 100644
--- a/src/video_core/debug_utils/debug_utils.h
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -17,7 +17,7 @@
17#include <vector> 17#include <vector>
18#include "common/common_types.h" 18#include "common/common_types.h"
19#include "common/vector_math.h" 19#include "common/vector_math.h"
20#include "video_core/pica.h" 20#include "video_core/regs.h"
21 21
22namespace CiTrace { 22namespace CiTrace {
23class Recorder; 23class Recorder;
@@ -182,9 +182,9 @@ namespace DebugUtils {
182#define PICA_DUMP_TEXTURES 0 182#define PICA_DUMP_TEXTURES 0
183#define PICA_LOG_TEV 0 183#define PICA_LOG_TEV 0
184 184
185void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, 185void DumpShader(const std::string& filename, const ShaderRegs& config,
186 const Shader::ShaderSetup& setup, 186 const Shader::ShaderSetup& setup,
187 const Regs::VSOutputAttributes* output_attributes); 187 const RasterizerRegs::VSOutputAttributes* output_attributes);
188 188
189// Utility class to log Pica commands. 189// Utility class to log Pica commands.
190struct PicaTrace { 190struct PicaTrace {
@@ -205,13 +205,13 @@ inline bool IsPicaTracing() {
205void OnPicaRegWrite(PicaTrace::Write write); 205void OnPicaRegWrite(PicaTrace::Write write);
206std::unique_ptr<PicaTrace> FinishPicaTracing(); 206std::unique_ptr<PicaTrace> FinishPicaTracing();
207 207
208void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data); 208void DumpTexture(const TexturingRegs::TextureConfig& texture_config, u8* data);
209 209
210std::string GetTevStageConfigColorCombinerString(const Pica::Regs::TevStageConfig& tev_stage); 210std::string GetTevStageConfigColorCombinerString(const TexturingRegs::TevStageConfig& tev_stage);
211std::string GetTevStageConfigAlphaCombinerString(const Pica::Regs::TevStageConfig& tev_stage); 211std::string GetTevStageConfigAlphaCombinerString(const TexturingRegs::TevStageConfig& tev_stage);
212 212
213/// Dumps the Tev stage config to log at trace level 213/// Dumps the Tev stage config to log at trace level
214void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig, 6>& stages); 214void DumpTevStageConfig(const std::array<TexturingRegs::TevStageConfig, 6>& stages);
215 215
216/** 216/**
217 * Used in the vertex loader to merge access records. TODO: Investigate if actually useful. 217 * Used in the vertex loader to merge access records. TODO: Investigate if actually useful.