Module: Mesa Branch: main Commit: 4ddcda8369b1c9cbd993402bbac6d1bb84778c2f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ddcda8369b1c9cbd993402bbac6d1bb84778c2f
Author: Simon Perretta <[email protected]> Date: Tue Feb 14 00:45:01 2023 +0000 pvr: Add support for generating per-job EOT program Signed-off-by: Simon Perretta <[email protected]> Acked-by: Frank Binns <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21474> --- src/imagination/vulkan/meson.build | 2 ++ src/imagination/vulkan/usc/pvr_uscgen.c | 63 +++++++++++++++++++++++++++++++++ src/imagination/vulkan/usc/pvr_uscgen.h | 36 +++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/src/imagination/vulkan/meson.build b/src/imagination/vulkan/meson.build index ba4538239fe..2237510db88 100644 --- a/src/imagination/vulkan/meson.build +++ b/src/imagination/vulkan/meson.build @@ -64,6 +64,8 @@ pvr_files = files( 'pvr_spm.c', 'pvr_tex_state.c', 'pvr_wsi.c', + + 'usc/pvr_uscgen.c', ) pvr_includes = [ diff --git a/src/imagination/vulkan/usc/pvr_uscgen.c b/src/imagination/vulkan/usc/pvr_uscgen.c new file mode 100644 index 00000000000..7dd243304a8 --- /dev/null +++ b/src/imagination/vulkan/usc/pvr_uscgen.c @@ -0,0 +1,63 @@ +/* + * Copyright © 2023 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. + */ + +#include "pvr_job_transfer.h" +#include "pvr_uscgen.h" +#include "rogue/rogue.h" +#include "rogue/rogue_builder.h" +#include "util/u_dynarray.h" + +#include <stdbool.h> + +void pvr_uscgen_per_job_eot(uint32_t state0, + uint32_t state1, + unsigned *temps_used, + struct util_dynarray *binary) +{ + rogue_builder b; + rogue_shader *shader = rogue_shader_create(NULL, MESA_SHADER_NONE); + rogue_set_shader_name(shader, "per-job EOT"); + rogue_builder_init(&b, shader); + rogue_push_block(&b); + + rogue_reg *state_word_0 = rogue_ssa_reg(shader, 0); + rogue_reg *state_word_1 = rogue_ssa_reg(shader, 1); + + rogue_MOV(&b, rogue_ref_reg(state_word_0), rogue_ref_imm(state0)); + rogue_MOV(&b, rogue_ref_reg(state_word_1), rogue_ref_imm(state1)); + + rogue_backend_instr *emitpix = rogue_EMITPIX(&b, + rogue_ref_reg(state_word_0), + rogue_ref_reg(state_word_1)); + rogue_set_backend_op_mod(emitpix, ROGUE_BACKEND_OP_MOD_FREEP); + + rogue_END(&b); + + rogue_shader_passes(shader); + rogue_encode_shader(NULL, shader, binary); + + *temps_used = rogue_count_used_regs(shader, ROGUE_REG_CLASS_TEMP); + + ralloc_free(shader); +} + diff --git a/src/imagination/vulkan/usc/pvr_uscgen.h b/src/imagination/vulkan/usc/pvr_uscgen.h new file mode 100644 index 00000000000..a4f0d956316 --- /dev/null +++ b/src/imagination/vulkan/usc/pvr_uscgen.h @@ -0,0 +1,36 @@ +/* + * Copyright © 2023 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_USCGEN_H +#define PVR_USCGEN_H + +#include "util/u_dynarray.h" + +#include <stdint.h> + +void pvr_uscgen_per_job_eot(uint32_t state0, + uint32_t state1, + unsigned *temps_used, + struct util_dynarray *binary); + +#endif /* PVR_USCGEN_H */
