mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 22:01:33 +00:00
[vulkan] Make z_up and box_rotations public
They're now qfv_* and shared within the vulkan renderer. qfv_z_up cannot be shared across renderers as they have their own ideas for the world frame. qfv_box_rotations currently can't be shared across renderers because if the Y-axis flip and the way it's handled, but sharing should be achievable by modifying the other renderers to handle the sides correctly (glsl and gl need to do lookups for the side enums, sw just needs to be shown which way is up).
This commit is contained in:
parent
931175b21d
commit
e83854a760
3 changed files with 56 additions and 53 deletions
|
@ -9,4 +9,7 @@ void QFV_Orthographic (mat4f_t proj, float xmin, float xmax,
|
|||
void QFV_PerspectiveTan (mat4f_t proj, float fov_x, float fov_y);
|
||||
void QFV_PerspectiveCos (mat4f_t proj, float fov);
|
||||
|
||||
extern const mat4f_t qfv_z_up;
|
||||
extern const mat4f_t qfv_box_rotations[6];
|
||||
|
||||
#endif//__QF_Vulkan_projection_h
|
||||
|
|
|
@ -35,6 +35,56 @@
|
|||
|
||||
#include "r_internal.h"
|
||||
|
||||
//FIXME? The box rotations (in particular top/bottom) for vulkan are not
|
||||
//compatible with the other renderers, so need a local version
|
||||
const mat4f_t qfv_box_rotations[] = {
|
||||
[BOX_FRONT] = {
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_RIGHT] = {
|
||||
{ 0,-1, 0, 0},
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_BEHIND] = {
|
||||
{-1, 0, 0, 0},
|
||||
{ 0,-1, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_LEFT] = {
|
||||
{ 0, 1, 0, 0},
|
||||
{-1, 0, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_BOTTOM] = {
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{-1, 0, 0, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_TOP] = {
|
||||
{ 0, 0,-1, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
};
|
||||
|
||||
// Quake's world is z-up, x-forward, y-left, but Vulkan's world is
|
||||
// z-forward, x-right, y-down.
|
||||
const mat4f_t qfv_z_up = {
|
||||
{ 0, 0, 1, 0},
|
||||
{-1, 0, 0, 0},
|
||||
{ 0,-1, 0, 0},
|
||||
{ 0, 0, 0, 1},
|
||||
};
|
||||
|
||||
void
|
||||
QFV_Orthographic (mat4f_t proj, float xmin, float xmax, float ymin, float ymax,
|
||||
float znear, float zfar)
|
||||
|
|
|
@ -58,56 +58,6 @@
|
|||
#include "r_internal.h"
|
||||
#include "vid_vulkan.h"
|
||||
|
||||
//FIXME? The box rotations (in particular top/bottom) for vulkan are not
|
||||
//compatible with the other renderers, so need a local version
|
||||
static mat4f_t box_rotations[] = {
|
||||
[BOX_FRONT] = {
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_RIGHT] = {
|
||||
{ 0,-1, 0, 0},
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_BEHIND] = {
|
||||
{-1, 0, 0, 0},
|
||||
{ 0,-1, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_LEFT] = {
|
||||
{ 0, 1, 0, 0},
|
||||
{-1, 0, 0, 0},
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_BOTTOM] = {
|
||||
{ 0, 0, 1, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{-1, 0, 0, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
[BOX_TOP] = {
|
||||
{ 0, 0,-1, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
},
|
||||
};
|
||||
|
||||
// Quake's world is z-up, x-forward, y-left, but Vulkan's world is
|
||||
// z-forward, x-right, y-down.
|
||||
static mat4f_t z_up = {
|
||||
{ 0, 0, 1, 0},
|
||||
{-1, 0, 0, 0},
|
||||
{ 0,-1, 0, 0},
|
||||
{ 0, 0, 0, 1},
|
||||
};
|
||||
|
||||
static void
|
||||
setup_view (vulkan_ctx_t *ctx)
|
||||
{
|
||||
|
@ -118,14 +68,14 @@ setup_view (vulkan_ctx_t *ctx)
|
|||
mat4f_t views[6];
|
||||
for (int i = 0; i < 6; i++) {
|
||||
mat4f_t rotinv;
|
||||
mat4ftranspose (rotinv, box_rotations[i]);
|
||||
mat4ftranspose (rotinv, qfv_box_rotations[i]);
|
||||
mmulf (views[i], rotinv, r_refdef.camera_inverse);
|
||||
mmulf (views[i], z_up, views[i]);
|
||||
mmulf (views[i], qfv_z_up, views[i]);
|
||||
}
|
||||
Vulkan_SetViewMatrices (ctx, views, 6);
|
||||
} else {
|
||||
mat4f_t view;
|
||||
mmulf (view, z_up, r_refdef.camera_inverse);
|
||||
mmulf (view, qfv_z_up, r_refdef.camera_inverse);
|
||||
Vulkan_SetViewMatrices (ctx, &view, 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue