diff --git a/src/imagination/vulkan/usc/programs/pvr_shader_factory.h b/src/imagination/vulkan/usc/programs/pvr_shader_factory.h new file mode 100644 index 00000000000..be3548b3c29 --- /dev/null +++ b/src/imagination/vulkan/usc/programs/pvr_shader_factory.h @@ -0,0 +1,99 @@ +/* + * 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_SHADER_FACTORY_H +#define PVR_SHADER_FACTORY_H + +#include + +/* Occlusion query availability writes. */ +enum pvr_query_availability_write_pool_const { + PVR_QUERY_AVAILABILITY_WRITE_INDEX_COUNT, + PVR_QUERY_AVAILABILITY_WRITE_COUNT, +}; + +/* Copy query pool results. */ +enum pvr_copy_query_pool_const { + PVR_COPY_QUERY_POOL_RESULTS_INDEX_COUNT, + PVR_COPY_QUERY_POOL_RESULTS_BASE_ADDRESS_LOW, + PVR_COPY_QUERY_POOL_RESULTS_BASE_ADDRESS_HIGH, + PVR_COPY_QUERY_POOL_RESULTS_DEST_STRIDE, + PVR_COPY_QUERY_POOL_RESULTS_PARTIAL_RESULT_FLAG, + PVR_COPY_QUERY_POOL_RESULTS_64_BIT_FLAG, + PVR_COPY_QUERY_POOL_RESULTS_WITH_AVAILABILITY_FLAG, + PVR_COPY_QUERY_POOL_RESULTS_COUNT, +}; + +/* Reset query pool. */ +enum pvr_reset_query_pool_pool_const { + PVR_RESET_QUERY_POOL_INDEX_COUNT, + PVR_RESET_QUERY_POOL_COUNT, +}; + +/* ClearAttachments. */ +enum pvr_clear_attachment_const { + PVR_CLEAR_ATTACHMENT_CONST_COMPONENT_0, + PVR_CLEAR_ATTACHMENT_CONST_COMPONENT_1, + PVR_CLEAR_ATTACHMENT_CONST_COMPONENT_2, + PVR_CLEAR_ATTACHMENT_CONST_COMPONENT_3, + PVR_CLEAR_ATTACHMENT_CONST_TILE_BUFFER_UPPER, + PVR_CLEAR_ATTACHMENT_CONST_TILE_BUFFER_LOWER, + PVR_CLEAR_ATTACHMENT_CONST_COUNT, +}; + +#define PVR_CLEAR_ATTACHMENT_DEST_ID_UNUSED (~0U) + +/* 8 + 8 = 16 <- 1 Dword, 8 offsets, to registers/tile buffers + * 7 + 7 = 14 <- 2 Dwords, 7 offsets, to registers/tile buffers + * 6 + 6 = 12 <- 3 Dwords, 6 offsets, to registers/tile buffers + * 5 + 5 = 10 <- 4 Dwords, 5 offsets, to registers/tile buffers + */ +#define PVR_CLEAR_ATTACHMENT_PROGRAM_COUNT 52 + +/* This defines the max theoretic number of clear attachment programs. In cases + * where the dword count goes past the number of on-chip on-tile-buffer targets + * there are unused elements. There are 4 versions for clearing 1..4 dwords, 8 + * versions for clearing offsets 0..7 and 2 versions for clearing either on + * chip or in memory calculated as 4 * 8 * 2 = 64. + */ +#define PVR_CLEAR_ATTACHMENT_PROGRAM_COUNT_WITH_HOLES 64 + +#define PVR_CLEAR_ATTACHMENT_PROGRAM_DWORDS_SHIFT (4U) +#define PVR_CLEAR_ATTACHMENT_PROGRAM_DWORDS_SETMASK (0x30U) +#define PVR_CLEAR_ATTACHMENT_PROGRAM_OFFSET_SHIFT (1U) +#define PVR_CLEAR_ATTACHMENT_PROGRAM_OFFSET_SETMASK (0x0EU) +#define PVR_CLEAR_ATTACHMENT_PROGRAM_DEST_SHIFT (0U) +#define PVR_CLEAR_ATTACHMENT_PROGRAM_DEST_SETMASK (0x01U) + +static inline uint32_t +pvr_get_clear_attachment_program_index(uint32_t dwords, + uint32_t offset, + uint8_t tile_buffer) +{ + return (((dwords - 1) << PVR_CLEAR_ATTACHMENT_PROGRAM_DWORDS_SHIFT) | + (offset << PVR_CLEAR_ATTACHMENT_PROGRAM_OFFSET_SHIFT) | + (tile_buffer << PVR_CLEAR_ATTACHMENT_PROGRAM_DEST_SHIFT)) & + 0x3f; +} + +#endif /* PVR_SHADER_FACTORY_H */ diff --git a/src/imagination/vulkan/usc/programs/pvr_static_shaders.h b/src/imagination/vulkan/usc/programs/pvr_static_shaders.h new file mode 100644 index 00000000000..b39c226b9ac --- /dev/null +++ b/src/imagination/vulkan/usc/programs/pvr_static_shaders.h @@ -0,0 +1,157 @@ +/* + * 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_STATIC_SHADERS_H +#define PVR_STATIC_SHADERS_H + +#include + +/* TODO: Remove this once compiler is integrated. */ +#define PVR_INVALID_INST (~0) + +struct pvr_static_buffer { + uint32_t dst_idx; + uint32_t value; +}; + +struct pvr_shader_factory_info { + uint32_t temps_required; + uint32_t const_shared_regs; + uint32_t coeff_regs; + uint32_t input_regs; + uint32_t explicit_const_start_offset; + uint32_t code_size; + const uint8_t *const shader_code; + uint32_t const_calc_prog_inst_bytes; + uint32_t sec_temp_regs; + const uint8_t *const_calc_program; + uint32_t coeff_update_prog_start; + uint32_t coeff_update_temp_regs; + const uint32_t *driver_const_location_map; + uint32_t num_driver_consts; + const struct pvr_static_buffer *static_const_buffer; + uint32_t num_static_const; +}; + +static const uint8_t availability_query_write_shader[144] = { 0 }; + +static const uint32_t availability_query_write_location_map[1] = { + 0, +}; + +static const struct pvr_static_buffer + availability_query_write_static_consts[3] = { + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + }; + +static const struct pvr_shader_factory_info availability_query_write_info = { + 0, + 0, + 0, + 0, + 0, + 0, + availability_query_write_shader, + 0, + 0, + NULL, + PVR_INVALID_INST, + 0, + availability_query_write_location_map, + 0, + availability_query_write_static_consts, + 0, +}; + +static const uint8_t copy_query_results_shader[384] = { 0 }; + +static const uint32_t copy_query_results_location_map[7] = { + 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct pvr_static_buffer copy_query_results_static_consts[2] = { + { 0, 0 }, + { 0, 0 }, +}; + +static const struct pvr_shader_factory_info copy_query_results_info = { + 0, + 0, + 0, + 0, + 0, + 0, + copy_query_results_shader, + 0, + 0, + NULL, + PVR_INVALID_INST, + 0, + copy_query_results_location_map, + 0, + copy_query_results_static_consts, + 0, +}; + +static const uint8_t reset_query_shader_code[136] = { 0 }; + +static const uint32_t reset_query_location_map[1] = { + 0, +}; + +static const struct pvr_static_buffer reset_query_static_consts[2] = { + { 0, 0 }, + { 0, 0 }, +}; + +static const struct pvr_shader_factory_info reset_query_info = { + 0, + 0, + 0, + 0, + 0, + 0, + reset_query_shader_code, + 0, + 0, + NULL, + PVR_INVALID_INST, + 0, + reset_query_location_map, + 0, + reset_query_static_consts, + 0, +}; + +static const struct pvr_shader_factory_info + *const copy_query_results_collection[1] = { + ©_query_results_info, + }; + +static const struct pvr_shader_factory_info *const reset_query_collection[1] = { + &reset_query_info, +}; + +#endif /* PVR_STATIC_SHADERS_H */