summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorreduz <juan@okamstudio.com>2016-12-24 16:23:30 -0300
committerreduz <juan@okamstudio.com>2016-12-24 16:23:30 -0300
commit0d4abf2aa3a336a8a04c83f0576c6b42783ba6e9 (patch)
treeddbbc1aa82a80ccfe7e35a34f34a06cfa1dbb22e
parent3adb42e217d29033e0637ae334790aa1d742d194 (diff)
fixed a horrible bug on Windows AMD, scenes saved until now in this branch
are no longer valid :(
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp8
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp13
-rw-r--r--drivers/gles3/shaders/scene.glsl2
-rw-r--r--platform/windows/context_gl_win.cpp2
-rw-r--r--scene/resources/mesh.cpp6
-rw-r--r--servers/visual/visual_server_scene.cpp4
-rw-r--r--servers/visual_server.cpp17
8 files changed, 40 insertions, 16 deletions
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index bf3b902c5c..ccc5c70c97 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 d380d8d149..7fdd08a834 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 ec71f64049..ffcd462808 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;i<VS::ARRAY_MAX;i++) {
+ attribs[i].index=i;
+
if (! (p_format&(1<<i) ) ) {
attribs[i].enabled=false;
attribs[i].integer=false;
@@ -2489,7 +2491,6 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
attribs[i].enabled=true;
attribs[i].offset=stride;
- attribs[i].index=i;
attribs[i].integer=false;
switch(i) {
@@ -2499,7 +2500,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
if (p_format&VS::ARRAY_FLAG_USE_2D_VERTICES) {
attribs[i].size=2;
} else {
- attribs[i].size=3;
+ attribs[i].size=(p_format&VS::ARRAY_COMPRESS_VERTEX)?4:3;
}
if (p_format&VS::ARRAY_COMPRESS_VERTEX) {
@@ -2719,18 +2720,20 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_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 2dfbbd340d..b0b2782307 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 57950d33ca..fc6e33f408 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 ec33bb53d9..c454301e02 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -775,8 +775,10 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
DVector<int> indices = a[ARRAY_INDEX];
DVector<int>::Read ir = indices.read();
- for(int i=0;i<ic;i++)
- facesw[widx++]=vr[ ir[i] ];
+ for(int i=0;i<ic;i++) {
+ int index = ir[i];
+ facesw[widx++]=vr[ index ];
+ }
} else {
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index a7876d0815..aa97b2ebd6 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -2699,7 +2699,7 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,con
continue; // too far away
float dt = CLAMP((d+distance_adv)/local_radius,0,1);
- att*= pow(1.0-dt,light_cache.attenuation);
+ att*= powf(1.0-dt,light_cache.attenuation);
}
@@ -2710,7 +2710,7 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,con
continue;
float d = CLAMP(angle/light_cache.spot_angle,1,0);
- att*= pow(1.0-d,light_cache.spot_attenuation);
+ att*= powf(1.0-d,light_cache.spot_attenuation);
}
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index ac894f1286..6f26a36463 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -437,9 +437,9 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t
for (int i=0;i<p_vertex_array_len;i++) {
- uint16_t vector[3]={ Math::make_half_float(src[i].x), Math::make_half_float(src[i].y), Math::make_half_float(src[i].z) };
+ uint16_t vector[4]={ Math::make_half_float(src[i].x), Math::make_half_float(src[i].y), Math::make_half_float(src[i].z), Math::make_half_float(1.0) };
- copymem(&vw[p_offsets[ai]+i*p_stride], vector, sizeof(uint16_t)*3);
+ copymem(&vw[p_offsets[ai]+i*p_stride], vector, sizeof(uint16_t)*4);
if (i==0) {
@@ -952,6 +952,11 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi
elem_size*=sizeof(float);
}
+ if (elem_size==6) {
+ //had to pad
+ elem_size=8;
+ }
+
} break;
case VS::ARRAY_NORMAL: {
@@ -1138,6 +1143,10 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format,DVector<uint8_t> 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<uint8_t> 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<uint8_t> p
DVector<int> arr;
arr.resize(p_index_len);
- if (p_index_len<(1<<16)) {
+ if (p_vertex_len<(1<<16)) {
DVector<int>::Write w = arr.write();