summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2015-02-17 15:57:24 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2015-02-17 15:57:24 +0300
commite024ff89b224f803fe335efa95d3e99bffc3423f (patch)
tree84ca5323c97ef24cfcae202447ac6967783e9248 /drivers
parent6f93e6812edaf6c8c79c28dadbe5f1c4a8ced93e (diff)
parent2bea642583efeb68886e71950384f297f2d7ee12 (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp156
-rw-r--r--drivers/gles2/rasterizer_gles2.h28
-rw-r--r--drivers/unix/ip_unix.cpp7
-rw-r--r--drivers/unix/os_unix.cpp20
4 files changed, 142 insertions, 69 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 5903be9d81..d1e55f2488 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -4038,8 +4038,16 @@ void RasterizerGLES2::render_target_set_size(RID p_render_target,int p_width,int
glGenTextures(1, &rt->color);
glBindTexture(GL_TEXTURE_2D, rt->color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ if (rt->texture_ptr->flags&VS::TEXTURE_FLAG_FILTER) {
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ } else {
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ }
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->color, 0);
@@ -5494,13 +5502,15 @@ Error RasterizerGLES2::_setup_geometry(const Geometry *p_geometry, const Materia
base = surf->array_local;
glBindBuffer(GL_ARRAY_BUFFER, 0);
bool can_copy_to_local=surf->local_stride * surf->array_len <= skinned_buffer_size;
+ if (p_morphs && surf->stride * surf->array_len > skinned_buffer_size)
+ can_copy_to_local=false;
+
+
if (!can_copy_to_local)
skeleton_valid=false;
-
/* compute morphs */
-
if (p_morphs && surf->morph_target_count && can_copy_to_local) {
@@ -8320,7 +8330,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
CanvasItem *current_clip=NULL;
-
+ Shader *shader_cache=NULL;
canvas_opacity=1.0;
while(p_item_list) {
@@ -8365,6 +8375,8 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
}
}
+ shader_cache=shader;
+
if (shader) {
canvas_shader.set_custom_shader(shader->custom_code_id);
if (canvas_shader.bind())
@@ -8374,50 +8386,6 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
//todo optimize uniforms
shader_owner->shader_version=shader->version;
}
- //this can be optimized..
- int tex_id=1;
- int idx=0;
- for(Map<StringName,ShaderLanguage::Uniform>::Element *E=shader->uniforms.front();E;E=E->next()) {
-
- Map<StringName,Variant>::Element *F=shader_owner->shader_param.find(E->key());
-
- if ((E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP)) {
-
- RID rid;
- if (F) {
- rid=F->get();
- }
-
- if (!rid.is_valid()) {
-
- Map<StringName,RID>::Element *DT=shader->default_textures.find(E->key());
- if (DT) {
- rid=DT->get();
- }
- }
-
- if (rid.is_valid()) {
-
- int loc = canvas_shader.get_custom_uniform_location(idx); //should be automatic..
-
- glActiveTexture(GL_TEXTURE0+tex_id);
- Texture *t=texture_owner.get(rid);
- if (!t)
- glBindTexture(GL_TEXTURE_2D,white_tex);
- else
- glBindTexture(t->target,t->tex_id);
-
- glUniform1i(loc,tex_id);
- tex_id++;
- }
- } else {
- Variant &v=F?F->get():E->get().default_value;
- canvas_shader.set_custom_uniform(idx,v);
- }
-
- idx++;
- }
-
if (shader->has_texscreen && framebuffer.active) {
@@ -8426,8 +8394,8 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height));
canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(float(x)/framebuffer.width,float(y)/framebuffer.height,float(x+viewport.width)/framebuffer.width,float(y+viewport.height)/framebuffer.height));
- canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_TEX,tex_id);
- glActiveTexture(GL_TEXTURE0+tex_id);
+ canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_TEX,max_texture_units-1);
+ glActiveTexture(GL_TEXTURE0+max_texture_units-1);
glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color);
if (framebuffer.scale==1 && !canvas_texscreen_used) {
#ifdef GLEW_ENABLED
@@ -8439,14 +8407,12 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
}
canvas_texscreen_used=true;
- }
- tex_id++;
+ }
- }
-
- if (tex_id>1) {
glActiveTexture(GL_TEXTURE0);
+
}
+
if (shader->has_screen_uv) {
canvas_shader.set_uniform(CanvasShaderGLES2::SCREEN_UV_MULT,Vector2(1.0/viewport.width,1.0/viewport.height));
}
@@ -8460,6 +8426,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
uses_texpixel_size=shader->uses_texpixel_size;
} else {
+ shader_cache=NULL;
canvas_shader.set_custom_shader(0);
canvas_shader.bind();
uses_texpixel_size=false;
@@ -8471,6 +8438,59 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
canvas_last_shader=shader_owner->shader;
}
+ if (shader_cache) {
+
+ Shader *shader = shader_cache;
+ //this can be optimized..
+ int tex_id=1;
+ int idx=0;
+ for(Map<StringName,ShaderLanguage::Uniform>::Element *E=shader->uniforms.front();E;E=E->next()) {
+
+ Map<StringName,Variant>::Element *F=shader_owner->shader_param.find(E->key());
+
+ if ((E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP)) {
+
+ RID rid;
+ if (F) {
+ rid=F->get();
+ }
+
+ if (!rid.is_valid()) {
+
+ Map<StringName,RID>::Element *DT=shader->default_textures.find(E->key());
+ if (DT) {
+ rid=DT->get();
+ }
+ }
+
+ if (rid.is_valid()) {
+
+ int loc = canvas_shader.get_custom_uniform_location(idx); //should be automatic..
+
+ glActiveTexture(GL_TEXTURE0+tex_id);
+ Texture *t=texture_owner.get(rid);
+ if (!t)
+ glBindTexture(GL_TEXTURE_2D,white_tex);
+ else
+ glBindTexture(t->target,t->tex_id);
+
+ glUniform1i(loc,tex_id);
+ tex_id++;
+ }
+ } else {
+ Variant &v=F?F->get():E->get().default_value;
+ canvas_shader.set_custom_uniform(idx,v);
+ }
+
+ idx++;
+ }
+
+ if (tex_id>1) {
+ glActiveTexture(GL_TEXTURE0);
+ }
+
+ }
+
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
@@ -9581,9 +9601,6 @@ void RasterizerGLES2::init() {
//glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- skinned_buffer_size = GLOBAL_DEF("rasterizer/skinned_buffer_size",DEFAULT_SKINNED_BUFFER_SIZE);
- skinned_buffer = memnew_arr( uint8_t, skinned_buffer_size );
-
glGenTextures(1, &white_tex);
unsigned char whitetexdata[8*8*3];
for(int i=0;i<8*8*3;i++) {
@@ -9759,7 +9776,6 @@ void RasterizerGLES2::init() {
void RasterizerGLES2::finish() {
- memdelete_arr(skinned_buffer);
}
int RasterizerGLES2::get_render_info(VS::RenderInfo p_info) {
@@ -10039,10 +10055,29 @@ RasterizerGLES2* RasterizerGLES2::get_singleton() {
return _singleton;
};
+int RasterizerGLES2::RenderList::max_elements=RenderList::DEFAULT_MAX_ELEMENTS;
+
RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,bool p_default_fragment_lighting,bool p_use_reload_hooks) {
_singleton = this;
+ RenderList::max_elements=GLOBAL_DEF("rasterizer/max_render_elements",(int)RenderList::DEFAULT_MAX_ELEMENTS);
+ if (RenderList::max_elements>64000)
+ RenderList::max_elements=64000;
+ if (RenderList::max_elements<1024)
+ RenderList::max_elements=1024;
+
+ opaque_render_list.init();
+ alpha_render_list.init();
+
+ skinned_buffer_size = GLOBAL_DEF("rasterizer/skeleton_buffer_size_kb",DEFAULT_SKINNED_BUFFER_SIZE);
+ if (skinned_buffer_size<256)
+ skinned_buffer_size=256;
+ if (skinned_buffer_size>16384)
+ skinned_buffer_size=16384;
+ skinned_buffer_size*=1024;
+ skinned_buffer = memnew_arr( uint8_t, skinned_buffer_size );
+
keep_copies=p_keep_ram_copy;
use_reload_hooks=p_use_reload_hooks;
pack_arrays=p_compress_arrays;
@@ -10086,6 +10121,7 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo
RasterizerGLES2::~RasterizerGLES2() {
+ memdelete_arr(skinned_buffer);
};
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 0f77d18dee..508adf2859 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -65,7 +65,7 @@ class RasterizerGLES2 : public Rasterizer {
MAX_SCENE_LIGHTS=2048,
LIGHT_SPOT_BIT=0x80,
- DEFAULT_SKINNED_BUFFER_SIZE = 2048 * 1024, // 10k vertices
+ DEFAULT_SKINNED_BUFFER_SIZE = 2048, // 10k vertices
MAX_HW_LIGHTS = 1,
};
@@ -827,15 +827,18 @@ class RasterizerGLES2 : public Rasterizer {
GLuint gui_quad_buffer;
+
struct RenderList {
enum {
- MAX_ELEMENTS=4096,
+ DEFAULT_MAX_ELEMENTS=4096,
MAX_LIGHTS=4,
SORT_FLAG_SKELETON=1,
SORT_FLAG_INSTANCING=2,
};
+ static int max_elements;
+
struct Element {
@@ -868,8 +871,8 @@ class RasterizerGLES2 : public Rasterizer {
};
- Element _elements[MAX_ELEMENTS];
- Element *elements[MAX_ELEMENTS];
+ Element *_elements;
+ Element **elements;
int element_count;
void clear() {
@@ -1004,17 +1007,28 @@ class RasterizerGLES2 : public Rasterizer {
}
_FORCE_INLINE_ Element* add_element() {
- if (element_count>MAX_ELEMENTS)
+ if (element_count>=max_elements)
return NULL;
elements[element_count]=&_elements[element_count];
return elements[element_count++];
}
- RenderList() {
+ void init() {
element_count = 0;
- for (int i=0;i<MAX_ELEMENTS;i++)
+ elements=memnew_arr(Element*,max_elements);
+ _elements=memnew_arr(Element,max_elements);
+ for (int i=0;i<max_elements;i++)
elements[i]=&_elements[i]; // assign elements
+
+ }
+
+ RenderList() {
+
+ }
+ ~RenderList() {
+ memdelete_arr(elements);
+ memdelete_arr(_elements);
}
};
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp
index 841160f941..ad0d4e00ea 100644
--- a/drivers/unix/ip_unix.cpp
+++ b/drivers/unix/ip_unix.cpp
@@ -50,11 +50,16 @@
#ifdef ANDROID_ENABLED
#include "platform/android/ifaddrs_android.h"
#else
+ #ifdef __FreeBSD__
+ #include <sys/types.h>
+ #endif
#include <ifaddrs.h>
#endif
#include <arpa/inet.h>
#include <sys/socket.h>
-
+ #ifdef __FreeBSD__
+ #include <netinet/in.h>
+ #endif
#endif
IP_Address IP_Unix::_resolve_hostname(const String& p_hostname) {
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 2de975e5d1..d51a7c74e8 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -44,7 +44,9 @@
#include "stream_peer_tcp_posix.h"
#include "packet_peer_udp_posix.h"
-
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#endif
#include <stdarg.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -305,7 +307,17 @@ Error OS_Unix::execute(const String& p_path, const List<String>& p_arguments,boo
args.push_back((char*)cs[i].get_data());// shitty C cast
args.push_back(0);
+#ifdef __FreeBSD__
+ if(p_path.find("/")) {
+ // exec name contains path so use it
+ execv(p_path.utf8().get_data(),&args[0]);
+ }else{
+ // use program name and search through PATH to find it
+ execvp(getprogname(),&args[0]);
+ }
+#else
execv(p_path.utf8().get_data(),&args[0]);
+#endif
// still alive? something failed..
fprintf(stderr,"**ERROR** OS_Unix::execute - Could not create child process while executing: %s\n",p_path.utf8().get_data());
abort();
@@ -421,6 +433,12 @@ String OS_Unix::get_executable_path() const {
return OS::get_executable_path();
}
return b;
+#elif defined(__FreeBSD__)
+ char resolved_path[MAXPATHLEN];
+
+ realpath(OS::get_executable_path().utf8().get_data(), resolved_path);
+
+ return String(resolved_path);
#else
ERR_PRINT("Warning, don't know how to obtain executable path on this OS! Please override this function properly.");
return OS::get_executable_path();