1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Sync upstream changes to shiny

This commit is contained in:
scrawl 2014-08-04 19:02:00 +02:00
parent 44b517f66d
commit c5a9cd0aa1
7 changed files with 34 additions and 26 deletions

View file

@ -1,6 +1,7 @@
#if SH_HLSL == 1 || SH_CG == 1 #if SH_HLSL == 1 || SH_CG == 1
#define shTexture2D sampler2D #define shTexture2D sampler2D
#define shTexture3D sampler3D
#define shSample(tex, coord) tex2D(tex, coord) #define shSample(tex, coord) tex2D(tex, coord)
#define shCubicSample(tex, coord) texCUBE(tex, coord) #define shCubicSample(tex, coord) texCUBE(tex, coord)
#define shLerp(a, b, t) lerp(a, b, t) #define shLerp(a, b, t) lerp(a, b, t)
@ -8,6 +9,8 @@
#define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name) #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 shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name)
#define shMatrixMult(m, v) mul(m, v) #define shMatrixMult(m, v) mul(m, v)
@ -67,6 +70,7 @@
#define int3 ivec3 #define int3 ivec3
#define int4 ivec4 #define int4 ivec4
#define shTexture2D sampler2D #define shTexture2D sampler2D
#define shTexture3D sampler3D
#define shSample(tex, coord) texture2D(tex, coord) #define shSample(tex, coord) texture2D(tex, coord)
#define shCubicSample(tex, coord) textureCube(tex, coord) #define shCubicSample(tex, coord) textureCube(tex, coord)
#define shLerp(a, b, t) mix(a, b, t) #define shLerp(a, b, t) mix(a, b, t)
@ -76,6 +80,8 @@
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name) #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 shSamplerCube(name) uniform samplerCube name; @shUseSampler(name)
#define shMatrixMult(m, v) (m * v) #define shMatrixMult(m, v) (m * v)

View file

@ -278,14 +278,15 @@ namespace sh
MaterialMap::iterator it = mMaterials.find(name); MaterialMap::iterator it = mMaterials.find(name);
if (it != mMaterials.end()) if (it != mMaterials.end())
return &(it->second); return &(it->second);
else else
return NULL; return NULL;
} }
MaterialInstance* Factory::findInstance (const std::string& name) MaterialInstance* Factory::findInstance (const std::string& name)
{ {
assert (mMaterials.find(name) != mMaterials.end()); MaterialInstance* m = searchInstance(name);
return &mMaterials.find(name)->second; assert (m);
return m;
} }
MaterialInstance* Factory::requestMaterial (const std::string& name, const std::string& configuration, unsigned short lodIndex) MaterialInstance* Factory::requestMaterial (const std::string& name, const std::string& configuration, unsigned short lodIndex)
@ -297,27 +298,24 @@ namespace sh
if (m) if (m)
{ {
// make sure all lod techniques below (higher lod) exist if (m->createForConfiguration (configuration, 0))
int i = lodIndex;
while (i>0)
{ {
--i; if (mListener)
if (m->createForConfiguration (configuration, i)) mListener->materialCreated (m, configuration, 0);
}
else
return NULL;
for (LodConfigurationMap::iterator it = mLodConfigurations.begin(); it != mLodConfigurations.end(); ++it)
{
if (m->createForConfiguration (configuration, it->first))
{ {
if (mListener) if (mListener)
mListener->materialCreated (m, configuration, i); mListener->materialCreated (m, configuration, it->first);
} }
else else
return NULL; return NULL;
} }
if (m->createForConfiguration (configuration, lodIndex))
{
if (mListener)
mListener->materialCreated (m, configuration, lodIndex);
}
else
return NULL;
} }
return m; return m;
} }
@ -625,8 +623,14 @@ namespace sh
{ {
MaterialInstance* m = searchInstance (name); MaterialInstance* m = searchInstance (name);
assert(m); assert(m);
m->createForConfiguration (configuration, 0); 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) bool Factory::removeCache(const std::string& pattern)
{ {

View file

@ -259,8 +259,8 @@ namespace sh
Platform* mPlatform; Platform* mPlatform;
MaterialInstance* findInstance (const std::string& name); MaterialInstance* findInstance (const std::string& name);
private:
MaterialInstance* searchInstance (const std::string& name); MaterialInstance* searchInstance (const std::string& name);
/// @return was anything removed? /// @return was anything removed?
bool removeCache (const std::string& pattern); bool removeCache (const std::string& pattern);

View file

@ -163,7 +163,8 @@ namespace sh
mTexUnits.push_back(texUnit); mTexUnits.push_back(texUnit);
// set texture unit indices (required by GLSL) // 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); pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i);

View file

@ -9,8 +9,7 @@
/* /*
Almost exact copy of load_file_to_string policy found in Almost exact copy of load_file_to_string policy found in
boost::wave headers with the only change that it uses boost::wave headers with the only change that it uses
boost::filesystem facility to handle UTF-8 paths used boost::filesystem facility to handle UTF-8 paths properly on windows.
throughout OpenMW (bfs::fstream, bfs::path).
Original namespace is used due to required bost::wave Original namespace is used due to required bost::wave
internal symbols. internal symbols.

View file

@ -1,8 +1,6 @@
#ifndef SH_PREPROCESSOR_H #ifndef SH_PREPROCESSOR_H
#define SH_PREPROCESSOR_H #define SH_PREPROCESSOR_H
#include <stdint.h>
#include <string> #include <string>
#include <vector> #include <vector>

View file

@ -151,7 +151,7 @@ namespace sh
else if (typeid(*value) == typeid(IntValue)) else if (typeid(*value) == typeid(IntValue))
type = Ogre::GCT_INT1; type = Ogre::GCT_INT1;
else else
throw std::runtime_error("unexpected type"); throw std::runtime_error("unexpected type");
params->addConstantDefinition(name, type); params->addConstantDefinition(name, type);
mSharedParameters[name] = params; mSharedParameters[name] = params;
} }