Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 280 vs 283 for /trunk/Source Code/Hardware/Video/Shaders/ShaderProgram.cpp

Diff revisions: vs.
  @@ -10,10 +10,6 @@
10 10 #include "Geometry/Material/Headers/Material.h"
11 11 #include "Rendering/Lighting/ShadowMapping/Headers/ShadowMap.h"
12 12
13 - vec3<F32> ShaderProgram::_cachedCamEye;
14 - vec2<F32> ShaderProgram::_cachedZPlanes;
15 - vec2<F32> ShaderProgram::_cachedSceneZPlanes;
16 -
17 13 ShaderProgram::ShaderProgram(const bool optimise) : HardwareResource("temp_shader_program"),
18 14 _activeCamera(nullptr),
19 15 _optimise(optimise),
  @@ -33,19 +29,11 @@
33 29
34 30 _extendedMatricesDirty = true;
35 31 _sceneDataDirty = true;
36 - _extendedMatrixEntry[WORLD_MATRIX] = -1;
37 - _extendedMatrixEntry[WV_MATRIX] = -1;
38 - _extendedMatrixEntry[WV_INV_MATRIX] = -1;
39 - _extendedMatrixEntry[WVP_MATRIX] = -1;
40 - _extendedMatrixEntry[NORMAL_MATRIX] = -1;
41 - _invProjMatrixEntry = -1;
32 + _worldMatrixLoc = -1;
33 + _normalMatrixLoc = -1;
42 34 _timeLoc = -1;
43 - _cameraLocationLoc = -1;
44 35 _enableFogLoc = -1;
45 36 _lightAmbientLoc = -1;
46 - _zPlanesLoc = -1;
47 - _sceneZPlanesLoc = -1;
48 - _screenDimensionLoc = -1;
49 37 _invScreenDimension = -1;
50 38 _fogColorLoc = -1;
51 39 _fogDensityLoc = -1;
  @@ -64,11 +52,6 @@
