diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-11-06 20:26:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-11-06 20:26:53 +0300 |
commit | d52ddfa6ccc91a97562fc90fee3ef1f3eab774fd (patch) | |
tree | 2dd256d18bddafbae44febbfd0fa717f366dc569 | |
parent | 7ef03eae20c8613f52b4cfca3919b9a871860f3e (diff) | |
parent | 64cd9a079b987e1ef3daf926bd5af26185e297a5 (diff) |
Merge branch 'blender-v2.81-release'
-rw-r--r-- | intern/guardedalloc/intern/mmap_win.c | 7 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_fileops.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 22 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.c | 5 |
4 files changed, 27 insertions, 8 deletions
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index 5b0c4b6614a..3508ae4e1aa 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -125,8 +125,11 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o } } - /* note len is passed to a 32 bit DWORD, so can't be > 4 GB */ - maphandle = CreateFileMapping(fhandle, NULL, prot_flags, 0, len, NULL); + /* Split 64 bit size into low and high bits. */ + DWORD len_bits_high = len >> 32; + DWORD len_bits_low = len & 0xFFFFFFFF; + + maphandle = CreateFileMapping(fhandle, NULL, prot_flags, len_bits_high, len_bits_low, NULL); if (maphandle == 0) { errno = EBADF; return MAP_FAILED; diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index bdf7588291f..5c20e57181e 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -67,6 +67,7 @@ typedef struct _stat BLI_stat_t; typedef struct stat BLI_stat_t; #endif +int BLI_fstat(int fd, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); #ifdef WIN32 int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index fd5de717a24..7c481868d64 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -180,8 +180,8 @@ double BLI_dir_free_space(const char *dir) */ size_t BLI_file_descriptor_size(int file) { - struct stat st; - if ((file < 0) || (fstat(file, &st) == -1)) { + BLI_stat_t st; + if ((file < 0) || (BLI_fstat(file, &st) == -1)) { return -1; } return st.st_size; @@ -246,6 +246,15 @@ int BLI_exists(const char *name) } #ifdef WIN32 +int BLI_fstat(int fd, BLI_stat_t *buffer) +{ +# if defined(_MSC_VER) + return _fstat64(fd, buffer); +# else + return _fstat(fd, buffer); +# endif +} + int BLI_stat(const char *path, BLI_stat_t *buffer) { int r; @@ -266,6 +275,11 @@ int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer) # endif } #else +int BLI_fstat(int fd, struct stat *buffer) +{ + return fstat(fd, buffer); +} + int BLI_stat(const char *path, struct stat *buffer) { return stat(path, buffer); @@ -298,8 +312,8 @@ static void *file_read_data_as_mem_impl(FILE *fp, size_t pad_bytes, size_t *r_size) { - struct stat st; - if (fstat(fileno(fp), &st) == -1) { + BLI_stat_t st; + if (BLI_fstat(fileno(fp), &st) == -1) { return NULL; } if (S_ISDIR(st.st_mode)) { diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index fb439016a87..c30cf9f6328 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -484,7 +484,7 @@ static void *extract_tris_init(const MeshRenderData *mr, void *UNUSED(ibo)) return data; } -static void extract_tris_looptri_bmesh(const MeshRenderData *UNUSED(mr), +static void extract_tris_looptri_bmesh(const MeshRenderData *mr, int UNUSED(t), BMLoop **elt, void *_data) @@ -492,8 +492,9 @@ static void extract_tris_looptri_bmesh(const MeshRenderData *UNUSED(mr), if (!BM_elem_flag_test(elt[0]->f, BM_ELEM_HIDDEN)) { MeshExtract_Tri_Data *data = _data; int *mat_tri_ofs = data->tri_mat_end; + int mat = min_ii(elt[0]->f->mat_nr, mr->mat_len - 1); GPU_indexbuf_set_tri_verts(&data->elb, - mat_tri_ofs[elt[0]->f->mat_nr]++, + mat_tri_ofs[mat]++, BM_elem_index_get(elt[0]), BM_elem_index_get(elt[1]), BM_elem_index_get(elt[2])); |