SHARE
TWEET

Untitled

a guest Sep 16th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
  2. index 9899b6c0194..adda2df38e6 100644
  3. --- a/source/blender/draw/intern/draw_common.h
  4. +++ b/source/blender/draw/intern/draw_common.h
  5. @@ -281,6 +281,7 @@ struct DRW_Global {
  6.    struct GPUTexture *weight_ramp;
  7.  
  8.    struct GPUUniformBuffer *view_ubo;
  9. +  struct GPUUniformBuffer *dummy;
  10.  };
  11.  extern struct DRW_Global G_draw;
  12.  
  13. diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
  14. index 66e3905b212..3a61a1fd978 100644
  15. --- a/source/blender/draw/intern/draw_manager.c
  16. +++ b/source/blender/draw/intern/draw_manager.c
  17. @@ -731,6 +731,10 @@ static void drw_viewport_var_init(void)
  18.    if (G_draw.view_ubo == NULL) {
  19.      G_draw.view_ubo = DRW_uniformbuffer_create(sizeof(DRWViewUboStorage), NULL);
  20.    }
  21. +  if (G_draw.dummy == NULL) {
  22. +    G_draw.dummy = DRW_uniformbuffer_create(sizeof(DRWObjectMatrix) * DRW_RESOURCE_CHUNK_LEN,
  23. +                                            NULL);
  24. +  }
  25.  
  26.    if (DST.draw_list == NULL) {
  27.      DST.draw_list = GPU_draw_list_create(DRW_DRAWLIST_LEN);
  28. diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
  29. index cdf2c208351..b677e5e3048 100644
  30. --- a/source/blender/draw/intern/draw_manager_data.c
  31. +++ b/source/blender/draw/intern/draw_manager_data.c
  32. @@ -113,11 +113,6 @@ void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
  33.    }
  34.  
  35.    /* Remove unecessary buffers */
  36. -  for (int i = ubo_len; i < vmempool->ubo_len; i++) {
  37. -    GPU_uniformbuffer_free(vmempool->matrices_ubo[i]);
  38. -    GPU_uniformbuffer_free(vmempool->obinfos_ubo[i]);
  39. -  }
  40. -
  41.    if (ubo_len != vmempool->ubo_len) {
  42.      vmempool->matrices_ubo = MEM_recallocN(vmempool->matrices_ubo, list_size);
  43.      vmempool->obinfos_ubo = MEM_recallocN(vmempool->obinfos_ubo, list_size);
  44. @@ -128,16 +123,8 @@ void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
  45.    for (int i = 0; i < ubo_len; i++) {
  46.      void *data_obmat = BLI_memblock_elem_get(vmempool->obmats, i, 0);
  47.      void *data_infos = BLI_memblock_elem_get(vmempool->obinfos, i, 0);
  48. -    if (vmempool->matrices_ubo[i] == NULL) {
  49. -      vmempool->matrices_ubo[i] = GPU_uniformbuffer_create(
  50. -          sizeof(DRWObjectMatrix) * DRW_RESOURCE_CHUNK_LEN, data_obmat, NULL);
  51. -      vmempool->obinfos_ubo[i] = GPU_uniformbuffer_create(
  52. -          sizeof(DRWObjectInfos) * DRW_RESOURCE_CHUNK_LEN, data_infos, NULL);
  53. -    }
  54. -    else {
  55. -      GPU_uniformbuffer_update(vmempool->matrices_ubo[i], data_obmat);
  56. -      GPU_uniformbuffer_update(vmempool->obinfos_ubo[i], data_infos);
  57. -    }
  58. +    vmempool->matrices_ubo[i] = G_draw.dummy;
  59. +    vmempool->obinfos_ubo[i] = G_draw.dummy;
  60.    }
  61.  
  62.    /* Aligned alloc to avoid unaligned memcpy. */
  63. diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
  64. index 6bb11a7d4ce..29c41ce1352 100644
  65. --- a/source/blender/draw/intern/draw_manager_exec.c
  66. +++ b/source/blender/draw/intern/draw_manager_exec.c
  67. @@ -945,7 +945,7 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
  68.            break;
  69.          case DRW_UNIFORM_BLOCK_OBMATS:
  70.            state->obmats_loc = uni->location;
  71. -          ubo = DST.vmempool->matrices_ubo[0];
  72. +          ubo = G_draw.dummy;
  73.            GPU_uniformbuffer_bind(ubo, 0);
  74.            GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
  75.            break;
  76. @@ -1063,8 +1063,8 @@ static void draw_call_resource_bind(DRWCommandsState *state, const DRWResourceHa
  77.        GPU_shader_uniform_int(NULL, state->chunkid_loc, chunk);
  78.      }
  79.      if (state->obmats_loc != -1) {
  80. -      GPU_uniformbuffer_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
  81. -      GPU_uniformbuffer_bind(DST.vmempool->matrices_ubo[chunk], 0);
  82. +      GPU_uniformbuffer_unbind(G_draw.dummy);
  83. +      GPU_uniformbuffer_bind(G_draw.dummy, 0);
  84.      }
  85.      if (state->obinfos_loc != -1) {
  86.        GPU_uniformbuffer_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
  87. @@ -1188,7 +1188,8 @@ static void draw_call_batching_finish(DRWShadingGroup *shgroup, DRWCommandsState
  88.      GPU_uniformbuffer_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
  89.    }
  90.    if (state->obinfos_loc != -1) {
  91. -    GPU_uniformbuffer_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
  92. +    // GPU_uniformbuffer_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
  93. +    GPU_uniformbuffer_unbind(G_draw.dummy);
  94.    }
  95.  }
  96.  
  97. diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
  98. index 615af57c1bd..a52c920e5d1 100644
  99. --- a/source/blender/gpu/intern/gpu_viewport.c
  100. +++ b/source/blender/gpu/intern/gpu_viewport.c
  101. @@ -661,8 +661,8 @@ void GPU_viewport_free(GPUViewport *viewport)
  102.    }
  103.  
  104.    for (int i = 0; i < viewport->vmempool.ubo_len; i++) {
  105. -    GPU_uniformbuffer_free(viewport->vmempool.matrices_ubo[i]);
  106. -    GPU_uniformbuffer_free(viewport->vmempool.obinfos_ubo[i]);
  107. +    // GPU_uniformbuffer_free(viewport->vmempool.matrices_ubo[i]);
  108. +    // GPU_uniformbuffer_free(viewport->vmempool.obinfos_ubo[i]);
  109.    }
  110.    MEM_SAFE_FREE(viewport->vmempool.matrices_ubo);
  111.    MEM_SAFE_FREE(viewport->vmempool.obinfos_ubo);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top