Get rid of strange offset in Vulkan matrix converter
This commit is contained in:
parent
e45c24b75f
commit
a995dd2ff4
5 changed files with 26 additions and 33 deletions
|
@ -640,31 +640,33 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
|
||||||
float hScale = 1.0f;
|
float hScale = 1.0f;
|
||||||
float yOffset = 0.0f;
|
float yOffset = 0.0f;
|
||||||
|
|
||||||
// If we're within the bounds, we want clipping the viewport way. So leave it be.
|
if (!gstate_c.Supports(GPU_SUPPORTS_LARGE_VIEWPORTS)) {
|
||||||
if (left < 0.0f || right > renderWidth) {
|
// If we're within the bounds, we want clipping the viewport way. So leave it be.
|
||||||
float overageLeft = std::max(-left, 0.0f);
|
if (left < 0.0f || right > renderWidth) {
|
||||||
float overageRight = std::max(right - renderWidth, 0.0f);
|
float overageLeft = std::max(-left, 0.0f);
|
||||||
// Our center drifted by the difference in overages.
|
float overageRight = std::max(right - renderWidth, 0.0f);
|
||||||
float drift = overageRight - overageLeft;
|
// Our center drifted by the difference in overages.
|
||||||
|
float drift = overageRight - overageLeft;
|
||||||
|
|
||||||
left += overageLeft;
|
left += overageLeft;
|
||||||
right -= overageRight;
|
right -= overageRight;
|
||||||
|
|
||||||
wScale = vpWidth / (right - left);
|
wScale = vpWidth / (right - left);
|
||||||
xOffset = drift / (right - left);
|
xOffset = drift / (right - left);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top < 0.0f || bottom > renderHeight) {
|
if (top < 0.0f || bottom > renderHeight) {
|
||||||
float overageTop = std::max(-top, 0.0f);
|
float overageTop = std::max(-top, 0.0f);
|
||||||
float overageBottom = std::max(bottom - renderHeight, 0.0f);
|
float overageBottom = std::max(bottom - renderHeight, 0.0f);
|
||||||
// Our center drifted by the difference in overages.
|
// Our center drifted by the difference in overages.
|
||||||
float drift = overageBottom - overageTop;
|
float drift = overageBottom - overageTop;
|
||||||
|
|
||||||
top += overageTop;
|
top += overageTop;
|
||||||
bottom -= overageBottom;
|
bottom -= overageBottom;
|
||||||
|
|
||||||
hScale = vpHeight / (bottom - top);
|
hScale = vpHeight / (bottom - top);
|
||||||
yOffset = drift / (bottom - top);
|
yOffset = drift / (bottom - top);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.viewportX = left + displayOffsetX;
|
out.viewportX = left + displayOffsetX;
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ int VertexDecoder::ToString(char *output) const {
|
||||||
if (tc)
|
if (tc)
|
||||||
output += sprintf(output, "T: %s ", tcnames[tc]);
|
output += sprintf(output, "T: %s ", tcnames[tc]);
|
||||||
if (weighttype)
|
if (weighttype)
|
||||||
output += sprintf(output, "W: %s (%ix)", weightnames[weighttype], nweights);
|
output += sprintf(output, "W: %s (%ix) ", weightnames[weighttype], nweights);
|
||||||
if (idx)
|
if (idx)
|
||||||
output += sprintf(output, "I: %s ", idxnames[idx]);
|
output += sprintf(output, "I: %s ", idxnames[idx]);
|
||||||
if (morphcount > 1)
|
if (morphcount > 1)
|
||||||
|
|
|
@ -457,6 +457,7 @@ enum {
|
||||||
GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5),
|
GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5),
|
||||||
GPU_USE_DEPTH_RANGE_HACK = FLAG_BIT(6),
|
GPU_USE_DEPTH_RANGE_HACK = FLAG_BIT(6),
|
||||||
GPU_SUPPORTS_WIDE_LINES = FLAG_BIT(7),
|
GPU_SUPPORTS_WIDE_LINES = FLAG_BIT(7),
|
||||||
|
GPU_SUPPORTS_LARGE_VIEWPORTS = FLAG_BIT(16),
|
||||||
GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17),
|
GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17),
|
||||||
GPU_SUPPORTS_VAO = FLAG_BIT(18),
|
GPU_SUPPORTS_VAO = FLAG_BIT(18),
|
||||||
GPU_SUPPORTS_ANY_COPY_IMAGE = FLAG_BIT(19),
|
GPU_SUPPORTS_ANY_COPY_IMAGE = FLAG_BIT(19),
|
||||||
|
|
|
@ -477,6 +477,7 @@ void GPU_Vulkan::CheckGPUFeatures() {
|
||||||
gstate_c.featureFlags |= GPU_SUPPORTS_BLEND_MINMAX;
|
gstate_c.featureFlags |= GPU_SUPPORTS_BLEND_MINMAX;
|
||||||
gstate_c.featureFlags |= GPU_SUPPORTS_ANY_COPY_IMAGE;
|
gstate_c.featureFlags |= GPU_SUPPORTS_ANY_COPY_IMAGE;
|
||||||
gstate_c.featureFlags |= GPU_SUPPORTS_OES_TEXTURE_NPOT;
|
gstate_c.featureFlags |= GPU_SUPPORTS_OES_TEXTURE_NPOT;
|
||||||
|
gstate_c.featureFlags |= GPU_SUPPORTS_LARGE_VIEWPORTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_Vulkan::BeginHostFrame() {
|
void GPU_Vulkan::BeginHostFrame() {
|
||||||
|
|
|
@ -151,18 +151,7 @@ std::string VulkanVertexShader::GetShaderString(DebugShaderStringType type) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ConvertProjMatrixToVulkan(Matrix4x4 &in, bool invertedX, bool invertedY) {
|
static void ConvertProjMatrixToVulkan(Matrix4x4 &in, bool invertedX, bool invertedY) {
|
||||||
// Half pixel offset hack
|
const Vec3 trans(0, 0, gstate_c.vpZOffset * 0.5f + 0.5f);
|
||||||
float xoff = 0.5f / gstate_c.curRTRenderWidth;
|
|
||||||
xoff = gstate_c.vpXOffset + (invertedX ? xoff : -xoff);
|
|
||||||
float yoff = 0.5f / gstate_c.curRTRenderHeight;
|
|
||||||
yoff = gstate_c.vpYOffset + (invertedY ? yoff : -yoff);
|
|
||||||
|
|
||||||
if (invertedX)
|
|
||||||
xoff = -xoff;
|
|
||||||
if (invertedY)
|
|
||||||
yoff = -yoff;
|
|
||||||
|
|
||||||
const Vec3 trans(xoff, yoff, gstate_c.vpZOffset * 0.5f + 0.5f);
|
|
||||||
const Vec3 scale(gstate_c.vpWidthScale, gstate_c.vpHeightScale, gstate_c.vpDepthScale * 0.5f);
|
const Vec3 scale(gstate_c.vpWidthScale, gstate_c.vpHeightScale, gstate_c.vpDepthScale * 0.5f);
|
||||||
in.translateAndScale(trans, scale);
|
in.translateAndScale(trans, scale);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue