From c5a9cd0aa11e7469eee7e694d1594cb49d96a2ba Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 4 Aug 2014 19:02:00 +0200 Subject: [PATCH] Sync upstream changes to shiny --- extern/shiny/Extra/core.h | 8 +++- extern/shiny/Main/Factory.cpp | 40 +++++++++++--------- extern/shiny/Main/Factory.hpp | 2 +- extern/shiny/Main/MaterialInstance.cpp | 3 +- extern/shiny/Main/Preprocessor.cpp | 3 +- extern/shiny/Main/Preprocessor.hpp | 2 - extern/shiny/Platforms/Ogre/OgrePlatform.cpp | 2 +- 7 files changed, 34 insertions(+), 26 deletions(-) diff --git a/extern/shiny/Extra/core.h b/extern/shiny/Extra/core.h index cba716777..1687d5ed1 100644 --- a/extern/shiny/Extra/core.h +++ b/extern/shiny/Extra/core.h @@ -1,13 +1,16 @@ #if SH_HLSL == 1 || SH_CG == 1 #define shTexture2D sampler2D + #define shTexture3D sampler3D #define shSample(tex, coord) tex2D(tex, coord) #define shCubicSample(tex, coord) texCUBE(tex, coord) #define shLerp(a, b, t) lerp(a, b, t) #define shSaturate(a) saturate(a) #define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name) - + + #define shSampler3D(name) , uniform sampler3D name : register(s@shCounter(0)) @shUseSampler(name) + #define shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name) #define shMatrixMult(m, v) mul(m, v) @@ -67,6 +70,7 @@ #define int3 ivec3 #define int4 ivec4 #define shTexture2D sampler2D + #define shTexture3D sampler3D #define shSample(tex, coord) texture2D(tex, coord) #define shCubicSample(tex, coord) textureCube(tex, coord) #define shLerp(a, b, t) mix(a, b, t) @@ -76,6 +80,8 @@ #define shSampler2D(name) uniform sampler2D name; @shUseSampler(name) + #define shSampler3D(name) uniform sampler3D name; @shUseSampler(name) + #define shSamplerCube(name) uniform samplerCube name; @shUseSampler(name) #define shMatrixMult(m, v) (m * v) diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index eab5c8dfc..48caa225a 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -278,14 +278,15 @@ namespace sh MaterialMap::iterator it = mMaterials.find(name); if (it != mMaterials.end()) return &(it->second); - else + else return NULL; } MaterialInstance* Factory::findInstance (const std::string& name) { - assert (mMaterials.find(name) != mMaterials.end()); - return &mMaterials.find(name)->second; + MaterialInstance* m = searchInstance(name); + assert (m); + return m; } MaterialInstance* Factory::requestMaterial (const std::string& name, const std::string& configuration, unsigned short lodIndex) @@ -297,27 +298,24 @@ namespace sh if (m) { - // make sure all lod techniques below (higher lod) exist - int i = lodIndex; - while (i>0) + if (m->createForConfiguration (configuration, 0)) + { + if (mListener) + mListener->materialCreated (m, configuration, 0); + } + else + return NULL; + + for (LodConfigurationMap::iterator it = mLodConfigurations.begin(); it != mLodConfigurations.end(); ++it) { - --i; - if (m->createForConfiguration (configuration, i)) + if (m->createForConfiguration (configuration, it->first)) { if (mListener) - mListener->materialCreated (m, configuration, i); + mListener->materialCreated (m, configuration, it->first); } else return NULL; } - - if (m->createForConfiguration (configuration, lodIndex)) - { - if (mListener) - mListener->materialCreated (m, configuration, lodIndex); - } - else - return NULL; } return m; } @@ -625,8 +623,14 @@ namespace sh { MaterialInstance* m = searchInstance (name); assert(m); + m->createForConfiguration (configuration, 0); - } + + for (LodConfigurationMap::iterator it = mLodConfigurations.begin(); it != mLodConfigurations.end(); ++it) + { + m->createForConfiguration (configuration, it->first); + } + } bool Factory::removeCache(const std::string& pattern) { diff --git a/extern/shiny/Main/Factory.hpp b/extern/shiny/Main/Factory.hpp index e8562011c..721b4af7d 100644 --- a/extern/shiny/Main/Factory.hpp +++ b/extern/shiny/Main/Factory.hpp @@ -259,8 +259,8 @@ namespace sh Platform* mPlatform; MaterialInstance* findInstance (const std::string& name); - private: MaterialInstance* searchInstance (const std::string& name); + /// @return was anything removed? bool removeCache (const std::string& pattern); diff --git a/extern/shiny/Main/MaterialInstance.cpp b/extern/shiny/Main/MaterialInstance.cpp index 128cc593b..c69d13401 100644 --- a/extern/shiny/Main/MaterialInstance.cpp +++ b/extern/shiny/Main/MaterialInstance.cpp @@ -163,7 +163,8 @@ namespace sh mTexUnits.push_back(texUnit); // set texture unit indices (required by GLSL) - if (useShaders && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && (mFactory->getCurrentLanguage () == Language_GLSL || mFactory->getCurrentLanguage() == Language_GLSLES)) + if (useShaders && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && (mFactory->getCurrentLanguage () == Language_GLSL + || mFactory->getCurrentLanguage() == Language_GLSLES)) { pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i); diff --git a/extern/shiny/Main/Preprocessor.cpp b/extern/shiny/Main/Preprocessor.cpp index c03879d46..26481aa03 100644 --- a/extern/shiny/Main/Preprocessor.cpp +++ b/extern/shiny/Main/Preprocessor.cpp @@ -9,8 +9,7 @@ /* Almost exact copy of load_file_to_string policy found in boost::wave headers with the only change that it uses - boost::filesystem facility to handle UTF-8 paths used - throughout OpenMW (bfs::fstream, bfs::path). + boost::filesystem facility to handle UTF-8 paths properly on windows. Original namespace is used due to required bost::wave internal symbols. diff --git a/extern/shiny/Main/Preprocessor.hpp b/extern/shiny/Main/Preprocessor.hpp index 4eb533499..7ee30ae7f 100644 --- a/extern/shiny/Main/Preprocessor.hpp +++ b/extern/shiny/Main/Preprocessor.hpp @@ -1,8 +1,6 @@ #ifndef SH_PREPROCESSOR_H #define SH_PREPROCESSOR_H -#include - #include #include diff --git a/extern/shiny/Platforms/Ogre/OgrePlatform.cpp b/extern/shiny/Platforms/Ogre/OgrePlatform.cpp index 9f309fbcd..eab8f93e2 100644 --- a/extern/shiny/Platforms/Ogre/OgrePlatform.cpp +++ b/extern/shiny/Platforms/Ogre/OgrePlatform.cpp @@ -151,7 +151,7 @@ namespace sh else if (typeid(*value) == typeid(IntValue)) type = Ogre::GCT_INT1; else - throw std::runtime_error("unexpected type"); + throw std::runtime_error("unexpected type"); params->addConstantDefinition(name, type); mSharedParameters[name] = params; }