64 52 _shaderIdMap.clear();
65 53 }
66 54
67 - void ShaderProgram::updateCamera(const Camera& activeCamera) {
68 - _cachedCamEye = activeCamera.getEye();
69 - _cachedZPlanes = activeCamera.getZPlanes();
70 - }
71 -
72 55 U8 ShaderProgram::update(const U64 deltaTime){
73 56 _elapsedTime += deltaTime;
74 57 _elapsedTimeMS = static_cast<F32>(getUsToMs(_elapsedTime));
  @@ -100,7 +83,6 @@
100 83 }
101 84 if(_dirty){
102 85 const vec2<U16>& screenRes = GFX_DEVICE.getRenderTarget(GFXDevice::RENDER_TARGET_SCREEN)->getResolution();
103 - this->Uniform(_screenDimensionLoc, screenRes);
104 86 this->Uniform(_invScreenDimension, vec2<F32>(1.0f / screenRes.width, 1.0f / screenRes.height));
105 87 //Apply global shader values valid throughout application runtime:
106 88 char depthMapSampler1[32], depthMapSampler2[32], depthMapSampler3[32];
  @@ -140,19 +122,11 @@
140 122
141 123 DIVIDE_ASSERT(isHWInitComplete(), "ShaderProgram error: hardware initialization failed!");
142 124
143 - _extendedMatrixEntry[WORLD_MATRIX] = this->cachedLoc("dvd_WorldMatrix[0]");
144 - _extendedMatrixEntry[WV_MATRIX] = this->cachedLoc("dvd_WorldViewMatrix");
145 - _extendedMatrixEntry[WV_INV_MATRIX] = this->cachedLoc("dvd_WorldViewMatrixInverse");
146 - _extendedMatrixEntry[WVP_MATRIX] = this->cachedLoc("dvd_WorldViewProjectionMatrix");
147 - _extendedMatrixEntry[NORMAL_MATRIX] = this->cachedLoc("dvd_NormalMatrix[0]");
148 - _invProjMatrixEntry = this->cachedLoc("dvd_ProjectionMatrixInverse");
125 + _worldMatrixLoc = this->cachedLoc("dvd_WorldMatrix[0]");
126 + _normalMatrixLoc = this->cachedLoc("dvd_NormalMatrix[0]");
149 127 _timeLoc = this->cachedLoc("dvd_time");
150 - _cameraLocationLoc = this->cachedLoc("dvd_cameraPosition");
151 128 _enableFogLoc = this->cachedLoc("dvd_enableFog");
152 129 _lightAmbientLoc = this->cachedLoc("dvd_lightAmbient");
153 - _zPlanesLoc = this->cachedLoc("dvd_zPlanes");
154 - _sceneZPlanesLoc = this->cachedLoc("dvd_sceneZPlanes");
155 - _screenDimensionLoc = this->cachedLoc("dvd_screenDimension");
156 130 _invScreenDimension = this->cachedLoc("dvd_invScreenDimension");
157 131 _fogColorLoc = this->cachedLoc("fogColor");
158 132 _fogDensityLoc = this->cachedLoc("fogDensity");
  @@ -173,49 +147,16 @@
173 147 }
174 148
175 149 void ShaderProgram::uploadNodeMatrices(){
176 - DIVIDE_ASSERT(_bound, "ShaderProgram error: tried to upload transform data to an unbound shader program!");
177 -
178 - GFXDevice& GFX = GFX_DEVICE;
150 + if(!_extendedMatricesDirty)
151 + return;
179 152
180 - this->Uniform(_cameraLocationLoc, _cachedCamEye);
181 - this->Uniform(_zPlanesLoc, _cachedZPlanes);
182 - this->Uniform(_sceneZPlanesLoc, _cachedSceneZPlanes);
183 -
184 - I32 currentLocation = -1;
185 - /*Get and upload matrix data*/
186 - if (_extendedMatricesDirty == true){
187 -
188 - currentLocation = _extendedMatrixEntry[NORMAL_MATRIX];
189 - if (currentLocation != -1){
190 - this->Uniform(currentLocation, GFX.getMatrix3(NORMAL_MATRIX));
191 - }
192 -
193 - currentLocation = _extendedMatrixEntry[WORLD_MATRIX];
194 - if (currentLocation != -1){
195 - this->Uniform(currentLocation, GFX.getMatrix4(WORLD_MATRIX));
196 - }
153 + if (_normalMatrixLoc != -1)
154 + this->Uniform(_normalMatrixLoc, GFX_DEVICE.getMatrix3(NORMAL_MATRIX));
155 +
156 + if (_worldMatrixLoc != -1)
157 + this->Uniform(_worldMatrixLoc, GFX_DEVICE.getMatrix4(WORLD_MATRIX));
197 158
198 - currentLocation = _extendedMatrixEntry[WV_MATRIX];
199 - if (currentLocation != -1){
200 - this->Uniform(currentLocation, GFX.getMatrix4(WV_MATRIX));
201 - }
202 -
203 - currentLocation = _extendedMatrixEntry[WV_INV_MATRIX];
204 - if (currentLocation != -1){
205 - this->Uniform(currentLocation, GFX.getMatrix4(WV_INV_MATRIX));
206 - }
207 -
208 - currentLocation = _extendedMatrixEntry[WVP_MATRIX];
209 - if (currentLocation != -1){
210 - this->Uniform(currentLocation, GFX.getMatrix4(WVP_MATRIX));
211 - }
212 -
213 - currentLocation = _invProjMatrixEntry;
214 - if (currentLocation != -1){
215 - this->Uniform(currentLocation, GFX.getMatrix(PROJECTION_INV_MATRIX));
216 - }
217 - _extendedMatricesDirty = false;
218 - }
159 + _extendedMatricesDirty = false;
219 160 }
220 161
221 162 void ShaderProgram::SetLOD(U8 currentLOD){