Skip to content
Permalink
Browse files

Address feedback, delete some unused code.

  • Loading branch information...
hrydgard committed Jun 22, 2019
1 parent 0f9dbaa commit b8bde71efebeaf725f8d620fdac1ccbbd1b65d74
@@ -734,7 +734,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int
// We are drawing to the back buffer so need to flip.
if (needBackBufferYSwap_)
std::swap(v0, v1);
flags = (DrawTextureFlags)(flags | DRAWTEX_TO_BACKBUFFER);
flags = flags | DRAWTEX_TO_BACKBUFFER;
float x, y, w, h;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL);
SetViewport2D(x, y, w, h);
@@ -809,7 +809,7 @@ void FramebufferManagerCommon::DrawFramebufferToOutput(const u8 *srcPixels, GEBu
std::swap(v0, v1);

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) {
// Left Eye Image
SetViewport2D(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
@@ -979,7 +979,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_);
Bind2DShader();
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
// flip V.
if (needBackBufferYSwap_)
@@ -1010,7 +1010,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, renderWidth_, renderHeight_, &uniforms);
BindPostShader(uniforms);
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);

draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_);
@@ -1030,7 +1030,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
std::swap(v0, v1);
Bind2DShader();
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) {
// Left Eye Image
SetViewport2D(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
@@ -1054,7 +1054,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
if (needBackBufferYSwap_)
std::swap(v0, v1);
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{};
CalculatePostShaderUniforms(vfb->bufferWidth, vfb->bufferHeight, vfb->renderWidth, vfb->renderHeight, &uniforms);
@@ -158,6 +158,10 @@ enum DrawTextureFlags {
DRAWTEX_TO_BACKBUFFER = 8,
};

inline DrawTextureFlags operator | (const DrawTextureFlags &lhs, const DrawTextureFlags &rhs) {
return DrawTextureFlags((u32)lhs | (u32)rhs);
}

enum class TempFBO {
DEPAL,
BLIT,
@@ -24,6 +24,9 @@
// DbgNew is not compatible with Glslang
#ifdef DBG_NEW
#undef new
#undef free
#undef malloc
#undef realloc
#endif

#include "base/logging.h"
@@ -234,36 +234,6 @@ void Matrix4x4::setOrthoVulkan(float left, float right, float top, float bottom,
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 {
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,
@@ -35,7 +35,6 @@ class Matrix4x4 {
wx = v.x; wy = v.y; wz = v.z;
}


const float &operator[](int i) const {
return *(((const float *)this) + i);
}
@@ -56,13 +55,6 @@ class Matrix4x4 {
empty();
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() {
setScaling(1.0f);
@@ -73,41 +65,35 @@ class Matrix4x4 {
wy = trans.y;
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 simpleInverse() const;
Matrix4x4 transpose() const;

void setRotationX(const float a) {
empty();
float c=cosf(a);
float s=sinf(a);
float c = cosf(a);
float s = sinf(a);
xx = 1.0f;
yy = c; yz = s;
zy = -s; zz = c;
yy = c; yz = s;
zy = -s; zz = c;
ww = 1.0f;
}
void setRotationY(const float a) {
empty();
float c=cosf(a);
float s=sinf(a);
xx = c; xz = -s;
yy = 1.0f;
zx = s; zz = c ;
float c = cosf(a);
float s = sinf(a);
xx = c; xz = -s;
yy = 1.0f;
zx = s; zz = c;
ww = 1.0f;
}
void setRotationZ(const float a) {
empty();
float c=cosf(a);
float s=sinf(a);
xx = c; xy = s;
yx = -s; yy = c;
float c = cosf(a);
float s = sinf(a);
xx = c; xy = s;
yx = -s; yy = c;
zz = 1.0f;
ww = 1.0f;
}
@@ -116,67 +102,42 @@ class Matrix4x4 {
empty();
float c = 0.0f;
float s = 1.0f;
xx = c; xy = s;
yx = -s; yy = c;
xx = c; xy = s;
yx = -s; yy = c;
zz = 1.0f;
ww = 1.0f;
}
void setRotationZ180() {
empty();
float c = -1.0f;
float s = 0.0f;
xx = c; xy = s;
yx = -s; yy = c;
xx = c; xy = s;
yx = -s; yy = c;
zz = 1.0f;
ww = 1.0f;
}
void setRotationZ270() {
empty();
float c = 0.0f;
float s = -1.0f;
xx = c; xy = s;
yx = -s; yy = c;
xx = c; xy = s;
yx = -s; yy = c;
zz = 1.0f;
ww = 1.0f;
}
void setRotationAxisAngle(const Vec3 &axis, float angle);


void setRotation(float x,float y, float z);
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 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 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 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 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 stabilizeOrtho() {
/*
front().normalize();
right().normalize();
up() = front() % right();
right() = up() % front();
*/
}
void toText(char *buffer, int len) const;
void print() const;
static Matrix4x4 fromPRS(const Vec3 &position, const Quaternion &normal, const Vec3 &scale);

void translateAndScale(const Vec3 &trans, const Vec3 &scale) {
xx = xx * scale.x + xw * trans.x;

0 comments on commit b8bde71

Please sign in to comment.
You can’t perform that action at this time.