Created
March 27, 2020 16:30
-
-
Save ThomasWilshaw/f1977ddaf10408bce8e7274fc8160cfa to your computer and use it in GitHub Desktop.
Patch that possibly fixes the missing UBO error I was getting with Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c | |
index 8e712295b61..dc02ec792f4 100644 | |
--- a/source/blender/draw/intern/draw_manager_exec.c | |
+++ b/source/blender/draw/intern/draw_manager_exec.c | |
@@ -859,6 +859,10 @@ static void bind_ubo(GPUUniformBuffer *ubo, char bind_type) | |
* | |
* See T55475. | |
* */ | |
+ | |
+static GLuint debug_buffer = 0; | |
+static GLint debug_buffer_size = 0; | |
+ | |
static bool ubo_bindings_validate(DRWShadingGroup *shgroup) | |
{ | |
bool valid = true; | |
@@ -879,13 +883,35 @@ static bool ubo_bindings_validate(DRWShadingGroup *shgroup) | |
if (buffer == 0) { | |
char blockname[64]; | |
+ GLint data_size = 0; | |
glGetActiveUniformBlockName(program, i, sizeof(blockname), NULL, blockname); | |
+ glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_DATA_SIZE, &data_size); | |
+ | |
+ if (debug_buffer == 0) { | |
+ glGenBuffers(1, &debug_buffer); | |
+ debug_buffer_size = 0; | |
+ } | |
+ if (debug_buffer_size < data_size) { | |
+ debug_buffer_size = data_size; | |
+ glBindBuffer(GL_UNIFORM_BUFFER, debug_buffer); | |
+ glBufferData(GL_UNIFORM_BUFFER, debug_buffer_size, NULL, GL_DYNAMIC_DRAW); | |
+ glBindBuffer(GL_UNIFORM_BUFFER, 0); | |
+ } | |
+ | |
+ // Update binding. GL_MAX_UNIFORM_BUFFER_BINDINGS is at least 36. | |
+ if (binding == 0) | |
+ { | |
+ binding = 35; | |
+ glUniformBlockBinding(program, i, binding); | |
+ } | |
+ glBindBufferBase(GL_UNIFORM_BUFFER, binding, debug_buffer); | |
+ /* | |
if (valid) { | |
printf("Trying to draw with missing UBO binding.\n"); | |
valid = false; | |
} | |
- | |
+ */ | |
DRWPass *parent_pass = DRW_memblock_elem_from_handle(DST.vmempool->passes, | |
&shgroup->pass_handle); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment