Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager_shader.c
| Show First 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | |||||
| GPUShader *DRW_shader_create_3d_depth_only(eGPUShaderConfig sh_cfg) | GPUShader *DRW_shader_create_3d_depth_only(eGPUShaderConfig sh_cfg) | ||||
| { | { | ||||
| return GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_DEPTH_ONLY, sh_cfg); | return GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_DEPTH_ONLY, sh_cfg); | ||||
| } | } | ||||
| GPUMaterial *DRW_shader_find_from_world(World *wo, | GPUMaterial *DRW_shader_find_from_world(World *wo, | ||||
| const void *engine_type, | const void *engine_type, | ||||
| int options, | const int options, | ||||
| bool deferred) | bool deferred) | ||||
| { | { | ||||
| GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options); | GPUMaterial *mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options); | ||||
| if (DRW_state_is_image_render() || !deferred) { | if (DRW_state_is_image_render() || !deferred) { | ||||
| if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) { | if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) { | ||||
| /* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX | /* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX | ||||
| * with the shader code and we will resume the compilation from there. */ | * with the shader code and we will resume the compilation from there. */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| return mat; | return mat; | ||||
| } | } | ||||
| GPUMaterial *DRW_shader_find_from_material(Material *ma, | GPUMaterial *DRW_shader_find_from_material(Material *ma, | ||||
| const void *engine_type, | const void *engine_type, | ||||
| int options, | const int options, | ||||
| bool deferred) | bool deferred) | ||||
| { | { | ||||
| GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options); | GPUMaterial *mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options); | ||||
| if (DRW_state_is_image_render() || !deferred) { | if (DRW_state_is_image_render() || !deferred) { | ||||
| if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) { | if (mat != NULL && GPU_material_status(mat) == GPU_MAT_QUEUED) { | ||||
| /* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX | /* XXX Hack : we return NULL so that the engine will call DRW_shader_create_from_XXX | ||||
| * with the shader code and we will resume the compilation from there. */ | * with the shader code and we will resume the compilation from there. */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| return mat; | return mat; | ||||
| } | } | ||||
| GPUMaterial *DRW_shader_create_from_world(struct Scene *scene, | GPUMaterial *DRW_shader_create_from_world(struct Scene *scene, | ||||
| World *wo, | World *wo, | ||||
| const void *engine_type, | const void *engine_type, | ||||
| int options, | const int options, | ||||
| const bool is_volume_shader, | |||||
| const char *vert, | const char *vert, | ||||
| const char *geom, | const char *geom, | ||||
| const char *frag_lib, | const char *frag_lib, | ||||
| const char *defines, | const char *defines, | ||||
| bool deferred) | bool deferred) | ||||
| { | { | ||||
| GPUMaterial *mat = NULL; | GPUMaterial *mat = NULL; | ||||
| if (DRW_state_is_image_render()) { | if (DRW_state_is_image_render()) { | ||||
| mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options); | mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options); | ||||
| } | } | ||||
| if (mat == NULL) { | if (mat == NULL) { | ||||
| scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id); | scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id); | ||||
| mat = GPU_material_from_nodetree(scene, | mat = GPU_material_from_nodetree(scene, | ||||
| NULL, | NULL, | ||||
| wo->nodetree, | wo->nodetree, | ||||
| &wo->gpumaterial, | &wo->gpumaterial, | ||||
| engine_type, | engine_type, | ||||
| options, | options, | ||||
| is_volume_shader, | |||||
| vert, | vert, | ||||
| geom, | geom, | ||||
| frag_lib, | frag_lib, | ||||
| defines, | defines, | ||||
| wo->id.name); | wo->id.name); | ||||
| } | } | ||||
| if (GPU_material_status(mat) == GPU_MAT_QUEUED) { | if (GPU_material_status(mat) == GPU_MAT_QUEUED) { | ||||
| drw_deferred_shader_add(mat, deferred); | drw_deferred_shader_add(mat, deferred); | ||||
| } | } | ||||
| return mat; | return mat; | ||||
| } | } | ||||
| GPUMaterial *DRW_shader_create_from_material(struct Scene *scene, | GPUMaterial *DRW_shader_create_from_material(struct Scene *scene, | ||||
| Material *ma, | Material *ma, | ||||
| const void *engine_type, | const void *engine_type, | ||||
| int options, | const int options, | ||||
| const bool is_volume_shader, | |||||
| const char *vert, | const char *vert, | ||||
| const char *geom, | const char *geom, | ||||
| const char *frag_lib, | const char *frag_lib, | ||||
| const char *defines, | const char *defines, | ||||
| bool deferred) | bool deferred) | ||||
| { | { | ||||
| GPUMaterial *mat = NULL; | GPUMaterial *mat = NULL; | ||||
| if (DRW_state_is_image_render()) { | if (DRW_state_is_image_render()) { | ||||
| mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options); | mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options); | ||||
| } | } | ||||
| if (mat == NULL) { | if (mat == NULL) { | ||||
| scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id); | scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id); | ||||
| mat = GPU_material_from_nodetree(scene, | mat = GPU_material_from_nodetree(scene, | ||||
| ma, | ma, | ||||
| ma->nodetree, | ma->nodetree, | ||||
| &ma->gpumaterial, | &ma->gpumaterial, | ||||
| engine_type, | engine_type, | ||||
| options, | options, | ||||
| is_volume_shader, | |||||
| vert, | vert, | ||||
| geom, | geom, | ||||
| frag_lib, | frag_lib, | ||||
| defines, | defines, | ||||
| ma->id.name); | ma->id.name); | ||||
| } | } | ||||
| if (GPU_material_status(mat) == GPU_MAT_QUEUED) { | if (GPU_material_status(mat) == GPU_MAT_QUEUED) { | ||||
| Show All 10 Lines | |||||