diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 78 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.h | 20 |
2 files changed, 20 insertions, 78 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index fe8373b20d..24e6be588e 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -645,6 +645,10 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image bool srgb; + if (config.keep_original_textures && !(texture->flags&VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { + texture->images[p_cube_side]=p_image; + } + Image img = _get_gl_image_and_format(p_image, p_image.get_format(),texture->flags,format,internal_format,type,compressed,srgb); if (config.shrink_textures_x2 && (p_image.has_mipmaps() || !p_image.is_compressed()) && !(texture->flags&VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { @@ -822,6 +826,9 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c ERR_FAIL_COND_V(texture->data_size==0,Image()); ERR_FAIL_COND_V(texture->render_target,Image()); + if (!texture->images[p_cube_side].empty()) + return texture->images[p_cube_side]; + #ifdef GLES_OVER_GL DVector<uint8_t> data; @@ -871,6 +878,7 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c #else ERR_EXPLAIN("Sorry, It's not posible to obtain images back in OpenGL ES"); + return Image(); #endif } @@ -1047,6 +1055,11 @@ void RasterizerStorageGLES3::texture_set_shrink_all_x2_on_set_data(bool p_enable config.shrink_textures_x2=p_enable; } +void RasterizerStorageGLES3::textures_keep_original(bool p_enable) { + + config.keep_original_textures=p_enable; +} + RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_resolution) const { Texture * texture = texture_owner.get(p_source); @@ -4690,9 +4703,6 @@ RID RasterizerStorageGLES3::gi_probe_create() { GIProbe *gip = memnew( GIProbe ); - gip->data_width=0; - gip->data_height=0; - gip->data_depth=0; gip->bounds=AABB(Vector3(),Vector3(1,1,1)); gip->dynamic_range=1.0; gip->energy=1.0; @@ -4827,64 +4837,6 @@ float RasterizerStorageGLES3::gi_probe_get_energy(RID p_probe) const{ } -void RasterizerStorageGLES3::gi_probe_set_static_data(RID p_gi_probe,const DVector<uint8_t>& p_data,VS::GIProbeDataFormat p_format,int p_width,int p_height,int p_depth) { - - GIProbe *gip = gi_probe_owner.getornull(p_gi_probe); - ERR_FAIL_COND(!gip); - - if (gip->data.is_valid()) { - free(gip->data); - } - - gip->data=RID(); - //this is platform dependent - - gip->version++; - gip->instance_change_notify(); - -} -DVector<uint8_t> RasterizerStorageGLES3::gi_probe_get_static_data(RID p_gi_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_gi_probe); - ERR_FAIL_COND_V(!gip,DVector<uint8_t>()); - - //platform dependent - return DVector<uint8_t>(); -} -VS::GIProbeDataFormat RasterizerStorageGLES3::gi_probe_get_static_data_format(RID p_gi_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_gi_probe); - ERR_FAIL_COND_V(!gip,VS::GI_PROBE_DATA_RGBA8); - - return gip->data_format; -} -int RasterizerStorageGLES3::gi_probe_get_static_data_width(RID p_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,0); - - return gip->data_width; -} -int RasterizerStorageGLES3::gi_probe_get_static_data_height(RID p_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,0); - return gip->data_height; -} -int RasterizerStorageGLES3::gi_probe_get_static_data_depth(RID p_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,0); - return gip->data_depth; -} - -RID RasterizerStorageGLES3::gi_probe_get_data(RID p_probe) { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,RID()); - - return gip->data; -} uint32_t RasterizerStorageGLES3::gi_probe_get_version(RID p_probe) { @@ -5892,9 +5844,6 @@ bool RasterizerStorageGLES3::free(RID p_rid){ // delete the texture GIProbe *gi_probe = gi_probe_owner.get(p_rid); - if (gi_probe->data.is_valid()) { - free(gi_probe->data); - } gi_probe_owner.free(p_rid); memdelete(gi_probe); @@ -6119,6 +6068,7 @@ void RasterizerStorageGLES3::initialize() { glEnable(_EXT_TEXTURE_CUBE_MAP_SEAMLESS); frame.count=0; + config.keep_original_textures=false; } void RasterizerStorageGLES3::finalize() { diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index c51cd8d90b..5a8246f030 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -56,6 +56,8 @@ public: int max_texture_size; Set<String> extensions; + + bool keep_original_textures; } config; mutable struct Shaders { @@ -221,6 +223,8 @@ public: RenderTarget *render_target; + Image images[6]; + Texture() { using_srgb=false; @@ -272,6 +276,8 @@ public: virtual RID texture_create_radiance_cubemap(RID p_source,int p_resolution=-1) const; + virtual void textures_keep_original(bool p_enable); + /* SKYBOX API */ struct SkyBox : public RID_Data { @@ -898,12 +904,6 @@ public: DVector<int> dynamic_data; - RID data; - int data_width; - int data_height; - int data_depth; - VS::GIProbeDataFormat data_format; - }; @@ -932,14 +932,6 @@ public: virtual void gi_probe_set_interior(RID p_probe,bool p_enable); virtual bool gi_probe_is_interior(RID p_probe) const; - virtual void gi_probe_set_static_data(RID p_gi_probe,const DVector<uint8_t>& p_data,VS::GIProbeDataFormat p_format,int p_width,int p_height,int p_depth); - virtual DVector<uint8_t> gi_probe_get_static_data(RID p_gi_probe) const; - virtual VS::GIProbeDataFormat gi_probe_get_static_data_format(RID p_gi_probe) const; - virtual int gi_probe_get_static_data_width(RID p_probe) const; - virtual int gi_probe_get_static_data_height(RID p_probe) const; - virtual int gi_probe_get_static_data_depth(RID p_probe) const; - - virtual RID gi_probe_get_data(RID p_probe); //get data in case this is static virtual uint32_t gi_probe_get_version(RID p_probe); struct GIProbeData : public RID_Data { |