pvr: Generate EOT program at runtime
authorJarred Davies <jarred.davies@imgtec.com>
Sun, 26 Feb 2023 08:10:37 +0000 (08:10 +0000)
committerMarge Bot <emma+marge@anholt.net>
Mon, 20 Mar 2023 14:35:19 +0000 (14:35 +0000)
Also removes hardcoded EOT program.

Signed-off-by: Jarred Davies <jarred.davies@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21596>

src/imagination/vulkan/pvr_cmd_buffer.c
src/imagination/vulkan/usc/programs/pvr_end_of_tile.h [deleted file]

index 4282a6d..0cb7399 100644 (file)
@@ -35,7 +35,6 @@
 #include "pvr_csb.h"
 #include "pvr_csb_enum_helpers.h"
 #include "pvr_device_info.h"
-#include "pvr_end_of_tile.h"
 #include "pvr_formats.h"
 #include "pvr_hardcode.h"
 #include "pvr_hw_pass.h"
@@ -46,6 +45,7 @@
 #include "pvr_private.h"
 #include "pvr_tex_state.h"
 #include "pvr_types.h"
+#include "pvr_uscgen.h"
 #include "pvr_winsys.h"
 #include "util/bitscan.h"
 #include "util/bitset.h"
@@ -489,33 +489,27 @@ static VkResult pvr_sub_cmd_gfx_per_job_fragment_programs_create_and_upload(
       cmd_buffer->device->pixel_event_data_size_in_dwords * sizeof(uint32_t);
    const VkAllocationCallbacks *const allocator = &cmd_buffer->vk.pool->alloc;
    struct pvr_device *const device = cmd_buffer->device;
-   /* FIXME: This should come from the compiler for the USC pixel program. */
-   const uint32_t usc_temp_count = 0;
-   struct pvr_bo *usc_eot_program;
-   uint8_t *usc_eot_program_ptr;
+   struct util_dynarray eot_program_bin;
+   struct pvr_bo *usc_eot_program = NULL;
    uint32_t *staging_buffer;
+   uint32_t usc_temp_count;
    VkResult result;
 
+   pvr_uscgen_per_job_eot(pbe_cs_words[0],
+                          pbe_cs_words[1],
+                          &usc_temp_count,
+                          &eot_program_bin);
+
    result = pvr_cmd_buffer_upload_usc(cmd_buffer,
-                                      pvr_end_of_tile_program,
-                                      sizeof(pvr_end_of_tile_program),
+                                      eot_program_bin.data,
+                                      eot_program_bin.size,
                                       4,
                                       &usc_eot_program);
-   if (result != VK_SUCCESS)
-      return result;
 
-   assert((pbe_cs_words[1] & 0x3F) == 0x20);
+   util_dynarray_fini(&eot_program_bin);
 
-   /* FIXME: Stop patching the framebuffer address (this will require the
-    * end-of-tile program to be generated at run-time).
-    */
-   pvr_bo_cpu_map(device, usc_eot_program);
-   usc_eot_program_ptr = usc_eot_program->bo->map;
-   usc_eot_program_ptr[6] = (pbe_cs_words[0] >> 0) & 0xFF;
-   usc_eot_program_ptr[7] = (pbe_cs_words[0] >> 8) & 0xFF;
-   usc_eot_program_ptr[8] = (pbe_cs_words[0] >> 16) & 0xFF;
-   usc_eot_program_ptr[9] = (pbe_cs_words[0] >> 24) & 0xFF;
-   pvr_bo_cpu_unmap(device, usc_eot_program);
+   if (result != VK_SUCCESS)
+      return result;
 
    pvr_pds_setup_doutu(&pixel_event_program.task_control,
                        usc_eot_program->vma->dev_addr.addr,
diff --git a/src/imagination/vulkan/usc/programs/pvr_end_of_tile.h b/src/imagination/vulkan/usc/programs/pvr_end_of_tile.h
deleted file mode 100644 (file)
index 2ec962c..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright © 2022 Imagination Technologies Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef PVR_END_OF_TILE_H
-#define PVR_END_OF_TILE_H
-
-#include <stdint.h>
-
-/* clang-format off */
-static const uint8_t pvr_end_of_tile_program[] = {
-   0xa9, 0xf2, 0x40, 0x00,
-   0x47, 0x91, 0x00, 0x50,
-   0x04, 0x00, 0x80, 0x40,
-   0x00, 0x00, 0x80, 0x80,
-   0x24, 0xff, 0xa9, 0xf2,
-   0x40, 0x00, 0x47, 0x91,
-   0x20, 0x20, 0x08, 0x00,
-   0x80, 0x40, 0x00, 0x00,
-   0x80, 0x80, 0x25, 0xff,
-   0x45, 0xa0, 0x80, 0xc2,
-   0xa4, 0x40, 0x00, 0x25,
-   0x00, 0x00
-};
-/* clang-format on */
-
-#endif /* PVR_END_OF_TILE_H */