mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 17:53:42 +01:00
Optimize uniform uploads for D3D9 and GL as well.
This commit is contained in:
1 parent
73a94f4b11
commit
c2bd739b49
4 files changed
+35
-58
No files matched your search
@@ -25,6 +25,7 @@
|
||||
#include "i18n/i18n.h"
|
||||
#include "math/lin/matrix4x4.h"
|
||||
#include "math/math_util.h"
|
||||
#include "math/dataconv.h"
|
||||
#include "util/text/utf8.h"
|
||||
|
||||
#include "Common/Common.h"
|
||||
@@ -140,23 +141,15 @@ std::string VSShader::GetShaderString(DebugShaderStringType type) const {
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::PSSetColorUniform3(int creg, u32 color) {
|
||||
const float col[4] = {
|
||||
((color & 0xFF)) * (1.0f / 255.0f),
|
||||
((color & 0xFF00) >> 8) * (1.0f / 255.0f),
|
||||
((color & 0xFF0000) >> 16) * (1.0f / 255.0f),
|
||||
0.0f
|
||||
};
|
||||
device_->SetPixelShaderConstantF(creg, col, 1);
|
||||
float f[4];
|
||||
Uint8x3ToFloat4(f, color);
|
||||
device_->SetPixelShaderConstantF(creg, f, 1);
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::PSSetColorUniform3Alpha255(int creg, u32 color, u8 alpha) {
|
||||
const float col[4] = {
|
||||
(float)((color & 0xFF)),
|
||||
(float)((color & 0xFF00) >> 8),
|
||||
(float)((color & 0xFF0000) >> 16),
|
||||
(float)alpha,
|
||||
};
|
||||
device_->SetPixelShaderConstantF(creg, col, 1);
|
||||
float f[4];
|
||||
Uint8x3ToFloat4_AlphaUint8(f, color, alpha);
|
||||
device_->SetPixelShaderConstantF(creg, f, 1);
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::PSSetFloat(int creg, float value) {
|
||||
@@ -187,13 +180,9 @@ void ShaderManagerDX9::VSSetFloatArray(int creg, const float *value, int count)
|
||||
|
||||
// Utility
|
||||
void ShaderManagerDX9::VSSetColorUniform3(int creg, u32 color) {
|
||||
const float col[4] = {
|
||||
((color & 0xFF)) / 255.0f,
|
||||
((color & 0xFF00) >> 8) / 255.0f,
|
||||
((color & 0xFF0000) >> 16) / 255.0f,
|
||||
0.0f
|
||||
};
|
||||
device_->SetVertexShaderConstantF(creg, col, 1);
|
||||
float f[4];
|
||||
Uint8x3ToFloat4(f, color);
|
||||
device_->SetVertexShaderConstantF(creg, f, 1);
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::VSSetFloatUniform4(int creg, float data[4]) {
|
||||
@@ -201,20 +190,15 @@ void ShaderManagerDX9::VSSetFloatUniform4(int creg, float data[4]) {
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::VSSetFloat24Uniform3(int creg, const u32 data[3]) {
|
||||
const u32 col[4] = {
|
||||
data[0] << 8, data[1] << 8, data[2] << 8, 0
|
||||
};
|
||||
device_->SetVertexShaderConstantF(creg, (const float *)&col[0], 1);
|
||||
float f[4];
|
||||
ExpandFloat24x3ToFloat4(f, data);
|
||||
device_->SetVertexShaderConstantF(creg, f, 1);
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::VSSetColorUniform3Alpha(int creg, u32 color, u8 alpha) {
|
||||
const float col[4] = {
|
||||
((color & 0xFF)) / 255.0f,
|
||||
((color & 0xFF00) >> 8) / 255.0f,
|
||||
((color & 0xFF0000) >> 16) / 255.0f,
|
||||
alpha/255.0f
|
||||
};
|
||||
device_->SetVertexShaderConstantF(creg, col, 1);
|
||||
float f[4];
|
||||
Uint8x3ToFloat4_AlphaUint8(f, color, alpha);
|
||||
device_->SetVertexShaderConstantF(creg, f, 1);
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::VSSetColorUniform3ExtraFloat(int creg, u32 color, float extra) {
|
||||
|
||||
@@ -95,16 +95,16 @@ public:
|
||||
private:
|
||||
void PSUpdateUniforms(u64 dirtyUniforms);
|
||||
void VSUpdateUniforms(u64 dirtyUniforms);
|
||||
void PSSetColorUniform3Alpha255(int creg, u32 color, u8 alpha);
|
||||
void PSSetColorUniform3(int creg, u32 color);
|
||||
void PSSetFloat(int creg, float value);
|
||||
void PSSetFloatArray(int creg, const float *value, int count);
|
||||
inline void PSSetColorUniform3Alpha255(int creg, u32 color, u8 alpha);
|
||||
inline void PSSetColorUniform3(int creg, u32 color);
|
||||
inline void PSSetFloat(int creg, float value);
|
||||
inline void PSSetFloatArray(int creg, const float *value, int count);
|
||||
|
||||
void VSSetMatrix4x3(int creg, const float *m4x3);
|
||||
void VSSetMatrix4x3_3(int creg, const float *m4x3);
|
||||
void VSSetColorUniform3(int creg, u32 color);
|
||||
void VSSetColorUniform3ExtraFloat(int creg, u32 color, float extra);
|
||||
void VSSetColorUniform3Alpha(int creg, u32 color, u8 alpha);
|
||||
inline void VSSetColorUniform3(int creg, u32 color);
|
||||
inline void VSSetColorUniform3ExtraFloat(int creg, u32 color, float extra);
|
||||
inline void VSSetColorUniform3Alpha(int creg, u32 color, u8 alpha);
|
||||
void VSSetMatrix(int creg, const float* pMatrix);
|
||||
void VSSetFloat(int creg, float value);
|
||||
void VSSetFloatArray(int creg, const float *value, int count);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <map>
|
||||
#include <cstdio>
|
||||
|
||||
#include "math/dataconv.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/timeutil.h"
|
||||
#include "gfx/gl_debug_log.h"
|
||||
@@ -324,22 +325,15 @@ LinkedShader::~LinkedShader() {
|
||||
|
||||
// Utility
|
||||
static void SetColorUniform3(int uniform, u32 color) {
|
||||
const float col[3] = {
|
||||
((color & 0xFF)) / 255.0f,
|
||||
((color & 0xFF00) >> 8) / 255.0f,
|
||||
((color & 0xFF0000) >> 16) / 255.0f
|
||||
};
|
||||
glUniform3fv(uniform, 1, col);
|
||||
float f[4];
|
||||
Uint8x4ToFloat4(f, color);
|
||||
glUniform3fv(uniform, 1, f);
|
||||
}
|
||||
|
||||
static void SetColorUniform3Alpha(int uniform, u32 color, u8 alpha) {
|
||||
const float col[4] = {
|
||||
((color & 0xFF)) / 255.0f,
|
||||
((color & 0xFF00) >> 8) / 255.0f,
|
||||
((color & 0xFF0000) >> 16) / 255.0f,
|
||||
alpha/255.0f
|
||||
};
|
||||
glUniform4fv(uniform, 1, col);
|
||||
float f[4];
|
||||
Uint8x3ToFloat4_AlphaUint8(f, color, alpha);
|
||||
glUniform4fv(uniform, 1, f);
|
||||
}
|
||||
|
||||
// This passes colors unscaled (e.g. 0 - 255 not 0 - 1.)
|
||||
@@ -383,11 +377,10 @@ static void SetColorUniform3ExtraFloat(int uniform, u32 color, float extra) {
|
||||
glUniform4fv(uniform, 1, col);
|
||||
}
|
||||
|
||||
static void SetFloat24Uniform3(int uniform, const u32 data[3]) {
|
||||
const u32 col[3] = {
|
||||
data[0] << 8, data[1] << 8, data[2] << 8
|
||||
};
|
||||
glUniform3fv(uniform, 1, (const GLfloat *)&col[0]);
|
||||
static void SetFloat24Uniform3(int uniform, const uint32_t data[3]) {
|
||||
float f[4];
|
||||
ExpandFloat24x3ToFloat4(f, data);
|
||||
glUniform3fv(uniform, 1, f);
|
||||
}
|
||||
|
||||
static void SetFloatUniform4(int uniform, float data[4]) {
|
||||
|
||||
@@ -134,7 +134,7 @@ inline void CopyMatrix4x4(float dest[16], const float src[16]) {
|
||||
memcpy(dest, src, sizeof(float) * 16);
|
||||
}
|
||||
|
||||
inline void ExpandFloat24x3ToFloat4(float dest[4], uint32_t src[3]) {
|
||||
inline void ExpandFloat24x3ToFloat4(float dest[4], const uint32_t src[3]) {
|
||||
#ifdef _M_SSE
|
||||
__m128i values = _mm_slli_epi32(_mm_load_si128((const __m128i *)src), 8);
|
||||
_mm_storeu_si128((__m128i *)dest, values);
|
||||
|
||||
Reference in new issue
Block a user