From 821da19046b2a1ac0ee988a3300d7dc2ff41937f Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Thu, 15 Sep 2022 16:09:23 +0100 Subject: [PATCH] pvr: Add multi layer passthough vert shader upload in device. Signed-off-by: Karmjit Mahil Reviewed-by: Frank Binns Part-of: --- src/imagination/vulkan/pvr_device.c | 29 ++++++++++++++++++++++++++- src/imagination/vulkan/pvr_hardcode.c | 17 ++++++++++++++++ src/imagination/vulkan/pvr_hardcode.h | 4 ++++ src/imagination/vulkan/pvr_private.h | 2 ++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index 5704f57d27c..4415910173d 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -1778,6 +1778,29 @@ pvr_device_init_graphics_static_clear_state(struct pvr_device *device) { 0.0f, vf_y_max, 0.0f }, { vf_x_max, vf_y_max, 0.0f } }; + if (PVR_HAS_FEATURE(dev_info, gs_rta_support)) { + struct util_dynarray passthrough_rta_vert_shader; + + util_dynarray_init(&passthrough_rta_vert_shader, NULL); + pvr_hard_code_get_passthrough_rta_vertex_shader( + dev_info, + &passthrough_rta_vert_shader); + + result = pvr_gpu_upload_usc(device, + passthrough_rta_vert_shader.data, + passthrough_rta_vert_shader.size, + cache_line_size, + &state->usc_multi_layer_vertex_shader_bo); + if (result != VK_SUCCESS) { + util_dynarray_fini(&passthrough_rta_vert_shader); + return result; + } + + util_dynarray_fini(&passthrough_rta_vert_shader); + } else { + state->usc_multi_layer_vertex_shader_bo = NULL; + } + pvr_hard_code_get_passthrough_vertex_shader(dev_info, &passthrough_vert_shader); @@ -1787,7 +1810,7 @@ pvr_device_init_graphics_static_clear_state(struct pvr_device *device) cache_line_size, &state->usc_vertex_shader_bo); if (result != VK_SUCCESS) - return result; + goto err_free_usc_multi_layer_shader; result = pvr_gpu_upload(device, device->heaps.general_heap, @@ -1894,6 +1917,9 @@ err_free_verices_buffer: err_free_usc_shader: pvr_bo_free(device, state->usc_vertex_shader_bo); +err_free_usc_multi_layer_shader: + pvr_bo_free(device, state->usc_multi_layer_vertex_shader_bo); + return result; } @@ -1905,6 +1931,7 @@ pvr_device_finish_graphics_static_clear_state(struct pvr_device *device) pvr_bo_free(device, state->pds.pvr_bo); pvr_bo_free(device, state->vertices_bo); pvr_bo_free(device, state->usc_vertex_shader_bo); + pvr_bo_free(device, state->usc_multi_layer_vertex_shader_bo); } /* FIXME: We should be calculating the size when we upload the code in diff --git a/src/imagination/vulkan/pvr_hardcode.c b/src/imagination/vulkan/pvr_hardcode.c index 62b960cba19..27f6e169b34 100644 --- a/src/imagination/vulkan/pvr_hardcode.c +++ b/src/imagination/vulkan/pvr_hardcode.c @@ -35,6 +35,7 @@ #include "rogue/rogue.h" #include "usc/hardcoded_apps/pvr_simple_compute.h" #include "util/macros.h" +#include "util/u_dynarray.h" #include "util/u_process.h" /** @@ -47,6 +48,9 @@ #define PVR_AXE_1_16M_BVNC PVR_BVNC_PACK(33, 15, 11, 3) #define PVR_GX6250_BVNC PVR_BVNC_PACK(4, 40, 2, 51) +#define util_dynarray_append_mem(buf, size, mem) \ + memcpy(util_dynarray_grow_bytes((buf), 1, size), mem, size) + enum pvr_hard_code_shader_type { PVR_HARD_CODE_SHADER_TYPE_COMPUTE, PVR_HARD_CODE_SHADER_TYPE_GRAPHICS, @@ -363,3 +367,16 @@ void pvr_hard_code_get_passthrough_vertex_shader( "No hard coded passthrough vertex shader. Returning empty shader."); *program_out = &shader; }; + +/* Render target array (RTA). */ +void pvr_hard_code_get_passthrough_rta_vertex_shader( + const struct pvr_device_info *const dev_info, + struct util_dynarray *program_out) +{ + uint32_t shader[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + util_dynarray_append_mem(program_out, ARRAY_SIZE(shader), &shader); + + mesa_loge("No hard coded passthrough rta vertex shader. Returning " + "empty shader."); +} diff --git a/src/imagination/vulkan/pvr_hardcode.h b/src/imagination/vulkan/pvr_hardcode.h index af0716ca67b..069201452f1 100644 --- a/src/imagination/vulkan/pvr_hardcode.h +++ b/src/imagination/vulkan/pvr_hardcode.h @@ -30,6 +30,7 @@ #include "compiler/shader_enums.h" #include "rogue/rogue_build_data.h" +#include "util/u_dynarray.h" /** * \file pvr_hardcode.h @@ -128,5 +129,8 @@ void pvr_hard_code_get_idfwdf_program( void pvr_hard_code_get_passthrough_vertex_shader( const struct pvr_device_info *const dev_info, const struct rogue_shader_binary **const program_out); +void pvr_hard_code_get_passthrough_rta_vertex_shader( + const struct pvr_device_info *const dev_info, + struct util_dynarray *program_out); #endif /* PVR_HARDCODE_SHADERS_H */ diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index 95c1654bdeb..157e5281066 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -418,6 +418,8 @@ struct pvr_device { struct pvr_bo *vertices_bo; struct pvr_pds_upload pds; + struct pvr_bo *usc_multi_layer_vertex_shader_bo; + struct pvr_static_clear_ppp_base ppp_base; struct pvr_static_clear_ppp_template ppp_templates[PVR_STATIC_CLEAR_VARIANT_COUNT];