• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "util/macros.h"
25 #include "compiler/shader_enums.h"
26 
27 #include "pan_cs.h"
28 #include "pan_pool.h"
29 
30 #include "panvk_cs.h"
31 #include "panvk_private.h"
32 
33 /*
34  * Upload the viewport scale. Defined as (px/2, py/2, pz) at the start of section
35  * 24.5 ("Controlling the Viewport") of the Vulkan spec. At the end of the
36  * section, the spec defines:
37  *
38  * px = width
39  * py = height
40  * pz = maxDepth - minDepth
41  */
42 void
panvk_sysval_upload_viewport_scale(const VkViewport * viewport,union panvk_sysval_vec4 * data)43 panvk_sysval_upload_viewport_scale(const VkViewport *viewport,
44                                    union panvk_sysval_vec4 *data)
45 {
46    data->f32[0] = 0.5f * viewport->width;
47    data->f32[1] = 0.5f * viewport->height;
48    data->f32[2] = (viewport->maxDepth - viewport->minDepth);
49 }
50 
51 /*
52  * Upload the viewport offset. Defined as (ox, oy, oz) at the start of section
53  * 24.5 ("Controlling the Viewport") of the Vulkan spec. At the end of the
54  * section, the spec defines:
55  *
56  * ox = x + width/2
57  * oy = y + height/2
58  * oz = minDepth
59  */
60 void
panvk_sysval_upload_viewport_offset(const VkViewport * viewport,union panvk_sysval_vec4 * data)61 panvk_sysval_upload_viewport_offset(const VkViewport *viewport,
62                                     union panvk_sysval_vec4 *data)
63 {
64    data->f32[0] = (0.5f * viewport->width) + viewport->x;
65    data->f32[1] = (0.5f * viewport->height) + viewport->y;
66    data->f32[2] = viewport->minDepth;
67 }
68