Skip to content

Commit

Permalink
Address feedback, delete some unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jun 22, 2019
1 parent 0f9dbaa commit b8bde71
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 94 deletions.
12 changes: 6 additions & 6 deletions GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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_)
Expand Down Expand Up @@ -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_);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions GPU/Common/FramebufferCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions GPU/Common/ShaderTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 0 additions & 30 deletions ext/native/math/lin/matrix4x4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
77 changes: 19 additions & 58 deletions ext/native/math/lin/matrix4x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit b8bde71

Please sign in to comment.