EEVEE Next: GLSL Metal shader type compatibility #107178
|
@ -628,7 +628,7 @@ struct LightData {
|
|||
float radius_squared;
|
||||
/** NOTE: It is ok to use float3 here. A float is declared right after it.
|
||||
* float3 is also aligned to 16 bytes. */
|
||||
float3 color;
|
||||
packed_float3 color;
|
||||
/** Light Type. */
|
||||
eLightType type;
|
||||
/** Spot size. Aligned to size of float2. */
|
||||
|
|
|
@ -12,7 +12,7 @@ void main()
|
|||
|
||||
/* Display backfacing surfels with a transparent checkerboard grid. */
|
||||
if (!gl_FrontFacing) {
|
||||
ivec2 grid_uv = ivec2(gl_FragCoord) / 5;
|
||||
ivec2 grid_uv = ivec2(gl_FragCoord.xy) / 5;
|
||||
if ((grid_uv.x + grid_uv.y) % 2 == 0) {
|
||||
discard;
|
||||
return;
|
||||
|
|
|
@ -45,7 +45,8 @@ void main()
|
|||
case LIGHT_RECT:
|
||||
case LIGHT_ELLIPSE:
|
||||
case LIGHT_POINT:
|
||||
sphere = Sphere(light._position, light.influence_radius_max);
|
||||
sphere.center = light._position;
|
||||
sphere.radius = light.influence_radius_max;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ bool debug_tilemaps(vec3 P, LightData light)
|
|||
out_color_add = vec4(debug_tile_state_color(tile), 0.0);
|
||||
out_color_mul = vec4(0.0);
|
||||
|
||||
if (ivec2(gl_FragCoord.xy) == ivec2(0)) {
|
||||
if (all(equal(ivec2(gl_FragCoord.xy), ivec2(0)))) {
|
||||
drw_print(light.object_mat);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
#pragma BLENDER_REQUIRE(eevee_shadow_tilemap_lib.glsl)
|
||||
|
||||
/* TODO(@fclem): Implement. */
|
||||
#define assert(check)
|
||||
#ifndef GPU_METAL
|
||||
# define assert(check)
|
||||
#endif
|
||||
|
||||
/* Remove page ownership from the tile and append it to the cache. */
|
||||
void shadow_page_free(inout ShadowTileData tile)
|
||||
|
|
|
@ -45,7 +45,7 @@ float pixel_size_at(float linear_depth)
|
|||
if (is_persp) {
|
||||
pixel_size *= max(0.01, linear_depth);
|
||||
}
|
||||
return pixel_size * exp2(fb_lod);
|
||||
return pixel_size * exp2(float(fb_lod));
|
||||
}
|
||||
|
||||
void step_bounding_sphere(vec3 vs_near_plane,
|
||||
|
@ -117,6 +117,7 @@ void main()
|
|||
step_bounding_sphere(vs_near_plane, vs_view_direction, t, t + step_size, P, step_radius);
|
||||
vec3 vP = point_world_to_view(P);
|
||||
|
||||
shadow_tag_usage(vP, P, ws_view_direction, step_radius, t, gl_FragCoord.xy * exp2(fb_lod));
|
||||
shadow_tag_usage(
|
||||
vP, P, ws_view_direction, step_radius, t, gl_FragCoord.xy * exp2(float(fb_lod)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ void inflate_bounds(vec3 ls_center, inout vec3 P, inout vec3 lP)
|
|||
{
|
||||
vec3 vP = point_world_to_view(P);
|
||||
|
||||
float inflate_scale = pixel_world_radius * exp2(fb_lod);
|
||||
float inflate_scale = pixel_world_radius * exp2(float(fb_lod));
|
||||
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
|
||||
if (is_persp) {
|
||||
inflate_scale *= -vP.z;
|
||||
|
|
|
@ -45,6 +45,8 @@ void write_depth(ivec2 texel_co, const int lod, ivec2 tile_co, float depth)
|
|||
/* Quantization bias. Equivalent to nextafter in C without all the safety. 1 is not enough. */
|
||||
u_depth += 2;
|
||||
|
||||
/* TOOD(Metal): For Metal, textures will need to be viewed as buffers to workaround missing image
|
||||
* atomics support. */
|
||||
imageAtomicMin(shadow_atlas_img, out_texel, u_depth);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
/** \name Shadow pipeline
|
||||
* \{ */
|
||||
|
||||
/* NOTE(Metal): As this is implemented using a fundamental data type, this needs to be specified
|
||||
* explicitly as uint for code generation, as the MSLShaderGenerator needs to be able to
|
||||
* distinguish between classes and fundamental types during code generation. */
|
||||
#define SHADOW_TILE_DATA_PACKED "uint"
|
||||
|
||||
GPU_SHADER_CREATE_INFO(eevee_shadow_clipmap_clear)
|
||||
.do_static_compilation(true)
|
||||
.local_group_size(SHADOW_CLIPMAP_GROUP_SIZE)
|
||||
|
@ -34,7 +39,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_init)
|
|||
.do_static_compilation(true)
|
||||
.local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES)
|
||||
.storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.storage_buf(2, Qualifier::READ_WRITE, "ShadowTileMapClip", "tilemaps_clip_buf[]")
|
||||
.storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]")
|
||||
.additional_info("eevee_shared")
|
||||
|
@ -44,7 +49,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tag_update)
|
|||
.do_static_compilation(true)
|
||||
.local_group_size(1, 1, 1)
|
||||
.storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.storage_buf(5, Qualifier::READ, "ObjectBounds", "bounds_buf[]")
|
||||
.storage_buf(6, Qualifier::READ, "uint", "resource_ids_buf[]")
|
||||
.additional_info("eevee_shared", "draw_view", "draw_view_culling")
|
||||
|
@ -55,7 +60,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_opaque)
|
|||
.local_group_size(SHADOW_DEPTH_SCAN_GROUP_SIZE, SHADOW_DEPTH_SCAN_GROUP_SIZE)
|
||||
.sampler(0, ImageType::DEPTH_2D, "depth_tx")
|
||||
.storage_buf(5, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(6, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(6, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.push_constant(Type::FLOAT, "tilemap_projection_ratio")
|
||||
.additional_info("eevee_shared", "draw_view", "draw_view_culling", "eevee_light_data")
|
||||
.compute_source("eevee_shadow_tag_usage_comp.glsl");
|
||||
|
@ -71,7 +76,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_transparent)
|
|||
.vertex_in(0, Type::VEC3, "pos")
|
||||
.storage_buf(4, Qualifier::READ, "ObjectBounds", "bounds_buf[]")
|
||||
.storage_buf(5, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(6, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(6, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.push_constant(Type::FLOAT, "tilemap_projection_ratio")
|
||||
.push_constant(Type::FLOAT, "pixel_world_radius")
|
||||
.push_constant(Type::IVEC2, "fb_resolution")
|
||||
|
@ -91,7 +96,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_mask)
|
|||
.do_static_compilation(true)
|
||||
.local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES)
|
||||
.storage_buf(0, Qualifier::READ, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.additional_info("eevee_shared")
|
||||
.compute_source("eevee_shadow_page_mask_comp.glsl");
|
||||
|
||||
|
@ -99,7 +104,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_free)
|
|||
.do_static_compilation(true)
|
||||
.local_group_size(SHADOW_TILEMAP_LOD0_LEN)
|
||||
.storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf")
|
||||
.storage_buf(3, Qualifier::READ_WRITE, "uint", "pages_free_buf[]")
|
||||
.storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]")
|
||||
|
@ -110,7 +115,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_defrag)
|
|||
.do_static_compilation(true)
|
||||
.local_group_size(1)
|
||||
.typedef_source("draw_shader_shared.h")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf")
|
||||
.storage_buf(3, Qualifier::READ_WRITE, "uint", "pages_free_buf[]")
|
||||
.storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]")
|
||||
|
@ -124,7 +129,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_allocate)
|
|||
.local_group_size(SHADOW_TILEMAP_LOD0_LEN)
|
||||
.typedef_source("draw_shader_shared.h")
|
||||
.storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf")
|
||||
.storage_buf(3, Qualifier::READ_WRITE, "uint", "pages_free_buf[]")
|
||||
.storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]")
|
||||
|
@ -137,7 +142,7 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_finalize)
|
|||
.typedef_source("draw_shader_shared.h")
|
||||
.local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES)
|
||||
.storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf")
|
||||
.storage_buf(3, Qualifier::WRITE, "ViewMatrices", "view_infos_buf[64]")
|
||||
.storage_buf(4, Qualifier::READ_WRITE, "ShadowStatistics", "statistics_buf")
|
||||
|
@ -183,11 +188,12 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_debug)
|
|||
.do_static_compilation(true)
|
||||
.additional_info("eevee_shared")
|
||||
.storage_buf(5, Qualifier::READ, "ShadowTileMapData", "tilemaps_buf[]")
|
||||
.storage_buf(6, Qualifier::READ, "ShadowTileDataPacked", "tiles_buf[]")
|
||||
.storage_buf(6, Qualifier::READ, SHADOW_TILE_DATA_PACKED, "tiles_buf[]")
|
||||
.fragment_out(0, Type::VEC4, "out_color_add", DualBlend::SRC_0)
|
||||
.fragment_out(0, Type::VEC4, "out_color_mul", DualBlend::SRC_1)
|
||||
.push_constant(Type::INT, "debug_mode")
|
||||
.push_constant(Type::INT, "debug_tilemap_index")
|
||||
.depth_write(DepthWrite::ANY)
|
||||
.fragment_source("eevee_shadow_debug_frag.glsl")
|
||||
.additional_info(
|
||||
"draw_fullscreen", "draw_view", "eevee_hiz_data", "eevee_light_data", "eevee_shadow_data");
|
||||
|
|
|
@ -350,6 +350,16 @@ struct DRWDebugVert {
|
|||
};
|
||||
BLI_STATIC_ASSERT_ALIGN(DRWDebugVert, 16)
|
||||
|
||||
inline DRWDebugVert debug_vert_make(uint in_pos0, uint in_pos1, uint in_pos2, uint in_vert_color)
|
||||
{
|
||||
DRWDebugVert debug_vert;
|
||||
debug_vert.pos0 = in_pos0;
|
||||
debug_vert.pos1 = in_pos1;
|
||||
debug_vert.pos2 = in_pos2;
|
||||
debug_vert.vert_color = in_vert_color;
|
||||
return debug_vert;
|
||||
}
|
||||
|
||||
/* Take the header (DrawCommand) into account. */
|
||||
#define DRW_DEBUG_DRAW_VERT_MAX (64 * 8192) - 1
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ uint drw_debug_color_pack(vec4 v_color)
|
|||
|
||||
void drw_debug_line(inout uint vertid, vec3 v1, vec3 v2, uint v_color)
|
||||
{
|
||||
drw_debug_verts_buf[vertid++] = DRWDebugVert(
|
||||
drw_debug_verts_buf[vertid++] = debug_vert_make(
|
||||
floatBitsToUint(v1.x), floatBitsToUint(v1.y), floatBitsToUint(v1.z), v_color);
|
||||
drw_debug_verts_buf[vertid++] = DRWDebugVert(
|
||||
drw_debug_verts_buf[vertid++] = debug_vert_make(
|
||||
floatBitsToUint(v2.x), floatBitsToUint(v2.y), floatBitsToUint(v2.z), v_color);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue