diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-02-06 00:38:39 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-02-06 00:38:39 -0300 |
commit | 6f2e16306a6552d704fb2346c9abdd26e0e523b7 (patch) | |
tree | e1fadf2a05d6f04675045b9e34128ed96628e07c /drivers | |
parent | af3fabeb7745e6f7f4e7fe7a299bdd234fff26a6 (diff) |
Several bugfixes, improving the import workflow
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 25 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.h | 1 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 51 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.h | 15 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 1 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 8 | ||||
-rw-r--r-- | drivers/unix/os_unix.h | 2 |
7 files changed, 96 insertions, 7 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index c0af9b3bcf..2e2edaafb6 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1081,6 +1081,18 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m state.current_line_width=p_material->line_width; } + if (state.current_depth_test!=(!p_material->shader->spatial.ontop)) { + if (p_material->shader->spatial.ontop) { + glDisable(GL_DEPTH_TEST); + + } else { + glEnable(GL_DEPTH_TEST); + + } + + state.current_depth_test=!p_material->shader->spatial.ontop; + } + if (state.current_depth_draw!=p_material->shader->spatial.depth_draw_mode) { switch(p_material->shader->spatial.depth_draw_mode) { case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS: @@ -1204,6 +1216,11 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m } else { +#ifdef TOOLS_ENABLED + if (t->detect_3d) { + t->detect_3d(t->detect_3d_ud); + } +#endif if (storage->config.srgb_decode_supported) { //if SRGB decode extension is present, simply switch the texture to whathever is needed bool must_srgb=false; @@ -1216,9 +1233,8 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m if (must_srgb) { glTexParameteri(t->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT); #ifdef TOOLS_ENABLED - if (!(t->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - t->flags|=VS::TEXTURE_FLAG_CONVERT_TO_LINEAR; - //notify that texture must be set to linear beforehand, so it works in other platforms when exported + if (t->detect_srgb) { + t->detect_srgb(t->detect_srgb_ud); } #endif @@ -1714,6 +1730,9 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e state.cull_front=false; glCullFace(GL_BACK); + state.current_depth_test=true; + glEnable(GL_DEPTH_TEST); + state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON,false); state.current_blend_mode=-1; diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 7838345e59..e5bc4feb85 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -61,6 +61,7 @@ public: int current_blend_mode; float current_line_width; int current_depth_draw; + bool current_depth_test; GLuint current_main_tex; SceneShaderGLES3 scene_shader; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index a96fd8dd41..1cc346410b 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -218,7 +218,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.s3tc_supported) { - r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; + r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_S3TC_DXT1_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; r_gl_format=GL_RGBA; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -785,7 +785,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image if (texture->compressed) { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glCompressedTexImage2D( blit_target, i, format,w,h,0,size,&read[ofs] ); + glCompressedTexImage2D( blit_target, i, internal_format,w,h,0,size,&read[ofs] ); } else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -814,6 +814,10 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && mipmaps==1 && !texture->ignore_mipmaps && (!(texture->flags&VS::TEXTURE_FLAG_CUBEMAP) || texture->stored_cube_sides==(1<<6)-1)) { //generate mipmaps if they were requested and the image does not contain them glGenerateMipmap(texture->target); + } else if (mipmaps>1) { + glTexParameteri(texture->target, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, mipmaps-1); + } texture->mipmaps=mipmaps; @@ -1066,6 +1070,26 @@ void RasterizerStorageGLES3::textures_keep_original(bool p_enable) { config.keep_original_textures=p_enable; } +void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata) { + + Texture * texture = texture_owner.get(p_texture); + ERR_FAIL_COND(!texture); + + texture->detect_3d=p_callback; + texture->detect_3d_ud=p_userdata; +} + +void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata){ + Texture * texture = texture_owner.get(p_texture); + ERR_FAIL_COND(!texture); + + texture->detect_srgb=p_callback; + texture->detect_srgb_ud=p_userdata; + +} + + + RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_resolution) const { Texture * texture = texture_owner.get(p_source); @@ -1515,12 +1539,12 @@ void RasterizerStorageGLES3::_update_shader(Shader* p_shader) const { actions->uniforms=&p_shader->uniforms; - } + } break; case VS::SHADER_PARTICLES: { actions=&shaders.actions_particles; actions->uniforms=&p_shader->uniforms; - } + } break; } @@ -6294,6 +6318,25 @@ bool RasterizerStorageGLES3::free(RID p_rid){ return true; } + +bool RasterizerStorageGLES3::has_os_feature(const String& p_feature) const { + + if (p_feature=="s3tc") + return config.s3tc_supported; + + if (p_feature=="etc") + return config.etc_supported; + + if (p_feature=="etc2") + return config.etc2_supported; + + if (p_feature=="pvrtc") + return config.pvrtc_supported; + + return false; + +} + //////////////////////////////////////////// diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index c8f04f72c1..5beb6e48aa 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -228,6 +228,12 @@ public: Image images[6]; + VisualServer::TextureDetectCallback detect_3d; + void *detect_3d_ud; + + VisualServer::TextureDetectCallback detect_srgb; + void *detect_srgb_ud; + Texture() { using_srgb=false; @@ -243,6 +249,10 @@ public: total_data_size=0; target=GL_TEXTURE_2D; mipmaps=0; + detect_3d=NULL; + detect_3d_ud=NULL; + detect_srgb=NULL; + detect_srgb_ud=NULL; } @@ -281,6 +291,10 @@ public: virtual void textures_keep_original(bool p_enable); + virtual void texture_set_detect_3d_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata); + virtual void texture_set_detect_srgb_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata); + + /* SKYBOX API */ struct SkyBox : public RID_Data { @@ -1237,6 +1251,7 @@ public: void initialize(); void finalize(); + virtual bool has_os_feature(const String& p_feature) const; RasterizerStorageGLES3(); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 97872226a4..12aac79912 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -582,6 +582,7 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String& p_code, used_name_defines.clear(); used_rmode_defines.clear(); + used_flag_pointers.clear(); _dump_node_code(parser.get_shader(),1,r_gen_code,*p_actions,actions[p_mode]); diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 283cff0486..cc69283f97 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -30,6 +30,7 @@ #ifdef UNIX_ENABLED +#include "servers/visual_server.h" #include "thread_posix.h" #include "semaphore_posix.h" @@ -478,6 +479,13 @@ String OS_Unix::get_data_dir() const { } +bool OS_Unix::check_feature_support(const String& p_feature) { + + return VisualServer::get_singleton()->has_os_feature(p_feature); + +} + + String OS_Unix::get_installed_templates_path() const { String p=get_global_settings_path(); if (p!="") diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index b28adc2ee0..220f818ff6 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -117,6 +117,8 @@ public: virtual String get_executable_path() const; virtual String get_data_dir() const; + virtual bool check_feature_support(const String& p_feature); + //virtual void run( MainLoop * p_main_loop ); |