mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Move to common (todo: merge with above)
This commit is contained in:
parent
d55c4a3456
commit
1d3075566f
@ -120,6 +120,4 @@ void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *ver
|
||||
}
|
||||
draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &draw2DSamplerLinear_);
|
||||
draw_->DrawUP(verts, vertexCount);
|
||||
|
||||
gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include "Common/GPU/OpenGL/GLFeatures.h"
|
||||
#include "Common/Data/Convert/ColorConv.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Math/lin/matrix4x4.h"
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
@ -44,8 +47,7 @@
|
||||
#include "GPU/GPUState.h"
|
||||
|
||||
FramebufferManagerCommon::FramebufferManagerCommon(Draw::DrawContext *draw)
|
||||
: draw_(draw),
|
||||
displayFormat_(GE_FORMAT_565) {
|
||||
: draw_(draw), displayFormat_(GE_FORMAT_565) {
|
||||
presentation_ = new PresentationCommon(draw);
|
||||
}
|
||||
|
||||
@ -2504,3 +2506,56 @@ void FramebufferManagerCommon::DeviceRestore(Draw::DrawContext *draw) {
|
||||
draw_ = draw;
|
||||
presentation_->DeviceRestore(draw);
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) {
|
||||
// Will be drawn as a strip.
|
||||
Draw2DVertex coord[4] = {
|
||||
{x, y, u0, v0},
|
||||
{x + w, y, u1, v0},
|
||||
{x + w, y + h, u1, v1},
|
||||
{x, y + h, u0, v1},
|
||||
};
|
||||
|
||||
if (uvRotation != ROTATION_LOCKED_HORIZONTAL) {
|
||||
float temp[8];
|
||||
int rotation = 0;
|
||||
switch (uvRotation) {
|
||||
case ROTATION_LOCKED_HORIZONTAL180: rotation = 2; break;
|
||||
case ROTATION_LOCKED_VERTICAL: rotation = 1; break;
|
||||
case ROTATION_LOCKED_VERTICAL180: rotation = 3; break;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
temp[i * 2] = coord[((i + rotation) & 3)].u;
|
||||
temp[i * 2 + 1] = coord[((i + rotation) & 3)].v;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
coord[i].u = temp[i * 2];
|
||||
coord[i].v = temp[i * 2 + 1];
|
||||
}
|
||||
}
|
||||
|
||||
const float invDestW = 2.0f / destW;
|
||||
const float invDestH = 2.0f / destH;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
coord[i].x = coord[i].x * invDestW - 1.0f;
|
||||
coord[i].y = coord[i].y * invDestH - 1.0f;
|
||||
}
|
||||
|
||||
if ((flags & DRAWTEX_TO_BACKBUFFER) && g_display_rotation != DisplayRotation::ROTATE_0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// backwards notation, should fix that...
|
||||
Lin::Vec3 pos = Lin::Vec3(coord[i].x, coord[i].y, 0.0);
|
||||
pos = pos * g_display_rot_matrix;
|
||||
coord[i].x = pos.x;
|
||||
coord[i].y = pos.y;
|
||||
}
|
||||
}
|
||||
|
||||
// Rearrange to strip form.
|
||||
std::swap(coord[2], coord[3]);
|
||||
|
||||
DrawStrip2D(nullptr, coord, 4);
|
||||
|
||||
gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ protected:
|
||||
virtual void PackFramebufferSync_(VirtualFramebuffer *vfb, int x, int y, int w, int h);
|
||||
void SetViewport2D(int x, int y, int w, int h);
|
||||
Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height);
|
||||
virtual void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) = 0;
|
||||
virtual void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags);
|
||||
virtual void Bind2DShader() = 0;
|
||||
|
||||
void DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount);
|
||||
|
@ -21,9 +21,6 @@
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/Data/Convert/ColorConv.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/Math/lin/matrix4x4.h"
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/GPU/thin3d.h"
|
||||
|
||||
#include "Core/MemMap.h"
|
||||
@ -170,59 +167,6 @@ void FramebufferManagerD3D11::SetDrawEngine(DrawEngineD3D11 *td) {
|
||||
drawEngine_ = td;
|
||||
}
|
||||
|
||||
void FramebufferManagerD3D11::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) {
|
||||
// Will be drawn as a strip.
|
||||
Draw2DVertex coord[4] = {
|
||||
{x, y, u0, v0},
|
||||
{x + w, y, u1, v0},
|
||||
{x + w, y + h, u1, v1},
|
||||
{x, y + h, u0, v1},
|
||||
};
|
||||
|
||||
if (uvRotation != ROTATION_LOCKED_HORIZONTAL) {
|
||||
float temp[8];
|
||||
int rotation = 0;
|
||||
switch (uvRotation) {
|
||||
case ROTATION_LOCKED_HORIZONTAL180: rotation = 2; break;
|
||||
case ROTATION_LOCKED_VERTICAL: rotation = 1; break;
|
||||
case ROTATION_LOCKED_VERTICAL180: rotation = 3; break;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
temp[i * 2] = coord[((i + rotation) & 3)].u;
|
||||
temp[i * 2 + 1] = coord[((i + rotation) & 3)].v;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
coord[i].u = temp[i * 2];
|
||||
coord[i].v = temp[i * 2 + 1];
|
||||
}
|
||||
}
|
||||
|
||||
const float invDestW = 2.0f / destW;
|
||||
const float invDestH = 2.0f / destH;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
coord[i].x = coord[i].x * invDestW - 1.0f;
|
||||
coord[i].y = coord[i].y * invDestH - 1.0f;
|
||||
}
|
||||
|
||||
if ((flags & DRAWTEX_TO_BACKBUFFER) && g_display_rotation != DisplayRotation::ROTATE_0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// backwards notation, should fix that...
|
||||
Lin::Vec3 pos = Lin::Vec3(coord[i].x, coord[i].y, 0.0);
|
||||
pos = pos * g_display_rot_matrix;
|
||||
coord[i].x = pos.x;
|
||||
coord[i].y = pos.y;
|
||||
}
|
||||
}
|
||||
|
||||
// Rearrange to strip form.
|
||||
std::swap(coord[2], coord[3]);
|
||||
|
||||
DrawStrip2D(nullptr, coord, 4);
|
||||
|
||||
gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE);
|
||||
}
|
||||
|
||||
void FramebufferManagerD3D11::Bind2DShader() {
|
||||
context_->IASetInputLayout(quadInputLayout_);
|
||||
context_->PSSetShader(quadPixelShader_, 0, 0);
|
||||
|
@ -39,7 +39,6 @@ public:
|
||||
void SetTextureCache(TextureCacheD3D11 *tc);
|
||||
void SetShaderManager(ShaderManagerD3D11 *sm);
|
||||
void SetDrawEngine(DrawEngineD3D11 *td);
|
||||
void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) override;
|
||||
|
||||
void EndFrame();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user