mirror of https://github.com/PCSX2/pcsx2.git
GSdx: SW+SDL output, commented out until it can be compiled on every system
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4336 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
9b658615f5
commit
57cb0afa2a
|
@ -195,7 +195,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
|
|||
#ifdef _WINDOWS
|
||||
case 0: case 1: case 2: dev = new GSDevice9(); break;
|
||||
case 3: case 4: case 5: dev = new GSDevice11(); break;
|
||||
// case 3: case 4: case 5: dev = new GSDeviceSW(); break;
|
||||
// case 3: case 4: case 5: dev = new GSDeviceSDL(); break;
|
||||
#endif
|
||||
case 12: case 13: dev = new GSDeviceNull(); break;
|
||||
}
|
||||
|
|
|
@ -99,12 +99,17 @@ void GSDevice::Present(const GSVector4i& r, int shader)
|
|||
{
|
||||
static int s_shader[3] = {0, 5, 6}; // FIXME
|
||||
|
||||
StretchRect(m_current, m_backbuffer, GSVector4(r), s_shader[shader]);
|
||||
Present(m_current, m_backbuffer, GSVector4(r), s_shader[shader]);
|
||||
}
|
||||
|
||||
Flip();
|
||||
}
|
||||
|
||||
void GSDevice::Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader)
|
||||
{
|
||||
StretchRect(st, dt, dr, shader);
|
||||
}
|
||||
|
||||
GSTexture* GSDevice::Fetch(int type, int w, int h, bool msaa, int format)
|
||||
{
|
||||
GSVector2i size(w, h);
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
virtual bool Reset(int w, int h);
|
||||
virtual bool IsLost(bool update = false) {return false;}
|
||||
virtual void Present(const GSVector4i& r, int shader);
|
||||
virtual void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0);
|
||||
virtual void Flip() {}
|
||||
|
||||
virtual void SetVSync(bool enable) {m_vsync = enable;}
|
||||
|
|
|
@ -360,7 +360,7 @@ void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVecto
|
|||
|
||||
if(st[1] && !slbg)
|
||||
{
|
||||
StretchRect(st[1], *sr, dt, *dr);
|
||||
StretchRect(st[1], sr[1], dt, dr[1]);
|
||||
}
|
||||
|
||||
if(st[0])
|
||||
|
@ -371,7 +371,7 @@ void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVecto
|
|||
|
||||
ShaderAlpha2xBlend s;
|
||||
|
||||
::StretchRect(st[0], sr[0], dt, *dr, s, true);
|
||||
::StretchRect(st[0], sr[0], dt, dr[0], s, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -379,7 +379,7 @@ void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVecto
|
|||
|
||||
ShaderFactorBlend s((uint32)(int)(c.a * 255));
|
||||
|
||||
::StretchRect(st[0], sr[0], dt, *dr, s, true);
|
||||
::StretchRect(st[0], sr[0], dt, dr[0], s, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,3 +438,147 @@ void GSDeviceSW::Clear(GSTexture* t, uint32 c)
|
|||
t->Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _SDL_H
|
||||
|
||||
GSDeviceSDL::GSDeviceSDL()
|
||||
: m_window(NULL)
|
||||
, m_renderer(NULL)
|
||||
, m_texture(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
GSDeviceSDL::~GSDeviceSDL()
|
||||
{
|
||||
if(m_texture != NULL)
|
||||
{
|
||||
SDL_DestroyTexture(m_texture);
|
||||
}
|
||||
|
||||
if(m_renderer != NULL)
|
||||
{
|
||||
SDL_DestroyRenderer(m_renderer);
|
||||
}
|
||||
|
||||
if(m_window != NULL)
|
||||
{
|
||||
SDL_DestroyWindow(m_window);
|
||||
}
|
||||
}
|
||||
|
||||
bool GSDeviceSDL::Create(GSWnd* wnd)
|
||||
{
|
||||
if(SDL_Init(SDL_INIT_VIDEO) < 0) // ok here?
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_window = SDL_CreateWindowFrom(wnd->GetHandle());
|
||||
|
||||
if(m_window == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return GSDeviceSW::Create(wnd);
|
||||
}
|
||||
|
||||
bool GSDeviceSDL::Reset(int w, int h)
|
||||
{
|
||||
if(!GSDeviceSW::Reset(w, h))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_texture != NULL)
|
||||
{
|
||||
SDL_DestroyTexture(m_texture);
|
||||
|
||||
m_texture = NULL;
|
||||
}
|
||||
|
||||
if(m_renderer != NULL)
|
||||
{
|
||||
SDL_DestroyRenderer(m_renderer);
|
||||
|
||||
m_renderer = NULL;
|
||||
}
|
||||
|
||||
m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); // SDL_RENDERER_PRESENTVSYNC
|
||||
|
||||
return m_renderer != NULL;
|
||||
}
|
||||
|
||||
void GSDeviceSDL::Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader)
|
||||
{
|
||||
ASSERT(dt == m_backbuffer); // ignore m_backbuffer
|
||||
|
||||
GSVector2i size = st->GetSize();
|
||||
|
||||
if(m_texture != NULL)
|
||||
{
|
||||
Uint32 format;
|
||||
int access;
|
||||
int w, h;
|
||||
|
||||
if(SDL_QueryTexture(m_texture, &format, &access, &w, &h) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(w != size.x || h != size.y)
|
||||
{
|
||||
SDL_DestroyTexture(m_texture);
|
||||
|
||||
m_texture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_texture == NULL)
|
||||
{
|
||||
m_texture = SDL_CreateTexture(m_renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, size.x, size.y);
|
||||
}
|
||||
|
||||
if(m_texture == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GSTexture::GSMap sm, dm;
|
||||
|
||||
if(SDL_LockTexture(m_texture, NULL, (void**)&dm.bits, &dm.pitch) == 0)
|
||||
{
|
||||
if(st->Map(sm, NULL))
|
||||
{
|
||||
GSVector2i s = st->GetSize();
|
||||
|
||||
for(int j = s.y; j > 0; j--, sm.bits += sm.pitch, dm.bits += dm.pitch)
|
||||
{
|
||||
memcpy(dm.bits, sm.bits, s.x * 4);
|
||||
}
|
||||
|
||||
st->Unmap();
|
||||
}
|
||||
|
||||
SDL_UnlockTexture(m_texture);
|
||||
}
|
||||
|
||||
GSVector4i dri(dr);
|
||||
|
||||
SDL_Rect r;
|
||||
|
||||
r.x = dri.left;
|
||||
r.y = dri.top;
|
||||
r.w = dri.width();
|
||||
r.h = dri.height();
|
||||
|
||||
SDL_RenderClear(m_renderer);
|
||||
SDL_RenderCopy(m_renderer, m_texture, NULL, &r);
|
||||
}
|
||||
|
||||
void GSDeviceSDL::Flip()
|
||||
{
|
||||
SDL_RenderPresent(m_renderer);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -60,3 +60,29 @@ public:
|
|||
void PSSetShaderResource(int i, GSTexture* sr);
|
||||
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
|
||||
};
|
||||
|
||||
// WIP
|
||||
|
||||
// #include "../../3rdparty/SDL/include/SDL.h"
|
||||
|
||||
#ifdef _SDL_H
|
||||
|
||||
#pragma comment(lib, "../../3rdparty/SDL/SDL.lib")
|
||||
|
||||
class GSDeviceSDL : public GSDeviceSW
|
||||
{
|
||||
SDL_Window* m_window;
|
||||
SDL_Renderer* m_renderer;
|
||||
SDL_Texture* m_texture;
|
||||
|
||||
public:
|
||||
GSDeviceSDL();
|
||||
virtual ~GSDeviceSDL();
|
||||
|
||||
bool Create(GSWnd* wnd);
|
||||
bool Reset(int w, int h);
|
||||
void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0);
|
||||
void Flip();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue