| 196 | } |
| 197 | |
| 198 | void PostProcessingComputePass::draw(vkb::core::CommandBufferC &command_buffer, vkb::rendering::RenderTargetC &default_render_target) |
| 199 | { |
| 200 | transition_images(command_buffer, default_render_target); |
| 201 | |
| 202 | // Get compute shader from cache |
| 203 | auto &resource_cache = command_buffer.get_device().get_resource_cache(); |
| 204 | auto &shader_module = resource_cache.request_shader_module(VK_SHADER_STAGE_COMPUTE_BIT, cs_source, cs_variant); |
| 205 | |
| 206 | // Create pipeline layout and bind it |
| 207 | auto &pipeline_layout = resource_cache.request_pipeline_layout({&shader_module}); |
| 208 | command_buffer.bind_pipeline_layout(pipeline_layout); |
| 209 | |
| 210 | const auto &bindings = pipeline_layout.get_descriptor_set_layout(0); |
| 211 | |
| 212 | // Bind samplers to set = 0, binding = <according to name> |
| 213 | for (const auto &it : sampled_images) |
| 214 | { |
| 215 | if (auto layout_binding = bindings.get_layout_binding(it.first)) |
| 216 | { |
| 217 | const auto &view = it.second.get_image_view(default_render_target); |
| 218 | |
| 219 | // Get the properties for the image format. We need to check whether a linear sampler is valid. |
| 220 | const VkFormatProperties fmtProps = get_render_context().get_device().get_gpu().get_format_properties(view.get_format()); |
| 221 | bool has_linear_filter = (fmtProps.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT); |
| 222 | |
| 223 | const auto &sampler = it.second.get_sampler() ? *it.second.get_sampler() : |
| 224 | (has_linear_filter ? *default_sampler : *default_sampler_nearest); |
| 225 | |
| 226 | command_buffer.bind_image(view, sampler, 0, layout_binding->binding, 0); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | // Bind storage images to set = 0, binding = <according to name> |
| 231 | for (const auto &it : storage_images) |
| 232 | { |
| 233 | if (auto layout_binding = bindings.get_layout_binding(it.first)) |
| 234 | { |
| 235 | const auto &view = it.second.get_image_view(default_render_target); |
| 236 | command_buffer.bind_image(view, 0, layout_binding->binding, 0); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | if (!uniform_data.empty()) |
| 241 | { |
| 242 | auto &render_frame = parent->get_render_context().get_active_frame(); |
| 243 | |
| 244 | uniform_alloc = std::make_unique<BufferAllocationC>(render_frame.allocate_buffer(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, uniform_data.size())); |
| 245 | uniform_alloc->update(uniform_data); |
| 246 | |
| 247 | // Bind buffer to set = 0, binding = 0 |
| 248 | command_buffer.bind_buffer(uniform_alloc->get_buffer(), uniform_alloc->get_offset(), uniform_alloc->get_size(), 0, 0, 0); |
| 249 | } |
| 250 | |
| 251 | if (!push_constants_data.empty()) |
| 252 | { |
| 253 | command_buffer.push_constants(push_constants_data); |
| 254 | } |
| 255 |
nothing calls this directly
no test coverage detected