| 9 | DAXA_DECL_TASK_HEAD_END |
| 10 | |
| 11 | void example_task_callback(daxa::TaskInterface ti) |
| 12 | { |
| 13 | auto const & AI = ExampleTaskHead::Info::AT; |
| 14 | |
| 15 | // There are two ways to get the info for any attachment: |
| 16 | { |
| 17 | // daxa::TaskBufferAttachmentIndex index: |
| 18 | [[maybe_unused]] daxa::TaskBufferAttachmentInfo const & buffer0_attachment0 = ti.get(AI.buffer0); |
| 19 | // daxa::TaskBufferView assigned to the buffer attachment: |
| 20 | [[maybe_unused]] daxa::TaskBufferAttachmentInfo const & buffer0_attachment1 = ti.get(buffer0_attachment0.view); |
| 21 | } |
| 22 | // The Buffer Attachment info contents: |
| 23 | { |
| 24 | [[maybe_unused]] daxa::BufferId id = ti.get(AI.buffer0).id; |
| 25 | [[maybe_unused]] char const * name = ti.get(AI.buffer0).name; |
| 26 | [[maybe_unused]] daxa::TaskAccess access = ti.get(AI.buffer0).task_access; |
| 27 | [[maybe_unused]] u8 shader_array_size = ti.get(AI.buffer0).shader_array_size; |
| 28 | [[maybe_unused]] bool shader_as_address = ti.get(AI.buffer0).shader_as_address; |
| 29 | [[maybe_unused]] daxa::TaskBufferView view = ti.get(AI.buffer0).view; |
| 30 | [[maybe_unused]] std::span<daxa::BufferId const> ids = ti.get(AI.buffer0).ids; |
| 31 | } |
| 32 | // The Image Attachment info contents: |
| 33 | { |
| 34 | [[maybe_unused]] char const * name = ti.get(AI.image0).name; |
| 35 | [[maybe_unused]] daxa::TaskAccess access = ti.get(AI.image0).task_access; |
| 36 | [[maybe_unused]] daxa::ImageViewType view_type = ti.get(AI.image0).view_type; |
| 37 | [[maybe_unused]] u8 shader_array_size = ti.get(AI.image0).shader_array_size; |
| 38 | [[maybe_unused]] bool is_mip_array = ti.get(AI.image0).is_mip_array; |
| 39 | [[maybe_unused]] daxa::TaskImageView view = ti.get(AI.image0).view; |
| 40 | [[maybe_unused]] daxa::ImageId id = ti.get(AI.image0).id; |
| 41 | [[maybe_unused]] std::span<daxa::ImageViewId const> view_ids = ti.get(AI.image0).view_ids; |
| 42 | } |
| 43 | // The interface has multiple convenience functions for easier access to the underlying resources attributes: |
| 44 | { |
| 45 | // Overloaded for buffer, blas, tlas, image |
| 46 | [[maybe_unused]] daxa::BufferInfo info = ti.info(AI.buffer0).value(); |
| 47 | // Overloaded for buffer, blas, tlas |
| 48 | [[maybe_unused]] daxa::DeviceAddress address = ti.device_address(AI.buffer0).value(); |
| 49 | |
| 50 | [[maybe_unused]] std::byte * host_address = ti.buffer_host_address(AI.buffer0).value(); |
| 51 | [[maybe_unused]] daxa::ImageViewInfo img_view_info = ti.image_view_info(AI.image0).value(); |
| 52 | |
| 53 | // In case the task resource has an array of real resources, one can use the optional second parameter to access those: |
| 54 | [[maybe_unused]] daxa::BufferInfo info2 = ti.info(AI.buffer0, 123 /*resource index*/).value(); |
| 55 | } |
| 56 | // The attachment infos are also provided, directly via a span: |
| 57 | for ([[maybe_unused]] daxa::TaskAttachmentInfo const & attach : ti.attachment_infos) |
| 58 | { |
| 59 | } |
| 60 | // The tasks shader side struct of ids and addresses is automatically filled and serialized to a blob: |
| 61 | [[maybe_unused]] auto generated_blob = ti.attachment_shader_blob; |
| 62 | // The head also declared an aligned struct with the right size as a dummy on the c++ side. |
| 63 | // This can be used to declare shader/c++ shared structs containing this blob : |
| 64 | [[maybe_unused]] ExampleTaskHead::AttachmentShaderBlob blob = {}; |
| 65 | // The blob also declares a constructor and assignment operator to take in the byte span generated by the taskgraph: |
| 66 | blob = generated_blob; |
| 67 | [[maybe_unused]] ExampleTaskHead::AttachmentShaderBlob blob2{ti.attachment_shader_blob}; |
| 68 | } |
nothing calls this directly
no test coverage detected