summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexShaderManager.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2015-09-21 01:16:21 -0400
committerLioncash <mathew1800@gmail.com>2015-10-15 23:34:54 -0400
commitb5b304cff2e9489816b44d539415970c4aa73d0b (patch)
treec148b756da8568701f434d6c554046bbaade017d /Source/Core/VideoCommon/VertexShaderManager.cpp
parent28cb62dc7f869b7064b1152ae8b6bf44e250728c (diff)
VertexShaderManager: Get rid of float pointer casts
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp56
1 files changed, 30 insertions, 26 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index 93d248938b..9a828febb0 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -4,9 +4,11 @@
#include <cfloat>
#include <cmath>
+#include <cstring>
#include <sstream>
#include "Common/BitSet.h"
+#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
#include "Core/ConfigManager.h"
@@ -331,30 +333,30 @@ void VertexShaderManager::SetConstants()
{
bPosNormalMatrixChanged = false;
- const float *pos = (const float *)xfmem.posMatrices + g_main_cp_state.matrix_index_a.PosNormalMtxIdx * 4;
- const float *norm = (const float *)xfmem.normalMatrices + 3 * (g_main_cp_state.matrix_index_a.PosNormalMtxIdx & 31);
+ const float* pos = &xfmem.posMatrices[g_main_cp_state.matrix_index_a.PosNormalMtxIdx * 4];
+ const float* norm = &xfmem.normalMatrices[3 * (g_main_cp_state.matrix_index_a.PosNormalMtxIdx & 31)];
- memcpy(constants.posnormalmatrix, pos, 3*16);
- memcpy(constants.posnormalmatrix[3], norm, 12);
- memcpy(constants.posnormalmatrix[4], norm+3, 12);
- memcpy(constants.posnormalmatrix[5], norm+6, 12);
+ memcpy(constants.posnormalmatrix, pos, 3 * sizeof(float4));
+ memcpy(constants.posnormalmatrix[3], norm, 3 * sizeof(u32));
+ memcpy(constants.posnormalmatrix[4], norm + 3, 3 * sizeof(u32));
+ memcpy(constants.posnormalmatrix[5], norm + 6, 3 * sizeof(u32));
dirty = true;
}
if (bTexMatricesChanged[0])
{
bTexMatricesChanged[0] = false;
- const float *fptrs[] =
+ const float* pos_matrix_ptrs[] =
{
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex0MtxIdx * 4],
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex1MtxIdx * 4],
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex2MtxIdx * 4],
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex3MtxIdx * 4]
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex0MtxIdx * 4],
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex1MtxIdx * 4],
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex2MtxIdx * 4],
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex3MtxIdx * 4]
};
- for (int i = 0; i < 4; ++i)
+ for (size_t i = 0; i < ArraySize(pos_matrix_ptrs); ++i)
{
- memcpy(constants.texmatrices[3 * i], fptrs[i], 3 * 16);
+ memcpy(constants.texmatrices[3 * i], pos_matrix_ptrs[i], 3 * sizeof(float4));
}
dirty = true;
}
@@ -362,16 +364,16 @@ void VertexShaderManager::SetConstants()
if (bTexMatricesChanged[1])
{
bTexMatricesChanged[1] = false;
- const float *fptrs[] = {
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex4MtxIdx * 4],
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex5MtxIdx * 4],
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex6MtxIdx * 4],
- (const float *)&xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex7MtxIdx * 4]
+ const float* pos_matrix_ptrs[] = {
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex4MtxIdx * 4],
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex5MtxIdx * 4],
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex6MtxIdx * 4],
+ &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex7MtxIdx * 4]
};
- for (int i = 0; i < 4; ++i)
+ for (size_t i = 0; i < ArraySize(pos_matrix_ptrs); ++i)
{
- memcpy(constants.texmatrices[3*i + 12], fptrs[i], 3*16);
+ memcpy(constants.texmatrices[3*i + 12], pos_matrix_ptrs[i], 3 * sizeof(float4));
}
dirty = true;
}
@@ -732,16 +734,18 @@ void VertexShaderManager::ResetView()
void VertexShaderManager::TransformToClipSpace(const float* data, float* out, u32 MtxIdx)
{
- const float* world_matrix = (const float*)xfmem.posMatrices + (MtxIdx & 0x3f) * 4;
- // We use the projection matrix calculated by vertexShaderManager, because it
+ const float* world_matrix = &xfmem.posMatrices[(MtxIdx & 0x3f) * 4];
+
+ // We use the projection matrix calculated by VertexShaderManager, because it
// includes any free look transformations.
// Make sure VertexManager::SetConstants() has been called first.
const float* proj_matrix = &g_fProjectionMatrix[0];
- float t[3];
- t[0] = data[0] * world_matrix[0] + data[1] * world_matrix[1] + data[2] * world_matrix[2] + world_matrix[3];
- t[1] = data[0] * world_matrix[4] + data[1] * world_matrix[5] + data[2] * world_matrix[6] + world_matrix[7];
- t[2] = data[0] * world_matrix[8] + data[1] * world_matrix[9] + data[2] * world_matrix[10] + world_matrix[11];
+ const float t[3] = {
+ data[0] * world_matrix[0] + data[1] * world_matrix[1] + data[2] * world_matrix[2] + world_matrix[3],
+ data[0] * world_matrix[4] + data[1] * world_matrix[5] + data[2] * world_matrix[6] + world_matrix[7],
+ data[0] * world_matrix[8] + data[1] * world_matrix[9] + data[2] * world_matrix[10] + world_matrix[11]
+ };
out[0] = t[0] * proj_matrix[0] + t[1] * proj_matrix[1] + t[2] * proj_matrix[2] + proj_matrix[3];
out[1] = t[0] * proj_matrix[4] + t[1] * proj_matrix[5] + t[2] * proj_matrix[6] + proj_matrix[7];