Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_codegen.c
| Show First 20 Lines • Show All 1,222 Lines • ▼ Show 20 Lines | if (!pass->compiled) { | ||||
| if (!gpu_pass_shader_validate(pass, shader)) { | if (!gpu_pass_shader_validate(pass, shader)) { | ||||
| success = false; | success = false; | ||||
| if (shader != NULL) { | if (shader != NULL) { | ||||
| fprintf(stderr, "GPUShader: error: too many samplers in shader.\n"); | fprintf(stderr, "GPUShader: error: too many samplers in shader.\n"); | ||||
| GPU_shader_free(shader); | GPU_shader_free(shader); | ||||
| shader = NULL; | shader = NULL; | ||||
| } | } | ||||
| } | } | ||||
| else if (!BLI_thread_is_main() && GPU_context_local_shaders_workaround()) { | |||||
| pass->binary.content = GPU_shader_get_binary( | |||||
| shader, &pass->binary.format, &pass->binary.len); | |||||
| GPU_shader_free(shader); | |||||
| shader = NULL; | |||||
| } | |||||
| pass->shader = shader; | pass->shader = shader; | ||||
| pass->compiled = true; | pass->compiled = true; | ||||
| } | } | ||||
| else if (pass->binary.content && BLI_thread_is_main()) { | |||||
| pass->shader = GPU_shader_load_from_binary( | |||||
| pass->binary.content, pass->binary.format, pass->binary.len, shname); | |||||
| MEM_SAFE_FREE(pass->binary.content); | |||||
| } | |||||
| return success; | return success; | ||||
| } | } | ||||
| void GPU_pass_release(GPUPass *pass) | void GPU_pass_release(GPUPass *pass) | ||||
| { | { | ||||
| BLI_assert(pass->refcount > 0); | BLI_assert(pass->refcount > 0); | ||||
| pass->refcount--; | pass->refcount--; | ||||
| } | } | ||||
| static void gpu_pass_free(GPUPass *pass) | static void gpu_pass_free(GPUPass *pass) | ||||
| { | { | ||||
| BLI_assert(pass->refcount == 0); | BLI_assert(pass->refcount == 0); | ||||
| if (pass->shader) { | if (pass->shader) { | ||||
| GPU_shader_free(pass->shader); | GPU_shader_free(pass->shader); | ||||
| } | } | ||||
| MEM_SAFE_FREE(pass->fragmentcode); | MEM_SAFE_FREE(pass->fragmentcode); | ||||
| MEM_SAFE_FREE(pass->geometrycode); | MEM_SAFE_FREE(pass->geometrycode); | ||||
| MEM_SAFE_FREE(pass->vertexcode); | MEM_SAFE_FREE(pass->vertexcode); | ||||
| MEM_SAFE_FREE(pass->defines); | MEM_SAFE_FREE(pass->defines); | ||||
| if (pass->binary.content) { | |||||
| MEM_freeN(pass->binary.content); | |||||
| } | |||||
| MEM_freeN(pass); | MEM_freeN(pass); | ||||
| } | } | ||||
| void GPU_pass_cache_garbage_collect(void) | void GPU_pass_cache_garbage_collect(void) | ||||
| { | { | ||||
| static int lasttime = 0; | static int lasttime = 0; | ||||
| const int shadercollectrate = 60; /* hardcoded for now. */ | const int shadercollectrate = 60; /* hardcoded for now. */ | ||||
| int ctime = (int)PIL_check_seconds_timer(); | int ctime = (int)PIL_check_seconds_timer(); | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||