fixes to skinned buffer

should avoid targets with large objects using morphs
also skinned buffer size is properly customizable on project settings.
This commit is contained in:
Juan Linietsky 2015-02-10 19:14:22 -03:00
parent dfb94de041
commit e74982e55e
3 changed files with 17 additions and 7 deletions

View file

@ -5502,13 +5502,15 @@ Error RasterizerGLES2::_setup_geometry(const Geometry *p_geometry, const Materia
base = surf->array_local; base = surf->array_local;
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
bool can_copy_to_local=surf->local_stride * surf->array_len <= skinned_buffer_size; 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) if (!can_copy_to_local)
skeleton_valid=false; skeleton_valid=false;
/* compute morphs */ /* compute morphs */
if (p_morphs && surf->morph_target_count && can_copy_to_local) { if (p_morphs && surf->morph_target_count && can_copy_to_local) {
@ -9589,9 +9591,6 @@ void RasterizerGLES2::init() {
//glClearDepth(1.0); //glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 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); glGenTextures(1, &white_tex);
unsigned char whitetexdata[8*8*3]; unsigned char whitetexdata[8*8*3];
for(int i=0;i<8*8*3;i++) { for(int i=0;i<8*8*3;i++) {
@ -9767,7 +9766,6 @@ void RasterizerGLES2::init() {
void RasterizerGLES2::finish() { void RasterizerGLES2::finish() {
memdelete_arr(skinned_buffer);
} }
int RasterizerGLES2::get_render_info(VS::RenderInfo p_info) { int RasterizerGLES2::get_render_info(VS::RenderInfo p_info) {
@ -10058,8 +10056,18 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo
RenderList::max_elements=64000; RenderList::max_elements=64000;
if (RenderList::max_elements<1024) if (RenderList::max_elements<1024)
RenderList::max_elements=1024; RenderList::max_elements=1024;
opaque_render_list.init(); opaque_render_list.init();
alpha_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; keep_copies=p_keep_ram_copy;
use_reload_hooks=p_use_reload_hooks; use_reload_hooks=p_use_reload_hooks;
pack_arrays=p_compress_arrays; pack_arrays=p_compress_arrays;
@ -10103,6 +10111,7 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo
RasterizerGLES2::~RasterizerGLES2() { RasterizerGLES2::~RasterizerGLES2() {
memdelete_arr(skinned_buffer);
}; };

View file

@ -65,7 +65,7 @@ class RasterizerGLES2 : public Rasterizer {
MAX_SCENE_LIGHTS=2048, MAX_SCENE_LIGHTS=2048,
LIGHT_SPOT_BIT=0x80, LIGHT_SPOT_BIT=0x80,
DEFAULT_SKINNED_BUFFER_SIZE = 2048 * 1024, // 10k vertices DEFAULT_SKINNED_BUFFER_SIZE = 2048, // 10k vertices
MAX_HW_LIGHTS = 1, MAX_HW_LIGHTS = 1,
}; };

1
make.bat Normal file
View file

@ -0,0 +1 @@
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" && c:\python27\scons p=windows