1#ifndef NXDK_PGRAPH_TESTS_TEST_HOST_H
2#define NXDK_PGRAPH_TESTS_TEST_HOST_H
4#include <debug_output.h>
6#include <pbkit/pbkit.h>
7#include <printf/printf.h>
14#include "pushbuffer.h"
16#include "texture_format.h"
17#include "texture_stage.h"
18#include "vertex_buffer.h"
19#include "xbox_math_types.h"
21using namespace XboxMath;
22using namespace PBKitPlusPlus;
24namespace PBKitPlusPlus {
25class VertexShaderProgram;
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);
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);
47 [[nodiscard]] std::shared_ptr<FTPLogger> GetFTPLogger()
const {
return ftp_logger_; }
50 static std::string
SaveTexture(
const std::string &output_directory,
const std::string &name,
const uint8_t *texture,
51 uint32_t width, uint32_t height, uint32_t pitch, uint32_t bits_per_pixel,
52 SDL_PixelFormatEnum format);
54 static std::string
SaveRawTexture(
const std::string &output_directory,
const std::string &name,
55 const uint8_t *texture, uint32_t width, uint32_t height, uint32_t pitch,
56 uint32_t bits_per_pixel);
58 [[nodiscard]] std::string
SaveZBuffer(
const std::string &output_directory,
const std::string &name)
const;
64 inline float CenterX(
float item_width,
bool pixel_align =
true) {
65 float ret = (GetFramebufferWidthF() - item_width) * 0.5f;
74 inline float CenterY(
float item_height,
bool pixel_align =
true) {
75 float ret = (GetFramebufferHeightF() - item_height) * 0.5f;
86 static std::string PrepareSaveFile(std::string output_directory,
const std::string &filename,
87 const std::string &ext =
".png");
88 static std::string SaveBackBuffer(
const std::string &output_directory,
const std::string &name);
91 bool save_results_{
true};
93 std::shared_ptr<FTPLogger> ftp_logger_;
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:205
float CenterY(float item_height, bool pixel_align=true)
Returns a Y coordinate sufficient to center a primitive with the given height within the framebuffer.
Definition test_host.h:74
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:75
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:181
float CenterX(float item_width, bool pixel_align=true)
Returns an X coordinate sufficient to center a primitive with the given width within the framebuffer.
Definition test_host.h:64
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:231
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:168
static std::string GetDrawPrimitiveName(DrawPrimitive primitive)
Returns a string name for the given DrawPrimitive.
Definition test_host.cpp:270