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:
authorClément Foucault <foucault.clem@gmail.com>2020-07-15 15:40:28 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-07-15 20:51:55 +0300
commit987d14a3b2427e9d1c136ddbea0a2eb9b25170f6 (patch)
tree78d35a8ac882e2efd030a6549ac9c48080909f3a
parent8e168730866a93c24f27c8147e5b3b5daad0867f (diff)
DRW: Shader: Fix const correctness and print better debug output
-rw-r--r--source/blender/draw/intern/DRW_render.h3
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c22
2 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index c992be333e5..7a889d9399e 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -265,7 +265,8 @@ void DRW_shader_library_add_file(DRWShaderLibrary *lib, char *lib_code, const ch
#define DRW_SHADER_LIB_ADD(lib, lib_name) \
DRW_shader_library_add_file(lib, datatoc_##lib_name##_glsl, STRINGIFY(lib_name) ".glsl")
-char *DRW_shader_library_create_shader_string(DRWShaderLibrary *lib, char *shader_code);
+char *DRW_shader_library_create_shader_string(const DRWShaderLibrary *lib,
+ const char *shader_code);
void DRW_shader_library_free(DRWShaderLibrary *lib);
#define DRW_SHADER_LIB_FREE_SAFE(lib) \
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 0c12b4fce86..0bb20631537 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -541,7 +541,7 @@ void DRW_shader_library_free(DRWShaderLibrary *lib)
MEM_SAFE_FREE(lib);
}
-static int drw_shader_library_search(DRWShaderLibrary *lib, const char *name)
+static int drw_shader_library_search(const DRWShaderLibrary *lib, const char *name)
{
for (int i = 0; i < MAX_LIB; i++) {
if (lib->libs[i]) {
@@ -557,18 +557,28 @@ static int drw_shader_library_search(DRWShaderLibrary *lib, const char *name)
}
/* Return bitmap of dependencies. */
-static uint32_t drw_shader_dependencies_get(DRWShaderLibrary *lib, char *lib_code)
+static uint32_t drw_shader_dependencies_get(const DRWShaderLibrary *lib, const char *lib_code)
{
/* Search dependencies. */
uint32_t deps = 0;
- char *haystack = lib_code;
+ const char *haystack = lib_code;
while ((haystack = strstr(haystack, "BLENDER_REQUIRE("))) {
haystack += 16;
int dep = drw_shader_library_search(lib, haystack);
if (dep == -1) {
+ char dbg_name[32];
+ int i = 0;
+ while ((haystack[0] != ')') && (i < 31)) {
+ dbg_name[i] = haystack[0];
+ haystack++;
+ i++;
+ }
+ dbg_name[i + 1] = '\0';
+
printf(
- "Error: Dependency not found.\n"
- "This might be due to bad lib ordering.\n");
+ "Error: Dependency not found: %s\n"
+ "This might be due to bad lib ordering.\n",
+ dbg_name);
BLI_assert(0);
}
else {
@@ -601,7 +611,7 @@ void DRW_shader_library_add_file(DRWShaderLibrary *lib, char *lib_code, const ch
/* Return an allocN'ed string containing the shader code with its dependencies prepended.
* Caller must free the string with MEM_freeN after use. */
-char *DRW_shader_library_create_shader_string(DRWShaderLibrary *lib, char *shader_code)
+char *DRW_shader_library_create_shader_string(const DRWShaderLibrary *lib, const char *shader_code)
{
uint32_t deps = drw_shader_dependencies_get(lib, shader_code);