Fix T97835: crash when creating hair particle system on Mac

Recently `gpu_shader_3D_smooth_color_frag.glsl` had the uniform declarations removed.

For shaders without `ShaderCreateInfo` that require this source this results in the error:
```
ERROR (gpu.shader): hair_refine_shader_transform_feedback_workaround_create FragShader:
      |
   54 |   fragColor = finalColor;
      |
      | gpu_shader_3D_smooth_color_frag.glsl:5:0: Error: Use of undeclared identifier 'fragColor'
      | gpu_shader_3D_smooth_color_frag.glsl:5:0: Error: Use of undeclared identifier 'finalColor'
      |
   55 |   fragColor = blender_srgb_to_framebuffer_space(fragColor);
      |
      | gpu_shader_3D_smooth_color_frag.glsl:6:0: Error: Use of undeclared identifier 'fragColor'
      | gpu_shader_3D_smooth_color_frag.glsl:6:0: Error: Use of undeclared identifier 'fragColor'
```

So port that shader to use `ShaderCreateInfo`.
This commit is contained in:
Germano Cavalcante 2022-05-04 21:42:38 -03:00
parent f11dba8892
commit adbe71c3fa
Notes: blender-bot 2023-02-14 06:19:41 +01:00
Referenced by commit 3505d948c6, DRW: Hair: Fix shader compilation of transform feedback shader
Referenced by issue #97835, Apple Silicon: crash when creating hair particle system
3 changed files with 25 additions and 23 deletions

View File

@ -53,19 +53,7 @@ static GPUShader *hair_refine_shader_transform_feedback_create(
static GPUShader *hair_refine_shader_transform_feedback_workaround_create(
ParticleRefineShader UNUSED(refinement))
{
GPUShader *sh = NULL;
char *shader_src = BLI_string_joinN(datatoc_common_hair_lib_glsl,
datatoc_common_hair_refine_vert_glsl);
sh = DRW_shader_create(shader_src,
NULL,
datatoc_gpu_shader_3D_smooth_color_frag_glsl,
"#define blender_srgb_to_framebuffer_space(a) a\n"
"#define HAIR_PHASE_SUBDIV\n"
"#define TF_WORKAROUND\n");
MEM_freeN(shader_src);
return sh;
return GPU_shader_create_from_info_name("draw_hair_refine_transform_feedback_workaround");
}
GPUShader *DRW_shader_hair_refine_get(ParticleRefineShader refinement,

View File

@ -1,13 +1,4 @@
/* To be compiled with common_hair_lib.glsl */
out vec4 finalColor;
#ifdef TF_WORKAROUND
uniform int targetWidth;
uniform int targetHeight;
uniform int idOffset;
#endif
#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
void main(void)
{

View File

@ -24,3 +24,26 @@ GPU_SHADER_CREATE_INFO(draw_hair_refine_compute)
.compute_source("common_hair_refine_comp.glsl")
.define("HAIR_PHASE_SUBDIV")
.do_static_compilation(true);
GPU_SHADER_INTERFACE_INFO(draw_hair_refine_transform_feedback_workaround_iface, "")
.smooth(Type::VEC4, "finalColor");
GPU_SHADER_CREATE_INFO(draw_hair_refine_transform_feedback_workaround)
.define("srgbTarget", "false")
.define("blender_srgb_to_framebuffer_space(a)", "a")
.define("HAIR_PHASE_SUBDIV")
.define("TF_WORKAROUND")
/* Move these to "draw_hair"? */
.sampler(0, ImageType::UINT_BUFFER, "hairStrandBuffer")
.sampler(1, ImageType::UINT_BUFFER, "hairStrandSegBuffer")
.push_constant(Type::INT, "targetWidth")
.push_constant(Type::INT, "targetHeight")
.push_constant(Type::INT, "idOffset")
.vertex_out(draw_hair_refine_transform_feedback_workaround_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("common_hair_refine_vert.glsl")
.fragment_source("gpu_shader_3D_smooth_color_frag.glsl")
.additional_info("draw_hair")
.do_static_compilation(true);