Address feedback, delete some unused code.

This commit is contained in:
Henrik Rydgård 2019-06-22 22:15:09 +02:00
parent 0f9dbaa2bc
commit b8bde71efe
5 changed files with 32 additions and 94 deletions

View file

@ -734,7 +734,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int
// We are drawing to the back buffer so need to flip. // We are drawing to the back buffer so need to flip.
if (needBackBufferYSwap_) if (needBackBufferYSwap_)
std::swap(v0, v1); std::swap(v0, v1);
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER); flags = flags | DRAWTEX_TO_BACKBUFFER;
float x, y, w, h; float x, y, w, h;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL); CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL);
SetViewport2D(x, y, w, h); SetViewport2D(x, y, w, h);
@ -809,7 +809,7 @@ void FramebufferManagerCommon::DrawFramebufferToOutput(const u8 *srcPixels, GEBu
std::swap(v0, v1); std::swap(v0, v1);
DrawTextureFlags flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST; DrawTextureFlags flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST;
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER); flags = flags | DRAWTEX_TO_BACKBUFFER;
if (cardboardSettings.enabled) { if (cardboardSettings.enabled) {
// Left Eye Image // Left Eye Image
SetViewport2D(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight); SetViewport2D(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
@ -979,7 +979,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_); draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_);
Bind2DShader(); Bind2DShader();
DrawTextureFlags flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST; DrawTextureFlags flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST;
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER); flags = flags | DRAWTEX_TO_BACKBUFFER;
// We are doing the DrawActiveTexture call directly to the backbuffer here. Hence, we must // We are doing the DrawActiveTexture call directly to the backbuffer here. Hence, we must
// flip V. // flip V.
if (needBackBufferYSwap_) if (needBackBufferYSwap_)
@ -1010,7 +1010,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, renderWidth_, renderHeight_, &uniforms); CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, renderWidth_, renderHeight_, &uniforms);
BindPostShader(uniforms); BindPostShader(uniforms);
DrawTextureFlags flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST; DrawTextureFlags flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST;
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER); flags = flags | DRAWTEX_TO_BACKBUFFER;
DrawActiveTexture(0, 0, fbo_w, fbo_h, fbo_w, fbo_h, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL, flags); DrawActiveTexture(0, 0, fbo_w, fbo_h, fbo_w, fbo_h, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL, flags);
draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_); draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_);
@ -1030,7 +1030,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
std::swap(v0, v1); std::swap(v0, v1);
Bind2DShader(); Bind2DShader();
flags = (!postShaderIsUpscalingFilter_ && g_Config.iBufFilter == SCALE_LINEAR) ? DRAWTEX_LINEAR : DRAWTEX_NEAREST; flags = (!postShaderIsUpscalingFilter_ && g_Config.iBufFilter == SCALE_LINEAR) ? DRAWTEX_LINEAR : DRAWTEX_NEAREST;
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER); flags = flags | DRAWTEX_TO_BACKBUFFER;
if (g_Config.bEnableCardboard) { if (g_Config.bEnableCardboard) {
// Left Eye Image // Left Eye Image
SetViewport2D(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight); SetViewport2D(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
@ -1054,7 +1054,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
if (needBackBufferYSwap_) if (needBackBufferYSwap_)
std::swap(v0, v1); std::swap(v0, v1);
DrawTextureFlags flags = (!postShaderIsUpscalingFilter_ && g_Config.iBufFilter == SCALE_LINEAR) ? DRAWTEX_LINEAR : DRAWTEX_NEAREST; DrawTextureFlags flags = (!postShaderIsUpscalingFilter_ && g_Config.iBufFilter == SCALE_LINEAR) ? DRAWTEX_LINEAR : DRAWTEX_NEAREST;
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER); flags = flags | DRAWTEX_TO_BACKBUFFER;
PostShaderUniforms uniforms{}; PostShaderUniforms uniforms{};
CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, vfb->renderWidth, vfb->renderHeight, &uniforms); CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, vfb->renderWidth, vfb->renderHeight, &uniforms);

View file

