Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/modes/paint_texture_mode.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| extern char datatoc_common_globals_lib_glsl[]; | extern char datatoc_common_globals_lib_glsl[]; | ||||
| extern char datatoc_common_view_lib_glsl[]; | extern char datatoc_common_view_lib_glsl[]; | ||||
| extern char datatoc_paint_texture_vert_glsl[]; | extern char datatoc_paint_texture_vert_glsl[]; | ||||
| extern char datatoc_paint_texture_frag_glsl[]; | extern char datatoc_paint_texture_frag_glsl[]; | ||||
| extern char datatoc_paint_wire_vert_glsl[]; | extern char datatoc_paint_wire_vert_glsl[]; | ||||
| extern char datatoc_paint_wire_frag_glsl[]; | extern char datatoc_paint_wire_frag_glsl[]; | ||||
| extern char datatoc_paint_face_vert_glsl[]; | extern char datatoc_paint_face_vert_glsl[]; | ||||
| extern char datatoc_paint_face_selection_vert_glsl[]; | |||||
| extern char datatoc_gpu_shader_uniform_color_frag_glsl[]; | extern char datatoc_gpu_shader_uniform_color_frag_glsl[]; | ||||
| /* *********** LISTS *********** */ | /* *********** LISTS *********** */ | ||||
| /* All lists are per viewport specific datas. | /* All lists are per viewport specific datas. | ||||
| * They are all free when viewport changes engines | * They are all free when viewport changes engines | ||||
| * or is free itself. Use PAINT_TEXTURE_engine_init() to | * or is free itself. Use PAINT_TEXTURE_engine_init() to | ||||
| * initialize most of them and PAINT_TEXTURE_cache_init() | * initialize most of them and PAINT_TEXTURE_cache_init() | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| static void PAINT_TEXTURE_engine_init(void *vedata) | static void PAINT_TEXTURE_engine_init(void *vedata) | ||||
| { | { | ||||
| PAINT_TEXTURE_StorageList *stl = ((PAINT_TEXTURE_Data *)vedata)->stl; | PAINT_TEXTURE_StorageList *stl = ((PAINT_TEXTURE_Data *)vedata)->stl; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| PAINT_TEXTURE_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | PAINT_TEXTURE_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | ||||
| if (!sh_data->fallback) { | if (!sh_data->fallback) { | ||||
| const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | ||||
| sh_data->fallback = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_UNIFORM_COLOR, | sh_data->fallback = GPU_shader_create_from_arrays({ | ||||
| draw_ctx->sh_cfg); | .vert = (const char *[]){sh_cfg_data->lib, | ||||
| datatoc_common_view_lib_glsl, | |||||
| datatoc_paint_face_vert_glsl, | |||||
| NULL}, | |||||
| .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, | |||||
| .defs = (const char *[]){sh_cfg_data->def, NULL}, | |||||
| }); | |||||
| sh_data->image = GPU_shader_create_from_arrays({ | sh_data->image = GPU_shader_create_from_arrays({ | ||||
| .vert = (const char *[]){sh_cfg_data->lib, | .vert = (const char *[]){sh_cfg_data->lib, | ||||
| datatoc_common_globals_lib_glsl, | datatoc_common_globals_lib_glsl, | ||||
| datatoc_common_view_lib_glsl, | datatoc_common_view_lib_glsl, | ||||
| datatoc_paint_texture_vert_glsl, | datatoc_paint_texture_vert_glsl, | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_paint_texture_frag_glsl, NULL}, | .frag = (const char *[]){datatoc_paint_texture_frag_glsl, NULL}, | ||||
| Show All 18 Lines | sh_data->wire_select_overlay = GPU_shader_create_from_arrays({ | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_paint_wire_frag_glsl, NULL}, | .frag = (const char *[]){datatoc_paint_wire_frag_glsl, NULL}, | ||||
| .defs = (const char *[]){sh_cfg_data->def, "#define USE_SELECT\n", NULL}, | .defs = (const char *[]){sh_cfg_data->def, "#define USE_SELECT\n", NULL}, | ||||
| }); | }); | ||||
| sh_data->face_select_overlay = GPU_shader_create_from_arrays({ | sh_data->face_select_overlay = GPU_shader_create_from_arrays({ | ||||
| .vert = (const char *[]){sh_cfg_data->lib, | .vert = (const char *[]){sh_cfg_data->lib, | ||||
| datatoc_common_view_lib_glsl, | datatoc_common_view_lib_glsl, | ||||
| datatoc_paint_face_vert_glsl, | datatoc_paint_face_selection_vert_glsl, | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_common_view_lib_glsl, | .frag = (const char *[]){datatoc_common_view_lib_glsl, | ||||
| datatoc_gpu_shader_uniform_color_frag_glsl, | datatoc_gpu_shader_uniform_color_frag_glsl, | ||||
| NULL}, | NULL}, | ||||
| .defs = (const char *[]){sh_cfg_data->def, NULL}, | .defs = (const char *[]){sh_cfg_data->def, NULL}, | ||||
| }); | }); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | |||||
| /* Cleanup when destroying the engine. | /* Cleanup when destroying the engine. | ||||
| * This is not per viewport ! only when quitting blender. | * This is not per viewport ! only when quitting blender. | ||||
| * Mostly used for freeing shaders */ | * Mostly used for freeing shaders */ | ||||
| static void PAINT_TEXTURE_engine_free(void) | static void PAINT_TEXTURE_engine_free(void) | ||||
| { | { | ||||
| for (int sh_data_index = 0; sh_data_index < ARRAY_SIZE(e_data.sh_data); sh_data_index++) { | for (int sh_data_index = 0; sh_data_index < ARRAY_SIZE(e_data.sh_data); sh_data_index++) { | ||||
| PAINT_TEXTURE_Shaders *sh_data = &e_data.sh_data[sh_data_index]; | PAINT_TEXTURE_Shaders *sh_data = &e_data.sh_data[sh_data_index]; | ||||
| /* Don't free builtins. */ | |||||
| sh_data->fallback = NULL; | |||||
| GPUShader **sh_data_as_array = (GPUShader **)sh_data; | GPUShader **sh_data_as_array = (GPUShader **)sh_data; | ||||
| for (int i = 0; i < (sizeof(PAINT_TEXTURE_Shaders) / sizeof(GPUShader *)); i++) { | for (int i = 0; i < (sizeof(PAINT_TEXTURE_Shaders) / sizeof(GPUShader *)); i++) { | ||||
| DRW_SHADER_FREE_SAFE(sh_data_as_array[i]); | DRW_SHADER_FREE_SAFE(sh_data_as_array[i]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static const DrawEngineDataSize PAINT_TEXTURE_data_size = DRW_VIEWPORT_DATA_SIZE( | static const DrawEngineDataSize PAINT_TEXTURE_data_size = DRW_VIEWPORT_DATA_SIZE( | ||||
| Show All 17 Lines | |||||