diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 6 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 174 | ||||
-rw-r--r-- | drivers/gles3/shaders/screen_space_reflection.glsl | 2 | ||||
-rw-r--r-- | drivers/unix/packet_peer_udp_posix.cpp | 36 | ||||
-rw-r--r-- | drivers/unix/packet_peer_udp_posix.h | 2 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 2 |
7 files changed, 127 insertions, 97 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 5deb78977a..3f54f887da 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -1579,7 +1579,7 @@ Variant RasterizerGLES2::shader_get_default_param(RID p_shader, const StringName Shader *shader = shader_owner.get(p_shader); ERR_FAIL_COND_V(!shader, Variant()); - //update shader params if necesary + //update shader params if necessary //make sure the shader is compiled and everything //so the actual parameters can be properly retrieved! if (shader->dirty_list.in_list()) { @@ -1651,7 +1651,7 @@ Variant RasterizerGLES2::material_get_param(RID p_material, const StringName &p_ ERR_FAIL_COND_V(!material, Variant()); if (material->shader.is_valid()) { - //update shader params if necesary + //update shader params if necessary //make sure the shader is compiled and everything //so the actual parameters can be properly retrieved! material->shader_cache = shader_owner.get(material->shader); @@ -5684,7 +5684,7 @@ void RasterizerGLES2::_render(const Geometry *p_geometry, const Material *p_mate }; } else if (use_attribute_instancing) { - //if not, using atributes instead of uniforms can be really fast in forward rendering architectures + //if not, using attributes instead of uniforms can be really fast in forward rendering architectures if (s->index_array_len > 0) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 81e137dffd..9aeb3af61a 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -1661,7 +1661,7 @@ public: void set_base_framebuffer(GLuint p_id, Vector2 p_size = Vector2(0, 0)); - virtual void flush_frame(); //not necesary in most cases + virtual void flush_frame(); //not necessary in most cases void set_extensions(const char *p_strings); virtual bool needs_to_draw_next_frame() const; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index b081936b99..4fcd09ed58 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -821,8 +821,10 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture, VS::CubeMapSide p_ ERR_FAIL_COND_V(texture->data_size == 0, Image()); ERR_FAIL_COND_V(texture->render_target, Image()); - if (!texture->images[p_cube_side].empty()) + if (!texture->images[p_cube_side].empty()) { return texture->images[p_cube_side]; + } + print_line("GETTING FROM GL "); #ifdef GLES_OVER_GL @@ -3047,18 +3049,17 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { if (!skused[j]) continue; - int base_ofs = ((j / 256) * 256) * 2 * 4 + (j % 256) * 4; Transform mtx; - mtx.basis[0].x=texture[base_ofs+0]; - mtx.basis[0].y=texture[base_ofs+1]; - mtx.origin.x=texture[base_ofs+3]; - base_ofs+=256*4; - mtx.basis[1].x=texture[base_ofs+0]; - mtx.basis[1].y=texture[base_ofs+1]; - mtx.origin.y=texture[base_ofs+3]; + mtx.basis[0].x = texture[base_ofs + 0]; + mtx.basis[0].y = texture[base_ofs + 1]; + mtx.origin.x = texture[base_ofs + 3]; + base_ofs += 256 * 4; + mtx.basis[1].x = texture[base_ofs + 0]; + mtx.basis[1].y = texture[base_ofs + 1]; + mtx.origin.y = texture[base_ofs + 3]; Rect3 baabb = mtx.xform(skbones[j]); if (first) { @@ -3078,20 +3079,20 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { Transform mtx; - mtx.basis[0].x=texture[base_ofs+0]; - mtx.basis[0].y=texture[base_ofs+1]; - mtx.basis[0].z=texture[base_ofs+2]; - mtx.origin.x=texture[base_ofs+3]; - base_ofs+=256*4; - mtx.basis[1].x=texture[base_ofs+0]; - mtx.basis[1].y=texture[base_ofs+1]; - mtx.basis[1].z=texture[base_ofs+2]; - mtx.origin.y=texture[base_ofs+3]; - base_ofs+=256*4; - mtx.basis[2].x=texture[base_ofs+0]; - mtx.basis[2].y=texture[base_ofs+1]; - mtx.basis[2].z=texture[base_ofs+2]; - mtx.origin.z=texture[base_ofs+3]; + mtx.basis[0].x = texture[base_ofs + 0]; + mtx.basis[0].y = texture[base_ofs + 1]; + mtx.basis[0].z = texture[base_ofs + 2]; + mtx.origin.x = texture[base_ofs + 3]; + base_ofs += 256 * 4; + mtx.basis[1].x = texture[base_ofs + 0]; + mtx.basis[1].y = texture[base_ofs + 1]; + mtx.basis[1].z = texture[base_ofs + 2]; + mtx.origin.y = texture[base_ofs + 3]; + base_ofs += 256 * 4; + mtx.basis[2].x = texture[base_ofs + 0]; + mtx.basis[2].y = texture[base_ofs + 1]; + mtx.basis[2].z = texture[base_ofs + 2]; + mtx.origin.z = texture[base_ofs + 3]; Rect3 baabb = mtx.xform(skbones[j]); if (first) { @@ -3927,7 +3928,7 @@ RID RasterizerStorageGLES3::skeleton_create() { Skeleton *skeleton = memnew(Skeleton); - glGenTextures(1,&skeleton->texture); + glGenTextures(1, &skeleton->texture); return skeleton_owner.make_rid(skeleton); } @@ -3941,22 +3942,22 @@ void RasterizerStorageGLES3::skeleton_allocate(RID p_skeleton, int p_bones, bool if (skeleton->size == p_bones && skeleton->use_2d == p_2d_skeleton) return; - skeleton->size=p_bones; - skeleton->use_2d=p_2d_skeleton; + skeleton->size = p_bones; + skeleton->use_2d = p_2d_skeleton; - int height = p_bones/256; - if (p_bones%256) + int height = p_bones / 256; + if (p_bones % 256) height++; glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D,skeleton->texture); + glBindTexture(GL_TEXTURE_2D, skeleton->texture); if (skeleton->use_2d) { - skeleton->skel_texture.resize(256*height*2*4); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 256, height*2, 0, GL_RGBA, GL_FLOAT, NULL); + skeleton->skel_texture.resize(256 * height * 2 * 4); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 256, height * 2, 0, GL_RGBA, GL_FLOAT, NULL); } else { - skeleton->skel_texture.resize(256*height*3*4); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 256, height*3, 0, GL_RGBA, GL_FLOAT, NULL); + skeleton->skel_texture.resize(256 * height * 3 * 4); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 256, height * 3, 0, GL_RGBA, GL_FLOAT, NULL); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -3988,21 +3989,20 @@ void RasterizerStorageGLES3::skeleton_bone_set_transform(RID p_skeleton, int p_b int base_ofs = ((p_bone / 256) * 256) * 3 * 4 + (p_bone % 256) * 4; - texture[base_ofs+0]=p_transform.basis[0].x; - texture[base_ofs+1]=p_transform.basis[0].y; - texture[base_ofs+2]=p_transform.basis[0].z; - texture[base_ofs+3]=p_transform.origin.x; - base_ofs+=256*4; - texture[base_ofs+0]=p_transform.basis[1].x; - texture[base_ofs+1]=p_transform.basis[1].y; - texture[base_ofs+2]=p_transform.basis[1].z; - texture[base_ofs+3]=p_transform.origin.y; - base_ofs+=256*4; - texture[base_ofs+0]=p_transform.basis[2].x; - texture[base_ofs+1]=p_transform.basis[2].y; - texture[base_ofs+2]=p_transform.basis[2].z; - texture[base_ofs+3]=p_transform.origin.z; - + texture[base_ofs + 0] = p_transform.basis[0].x; + texture[base_ofs + 1] = p_transform.basis[0].y; + texture[base_ofs + 2] = p_transform.basis[0].z; + texture[base_ofs + 3] = p_transform.origin.x; + base_ofs += 256 * 4; + texture[base_ofs + 0] = p_transform.basis[1].x; + texture[base_ofs + 1] = p_transform.basis[1].y; + texture[base_ofs + 2] = p_transform.basis[1].z; + texture[base_ofs + 3] = p_transform.origin.y; + base_ofs += 256 * 4; + texture[base_ofs + 0] = p_transform.basis[2].x; + texture[base_ofs + 1] = p_transform.basis[2].y; + texture[base_ofs + 2] = p_transform.basis[2].z; + texture[base_ofs + 3] = p_transform.origin.z; if (!skeleton->update_list.in_list()) { skeleton_update_list.add(&skeleton->update_list); @@ -4023,24 +4023,22 @@ Transform RasterizerStorageGLES3::skeleton_bone_get_transform(RID p_skeleton, in int base_ofs = ((p_bone / 256) * 256) * 3 * 4 + (p_bone % 256) * 4; - ret.basis[0].x=texture[base_ofs+0]; - ret.basis[0].y=texture[base_ofs+1]; - ret.basis[0].z=texture[base_ofs+2]; - ret.origin.x=texture[base_ofs+3]; - base_ofs+=256*4; - ret.basis[1].x=texture[base_ofs+0]; - ret.basis[1].y=texture[base_ofs+1]; - ret.basis[1].z=texture[base_ofs+2]; - ret.origin.y=texture[base_ofs+3]; - base_ofs+=256*4; - ret.basis[2].x=texture[base_ofs+0]; - ret.basis[2].y=texture[base_ofs+1]; - ret.basis[2].z=texture[base_ofs+2]; - ret.origin.z=texture[base_ofs+3]; - + ret.basis[0].x = texture[base_ofs + 0]; + ret.basis[0].y = texture[base_ofs + 1]; + ret.basis[0].z = texture[base_ofs + 2]; + ret.origin.x = texture[base_ofs + 3]; + base_ofs += 256 * 4; + ret.basis[1].x = texture[base_ofs + 0]; + ret.basis[1].y = texture[base_ofs + 1]; + ret.basis[1].z = texture[base_ofs + 2]; + ret.origin.y = texture[base_ofs + 3]; + base_ofs += 256 * 4; + ret.basis[2].x = texture[base_ofs + 0]; + ret.basis[2].y = texture[base_ofs + 1]; + ret.basis[2].z = texture[base_ofs + 2]; + ret.origin.z = texture[base_ofs + 3]; return ret; - } void RasterizerStorageGLES3::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) { @@ -4054,16 +4052,15 @@ void RasterizerStorageGLES3::skeleton_bone_set_transform_2d(RID p_skeleton, int int base_ofs = ((p_bone / 256) * 256) * 2 * 4 + (p_bone % 256) * 4; - texture[base_ofs+0]=p_transform[0][0]; - texture[base_ofs+1]=p_transform[1][0]; - texture[base_ofs+2]=0; - texture[base_ofs+3]=p_transform[2][0]; - base_ofs+=256*4; - texture[base_ofs+0]=p_transform[0][1]; - texture[base_ofs+1]=p_transform[1][1]; - texture[base_ofs+2]=0; - texture[base_ofs+3]=p_transform[2][1]; - + texture[base_ofs + 0] = p_transform[0][0]; + texture[base_ofs + 1] = p_transform[1][0]; + texture[base_ofs + 2] = 0; + texture[base_ofs + 3] = p_transform[2][0]; + base_ofs += 256 * 4; + texture[base_ofs + 0] = p_transform[0][1]; + texture[base_ofs + 1] = p_transform[1][1]; + texture[base_ofs + 2] = 0; + texture[base_ofs + 3] = p_transform[2][1]; if (!skeleton->update_list.in_list()) { skeleton_update_list.add(&skeleton->update_list); @@ -4083,13 +4080,13 @@ Transform2D RasterizerStorageGLES3::skeleton_bone_get_transform_2d(RID p_skeleto int base_ofs = ((p_bone / 256) * 256) * 2 * 4 + (p_bone % 256) * 4; - ret[0][0]=texture[base_ofs+0]; - ret[1][0]=texture[base_ofs+1]; - ret[2][0]=texture[base_ofs+3]; - base_ofs+=256*4; - ret[0][1]=texture[base_ofs+0]; - ret[1][1]=texture[base_ofs+1]; - ret[2][1]=texture[base_ofs+3]; + ret[0][0] = texture[base_ofs + 0]; + ret[1][0] = texture[base_ofs + 1]; + ret[2][0] = texture[base_ofs + 3]; + base_ofs += 256 * 4; + ret[0][1] = texture[base_ofs + 0]; + ret[1][1] = texture[base_ofs + 1]; + ret[2][1] = texture[base_ofs + 3]; return ret; } @@ -4103,15 +4100,12 @@ void RasterizerStorageGLES3::update_dirty_skeletons() { Skeleton *skeleton = skeleton_update_list.first()->self(); if (skeleton->size) { - - - int height = skeleton->size/256; - if (skeleton->size%256) + int height = skeleton->size / 256; + if (skeleton->size % 256) height++; - - glBindTexture(GL_TEXTURE_2D,skeleton->texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256,height*(skeleton->use_2d?2:3), GL_RGBA, GL_FLOAT, skeleton->skel_texture.ptr()); + glBindTexture(GL_TEXTURE_2D, skeleton->texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, height * (skeleton->use_2d ? 2 : 3), GL_RGBA, GL_FLOAT, skeleton->skel_texture.ptr()); } for (Set<RasterizerScene::InstanceBase *>::Element *E = skeleton->instances.front(); E; E = E->next()) { @@ -5892,7 +5886,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) { } else if (texture_owner.owns(p_rid)) { // delete the texture Texture *texture = texture_owner.get(p_rid); - ERR_FAIL_COND_V(texture->render_target, true); //cant free the render target texture, dude + ERR_FAIL_COND_V(texture->render_target, true); //can't free the render target texture, dude info.texture_mem -= texture->total_data_size; texture_owner.free(p_rid); memdelete(texture); @@ -5977,7 +5971,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) { skeleton_allocate(p_rid, 0, false); - glDeleteTextures(1,&skeleton->texture); + glDeleteTextures(1, &skeleton->texture); skeleton_owner.free(p_rid); memdelete(skeleton); diff --git a/drivers/gles3/shaders/screen_space_reflection.glsl b/drivers/gles3/shaders/screen_space_reflection.glsl index ec4bdf86c9..e4ba712de6 100644 --- a/drivers/gles3/shaders/screen_space_reflection.glsl +++ b/drivers/gles3/shaders/screen_space_reflection.glsl @@ -267,7 +267,7 @@ void main() { for(int i=0;i<7;i++) { - float op_len = 2.0 * tan(cone_angle) * cone_len; //oposite side of iso triangle + float op_len = 2.0 * tan(cone_angle) * cone_len; //opposite side of iso triangle float radius; { //fit to sphere inside cone (sphere ends at end of cone), something like this: diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index 98883f3267..e70e4fc349 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -107,10 +107,14 @@ Error PacketPeerUDPPosix::put_packet(const uint8_t *p_buffer, int p_buffer_size) errno = 0; int err; + _set_sock_blocking(blocking); + while ((err = sendto(sock, p_buffer, p_buffer_size, 0, (struct sockaddr *)&addr, addr_size)) != p_buffer_size) { if (errno != EAGAIN) { return FAILED; + } else if (!blocking) { + return ERR_UNAVAILABLE; } } @@ -173,10 +177,12 @@ Error PacketPeerUDPPosix::_poll(bool p_wait) { return FAILED; } + _set_sock_blocking(p_wait); + struct sockaddr_storage from = { 0 }; socklen_t len = sizeof(struct sockaddr_storage); int ret; - while ((ret = recvfrom(sockfd, recv_buffer, MIN((int)sizeof(recv_buffer), MAX(rb.space_left() - 24, 0)), p_wait ? 0 : MSG_DONTWAIT, (struct sockaddr *)&from, &len)) > 0) { + while ((ret = recvfrom(sockfd, recv_buffer, MIN((int)sizeof(recv_buffer), MAX(rb.space_left() - 24, 0)), 0, (struct sockaddr *)&from, &len)) > 0) { uint32_t port = 0; @@ -243,9 +249,35 @@ int PacketPeerUDPPosix::_get_socket() { sockfd = _socket_create(sock_type, SOCK_DGRAM, IPPROTO_UDP); + if (sockfd != -1) + _set_sock_blocking(false); + return sockfd; } +void PacketPeerUDPPosix::_set_sock_blocking(bool p_blocking) { + + if (sock_blocking == p_blocking) + return; + + sock_blocking = p_blocking; + +#ifndef NO_FCNTL + int opts = fcntl(sockfd, F_GETFL); + int ret = 0; + if (sock_blocking) + ret = fcntl(sockfd, F_SETFL, opts & ~O_NONBLOCK); + else + ret = fcntl(sockfd, F_SETFL, opts | O_NONBLOCK); + if (ret == -1) + perror("setting non-block mode"); +#else + int bval = sock_blocking ? 0 : 1; + if (ioctl(sockfd, FIONBIO, &bval) == -1) + perror("setting non-block mode"); +#endif +} + void PacketPeerUDPPosix::set_dest_address(const IP_Address &p_address, int p_port) { peer_addr = p_address; @@ -264,6 +296,8 @@ void PacketPeerUDPPosix::make_default() { PacketPeerUDPPosix::PacketPeerUDPPosix() { + blocking = true; + sock_blocking = true; sockfd = -1; packet_port = 0; queue_count = 0; diff --git a/drivers/unix/packet_peer_udp_posix.h b/drivers/unix/packet_peer_udp_posix.h index b44ef49f2c..60d5bf6580 100644 --- a/drivers/unix/packet_peer_udp_posix.h +++ b/drivers/unix/packet_peer_udp_posix.h @@ -47,6 +47,7 @@ class PacketPeerUDPPosix : public PacketPeerUDP { mutable int packet_port; mutable int queue_count; int sockfd; + bool sock_blocking; IP::Type sock_type; IP_Address peer_addr; @@ -55,6 +56,7 @@ class PacketPeerUDPPosix : public PacketPeerUDP { _FORCE_INLINE_ int _get_socket(); static PacketPeerUDP *_create(); + void _set_sock_blocking(bool p_blocking); virtual Error _poll(bool p_block); public: diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index bb5ab02d8c..b0710b2c36 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -39,7 +39,7 @@ /* -[03:57] <reduz> yessopie, so i dont havemak to rely on unicows +[03:57] <reduz> yessopie, so i don't havemak to rely on unicows [03:58] <yessopie> reduz- yeah, all of the functions fail, and then you can call GetLastError () which will return 120 [03:58] <drumstick> CategoryApl, hehe, what? :) [03:59] <CategoryApl> didn't Verona lead to some trouble |