Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-03-04 16:18:57 +0300
committermano-wii <germano.costa@ig.com.br>2019-03-04 16:27:41 +0300
commitf96fffe0db53145872a3d60bb8f4bd3b24e8d32b (patch)
treefb725cac052e7e37a0afef124aadb742d4c7999a /source/blender/draw/intern/draw_cache_impl_displist.c
parent46f1c1b15d80535b8fb914f6a227384866bb2caf (diff)
Fix/workaround T62167: Random crash when displaying wireframes.
Some old AMD drivers crash when a vbo with stride 1 is used a few times. I have not found a real solution to this problem. So the solution was to use a vbo with stride 4 (which in theory is less efficient and takes up more memory space).
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_displist.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index b9555c5e54b..63514acf1c2 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -35,6 +35,7 @@
#include "BKE_displist.h"
#include "GPU_batch.h"
+#include "GPU_extensions.h"
#include "draw_cache_impl.h" /* own include */
@@ -206,10 +207,16 @@ void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo)
void DRW_displist_vertbuf_create_wiredata(ListBase *lb, GPUVertBuf *vbo)
{
static GPUVertFormat format = { 0 };
- // static struct { uint wd; } attr_id; /* UNUSED */
+ static struct { uint wd; } attr_id;
if (format.attr_len == 0) {
/* initialize vertex format */
- /* attr_id.wd = */ GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ if (!GPU_crappy_amd_driver()) {
+ /* Some AMD drivers strangely crash with a vbo with this format. */
+ attr_id.wd = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+ else {
+ attr_id.wd = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ }
}
int vbo_len_used = curve_render_surface_vert_len_get(lb);
@@ -217,8 +224,16 @@ void DRW_displist_vertbuf_create_wiredata(ListBase *lb, GPUVertBuf *vbo)
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, vbo_len_used);
- BLI_assert(vbo->format.stride == 1);
- memset(vbo->data, 0xFF, (size_t)vbo_len_used);
+ if (vbo->format.stride == 1) {
+ memset(vbo->data, 0xFF, (size_t)vbo_len_used);
+ }
+ else {
+ GPUVertBufRaw wd_step;
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id.wd, &wd_step);
+ for (int i = 0; i < vbo_len_used; i++) {
+ *((float *)GPU_vertbuf_raw_step(&wd_step)) = 1.0f;
+ }
+ }
}
void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf *ibo)