-
Notifications
You must be signed in to change notification settings - Fork 0
/
PixelShaderState.cpp
94 lines (79 loc) · 1.99 KB
/
PixelShaderState.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "PixelShaderState.h"
#include "ShaderState.h"
void PixelShaderState::createFromBinary(string file)
{
PixelShader = RwCreateCompiledPixelShader(file);
}
void PixelShaderState::createFromFile(string file, string profile)
{
PixelShader = CreatePixelShader(file, profile);
}
void PixelShaderState::addFloatConstant(int index, float value)
{
float f[4];
f[0] = value;
f[1] = f[2] = f[3] = 0.0;
ConstantData cd;
cd.index = index;
cd.valueArray = f;
cd.size = 1;
ConstantsList.push_back(cd);
}
void PixelShaderState::addIntConstant(int index, int value)
{
float f[4];
f[0] = static_cast<float>(value);
f[1] = f[2] = f[3] = 0.0;
ConstantData cd;
cd.index = index;
cd.valueArray = f;
cd.size = 1;
ConstantsList.push_back(cd);
}
void PixelShaderState::addFloatArrayConstant(int index, float* value, size_t size)
{
ConstantData cd;
cd.index = index;
cd.valueArray = value;
cd.size = size;
ConstantsList.push_back(cd);
}
void PixelShaderState::addntArrayConstant(int index, int* value, size_t size)
{}
void PixelShaderState::addMatrixConstant(int index, void* matrix)
{
ConstantData cd;
cd.index = index;
cd.valueArray = matrix;
cd.size = 4;
ConstantsList.push_back(cd);
}
void PixelShaderState::addVectorConstant(int index, float* vector)
{
ConstantData cd;
cd.index = index;
cd.valueArray = vector;
cd.size = 1;
ConstantsList.push_back(cd);
}
void PixelShaderState::push()
{
_rwD3D9SetVertexShader(PixelShader);
int i = 0;
for(auto cd : ConstantsList)
{
_rwD3D9GetPixelShaderConstant(cd.index, &PixelShaderConstantsTable[cd.index *4], cd.size);
_rwD3D9SetPixelShaderConstant(cd.index, cd.valueArray, cd.size);
i++;
}
}
void PixelShaderState::pop()
{
int i = 0;
for(auto cd : ConstantsList)
{
_rwD3D9SetPixelShaderConstant(cd.index, &PixelShaderConstantsTable[cd.index *4], cd.size);
i++;
}
ConstantsList.clear();
}