VideoCommon/Statistics: Use std::array for projection values
Makes the members within the interface much nicer to look at, and also makes copying them over much nicer too.
This commit is contained in:
parent
baf02194c1
commit
04c06ec661
|
@ -58,7 +58,7 @@ static void MultiplyVec3Mat34(const Vec3& vec, const float* mat, Vec3& result)
|
|||
result.z = mat[8] * vec.x + mat[9] * vec.y + mat[10] * vec.z + mat[11];
|
||||
}
|
||||
|
||||
static void MultipleVec3Perspective(const Vec3& vec, const float* proj, Vec4& result)
|
||||
static void MultipleVec3Perspective(const Vec3& vec, const Projection::Raw& proj, Vec4& result)
|
||||
{
|
||||
result.x = proj[0] * vec.x + proj[1] * vec.z;
|
||||
result.y = proj[2] * vec.y + proj[3] * vec.z;
|
||||
|
@ -67,7 +67,7 @@ static void MultipleVec3Perspective(const Vec3& vec, const float* proj, Vec4& re
|
|||
result.w = -vec.z;
|
||||
}
|
||||
|
||||
static void MultipleVec3Ortho(const Vec3& vec, const float* proj, Vec4& result)
|
||||
static void MultipleVec3Ortho(const Vec3& vec, const Projection::Raw& proj, Vec4& result)
|
||||
{
|
||||
result.x = proj[0] * vec.x + proj[1];
|
||||
result.y = proj[2] * vec.y + proj[3];
|
||||
|
|
|
@ -102,22 +102,22 @@ void Statistics::DisplayProj()
|
|||
|
||||
ImGui::TextUnformatted("Projection #: X for Raw 6=0 (X for Raw 6!=0)");
|
||||
ImGui::NewLine();
|
||||
ImGui::Text("Projection 0: %f (%f) Raw 0: %f", stats.gproj_0, stats.g2proj_0, stats.proj_0);
|
||||
ImGui::Text("Projection 1: %f (%f)", stats.gproj_1, stats.g2proj_1);
|
||||
ImGui::Text("Projection 2: %f (%f) Raw 1: %f", stats.gproj_2, stats.g2proj_2, stats.proj_1);
|
||||
ImGui::Text("Projection 3: %f (%f)", stats.gproj_3, stats.g2proj_3);
|
||||
ImGui::Text("Projection 4: %f (%f)", stats.gproj_4, stats.g2proj_4);
|
||||
ImGui::Text("Projection 5: %f (%f) Raw 2: %f", stats.gproj_5, stats.g2proj_5, stats.proj_2);
|
||||
ImGui::Text("Projection 6: %f (%f) Raw 3: %f", stats.gproj_6, stats.g2proj_6, stats.proj_3);
|
||||
ImGui::Text("Projection 7: %f (%f)", stats.gproj_7, stats.g2proj_7);
|
||||
ImGui::Text("Projection 8: %f (%f)", stats.gproj_8, stats.g2proj_8);
|
||||
ImGui::Text("Projection 9: %f (%f)", stats.gproj_9, stats.g2proj_9);
|
||||
ImGui::Text("Projection 10: %f (%f) Raw 4: %f", stats.gproj_10, stats.g2proj_10, stats.proj_4);
|
||||
ImGui::Text("Projection 11: %f (%f) Raw 5: %f", stats.gproj_11, stats.g2proj_11, stats.proj_5);
|
||||
ImGui::Text("Projection 12: %f (%f)", stats.gproj_12, stats.g2proj_12);
|
||||
ImGui::Text("Projection 13: %f (%f)", stats.gproj_13, stats.g2proj_13);
|
||||
ImGui::Text("Projection 14: %f (%f)", stats.gproj_14, stats.g2proj_14);
|
||||
ImGui::Text("Projection 15: %f (%f)", stats.gproj_15, stats.g2proj_15);
|
||||
ImGui::Text("Projection 0: %f (%f) Raw 0: %f", stats.gproj[0], stats.g2proj[0], stats.proj[0]);
|
||||
ImGui::Text("Projection 1: %f (%f)", stats.gproj[1], stats.g2proj[1]);
|
||||
ImGui::Text("Projection 2: %f (%f) Raw 1: %f", stats.gproj[2], stats.g2proj[2], stats.proj[1]);
|
||||
ImGui::Text("Projection 3: %f (%f)", stats.gproj[3], stats.g2proj[3]);
|
||||
ImGui::Text("Projection 4: %f (%f)", stats.gproj[4], stats.g2proj[4]);
|
||||
ImGui::Text("Projection 5: %f (%f) Raw 2: %f", stats.gproj[5], stats.g2proj[5], stats.proj[2]);
|
||||
ImGui::Text("Projection 6: %f (%f) Raw 3: %f", stats.gproj[6], stats.g2proj[6], stats.proj[3]);
|
||||
ImGui::Text("Projection 7: %f (%f)", stats.gproj[7], stats.g2proj[7]);
|
||||
ImGui::Text("Projection 8: %f (%f)", stats.gproj[8], stats.g2proj[8]);
|
||||
ImGui::Text("Projection 9: %f (%f)", stats.gproj[9], stats.g2proj[9]);
|
||||
ImGui::Text("Projection 10: %f (%f) Raw 4: %f", stats.gproj[10], stats.g2proj[10], stats.proj[4]);
|
||||
ImGui::Text("Projection 11: %f (%f) Raw 5: %f", stats.gproj[11], stats.g2proj[11], stats.proj[5]);
|
||||
ImGui::Text("Projection 12: %f (%f)", stats.gproj[12], stats.g2proj[12]);
|
||||
ImGui::Text("Projection 13: %f (%f)", stats.gproj[13], stats.g2proj[13]);
|
||||
ImGui::Text("Projection 14: %f (%f)", stats.gproj[14], stats.g2proj[14]);
|
||||
ImGui::Text("Projection 15: %f (%f)", stats.gproj[15], stats.g2proj[15]);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
struct Statistics
|
||||
{
|
||||
int numPixelShadersCreated;
|
||||
|
@ -17,14 +19,9 @@ struct Statistics
|
|||
|
||||
int numVertexLoaders;
|
||||
|
||||
float proj_0, proj_1, proj_2, proj_3, proj_4, proj_5;
|
||||
float gproj_0, gproj_1, gproj_2, gproj_3, gproj_4, gproj_5;
|
||||
float gproj_6, gproj_7, gproj_8, gproj_9, gproj_10, gproj_11, gproj_12, gproj_13, gproj_14,
|
||||
gproj_15;
|
||||
|
||||
float g2proj_0, g2proj_1, g2proj_2, g2proj_3, g2proj_4, g2proj_5;
|
||||
float g2proj_6, g2proj_7, g2proj_8, g2proj_9, g2proj_10, g2proj_11, g2proj_12, g2proj_13,
|
||||
g2proj_14, g2proj_15;
|
||||
std::array<float, 6> proj;
|
||||
std::array<float, 16> gproj;
|
||||
std::array<float, 16> g2proj;
|
||||
|
||||
struct ThisFrame
|
||||
{
|
||||
|
|
|
@ -384,15 +384,15 @@ void VertexManagerBase::Flush()
|
|||
// Track some stats used elsewhere by the anamorphic widescreen heuristic.
|
||||
if (!SConfig::GetInstance().bWii)
|
||||
{
|
||||
float* rawProjection = xfmem.projection.rawProjection;
|
||||
bool viewport_is_4_3 = AspectIs4_3(xfmem.viewport.wd, xfmem.viewport.ht);
|
||||
if (AspectIs16_9(rawProjection[2], rawProjection[0]) && viewport_is_4_3)
|
||||
const auto& raw_projection = xfmem.projection.rawProjection;
|
||||
const bool viewport_is_4_3 = AspectIs4_3(xfmem.viewport.wd, xfmem.viewport.ht);
|
||||
if (AspectIs16_9(raw_projection[2], raw_projection[0]) && viewport_is_4_3)
|
||||
{
|
||||
// Projection is 16:9 and viewport is 4:3, we are rendering an anamorphic
|
||||
// widescreen picture.
|
||||
m_flush_count_anamorphic++;
|
||||
}
|
||||
else if (AspectIs4_3(rawProjection[2], rawProjection[0]) && viewport_is_4_3)
|
||||
else if (AspectIs4_3(raw_projection[2], raw_projection[0]) && viewport_is_4_3)
|
||||
{
|
||||
// Projection and viewports are both 4:3, we are rendering a normal image.
|
||||
m_flush_count_4_3++;
|
||||
|
|
|
@ -349,12 +349,11 @@ void VertexShaderManager::SetConstants()
|
|||
{
|
||||
bProjectionChanged = false;
|
||||
|
||||
float* rawProjection = xfmem.projection.rawProjection;
|
||||
const auto& rawProjection = xfmem.projection.rawProjection;
|
||||
|
||||
switch (xfmem.projection.type)
|
||||
{
|
||||
case GX_PERSPECTIVE:
|
||||
|
||||
g_fProjectionMatrix[0] = rawProjection[0] * g_ActiveConfig.fAspectRatioHackW;
|
||||
g_fProjectionMatrix[1] = 0.0f;
|
||||
g_fProjectionMatrix[2] = rawProjection[1] * g_ActiveConfig.fAspectRatioHackW;
|
||||
|
@ -376,26 +375,10 @@ void VertexShaderManager::SetConstants()
|
|||
g_fProjectionMatrix[14] = -1.0f;
|
||||
g_fProjectionMatrix[15] = 0.0f;
|
||||
|
||||
SETSTAT_FT(stats.gproj_0, g_fProjectionMatrix[0]);
|
||||
SETSTAT_FT(stats.gproj_1, g_fProjectionMatrix[1]);
|
||||
SETSTAT_FT(stats.gproj_2, g_fProjectionMatrix[2]);
|
||||
SETSTAT_FT(stats.gproj_3, g_fProjectionMatrix[3]);
|
||||
SETSTAT_FT(stats.gproj_4, g_fProjectionMatrix[4]);
|
||||
SETSTAT_FT(stats.gproj_5, g_fProjectionMatrix[5]);
|
||||
SETSTAT_FT(stats.gproj_6, g_fProjectionMatrix[6]);
|
||||
SETSTAT_FT(stats.gproj_7, g_fProjectionMatrix[7]);
|
||||
SETSTAT_FT(stats.gproj_8, g_fProjectionMatrix[8]);
|
||||
SETSTAT_FT(stats.gproj_9, g_fProjectionMatrix[9]);
|
||||
SETSTAT_FT(stats.gproj_10, g_fProjectionMatrix[10]);
|
||||
SETSTAT_FT(stats.gproj_11, g_fProjectionMatrix[11]);
|
||||
SETSTAT_FT(stats.gproj_12, g_fProjectionMatrix[12]);
|
||||
SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]);
|
||||
SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]);
|
||||
SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]);
|
||||
stats.gproj = g_fProjectionMatrix;
|
||||
break;
|
||||
|
||||
case GX_ORTHOGRAPHIC:
|
||||
|
||||
g_fProjectionMatrix[0] = rawProjection[0];
|
||||
g_fProjectionMatrix[1] = 0.0f;
|
||||
g_fProjectionMatrix[2] = 0.0f;
|
||||
|
@ -417,28 +400,8 @@ void VertexShaderManager::SetConstants()
|
|||
g_fProjectionMatrix[14] = 0.0f;
|
||||
g_fProjectionMatrix[15] = 1.0f;
|
||||
|
||||
SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]);
|
||||
SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]);
|
||||
SETSTAT_FT(stats.g2proj_2, g_fProjectionMatrix[2]);
|
||||
SETSTAT_FT(stats.g2proj_3, g_fProjectionMatrix[3]);
|
||||
SETSTAT_FT(stats.g2proj_4, g_fProjectionMatrix[4]);
|
||||
SETSTAT_FT(stats.g2proj_5, g_fProjectionMatrix[5]);
|
||||
SETSTAT_FT(stats.g2proj_6, g_fProjectionMatrix[6]);
|
||||
SETSTAT_FT(stats.g2proj_7, g_fProjectionMatrix[7]);
|
||||
SETSTAT_FT(stats.g2proj_8, g_fProjectionMatrix[8]);
|
||||
SETSTAT_FT(stats.g2proj_9, g_fProjectionMatrix[9]);
|
||||
SETSTAT_FT(stats.g2proj_10, g_fProjectionMatrix[10]);
|
||||
SETSTAT_FT(stats.g2proj_11, g_fProjectionMatrix[11]);
|
||||
SETSTAT_FT(stats.g2proj_12, g_fProjectionMatrix[12]);
|
||||
SETSTAT_FT(stats.g2proj_13, g_fProjectionMatrix[13]);
|
||||
SETSTAT_FT(stats.g2proj_14, g_fProjectionMatrix[14]);
|
||||
SETSTAT_FT(stats.g2proj_15, g_fProjectionMatrix[15]);
|
||||
SETSTAT_FT(stats.proj_0, rawProjection[0]);
|
||||
SETSTAT_FT(stats.proj_1, rawProjection[1]);
|
||||
SETSTAT_FT(stats.proj_2, rawProjection[2]);
|
||||
SETSTAT_FT(stats.proj_3, rawProjection[3]);
|
||||
SETSTAT_FT(stats.proj_4, rawProjection[4]);
|
||||
SETSTAT_FT(stats.proj_5, rawProjection[5]);
|
||||
stats.g2proj = g_fProjectionMatrix;
|
||||
stats.proj = rawProjection;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Common/BitField.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoCommon/CPMemory.h"
|
||||
|
@ -245,7 +247,9 @@ struct Viewport
|
|||
|
||||
struct Projection
|
||||
{
|
||||
float rawProjection[6];
|
||||
using Raw = std::array<float, 6>;
|
||||
|
||||
Raw rawProjection;
|
||||
u32 type; // only GX_PERSPECTIVE or GX_ORTHOGRAPHIC are allowed
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue