summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2015-01-10 22:29:17 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2015-01-10 22:29:17 +0300
commitb6c5cb1064eab63788060dc918d7fec53e57a532 (patch)
tree83f8345dd6ee0bc432ec21fc979c628edd808e5e /drivers
parenta7875c586af74302584544d777b189f4cb85c393 (diff)
parentf97582b5e9f069176a4c9226c39a880f786dae67 (diff)
Merge branch 'master' of github.com:okamstudio/godot
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp56
-rw-r--r--drivers/gles2/rasterizer_gles2.h3
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp3
-rw-r--r--drivers/png/resource_saver_png.cpp4
-rw-r--r--drivers/theoraplayer/SCsub2
5 files changed, 35 insertions, 33 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index fdf73a6c21..2092187431 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -1545,13 +1545,15 @@ void RasterizerGLES2::shader_set_default_texture_param(RID p_shader, const Strin
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND(!shader);
- ERR_FAIL_COND(!texture_owner.owns(p_texture));
+ ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
if (p_texture.is_valid())
shader->default_textures[p_name]=p_texture;
else
shader->default_textures.erase(p_name);
+ _shader_make_dirty(shader);
+
}
RID RasterizerGLES2::shader_get_default_texture_param(RID p_shader, const StringName& p_name) const{
@@ -1606,6 +1608,7 @@ void RasterizerGLES2::material_set_param(RID p_material, const StringName& p_par
material->shader_version=0; //get default!
} else {
E->get().value=p_value;
+ E->get().inuse=true;
}
} else {
@@ -1613,6 +1616,7 @@ void RasterizerGLES2::material_set_param(RID p_material, const StringName& p_par
ud.index=-1;
ud.value=p_value;
ud.istexture=p_value.get_type()==Variant::_RID; /// cache it being texture
+ ud.inuse=true;
material->shader_params[p_param]=ud; //may be got at some point, or erased
}
@@ -1644,7 +1648,7 @@ Variant RasterizerGLES2::material_get_param(RID p_material, const StringName& p_
}
- if (material->shader_params.has(p_param))
+ if (material->shader_params.has(p_param) && material->shader_params[p_param].inuse)
return material->shader_params[p_param].value;
else
return Variant();
@@ -4876,31 +4880,46 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
Material::UniformData ud;
- bool keep=true;
+ bool keep=true; //keep material value
+ bool has_old = old_mparams.has(E->key());
+ bool old_inuse=has_old && old_mparams[E->key()].inuse;
- if (!old_mparams.has(E->key()))
+ if (!has_old || !old_inuse)
keep=false;
else if (old_mparams[E->key()].value.get_type()!=E->value().default_value.get_type()) {
-
- if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
+ //type changed between old and new
+ /*if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures
keep=false;
} else if (!old_mparams[E->key()].value.is_num() || !E->value().default_value.get_type())
+ keep=false;*/
+
+ //value is invalid because type differs and default is not null
+ if (E->value().default_value.get_type()!=Variant::NIL)
keep=false;
}
+ ud.istexture=(E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP);
+
if (keep) {
ud.value=old_mparams[E->key()].value;
+
//print_line("KEEP: "+String(E->key()));
} else {
- ud.value=E->value().default_value;
+ if (ud.istexture && p_material->shader_cache->default_textures.has(E->key()))
+ ud.value=p_material->shader_cache->default_textures[E->key()];
+ else
+ ud.value=E->value().default_value;
+ old_inuse=false; //if reverted to default, obviously did not work
+
//print_line("NEW: "+String(E->key())+" because: hasold-"+itos(old_mparams.has(E->key())));
//if (old_mparams.has(E->key()))
// print_line(" told "+Variant::get_type_name(old_mparams[E->key()].value.get_type())+" tnew "+Variant::get_type_name(E->value().default_value.get_type()));
}
- ud.istexture=(E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP);
+
ud.index=idx++;
+ ud.inuse=old_inuse;
mparams[E->key()]=ud;
}
@@ -5021,23 +5040,8 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
E->get().value=RID(); //nullify, invalid texture
rid=RID();
}
- } else {
-
-
- }
-
- if (!rid.is_valid()) {
- //use from default textures
- Map<StringName,RID>::Element *F=p_material->shader_cache->default_textures.find(E->key());
- if (F) {
- t=texture_owner.get(F->get());
- if (!t) {
- p_material->shader_cache->default_textures.erase(E->key());
- }
- }
}
-
glActiveTexture(GL_TEXTURE0+texcoord);
glUniform1i(loc,texcoord); //TODO - this could happen automatically on compile...
if (t) {
@@ -5061,12 +5065,6 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
}
- for (Map<StringName,RID>::Element *E=p_material->shader_cache->default_textures.front();E;E=E->next()) {
- if (p_material->shader_params.has(E->key()))
- continue;
-
-
- }
if (p_material->shader_cache->has_texscreen && framebuffer.active) {
material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height));
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index dc596f9f6c..aa6a4e1f67 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -241,8 +241,9 @@ class RasterizerGLES2 : public Rasterizer {
struct UniformData {
+ bool inuse;
bool istexture;
- Variant value;
+ Variant value;
int index;
};
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index 50b63e1aa0..8eed423b8a 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -131,6 +131,7 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
SL::BlockNode *bnode=(SL::BlockNode*)p_node;
//variables
+ code+="{"ENDL;
for(Map<StringName,SL::DataType>::Element *E=bnode->variables.front();E;E=E->next()) {
code+=_mktab(p_level)+_typestr(E->value())+" "+replace_string(E->key())+";"ENDL;
@@ -141,6 +142,7 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";"ENDL;
}
+ code+="}"ENDL;
} break;
case SL::Node::TYPE_VARIABLE: {
@@ -676,6 +678,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
//mode_replace_table[1]["POSITION"]="IN_POSITION";
mode_replace_table[1]["NORMAL"]="normal";
mode_replace_table[1]["TANGENT"]="tangent";
+ mode_replace_table[1]["POSITION"]="gl_Position";
mode_replace_table[1]["BINORMAL"]="binormal";
mode_replace_table[1]["NORMALMAP"]="normalmap";
mode_replace_table[1]["NORMALMAP_DEPTH"]="normaldepth";
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp
index 1fee50c8b5..462051b21e 100644
--- a/drivers/png/resource_saver_png.cpp
+++ b/drivers/png/resource_saver_png.cpp
@@ -64,10 +64,10 @@ Error ResourceSaverPNG::save(const String &p_path,const RES& p_resource,uint32_t
text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"filter=true\n":"filter=false\n";
}
if (global_mipmaps!=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)) {
- text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"gen_mipmaps=true\n":"gen_mipmaps=false\n";
+ text+=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)?"gen_mipmaps=true\n":"gen_mipmaps=false\n";
}
if (global_repeat!=bool(texture->get_flags()&Texture::FLAG_REPEAT)) {
- text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"repeat=true\n":"repeat=false\n";
+ text+=bool(texture->get_flags()&Texture::FLAG_REPEAT)?"repeat=true\n":"repeat=false\n";
}
if (bool(texture->get_flags()&Texture::FLAG_ANISOTROPIC_FILTER)) {
text+="anisotropic=true\n";
diff --git a/drivers/theoraplayer/SCsub b/drivers/theoraplayer/SCsub
index 419f2b65ae..09fb13d8e9 100644
--- a/drivers/theoraplayer/SCsub
+++ b/drivers/theoraplayer/SCsub
@@ -70,7 +70,7 @@ if env["platform"] == "iphone":
env_theora.Append(CPPFLAGS=["-D_IOS", "-D__ARM_NEON__", "-fstrict-aliasing", "-fmessage-length=210", "-fdiagnostics-show-note-include-stack", "-fmacro-backtrace-limit=0", "-fcolor-diagnostics", "-Wno-trigraphs", "-fpascal-strings", "-fvisibility=hidden", "-fvisibility-inlines-hidden"])
env_theora.Append(CPPFLAGS=["-D_LIB", "-D__THEORA"]) # removed -D_YUV_C
-env_theora.Append(CPPFLAGS=["-D_YUV_LIBYUV", "-DLIBYUV_NEON"])
+env_theora.Append(CPPFLAGS=["-D_YUV_LIBYUV"])
#env_theora.Append(CPPFLAGS=["-D_YUV_C"])
if env["platform"] == "iphone":