From 0d4abf2aa3a336a8a04c83f0576c6b42783ba6e9 Mon Sep 17 00:00:00 2001 From: reduz Date: Sat, 24 Dec 2016 16:23:30 -0300 Subject: [PATCH] fixed a horrible bug on Windows AMD, scenes saved until now in this branch are no longer valid :( --- drivers/gles3/rasterizer_gles3.cpp | 8 +++++++- drivers/gles3/rasterizer_scene_gles3.cpp | 4 ++++ drivers/gles3/rasterizer_storage_gles3.cpp | 13 ++++++++----- drivers/gles3/shaders/scene.glsl | 2 +- platform/windows/context_gl_win.cpp | 2 +- scene/resources/mesh.cpp | 6 ++++-- servers/visual/visual_server_scene.cpp | 4 ++-- servers/visual_server.cpp | 17 +++++++++++++---- 8 files changed, 40 insertions(+), 16 deletions(-) diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index bf3b902c5cb..ccc5c70c97a 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -42,7 +42,13 @@ RasterizerScene *RasterizerGLES3::get_scene() { #define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148 #define _EXT_DEBUG_OUTPUT 0x92E0 -static void _gl_debug_print(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam) +#ifdef WINDOWS_ENABLED +#define GLAPIENTRY APIENTRY +#else +#define GLAPIENTRY +#endif + +static void GLAPIENTRY _gl_debug_print(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam) { if (type==_EXT_DEBUG_TYPE_OTHER_ARB) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index d380d8d149d..7fdd08a8347 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1337,6 +1337,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (s->index_array_len>0) { + glDrawElements(gl_primitive[s->primitive],s->index_array_len, (s->array_len>=(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT,0); storage->info.render_vertices_count+=s->index_array_len; @@ -1349,6 +1350,9 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { } + + + } break; case VS::INSTANCE_MULTIMESH: { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index ec71f64049f..ffcd462808c 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2481,6 +2481,8 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P for(int i=0;iindex_id); glBufferData(GL_ELEMENT_ARRAY_BUFFER,index_array_size,ir.ptr(),GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); //unbind + + } //generate arrays for faster state switching - for(int i=0;i<2;i++) { + for(int ai=0;ai<2;ai++) { - if (i==0) { + if (ai==0) { //for normal draw glGenVertexArrays(1,&surface->array_id); glBindVertexArray(surface->array_id); glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); - } else if (i==1) { + } else if (ai==1) { //for instancing draw (can be changed and no one cares) glGenVertexArrays(1,&surface->instancing_array_id); glBindVertexArray(surface->instancing_array_id); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 2dfbbd340d9..b0b27823075 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -872,7 +872,7 @@ vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, b dist += diameter * 0.5; } - color.rgb = mix(color.rgb,mix(ambient,color.rgb,alpha),blend_ambient); + //color.rgb = mix(color.rgb,mix(ambient,color.rgb,alpha),blend_ambient); return color.rgb; } diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index 57950d33ca2..fc6e33f408f 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -165,7 +165,7 @@ Error ContextGL_Win::initialize() { WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.3 context WGL_CONTEXT_MINOR_VERSION_ARB, 3, //and it shall be forward compatible so that we can only use up to date functionality - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB/*|WGL_CONTEXT_DEBUG_BIT_ARB*/, 0}; //zero indicates the end of the array PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; //pointer to the method diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index ec33bb53d98..c454301e02f 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -775,8 +775,10 @@ Ref Mesh::generate_triangle_mesh() const { DVector indices = a[ARRAY_INDEX]; DVector::Read ir = indices.read(); - for(int i=0;i p elem_size*=sizeof(float); } + if (elem_size==6) { + elem_size=8; + } + } break; case VS::ARRAY_NORMAL: { @@ -1207,7 +1216,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format,DVector p break; } /* determine wether using 16 or 32 bits indices */ - if (p_index_len>=(1<<16)) { + if (p_vertex_len>=(1<<16)) { elem_size=4; @@ -1505,7 +1514,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format,DVector p DVector arr; arr.resize(p_index_len); - if (p_index_len<(1<<16)) { + if (p_vertex_len<(1<<16)) { DVector::Write w = arr.write();