1/*
2 * Copyright (C) 2021 Collabora Ltd.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef PANVK_CS_H
25#define PANVK_CS_H
26
27#include "pan_encoder.h"
28
29#include <vulkan/vulkan.h>
30
31#include "compiler/shader_enums.h"
32#include "panfrost-job.h"
33#include "pan_cs.h"
34
35#include "vk_util.h"
36
37#include "panvk_private.h"
38
39struct pan_blend_state;
40struct pan_shader_info;
41struct panfrost_ptr;
42struct pan_pool;
43
44union panvk_sysval_data;
45struct panvk_framebuffer;
46struct panvk_cmd_state;
47struct panvk_compute_dim;
48struct panvk_device;
49struct panvk_batch;
50struct panvk_varyings_info;
51struct panvk_attrib_buf;
52struct panvk_attribs_info;
53struct panvk_pipeline;
54struct panvk_draw_info;
55struct panvk_descriptor_state;
56struct panvk_subpass;
57struct panvk_clear_value;
58
59#ifdef PAN_ARCH
60static inline enum mali_func
61panvk_per_arch(translate_compare_func)(VkCompareOp comp)
62{
63   STATIC_ASSERT(VK_COMPARE_OP_NEVER == (VkCompareOp)MALI_FUNC_NEVER);
64   STATIC_ASSERT(VK_COMPARE_OP_LESS == (VkCompareOp)MALI_FUNC_LESS);
65   STATIC_ASSERT(VK_COMPARE_OP_EQUAL == (VkCompareOp)MALI_FUNC_EQUAL);
66   STATIC_ASSERT(VK_COMPARE_OP_LESS_OR_EQUAL == (VkCompareOp)MALI_FUNC_LEQUAL);
67   STATIC_ASSERT(VK_COMPARE_OP_GREATER == (VkCompareOp)MALI_FUNC_GREATER);
68   STATIC_ASSERT(VK_COMPARE_OP_NOT_EQUAL == (VkCompareOp)MALI_FUNC_NOT_EQUAL);
69   STATIC_ASSERT(VK_COMPARE_OP_GREATER_OR_EQUAL == (VkCompareOp)MALI_FUNC_GEQUAL);
70   STATIC_ASSERT(VK_COMPARE_OP_ALWAYS == (VkCompareOp)MALI_FUNC_ALWAYS);
71
72   return (enum mali_func)comp;
73}
74
75static inline enum mali_func
76panvk_per_arch(translate_sampler_compare_func)(const VkSamplerCreateInfo *pCreateInfo)
77{
78   if (!pCreateInfo->compareEnable)
79      return MALI_FUNC_NEVER;
80
81   enum mali_func f = panvk_per_arch(translate_compare_func)(pCreateInfo->compareOp);
82   return panfrost_flip_compare_func(f);
83}
84#endif
85
86void
87panvk_sysval_upload_viewport_scale(const VkViewport *viewport,
88                                   union panvk_sysval_vec4 *data);
89
90void
91panvk_sysval_upload_viewport_offset(const VkViewport *viewport,
92                                    union panvk_sysval_vec4 *data);
93
94#endif
95