struct PushConstants { float4x4 view_proj; float3 cam_pos; uint32_t frame_timestamp; uint32_t width; uint32_t height; uint32_t chunk_width; uint32_t chunk_height; uint32_t chunk_alt; uint32_t table_base_slot_x; uint32_t table_base_slot_y; uint32_t table_base_slot_z; } [[vk::push_constant]] uniform PushConstants constants; [[vk::binding(0, 0)]] RWStructuredBuffer structure_pool; [[vk::binding(1, 0)]] RWStructuredBuffer attributes_pool[2]; [[vk::binding(2, 0)]] RWStructuredBuffer request_buffer; [[vk::binding(3, 0)]] RWStructuredBuffer usage_buffer; [[vk::binding(0, 1)]] RWStructuredBuffer structure_table_pointer; [[vk::binding(1, 1)]] RWStructuredBuffer> structure_table_request_buffer; [[vk::binding(0, 2)]] [[format("rgba32f")]] WTexture2D target_texture; [[vk::binding(1, 2)]] [[format("rgba32f")]] RWTexture2D gbuffer_position; [[vk::binding(2, 2)]] [[format("rgba32f")]] RWTexture2D gbuffer_albedo; [[vk::binding(3, 2)]] [[format("rgba32f")]] RWTexture2D gbuffer_normal; float3 get_ray_direction(uint32_t2 pixel_loc) { let ndc_loc_x = (float)pixel_loc.x / (float)constants.width * 2. - 1.; let ndc_loc_y = 1. - (float)pixel_loc.y / (float)constants.height * 2.; var world_loc = mul(constants.view_proj, float4(ndc_loc_x, ndc_loc_y, 1., 1.)); world_loc /= world_loc.w; return normalize(world_loc.xyz - constants.cam_pos); } [shader("compute")] [numthreads(16, 16, 1)] void gi(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_location: SV_GroupThreadID) { if (location.x >= constants.width || location.y >= constants.height) { return; } if (gbuffer_albedo.Load(location.xy).w == 0.) { target_texture.Store(location.xy, float4(0.)); return; } let pos = gbuffer_position.Load(location.xy); let normal = gbuffer_normal.Load(location.xy); let albedo = gbuffer_albedo.Load(location.xy); target_texture.Store(location.xy, albedo); return; }