Mesa (main): pvr: Add csb enum helper funciton header.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 8 08:43:01 UTC 2022
Module: Mesa
Branch: main
Commit: 81077a4c7db6e56b373fa79433334859d7aab651
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=81077a4c7db6e56b373fa79433334859d7aab651
Author: Karmjit Mahil <Karmjit.Mahil at imgtec.com>
Date: Thu May 26 14:22:08 2022 +0100
pvr: Add csb enum helper funciton header.
A new header is introduced which groups all vk, uint, rogue types
to csb enum type conversions.
Signed-off-by: Karmjit Mahil <Karmjit.Mahil at imgtec.com>
Reviewed-by: Frank Binns <frank.binns at imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16883>
---
src/imagination/vulkan/pvr_cmd_buffer.c | 63 +++----------
src/imagination/vulkan/pvr_csb_enum_helpers.h | 122 ++++++++++++++++++++++++++
src/imagination/vulkan/pvr_job_render.c | 21 +----
src/imagination/vulkan/pvr_pipeline.c | 3 +-
src/imagination/vulkan/pvr_private.h | 18 ----
5 files changed, 139 insertions(+), 88 deletions(-)
diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c
index 4940df6a659..084289e917a 100644
--- a/src/imagination/vulkan/pvr_cmd_buffer.c
+++ b/src/imagination/vulkan/pvr_cmd_buffer.c
@@ -33,6 +33,7 @@
#include "hwdef/rogue_hw_utils.h"
#include "pvr_bo.h"
#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"
@@ -3196,46 +3197,6 @@ static void pvr_setup_output_select(struct pvr_cmd_buffer *const cmd_buffer)
}
}
-/* clang-format off */
-static enum PVRX(TA_OBJTYPE)
-pvr_ppp_state_get_ispa_objtype_from_vk(const VkPrimitiveTopology topology)
-/* clang-format on */
-{
- switch (topology) {
- case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
- return PVRX(TA_OBJTYPE_SPRITE_01UV);
-
- case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
- case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
- case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
- case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
- return PVRX(TA_OBJTYPE_LINE);
-
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
- case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
- return PVRX(TA_OBJTYPE_TRIANGLE);
-
- default:
- unreachable("Invalid topology.");
- return 0;
- }
-}
-
-static inline enum PVRX(TA_CMPMODE) pvr_cmpmode(VkCompareOp op)
-{
- /* enum values are identical, so we can just cast the input directly. */
- return (enum PVRX(TA_CMPMODE))op;
-}
-
-static inline enum PVRX(TA_ISPB_STENCILOP) pvr_stencilop(VkStencilOp op)
-{
- /* enum values are identical, so we can just cast the input directly. */
- return (enum PVRX(TA_ISPB_STENCILOP))op;
-}
-
static void pvr_setup_isp_faces_and_control(
struct pvr_cmd_buffer *const cmd_buffer,
struct pvr_cmd_struct(TA_STATE_ISPA) *const ispa_out)
@@ -3262,8 +3223,7 @@ static void pvr_setup_isp_faces_and_control(
const bool disable_all = raster_discard_enabled || !attachment;
const VkPrimitiveTopology topology = gfx_pipeline->input_asm_state.topology;
- const enum PVRX(TA_OBJTYPE)
- obj_type = pvr_ppp_state_get_ispa_objtype_from_vk(topology);
+ const enum PVRX(TA_OBJTYPE) obj_type = pvr_ta_objtype(topology);
const bool disable_stencil_write = disable_all;
const bool disable_stencil_test =
@@ -3304,7 +3264,7 @@ static void pvr_setup_isp_faces_and_control(
if (disable_depth_test)
ispa.dcmpmode = PVRX(TA_CMPMODE_ALWAYS);
else
- ispa.dcmpmode = pvr_cmpmode(gfx_pipeline->depth_compare_op);
+ ispa.dcmpmode = pvr_ta_cmpmode(gfx_pipeline->depth_compare_op);
/* FIXME: Can we just have this and remove the assignment above?
* The user provides a depthTestEnable at vkCreateGraphicsPipelines()
@@ -3360,11 +3320,12 @@ static void pvr_setup_isp_faces_and_control(
(!disable_stencil_write) * dynamic_state->write_mask.front;
ispb.scmpmask = dynamic_state->compare_mask.front;
- ispb.sop3 = pvr_stencilop(gfx_pipeline->stencil_front.pass_op);
- ispb.sop2 = pvr_stencilop(gfx_pipeline->stencil_front.depth_fail_op);
- ispb.sop1 = pvr_stencilop(gfx_pipeline->stencil_front.fail_op);
+ ispb.sop3 = pvr_ta_stencilop(gfx_pipeline->stencil_front.pass_op);
+ ispb.sop2 =
+ pvr_ta_stencilop(gfx_pipeline->stencil_front.depth_fail_op);
+ ispb.sop1 = pvr_ta_stencilop(gfx_pipeline->stencil_front.fail_op);
- ispb.scmpmode = pvr_cmpmode(gfx_pipeline->stencil_front.compare_op);
+ ispb.scmpmode = pvr_ta_cmpmode(gfx_pipeline->stencil_front.compare_op);
}
pvr_csb_pack (&back_b, TA_STATE_ISPB, ispb) {
@@ -3372,11 +3333,11 @@ static void pvr_setup_isp_faces_and_control(
(!disable_stencil_write) * dynamic_state->write_mask.back;
ispb.scmpmask = dynamic_state->compare_mask.back;
- ispb.sop3 = pvr_stencilop(gfx_pipeline->stencil_back.pass_op);
- ispb.sop2 = pvr_stencilop(gfx_pipeline->stencil_back.depth_fail_op);
- ispb.sop1 = pvr_stencilop(gfx_pipeline->stencil_back.fail_op);
+ ispb.sop3 = pvr_ta_stencilop(gfx_pipeline->stencil_back.pass_op);
+ ispb.sop2 = pvr_ta_stencilop(gfx_pipeline->stencil_back.depth_fail_op);
+ ispb.sop1 = pvr_ta_stencilop(gfx_pipeline->stencil_back.fail_op);
- ispb.scmpmode = pvr_cmpmode(gfx_pipeline->stencil_back.compare_op);
+ ispb.scmpmode = pvr_ta_cmpmode(gfx_pipeline->stencil_back.compare_op);
}
}
diff --git a/src/imagination/vulkan/pvr_csb_enum_helpers.h b/src/imagination/vulkan/pvr_csb_enum_helpers.h
new file mode 100644
index 00000000000..0cd945e2e4a
--- /dev/null
+++ b/src/imagination/vulkan/pvr_csb_enum_helpers.h
@@ -0,0 +1,122 @@
+/*
+ * 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_CSB_ENUM_HELPERS_H
+#define PVR_CSB_ENUM_HELPERS_H
+
+#include <stdint.h>
+#include <vulkan/vulkan_core.h>
+
+#include "pvr_csb.h"
+#include "rogue/rogue.h"
+#include "util/macros.h"
+
+/******************************************************************************
+ CR
+ ******************************************************************************/
+
+/* clang-format off */
+static inline enum PVRX(CR_ISP_AA_MODE_TYPE)
+pvr_cr_isp_aa_mode_type(uint32_t samples)
+/* clang-format on */
+{
+ switch (samples) {
+ case 1:
+ return PVRX(CR_ISP_AA_MODE_TYPE_AA_NONE);
+ case 2:
+ return PVRX(CR_ISP_AA_MODE_TYPE_AA_2X);
+ case 3:
+ return PVRX(CR_ISP_AA_MODE_TYPE_AA_4X);
+ case 8:
+ return PVRX(CR_ISP_AA_MODE_TYPE_AA_8X);
+ default:
+ unreachable("Unsupported number of samples");
+ }
+}
+
+/******************************************************************************
+ PDS
+ ******************************************************************************/
+
+/* clang-format off */
+static inline enum PVRX(PDSINST_DOUTU_SAMPLE_RATE)
+pvr_pdsinst_doutu_sample_rate_from_rogue(enum rogue_msaa_mode msaa_mode)
+/* clang-format on */
+{
+ switch (msaa_mode) {
+ case ROGUE_MSAA_MODE_PIXEL:
+ return PVRX(PDSINST_DOUTU_SAMPLE_RATE_INSTANCE);
+ case ROGUE_MSAA_MODE_SELECTIVE:
+ return PVRX(PDSINST_DOUTU_SAMPLE_RATE_SELECTIVE);
+ case ROGUE_MSAA_MODE_FULL:
+ return PVRX(PDSINST_DOUTU_SAMPLE_RATE_FULL);
+ default:
+ unreachable("Undefined MSAA mode.");
+ }
+}
+
+/******************************************************************************
+ TA
+ ******************************************************************************/
+
+static inline enum PVRX(TA_CMPMODE) pvr_ta_cmpmode(VkCompareOp op)
+{
+ /* enum values are identical, so we can just cast the input directly. */
+ return (enum PVRX(TA_CMPMODE))op;
+}
+
+static inline enum PVRX(TA_ISPB_STENCILOP) pvr_ta_stencilop(VkStencilOp op)
+{
+ /* enum values are identical, so we can just cast the input directly. */
+ return (enum PVRX(TA_ISPB_STENCILOP))op;
+}
+
+/* clang-format off */
+static inline enum PVRX(TA_OBJTYPE)
+pvr_ta_objtype(VkPrimitiveTopology topology)
+/* clang-format on */
+{
+ switch (topology) {
+ case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+ return PVRX(TA_OBJTYPE_SPRITE_01UV);
+
+ case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+ case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+ case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+ case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+ return PVRX(TA_OBJTYPE_LINE);
+
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+ case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+ return PVRX(TA_OBJTYPE_TRIANGLE);
+
+ default:
+ unreachable("Invalid topology.");
+ return 0;
+ }
+}
+
+#endif /* PVR_CSB_ENUM_HELPERS_H */
diff --git a/src/imagination/vulkan/pvr_job_render.c b/src/imagination/vulkan/pvr_job_render.c
index ba5f4891fb6..cdb77ffe2e4 100644
--- a/src/imagination/vulkan/pvr_job_render.c
+++ b/src/imagination/vulkan/pvr_job_render.c
@@ -30,6 +30,7 @@
#include "hwdef/rogue_hw_utils.h"
#include "pvr_bo.h"
#include "pvr_csb.h"
+#include "pvr_csb_enum_helpers.h"
#include "pvr_job_common.h"
#include "pvr_job_context.h"
#include "pvr_job_render.h"
@@ -1293,29 +1294,13 @@ pvr_render_job_ws_fragment_state_init(struct pvr_render_ctx *ctx,
struct pvr_render_job *job,
struct pvr_winsys_fragment_state *state)
{
+ const enum PVRX(CR_ISP_AA_MODE_TYPE)
+ isp_aa_mode = pvr_cr_isp_aa_mode_type(job->samples);
const struct pvr_device_info *dev_info = &ctx->device->pdevice->dev_info;
- enum PVRX(CR_ISP_AA_MODE_TYPE) isp_aa_mode;
uint32_t isp_ctl;
/* FIXME: what to do when job->run_frag is false? */
- switch (job->samples) {
- case 1:
- isp_aa_mode = PVRX(CR_ISP_AA_MODE_TYPE_AA_NONE);
- break;
- case 2:
- isp_aa_mode = PVRX(CR_ISP_AA_MODE_TYPE_AA_2X);
- break;
- case 3:
- isp_aa_mode = PVRX(CR_ISP_AA_MODE_TYPE_AA_4X);
- break;
- case 8:
- isp_aa_mode = PVRX(CR_ISP_AA_MODE_TYPE_AA_8X);
- break;
- default:
- unreachable("Unsupported number of samples");
- }
-
/* FIXME: pass in the number of samples rather than isp_aa_mode? */
pvr_setup_tiles_in_flight(dev_info,
isp_aa_mode,
diff --git a/src/imagination/vulkan/pvr_pipeline.c b/src/imagination/vulkan/pvr_pipeline.c
index 09995357df3..97772100cf2 100644
--- a/src/imagination/vulkan/pvr_pipeline.c
+++ b/src/imagination/vulkan/pvr_pipeline.c
@@ -35,6 +35,7 @@
#include "nir/nir.h"
#include "pvr_bo.h"
#include "pvr_csb.h"
+#include "pvr_csb_enum_helpers.h"
#include "pvr_pds.h"
#include "pvr_private.h"
#include "pvr_shader.h"
@@ -162,7 +163,7 @@ VkResult pvr_pds_fragment_program_create_and_upload(
struct pvr_pds_upload *const pds_upload_out)
{
const enum PVRX(PDSINST_DOUTU_SAMPLE_RATE)
- sample_rate = pvr_sample_rate_from_usc_msaa_mode(msaa_mode);
+ sample_rate = pvr_pdsinst_doutu_sample_rate_from_rogue(msaa_mode);
struct pvr_pds_kickusc_program program = { 0 };
uint32_t staging_buffer_size;
uint32_t *staging_buffer;
diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h
index bfdded95ba5..f366753a8e2 100644
--- a/src/imagination/vulkan/pvr_private.h
+++ b/src/imagination/vulkan/pvr_private.h
@@ -1298,24 +1298,6 @@ to_pvr_graphics_pipeline(struct pvr_pipeline *pipeline)
return container_of(pipeline, struct pvr_graphics_pipeline, base);
}
-/* FIXME: Place this in USC specific header? */
-/* clang-format off */
-static inline enum PVRX(PDSINST_DOUTU_SAMPLE_RATE)
-pvr_sample_rate_from_usc_msaa_mode(enum rogue_msaa_mode msaa_mode)
-/* clang-format on */
-{
- switch (msaa_mode) {
- case ROGUE_MSAA_MODE_PIXEL:
- return PVRX(PDSINST_DOUTU_SAMPLE_RATE_INSTANCE);
- case ROGUE_MSAA_MODE_SELECTIVE:
- return PVRX(PDSINST_DOUTU_SAMPLE_RATE_SELECTIVE);
- case ROGUE_MSAA_MODE_FULL:
- return PVRX(PDSINST_DOUTU_SAMPLE_RATE_FULL);
- default:
- unreachable("Undefined MSAA mode.");
- }
-}
-
VkResult pvr_pds_fragment_program_create_and_upload(
struct pvr_device *device,
const VkAllocationCallbacks *allocator,
More information about the mesa-commit
mailing list