summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp9
-rw-r--r--drivers/gles2/rasterizer_gles2.h26
2 files changed, 29 insertions, 6 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 3e68c65d45..3e5e960695 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -10047,10 +10047,19 @@ 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();
keep_copies=p_keep_ram_copy;
use_reload_hooks=p_use_reload_hooks;
pack_arrays=p_compress_arrays;
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 0f77d18dee..5d5ec032b5 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -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);
}
};