Module: Mesa
Branch: main
Commit: cbfa4d52ed24a2af0baac0655cab42b1c4f86949
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbfa4d52ed24a2af0baac0655cab42b1c4f86949

Author: Frank Binns <[email protected]>
Date:   Wed Feb 22 22:42:14 2023 +0000

pvr: stop restricting the compiler to the Sascha Willems triangle demo

Do this by removing the compatibility table and only using hard coded shaders
when present. The hard coded shaders, along with the hard coding framework
itself, can be dropped once the compiler is capable of compiling the hard coded
shaders. In the meantime we don't want to risk regressing things that we know
work because we temporarily can't test them.

This restriction is being dropped now as the new compiler framework has been
merged and we want to make use of it so it can be developed further.

Signed-off-by: Frank Binns <[email protected]>
Reviewed-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21495>

---

 src/imagination/vulkan/pvr_cmd_buffer.c |  2 +-
 src/imagination/vulkan/pvr_hardcode.c   | 29 +++++++----------------------
 src/imagination/vulkan/pvr_hardcode.h   |  6 +++---
 src/imagination/vulkan/pvr_pipeline.c   | 16 +++++++---------
 4 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c 
b/src/imagination/vulkan/pvr_cmd_buffer.c
index 4560ab0ebff..a8fbbe046b0 100644
--- a/src/imagination/vulkan/pvr_cmd_buffer.c
+++ b/src/imagination/vulkan/pvr_cmd_buffer.c
@@ -3735,7 +3735,7 @@ static VkResult pvr_setup_descriptor_mappings(
    uint32_t *const descriptor_data_offset_out)
 {
    const bool old_path =
-      pvr_hard_code_shader_required(&cmd_buffer->device->pdevice->dev_info);
+      pvr_has_hard_coded_shaders(&cmd_buffer->device->pdevice->dev_info);
 
    if (old_path) {
       return pvr_setup_descriptor_mappings_old(cmd_buffer,
diff --git a/src/imagination/vulkan/pvr_hardcode.c 
b/src/imagination/vulkan/pvr_hardcode.c
index 8e2e1e62c80..ee04e1821ef 100644
--- a/src/imagination/vulkan/pvr_hardcode.c
+++ b/src/imagination/vulkan/pvr_hardcode.c
@@ -59,19 +59,6 @@ enum pvr_hard_code_shader_type {
 #define util_dynarray_append_mem(buf, size, mem) \
    memcpy(util_dynarray_grow_bytes((buf), 1, size), mem, size)
 
-/* Table indicating which demo and for which device the compiler is capable of
- * generating valid shaders.
- */
-static struct {
-   const char *const name;
-   uint64_t bvncs[3];
-} compatiblity_table[] = {
-   {
-      .name = "triangle",
-      .bvncs = { PVR_GX6250_BVNC, PVR_AXE_1_16M_BVNC, },
-   },
-};
-
 static const struct pvr_hard_coding_data {
    const char *const name;
    uint64_t bvnc;
@@ -155,22 +142,20 @@ pvr_device_get_bvnc(const struct pvr_device_info *const 
dev_info)
    return PVR_BVNC_PACK(ident->b, ident->v, ident->n, ident->c);
 }
 
-bool pvr_hard_code_shader_required(const struct pvr_device_info *const 
dev_info)
+bool pvr_has_hard_coded_shaders(const struct pvr_device_info *const dev_info)
 {
    const char *const program = util_get_process_name();
    const uint64_t bvnc = pvr_device_get_bvnc(dev_info);
 
-   for (uint32_t i = 0; i < ARRAY_SIZE(compatiblity_table); i++) {
-      for (uint32_t j = 0; j < ARRAY_SIZE(compatiblity_table[0].bvncs); j++) {
-         if (bvnc != compatiblity_table[i].bvncs[j])
-            continue;
+   for (uint32_t i = 0; i < ARRAY_SIZE(hard_coding_table); i++) {
+      if (bvnc != hard_coding_table[i].bvnc)
+         continue;
 
-         if (strcmp(program, compatiblity_table[i].name) == 0)
-            return false;
-      }
+      if (strcmp(program, hard_coding_table[i].name) == 0)
+         return true;
    }
 
-   return true;
+   return false;
 }
 
 static const struct pvr_hard_coding_data *
diff --git a/src/imagination/vulkan/pvr_hardcode.h 
b/src/imagination/vulkan/pvr_hardcode.h
index 3fcdd1e361e..024b12061fe 100644
--- a/src/imagination/vulkan/pvr_hardcode.h
+++ b/src/imagination/vulkan/pvr_hardcode.h
@@ -74,10 +74,10 @@ struct pvr_hard_code_graphics_build_info {
    struct pvr_explicit_constant_usage frag_explicit_conts_usage;
 };
 
-/* Returns true if the shader for the currently running program requires hard
- * coded shaders.
+/* Returns true if the shader for the currently running program has a hard 
coded
+ * shader.
  */
-bool pvr_hard_code_shader_required(const struct pvr_device_info *const 
dev_info);
+bool pvr_has_hard_coded_shaders(const struct pvr_device_info *const dev_info);
 
 VkResult pvr_hard_code_compute_pipeline(
    struct pvr_device *const device,
diff --git a/src/imagination/vulkan/pvr_pipeline.c 
b/src/imagination/vulkan/pvr_pipeline.c
index 00be7eb15f6..9442cd7b219 100644
--- a/src/imagination/vulkan/pvr_pipeline.c
+++ b/src/imagination/vulkan/pvr_pipeline.c
@@ -668,8 +668,7 @@ static VkResult 
pvr_pds_descriptor_program_create_and_upload(
    uint32_t *staging_buffer;
    VkResult result;
 
-   const bool old_path =
-      pvr_hard_code_shader_required(&device->pdevice->dev_info);
+   const bool old_path = 
pvr_has_hard_coded_shaders(&device->pdevice->dev_info);
 
    assert(stage != PVR_STAGE_ALLOCATION_COUNT);
 
@@ -1159,7 +1158,7 @@ static VkResult pvr_compute_pipeline_compile(
    uint32_t usc_temps;
    VkResult result;
 
-   if (pvr_hard_code_shader_required(&device->pdevice->dev_info)) {
+   if (pvr_has_hard_coded_shaders(&device->pdevice->dev_info)) {
       struct pvr_hard_code_compute_build_info build_info;
 
       result = pvr_hard_code_compute_pipeline(device,
@@ -1647,8 +1646,7 @@ pvr_graphics_pipeline_compile(struct pvr_device *const 
device,
    struct rogue_build_ctx *ctx;
    VkResult result;
 
-   const bool old_path =
-      pvr_hard_code_shader_required(&device->pdevice->dev_info);
+   const bool old_path = 
pvr_has_hard_coded_shaders(&device->pdevice->dev_info);
 
    /* Vars needed for the new path. */
    uint32_t sh_count[PVR_STAGE_ALLOCATION_COUNT] = { 0 };
@@ -1675,7 +1673,7 @@ pvr_graphics_pipeline_compile(struct pvr_device *const 
device,
       const VkPipelineShaderStageCreateInfo *create_info;
       size_t stage_index = gfx_pipeline->stage_indices[stage];
 
-      if (pvr_hard_code_shader_required(&device->pdevice->dev_info)) {
+      if (pvr_has_hard_coded_shaders(&device->pdevice->dev_info)) {
          if (pvr_hard_code_graphics_get_flags(&device->pdevice->dev_info) &
              BITFIELD_BIT(stage)) {
             continue;
@@ -1705,7 +1703,7 @@ pvr_graphics_pipeline_compile(struct pvr_device *const 
device,
    /* Back-end translation. */
    for (gl_shader_stage stage = MESA_SHADER_FRAGMENT; stage > MESA_SHADER_NONE;
         stage--) {
-      if (pvr_hard_code_shader_required(&device->pdevice->dev_info) &&
+      if (pvr_has_hard_coded_shaders(&device->pdevice->dev_info) &&
           pvr_hard_code_graphics_get_flags(&device->pdevice->dev_info) &
              BITFIELD_BIT(stage)) {
          const struct pvr_device_info *const dev_info =
@@ -1756,7 +1754,7 @@ pvr_graphics_pipeline_compile(struct pvr_device *const 
device,
       }
    }
 
-   if (pvr_hard_code_shader_required(&device->pdevice->dev_info) &&
+   if (pvr_has_hard_coded_shaders(&device->pdevice->dev_info) &&
        pvr_hard_code_graphics_get_flags(&device->pdevice->dev_info) &
           BITFIELD_BIT(MESA_SHADER_VERTEX)) {
       pvr_hard_code_graphics_vertex_state(&device->pdevice->dev_info,
@@ -1788,7 +1786,7 @@ pvr_graphics_pipeline_compile(struct pvr_device *const 
device,
    if (result != VK_SUCCESS)
       goto err_free_build_context;
 
-   if (pvr_hard_code_shader_required(&device->pdevice->dev_info) &&
+   if (pvr_has_hard_coded_shaders(&device->pdevice->dev_info) &&
        pvr_hard_code_graphics_get_flags(&device->pdevice->dev_info) &
           BITFIELD_BIT(MESA_SHADER_FRAGMENT)) {
       pvr_hard_code_graphics_fragment_state(

Reply via email to