Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 801 vs 804 for /trunk/Source Code/Geometry/Material/Material.cpp

Diff revisions: vs.
  @@ -20,8 +20,10 @@
20 20 const char* g_PassThroughMaterialShaderName = "passThrough";
21 21 };
22 22
23 - Material::Material(const stringImpl& name)
23 + Material::Material(GFXDevice& context, ResourceCache& parentCache, const stringImpl& name)
24 24 : Resource(ResourceType::DEFAULT, name),
25 + _context(context),
26 + _parentCache(parentCache),
25 27 _parallaxFactor(1.0f),
26 28 _dirty(false),
27 29 _doubleSided(false),
  @@ -83,7 +85,7 @@
83 85 "Material error: clone called without a valid name suffix!");
84 86
85 87 const Material& base = *this;
86 - Material_ptr cloneMat = CreateResource<Material>(ResourceDescriptor(getName() + nameSuffix));
88 + Material_ptr cloneMat = CreateResource<Material>(_parentCache, ResourceDescriptor(getName() + nameSuffix));
87 89
88 90 cloneMat->_shadingMode = base._shadingMode;
89 91 cloneMat->_translucencyCheck = base._translucencyCheck;
  @@ -209,7 +211,7 @@
209 211 // if we already had a shader assigned ...
210 212 if (!info._shader.empty()) {
211 213 // and we are trying to assign the same one again, return.
212 - info._shaderRef = FindResourceImpl<ShaderProgram>(info._shader);
214 + info._shaderRef = FindResourceImpl<ShaderProgram>(_parentCache, info._shader);
213 215 if (info._shader.compare(shader) != 0) {
214 216 Console::printfn(Locale::get(_ID("REPLACE_SHADER")), info._shader.c_str(), shader.c_str());
215 217 }
  @@ -233,7 +235,7 @@
233 235 queueElement._shaderData = &_shaderInfo[stageIndex];
234 236 queueElement._shaderDescriptor = shaderDescriptor;
235 237
236 - ShaderComputeQueue& shaderQueue = SceneManager::instance().shaderComputeQueue();
238 + ShaderComputeQueue& shaderQueue = _context.shaderComputeQueue();
237 239 if (computeOnAdd) {
238 240 shaderQueue.addToQueueFront(queueElement);
239 241 shaderQueue.stepQueue();
  @@ -245,9 +247,9 @@
245 247 void Material::clean() {
246 248 if (_dirty && _dumpToFile) {
247 249 updateTranslucency();
248 - #if !defined(DEBUG)
249 - XML::dumpMaterial(*this);
250 - #endif
250 + if (!Config::Build::IS_DEBUG_BUILD) {
251 + XML::dumpMaterial(_context, *this);
252 + }
251 253 _dirty = false;
252 254 }
253 255 }
  @@ -275,7 +277,7 @@
275 277 void Material::updateReflectionIndex(I32 index) {
276 278 _reflectionIndex = index;
277 279 if (_reflectionIndex > -1) {
278 - RenderTarget& reflectionTarget = GFXDevice::instance().renderTarget(RenderTargetID(RenderTargetUsage::REFLECTION, index));
280 + RenderTarget& reflectionTarget = _context.renderTarget(RenderTargetID(RenderTargetUsage::REFLECTION, index));
279 281 const Texture_ptr& refTex = reflectionTarget.getAttachment(RTAttachment::Type::Colour, 0).asTexture();
280 282 setTexture(ShaderProgram::TextureUsage::REFLECTION, refTex);
281 283 } else {
  @@ -286,7 +288,7 @@
286 288 void Material::updateRefractionIndex(I32 index) {
287 289 _refractionIndex = index;
288 290 if (_refractionIndex > -1) {
289 - RenderTarget& refractionTarget = GFXDevice::instance().renderTarget(RenderTargetID(RenderTargetUsage::REFRACTION, index));
291 + RenderTarget& refractionTarget = _context.renderTarget(RenderTargetID(RenderTargetUsage::REFRACTION, index));
290 292 const Texture_ptr& refTex = refractionTarget.getAttachment(RTAttachment::Type::Colour, 0).asTexture();
291 293 setTexture(ShaderProgram::TextureUsage::REFRACTION, refTex);
292 294 } else {
  @@ -344,7 +346,7 @@
344 346 }
345 347 }
346 348
347 - bool deferredPassShader = SceneManager::instance().getRenderer().getType() !=
349 + bool deferredPassShader = _context.getRenderer().getType() !=
348 350 RendererType::RENDERER_TILED_FORWARD_SHADING;
349 351 bool depthPassShader = renderStage == RenderStage::SHADOW ||
350 352 renderStage == RenderStage::Z_PRE_PASS;
  @@ -494,7 +496,7 @@
494 496 void Material::getTextureData(TextureDataContainer& textureData) {
495 497 const U32 textureCount = to_const_uint(ShaderProgram::TextureUsage::COUNT);
496 498
497 - if (!GFXDevice::instance().isDepthStage()) {
499 + if (!_context.isDepthStage()) {
498 500 getTextureData(ShaderProgram::TextureUsage::UNIT0, textureData);
499 501 getTextureData(ShaderProgram::TextureUsage::UNIT1, textureData);
500 502 getTextureData(ShaderProgram::TextureUsage::OPACITY, textureData);