nxdk_pgraph_tests
A collection of tests for the Xbox nv2a graphics processor
 
Loading...
Searching...
No Matches
test_host.h
1#ifndef NXDK_PGRAPH_TESTS_TEST_HOST_H
2#define NXDK_PGRAPH_TESTS_TEST_HOST_H
3
4#include <debug_output.h>
5#include <ftp_logger.h>
6#include <pbkit/pbkit.h>
7#include <printf/printf.h>
8
9#include <cstdint>
10#include <memory>
11
12#include "nv2astate.h"
13#include "nxdk_ext.h"
14#include "pushbuffer.h"
15#include "string"
16#include "texture_format.h"
17#include "texture_stage.h"
18#include "vertex_buffer.h"
19#include "xbox_math_types.h"
20
21using namespace XboxMath;
22using namespace PBKitPlusPlus;
23
24namespace PBKitPlusPlus {
25class VertexShaderProgram;
26struct Vertex;
27class VertexBuffer;
28} // namespace PBKitPlusPlus
29
33class TestHost : public NV2AState {
34 public:
35 TestHost(std::shared_ptr<FTPLogger> ftp_logger, uint32_t framebuffer_width, uint32_t framebuffer_height,
36 uint32_t max_texture_width, uint32_t max_texture_height, uint32_t max_texture_depth = 4);
37
39 void FinishDraw(bool allow_saving, const std::string &output_directory, const std::string &suite_name,
40 const std::string &name, bool save_zbuffer = false);
41
43 [[nodiscard]] bool GetSaveResults() const { return save_results_; }
45 void SetSaveResults(bool enable = true) { save_results_ = enable; }
46
48 static std::string SaveTexture(const std::string &output_directory, const std::string &name, const uint8_t *texture,
49 uint32_t width, uint32_t height, uint32_t pitch, uint32_t bits_per_pixel,
50 SDL_PixelFormatEnum format);
52 static std::string SaveRawTexture(const std::string &output_directory, const std::string &name,
53 const uint8_t *texture, uint32_t width, uint32_t height, uint32_t pitch,
54 uint32_t bits_per_pixel);
56 [[nodiscard]] std::string SaveZBuffer(const std::string &output_directory, const std::string &name) const;
57
59 static void EnsureFolderExists(const std::string &folder_path);
60
61 private:
62 static std::string PrepareSaveFile(std::string output_directory, const std::string &filename,
63 const std::string &ext = ".png");
64 static std::string SaveBackBuffer(const std::string &output_directory, const std::string &name);
65
66 private:
67 bool save_results_{true};
68
69 std::shared_ptr<FTPLogger> ftp_logger_;
70};
71
72#endif // NXDK_PGRAPH_TESTS_TEST_HOST_H
Definition test_host.h:33
static std::string SaveRawTexture(const std::string &output_directory, const std::string &name, const uint8_t *texture, uint32_t width, uint32_t height, uint32_t pitch, uint32_t bits_per_pixel)
Saves the given region of memory as a flat binary file.
Definition test_host.cpp:174
bool GetSaveResults() const
Returns the current override flag to allow/prevent artifact saving.
Definition test_host.h:43
static void EnsureFolderExists(const std::string &folder_path)
Creates the given directory if it does not already exist.
Definition test_host.cpp:44
static std::string SaveTexture(const std::string &output_directory, const std::string &name, const uint8_t *texture, uint32_t width, uint32_t height, uint32_t pitch, uint32_t bits_per_pixel, SDL_PixelFormatEnum format)
Saves the given texture to the filesystem as a PNG file.
Definition test_host.cpp:150
void FinishDraw(bool allow_saving, const std::string &output_directory, const std::string &suite_name, const std::string &name, bool save_zbuffer=false)
Marks drawing as completed, potentially causing artifacts (framebuffer, z/stencil-buffer) to be saved...
Definition test_host.cpp:200
void SetSaveResults(bool enable=true)
Sets the override flag to prevent artifact saving during FinishDraw.
Definition test_host.h:45
std::string SaveZBuffer(const std::string &output_directory, const std::string &name) const
Saves the Z/Stencil buffer to the filesystem/.
Definition test_host.cpp:137