@ -158,6 +158,10 @@ enum DrawTextureFlags {
DRAWTEX_TO_BACKBUFFER = 8, DRAWTEX_TO_BACKBUFFER = 8,
}; };
inline DrawTextureFlags operator | (const DrawTextureFlags &lhs, const DrawTextureFlags &rhs) {
return DrawTextureFlags((u32)lhs | (u32)rhs);
}
enum class TempFBO { enum class TempFBO {
DEPAL, DEPAL,
BLIT, BLIT,

View file

@ -24,6 +24,9 @@
// DbgNew is not compatible with Glslang // DbgNew is not compatible with Glslang
#ifdef DBG_NEW #ifdef DBG_NEW
#undef new #undef new
#undef free
#undef malloc
#undef realloc
#endif #endif
#include "base/logging.h" #include "base/logging.h"

View file

@ -234,36 +234,6 @@ void Matrix4x4::setOrthoVulkan(float left, float right, float top, float bottom,
ww = 1.0f; ww = 1.0f;
} }
void Matrix4x4::setProjectionInf(const float near_plane, const float fov_horiz, const float aspect) {
empty();
float f = fov_horiz*0.5f;
xx = 1.0f / tanf(f);
yy = 1.0f / tanf(f*aspect);
zz = 1;
wz = -near_plane;
zw = 1.0f;
}
void Matrix4x4::setRotationAxisAngle(const Vec3 &axis, float angle) {
Quaternion quat;
quat.setRotation(axis, angle);
quat.toMatrix(this);
}
// from a (Position, Rotation, Scale) vec3 quat vec3 tuple
Matrix4x4 Matrix4x4::fromPRS(const Vec3 &positionv, const Quaternion &rotv, const Vec3 &scalev) {
Matrix4x4 newM;
newM.setIdentity();
Matrix4x4 rot, scale;
rotv.toMatrix(&rot);
scale.setScaling(scalev);
newM = rot * scale;
newM.wx = positionv.x;
newM.wy = positionv.y;
newM.wz = positionv.z;
return newM;
}
void Matrix4x4::toText(char *buffer, int len) const { void Matrix4x4::toText(char *buffer, int len) const {
snprintf(buffer, len, "%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n", snprintf(buffer, len, "%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n",
xx,xy,xz,xw, xx,xy,xz,xw,

View file

@ -35,7 +35,6 @@ public:
wx = v.x; wy = v.y; wz = v.z; wx = v.x; wy = v.y; wz = v.z;
} }
const float &operator[](int i) const { const float &operator[](int i) const {
return *(((const float *)this) + i); return *(((const float *)this) + i);
} }
@ -56,13 +55,6 @@ public:
empty(); empty();
xx=yy=zz=f; ww=1.0f; xx=yy=zz=f; ww=1.0f;
} }
void setScaling(const Vec3 f) {
empty();
xx=f.x;
yy=f.y;
zz=f.z;
ww=1.0f;
}
void setIdentity() { void setIdentity() {
setScaling(1.0f); setScaling(1.0f);
@ -73,12 +65,6 @@ public:
wy = trans.y; wy = trans.y;
wz = trans.z; wz = trans.z;
} }
void setTranslationAndScaling(const Vec3 &trans, const Vec3 &scale) {
setScaling(scale);
wx = trans.x;
wy = trans.y;
wz = trans.z;
}
Matrix4x4 inverse() const; Matrix4x4 inverse() const;
Matrix4x4 simpleInverse() const; Matrix4x4 simpleInverse() const;
@ -86,28 +72,28 @@ public:
void setRotationX(const float a) { void setRotationX(const float a) {
empty(); empty();
float c=cosf(a); float c = cosf(a);
float s=sinf(a); float s = sinf(a);
xx = 1.0f; xx = 1.0f;
yy = c; yz = s; yy = c; yz = s;
zy = -s; zz = c; zy = -s; zz = c;
ww = 1.0f; ww = 1.0f;
} }
void setRotationY(const float a) { void setRotationY(const float a) {
empty(); empty();
float c=cosf(a); float c = cosf(a);
float s=sinf(a); float s = sinf(a);
xx = c; xz = -s; xx = c; xz = -s;
yy = 1.0f; yy = 1.0f;
zx = s; zz = c ; zx = s; zz = c;
ww = 1.0f; ww = 1.0f;
} }
void setRotationZ(const float a) { void setRotationZ(const float a) {
empty(); empty();
float c=cosf(a); float c = cosf(a);
float s=sinf(a); float s = sinf(a);
xx = c; xy = s; xx = c; xy = s;
yx = -s; yy = c; yx = -s; yy = c;
zz = 1.0f; zz = 1.0f;
ww = 1.0f; ww = 1.0f;
} }
@ -116,8 +102,8 @@ public:
empty(); empty();
float c = 0.0f; float c = 0.0f;
float s = 1.0f; float s = 1.0f;
xx = c; xy = s; xx = c; xy = s;
yx = -s; yy = c; yx = -s; yy = c;
zz = 1.0f; zz = 1.0f;
ww = 1.0f; ww = 1.0f;
} }
@ -125,8 +111,8 @@ public:
empty(); empty();
float c = -1.0f; float c = -1.0f;
float s = 0.0f; float s = 0.0f;
xx = c; xy = s; xx = c; xy = s;
yx = -s; yy = c; yx = -s; yy = c;
zz = 1.0f; zz = 1.0f;
ww = 1.0f; ww = 1.0f;
} }
@ -134,49 +120,24 @@ public:
empty(); empty();
float c = 0.0f; float c = 0.0f;
float s = -1.0f; float s = -1.0f;
xx = c; xy = s; xx = c; xy = s;
yx = -s; yy = c; yx = -s; yy = c;
zz = 1.0f; zz = 1.0f;
ww = 1.0f; ww = 1.0f;
} }
void setRotationAxisAngle(const Vec3 &axis, float angle);
void setRotation(float x,float y, float z); void setRotation(float x,float y, float z);
void setProjection(float near_plane, float far_plane, float fov_horiz, float aspect = 0.75f); void setProjection(float near_plane, float far_plane, float fov_horiz, float aspect = 0.75f);
void setProjectionD3D(float near_plane, float far_plane, float fov_horiz, float aspect = 0.75f); void setProjectionD3D(float near_plane, float far_plane, float fov_horiz, float aspect = 0.75f);
void setProjectionInf(float near_plane, float fov_horiz, float aspect = 0.75f);
void setOrtho(float left, float right, float bottom, float top, float near, float far); void setOrtho(float left, float right, float bottom, float top, float near, float far);
void setOrthoD3D(float left, float right, float bottom, float top, float near, float far); void setOrthoD3D(float left, float right, float bottom, float top, float near, float far);
void setOrthoVulkan(float left, float right, float top, float bottom, float near, float far); void setOrthoVulkan(float left, float right, float top, float bottom, float near, float far);
void setShadow(float Lx, float Ly, float Lz, float Lw) {
float Pa=0;
float Pb=1;
float Pc=0;
float Pd=0;
//P = normalize(Plane);
float d = (Pa*Lx + Pb*Ly + Pc*Lz + Pd*Lw);
xx=Pa * Lx + d; xy=Pa * Ly; xz=Pa * Lz; xw=Pa * Lw;
yx=Pb * Lx; yy=Pb * Ly + d; yz=Pb * Lz; yw=Pb * Lw;
zx=Pc * Lx; zy=Pc * Ly; zz=Pc * Lz + d; zw=Pc * Lw;
wx=Pd * Lx; wy=Pd * Ly; wz=Pd * Lz; ww=Pd * Lw + d;
}
void setViewLookAt(const Vec3 &from, const Vec3 &at, const Vec3 &worldup); void setViewLookAt(const Vec3 &from, const Vec3 &at, const Vec3 &worldup);
void setViewLookAtD3D(const Vec3 &from, const Vec3 &at, const Vec3 &worldup); void setViewLookAtD3D(const Vec3 &from, const Vec3 &at, const Vec3 &worldup);
void setViewFrame(const Vec3 &pos, const Vec3 &right, const Vec3 &forward, const Vec3 &up); void setViewFrame(const Vec3 &pos, const Vec3 &right, const Vec3 &forward, const Vec3 &up);
void stabilizeOrtho() {
/*
front().normalize();
right().normalize();
up() = front() % right();
right() = up() % front();
*/
}
void toText(char *buffer, int len) const; void toText(char *buffer, int len) const;
void print() const; void print() const;
static Matrix4x4 fromPRS(const Vec3 &position, const Quaternion &normal, const Vec3 &scale);
void translateAndScale(const Vec3 &trans, const Vec3 &scale) { void translateAndScale(const Vec3 &trans, const Vec3 &scale) {
xx = xx * scale.x + xw * trans.x; xx = xx * scale.x + xw * trans.x;