[GPU] Viewport in draw_util with host API flexibility

This commit is contained in:
Triang3l
2020-11-16 23:03:42 +03:00
parent eda027a220
commit 10d7bcde93
10 changed files with 471 additions and 398 deletions

View File

@@ -33,6 +33,28 @@ namespace draw_util {
// for use with the top-left rasterization rule later.
int32_t FloatToD3D11Fixed16p8(float f32);
struct ViewportInfo {
// The returned viewport will always be in the positive quarter-plane for
// simplicity of clamping to the maximum size supported by the host, negative
// offset will be applied via ndc_offset.
float left;
float top;
float width;
float height;
float z_min;
float z_max;
float ndc_scale[3];
float ndc_offset[3];
};
// Converts the guest viewport (or fakes one if drawing without a viewport) to
// a viewport, plus values to multiply-add the returned position by, usable on
// host graphics APIs such as Direct3D 11+ and Vulkan, also forcing it to the
// Direct3D clip space with 0...W Z rather than -W...W.
void GetHostViewportInfo(const RegisterFile& regs, float pixel_size_x,
float pixel_size_y, bool origin_bottom_left,
float xy_max, bool allow_reverse_z,
ViewportInfo& viewport_info_out);
struct Scissor {
uint32_t left;
uint32_t top;