From b2ba781df8975c6b9ae65db1a80267efde14b51e Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 16 Nov 2011 21:34:12 +0000 Subject: [PATCH 01/56] Create a branch to play with a new GSdx backend git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4969 96395faa-99c1-11dd-bbfe-3dabce05a288 From da66ca7fd957831b05f73dc11efc784beb2beb3b Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 16 Nov 2011 22:17:37 +0000 Subject: [PATCH 02/56] gsdx-ogl: preliminary work of an opengl backend. So far only skeleton and various note. Current goal is to implement the SW render with pure opengl instead of SDL. I plan to use OpenGL4.2 capability (the latest actually) => need libglew1.7 and a Dx11 capable GPU/drivers. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4970 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 8 + plugins/GSdx/GS.cpp | 10 +- plugins/GSdx/GSDeviceOGL.cpp | 643 +++++++++++++++++++++++++++++ plugins/GSdx/GSDeviceOGL.h | 242 +++++++++++ plugins/GSdx/GSLinuxDialog.cpp | 34 +- plugins/GSdx/GSRendererOGL.cpp | 43 ++ plugins/GSdx/GSRendererOGL.h | 50 +++ plugins/GSdx/GSSetting.h | 2 + plugins/GSdx/GSTextureCacheOGL.cpp | 101 +++++ plugins/GSdx/GSTextureCacheOGL.h | 37 ++ plugins/GSdx/GSTextureOGL.cpp | 257 ++++++++++++ plugins/GSdx/GSTextureOGL.h | 43 ++ plugins/GSdx/GSVertexList.h | 2 +- plugins/GSdx/GSWnd.cpp | 16 + plugins/GSdx/GSdx.cpp | 2 + plugins/GSdx/stdafx.h | 6 +- 16 files changed, 1488 insertions(+), 8 deletions(-) create mode 100644 plugins/GSdx/GSDeviceOGL.cpp create mode 100644 plugins/GSdx/GSDeviceOGL.h create mode 100644 plugins/GSdx/GSRendererOGL.cpp create mode 100644 plugins/GSdx/GSRendererOGL.h create mode 100644 plugins/GSdx/GSTextureCacheOGL.cpp create mode 100644 plugins/GSdx/GSTextureCacheOGL.h create mode 100644 plugins/GSdx/GSTextureOGL.cpp create mode 100644 plugins/GSdx/GSTextureOGL.h diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 46254d9bc8..35bc667776 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -58,6 +58,7 @@ set(GSdxSources GSCodeBuffer.cpp GSCrc.cpp GSDevice.cpp + GSDeviceOGL.cpp GSDeviceSDL.cpp GSDeviceSW.cpp GSDeviceNull.cpp @@ -76,6 +77,7 @@ set(GSdxSources GSRasterizer.cpp GSRenderer.cpp GSRendererNull.cpp + GSRendererOGL.cpp GSRendererSW.cpp GSSetting.cpp GSSetupPrimCodeGenerator.cpp @@ -88,6 +90,8 @@ set(GSdxSources GSTexture.cpp GSTextureCache.cpp GSTextureCacheSW.cpp + GSTextureCacheOGL.cpp + GSTextureOGL.cpp GSTextureNull.cpp GSTextureSW.cpp GSThread.cpp @@ -123,6 +127,7 @@ set(GSdxHeaders GSCodeBuffer.h GSCrc.h GSDevice.h + GSDeviceOGL.h GSDeviceNull.h GSDirtyRect.h GSDrawScanline.h @@ -137,6 +142,8 @@ set(GSdxHeaders GSRenderer.h GSRendererNull.h GSRendererSW.h + GSRendererHW.h + GSRendererOGL.h GSScanlineEnvironment.h GSSetting.h GSSetupPrimCodeGenerator.h @@ -145,6 +152,7 @@ set(GSdxHeaders GSTexture.h GSTextureCache.h GSTextureCacheSW.h + GSTextureCacheOGL.h GSTextureNull.h GSThread.h GSUtil.h diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index f3ccaf104b..d18be7fb2f 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -39,6 +39,9 @@ static HRESULT s_hr = E_FAIL; #else +#include "GSDeviceOGL.h" +#include "GSRendererOGL.h" + #include #include @@ -215,6 +218,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) #endif case 2: dev = new GSDeviceSDL(); break; case 3: dev = new GSDeviceNull(); break; + case 4: dev = new GSDeviceOGL(); break; } if(dev == NULL) @@ -227,11 +231,13 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) switch(renderer % 3) { default: - #ifdef _WINDOWS case 0: + #ifdef _WINDOWS s_gs = (renderer / 3) == 0 ? (GSRenderer*)new GSRendererDX9() : (GSRenderer*)new GSRendererDX11(); - break; + #else + s_gs = (GSRenderer*)new GSRendererOGL(); #endif + break; case 1: s_gs = new GSRendererSW(threads); break; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp new file mode 100644 index 0000000000..576fe1d68e --- /dev/null +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -0,0 +1,643 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "GSDeviceOGL.h" + +// Various Note: separate build of shader +// ************************** BUILD METHOD 1 +// 1/ create a stand alone prog +// uint CreateShaderProgramv( enum type, sizei count, const char **strings ); +// 2/ Create various prog pipeline (maybe 1 foreach combination or only 1) +// glGenProgramPipelines +// 3/ Attach a program to a pipeline +// void UseProgramStages( uint pipeline, bitfield stages, uint program ); +// ... +// ... +// 5/ Before the use of the program, we can validate it. (mandatory or not ?) +// glValidateProgramPipeline +// +// ************************** BUILD METHOD 2 +// Humm, there is another solutions. You can setup function pointer in GLSL and configure them with OPENGL. shader_subroutine. glUseProgram must be replace with glUseProgramInstance in this case (and instance must be managed) +//GL EXT: Overview +//GL EXT: +//GL EXT: This extension adds support to shaders for "indirect subroutine calls", +//GL EXT: where a single shader can include many subroutines and dynamically select +//GL EXT: through the API which subroutine is called from each call site. +//GL EXT: Switching subroutines dynamically in this fashion can avoid the cost of +//GL EXT: recompiling and managing multiple shaders, while still retaining most of +//GL EXT: the performance of specialized shaders. +// +// ************************** Uniform buffer +// // Note don't know how to chose block_binding_point (probably managed like texture unit +// maybe any number will be fine) +// index=glGetUniformBlockIndex(program, "BlockName"); +// glBindBufferBase(GL_UNIFORM_BUFFER, block_binding_point, some_buffer_object); +// glUniformBlockBinding(program, block_index, block_binding_point); + + +GSDeviceOGL::GSDeviceOGL() +{ + /* TODO */ + m_msaa = theApp.GetConfig("msaa", 0); +} + +GSDeviceOGL::~GSDeviceOGL() { /* TODO */ } + +GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) +{ + // A wrapper to call GSTextureOGL, with the different kind of parameter +} + +GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int format) +{ + // FIXME: keep DX code. Do not know how work msaa but not important for the moment +#if 0 + if(m_msaa < 2) { + msaa = false; + } +#endif + msaa = false; + + return GSDevice::FetchSurface(type, w, h, msaa, format); +} + +bool GSDeviceOGL::Create(GSWnd* wnd) +{ + /* TODO */ +} + +bool GSDeviceOGL::Reset(int w, int h) +{ + // Hum map, m_backbuffer to a GSTexture +} + +// Swap buffer (back buffer, front buffer) +// Warning it is not OGL dependent but application dependant (glx and so not portable) +void GSDeviceOGL::Flip() { /* TODO */ } + +// glDrawArrays +void GSDeviceOGL::DrawPrimitive() { /* TODO */ } + +// Just a wrapper around glClear* functions +void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { /* TODO */ } +void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) { /* TODO */ } +void GSDeviceOGL::ClearDepth(GSTexture* t, float c) { /* TODO */ } +void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) { /* TODO */ } + +// the 4 next functions are only used to set some default value for the format. +// Need to find the default format... +// depth_stencil => GL_DEPTH32F_STENCIL8 +// others => (need 4* 8bits unsigned normalized integer) (GL_RGBA8 ) +GSTexture* GSDeviceOGL::CreateRenderTarget(int w, int h, bool msaa, int format) { /* TODO */ } +GSTexture* GSDeviceOGL::CreateDepthStencil(int w, int h, bool msaa, int format) { /* TODO */ } +GSTexture* GSDeviceOGL::CreateTexture(int w, int h, int format) { /* TODO */ } +GSTexture* GSDeviceOGL::CreateOffscreen(int w, int h, int format) { /* TODO */ } + +// blit a texture into an offscreen buffer +GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format) +{ + // Need to find format equivalent. Then I think it will be straight forward + + // A four-component, 32-bit unsigned-normalized-integer format that supports 8 bits per channel including alpha. + // DXGI_FORMAT_R8G8B8A8_UNORM <=> GL_RGBA8 + + // A single-component, 16-bit unsigned-integer format that supports 16 bits for the red channel + // DXGI_FORMAT_R16_UINT <=> GL_R16 +#if 0 + GSTexture* dst = NULL; + + if(format == 0) + { + format = DXGI_FORMAT_R8G8B8A8_UNORM; + } + + if(format != DXGI_FORMAT_R8G8B8A8_UNORM && format != DXGI_FORMAT_R16_UINT) + { + ASSERT(0); + + return false; + } + + if(GSTexture* rt = CreateRenderTarget(w, h, false, format)) + { + GSVector4 dr(0, 0, w, h); + + if(GSTexture* src2 = src->IsMSAA() ? Resolve(src) : src) + { + StretchRect(src2, sr, rt, dr, m_convert.ps[format == DXGI_FORMAT_R16_UINT ? 1 : 0], NULL); + + if(src2 != src) Recycle(src2); + } + + dst = CreateOffscreen(w, h, format); + + if(dst) + { + m_ctx->CopyResource(*(GSTexture11*)dst, *(GSTexture11*)rt); + } + + Recycle(rt); + } + + return dst; +#endif +} + +// Copy a sub part of a texture into another +// Several question to answer did texture have same size? +// From a sub-part to the same sub-part +// From a sub-part to a full texture +void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) +{ +#if 0 + if(!st || !dt) + { + ASSERT(0); + return; + } + + D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; + + m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, 0, 0, 0, *(GSTexture11*)st, 0, &box); +#endif +} + + +// Raster flow to resize a texture +// Note just call the StretchRect hardware accelerated +void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear) +{ + /* TODO */ +} +void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear) +{ + // TODO +} + +// probably no difficult to convert when all helpers function will be done +void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL ps_cb, GSBlendStateOGL* bs, bool linear) +{ +#if 0 + if(!st || !dt) + { + ASSERT(0); + return; + } + + BeginScene(); + + GSVector2i ds = dt->GetSize(); + + // om + + OMSetDepthStencilState(m_convert.dss, 0); + OMSetBlendState(bs, 0); + OMSetRenderTargets(dt, NULL); + + // ia + + float left = dr.x * 2 / ds.x - 1.0f; + float top = 1.0f - dr.y * 2 / ds.y; + float right = dr.z * 2 / ds.x - 1.0f; + float bottom = 1.0f - dr.w * 2 / ds.y; + + GSVertexPT1 vertices[] = + { + {GSVector4(left, top, 0.5f, 1.0f), GSVector2(sr.x, sr.y)}, + {GSVector4(right, top, 0.5f, 1.0f), GSVector2(sr.z, sr.y)}, + {GSVector4(left, bottom, 0.5f, 1.0f), GSVector2(sr.x, sr.w)}, + {GSVector4(right, bottom, 0.5f, 1.0f), GSVector2(sr.z, sr.w)}, + }; + + IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices)); + IASetInputLayout(m_convert.il); + IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + // vs + + VSSetShader(m_convert.vs, NULL); + + // gs + + GSSetShader(NULL); + + // ps + + PSSetShaderResources(st, NULL); + PSSetSamplerState(linear ? m_convert.ln : m_convert.pt, NULL); + PSSetShader(ps, ps_cb); + + // + + DrawPrimitive(); + + // + + EndScene(); + + PSSetShaderResources(NULL, NULL); +#endif +} + +void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c) +{ +#if 0 + ClearRenderTarget(dt, c); + + if(st[1] && !slbg) + { + StretchRect(st[1], sr[1], dt, dr[1], m_merge.ps[0], NULL, true); + } + + if(st[0]) + { + m_ctx->UpdateSubresource(m_merge.cb, 0, NULL, &c, 0, 0); + + StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.cb, m_merge.bs, true); + } +#endif +} + +void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) +{ +#if 0 + GSVector4 s = GSVector4(dt->GetSize()); + + GSVector4 sr(0, 0, 1, 1); + GSVector4 dr(0.0f, yoffset, s.x, s.y + yoffset); + + InterlaceConstantBuffer cb; + + cb.ZrH = GSVector2(0, 1.0f / s.y); + cb.hH = s.y / 2; + + m_ctx->UpdateSubresource(m_interlace.cb, 0, NULL, &cb, 0, 0); + + StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); +#endif +} + +// copy a multisample texture to a non-texture multisample. On opengl you need 2 FBO with different level of +// sample and then do a blit. Headach expected to for the moment just drop MSAA... +GSTexture* GSDeviceOGL::Resolve(GSTexture* t) +{ +#if 0 + ASSERT(t != NULL && t->IsMSAA()); + + if(GSTexture* dst = CreateRenderTarget(t->GetWidth(), t->GetHeight(), false, t->GetFormat())) + { + dst->SetScale(t->GetScale()); + + m_ctx->ResolveSubresource(*(GSTexture11*)dst, 0, *(GSTexture11*)t, 0, (DXGI_FORMAT)t->GetFormat()); + + return dst; + } + + return NULL; +#endif + return NULL; +} + +void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t count) +{ + ASSERT(m_vertices.count == 0); + + if(count * stride > m_vertices.limit * m_vertices.stride) + { + // Current GPU buffer is too small need to realocate a new one +#if 0 + m_vb_old = m_vb; + m_vb = NULL; + + m_vertices.start = 0; + m_vertices.count = 0; + m_vertices.limit = std::max(count * 3 / 2, 11000); +#endif + } + + if(m_vb == NULL) + { + // Allocate a GPU buffer: GL_DYNAMIC_DRAW vs GL_STREAM_DRAW !!! + // glBufferData(GL_ARRAY_BUFFER, m_vertices.limit, NULL, GL_DYNAMIC_DRAW) +#if 0 + D3D11_BUFFER_DESC bd; + + memset(&bd, 0, sizeof(bd)); + + bd.Usage = D3D11_USAGE_DYNAMIC; + bd.ByteWidth = m_vertices.limit * stride; + bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; + bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + HRESULT hr; + + hr = m_dev->CreateBuffer(&bd, NULL, &m_vb); + + if(FAILED(hr)) return; +#endif + } + + // append data or go back to the beginning + // Hum why we don't always go back to the beginning !!! +#if 0 + D3D11_MAP type = D3D11_MAP_WRITE_NO_OVERWRITE; + + if(m_vertices.start + count > m_vertices.limit || stride != m_vertices.stride) + { + m_vertices.start = 0; + + type = D3D11_MAP_WRITE_DISCARD; + } +#endif + + // Allocate the buffer + // glBufferSubData +#if 0 + D3D11_MAPPED_SUBRESOURCE m; + + if(SUCCEEDED(m_ctx->Map(m_vb, 0, type, 0, &m))) + { + GSVector4i::storent((uint8*)m.pData + m_vertices.start * stride, vertices, count * stride); + + m_ctx->Unmap(m_vb, 0); + } +#endif + + m_vertices.count = count; + m_vertices.stride = stride; + +// Useless ? +// binding of the buffer must be done anyway before glBufferSubData or glBufferData calls. +#if 0 + IASetVertexBuffer(m_vb, stride); +#endif +} + +// Useless ? +#if 0 +void GSDeviceOGL::IASetVertexBuffer(GLuint vb, size_t stride) +{ + if(m_state.vb != vb || m_state.vb_stride != stride) + { + m_state.vb = vb; + m_state.vb_stride = stride; + + uint32 stride2 = stride; + uint32 offset = 0; + + m_ctx->IASetVertexBuffers(0, 1, &vb, &stride2, &offset); + } +} +#endif + +// Useless ? +#if 0 +void GSDeviceOGL::IASetInputLayout(ID3D11InputLayout* layout) +{ + if(m_state.layout != layout) + { + m_state.layout = layout; + + m_ctx->IASetInputLayout(layout); + } +} +#endif + +// Useless ? +#if 0 +void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) +{ + if(m_state.topology != topology) + { + m_state.topology = topology; + + m_ctx->IASetPrimitiveTopology(topology); + } +} +#endif + +void GSDeviceOGL::VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb) +{ + // glUseProgramStage +#if 0 + if(m_state.vs != vs) + { + m_state.vs = vs; + + m_ctx->VSSetShader(vs, NULL, 0); + } +#endif + + // glBindBufferBase +#if 0 + if(m_state.vs_cb != vs_cb) + { + m_state.vs_cb = vs_cb; + + m_ctx->VSSetConstantBuffers(0, 1, &vs_cb); + } +#endif +} + +void GSDeviceOGL::GSSetShader(GLuint gs) +{ + // glUseProgramStage +#if 0 + if(m_state.gs != gs) + { + m_state.gs = gs; + + m_ctx->GSSetShader(gs, NULL, 0); + } +#endif +} + +void GSDeviceOGL::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) +{ + PSSetShaderResource(0, sr0); + PSSetShaderResource(1, sr1); + PSSetShaderResource(2, NULL); +} + +void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr) +{ +#if 0 + ID3D11ShaderResourceView* srv = NULL; + + if(sr) srv = *(GSTexture11*)sr; + + if(m_state.ps_srv[i] != srv) + { + m_state.ps_srv[i] = srv; + + m_srv_changed = true; + } +#endif +} + +void GSDeviceOGL::PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2) +{ +#if 0 + if(m_state.ps_ss[0] != ss0 || m_state.ps_ss[1] != ss1 || m_state.ps_ss[2] != ss2) + { + m_state.ps_ss[0] = ss0; + m_state.ps_ss[1] = ss1; + m_state.ps_ss[2] = ss2; + + m_ss_changed = true; + } +#endif +} + +void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) +{ + + // glUseProgramStage +#if 0 + if(m_state.ps != ps) + { + m_state.ps = ps; + + m_ctx->PSSetShader(ps, NULL, 0); + } +#endif + +// Sampler and texture must be set at the same time +// 1/ select the texture unit +// glActiveTexture(GL_TEXTURE0 + 1); +// 2/ bind the texture +// glBindTexture(GL_TEXTURE_2D , brickTexture); +// 3/ sets the texture sampler in GLSL (could be useless with layout stuff) +// glUniform1i(brickSamplerId , 1); +// 4/ set the sampler state +// glBindSampler(1 , sampler); +#if 0 + if (m_srv_changed) + { + m_ctx->PSSetShaderResources(0, 3, m_state.ps_srv); + + m_srv_changed = false; + } + + if(m_ss_changed) + { + m_ctx->PSSetSamplers(0, 3, m_state.ps_ss); + + m_ss_changed = false; + } +#endif + + // glBindBufferBase +#if 0 + if(m_state.ps_cb != ps_cb) + { + m_state.ps_cb = ps_cb; + + m_ctx->PSSetConstantBuffers(0, 1, &ps_cb); + } +#endif +} + +void GSDeviceOGL::OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref) +{ + // Setup the stencil object. sref can be set by glStencilFunc (note remove it from the structure) +#if 0 + if(m_state.dss != dss || m_state.sref != sref) + { + m_state.dss = dss; + m_state.sref = sref; + + m_ctx->OMSetDepthStencilState(dss, sref); + } +#endif +} + +void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) +{ + // DX:Blend factor D3D11_BLEND_BLEND_FACTOR | D3D11_BLEND_INV_BLEND_FACTOR + // OPENGL: GL_CONSTANT_COLOR | GL_ONE_MINUS_CONSTANT_COLOR + // Note factor must be set before by glBlendColor +#if 0 + if(m_state.bs != bs || m_state.bf != bf) + { + m_state.bs = bs; + m_state.bf = bf; + + float BlendFactor[] = {bf, bf, bf, 0}; + + m_ctx->OMSetBlendState(bs, BlendFactor, 0xffffffff); + } +#endif +} + +void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor) +{ + // set the attachment inside the FBO + +#if 0 + ID3D11RenderTargetView* rtv = NULL; + ID3D11DepthStencilView* dsv = NULL; + + if(rt) rtv = *(GSTexture11*)rt; + if(ds) dsv = *(GSTexture11*)ds; + + if(m_state.rtv != rtv || m_state.dsv != dsv) + { + m_state.rtv = rtv; + m_state.dsv = dsv; + + m_ctx->OMSetRenderTargets(1, &rtv, dsv); + } +#endif + + // Viewport -> glViewport +#if 0 + if(m_state.viewport != rt->GetSize()) + { + m_state.viewport = rt->GetSize(); + + D3D11_VIEWPORT vp; + + memset(&vp, 0, sizeof(vp)); + + vp.TopLeftX = 0; + vp.TopLeftY = 0; + vp.Width = (float)rt->GetWidth(); + vp.Height = (float)rt->GetHeight(); + vp.MinDepth = 0.0f; + vp.MaxDepth = 1.0f; + + m_ctx->RSSetViewports(1, &vp); + } +#endif + + // Scissor -> glScissor (note must be enabled) +#if 0 + GSVector4i r = scissor ? *scissor : GSVector4i(rt->GetSize()).zwxy(); + + if(!m_state.scissor.eq(r)) + { + m_state.scissor = r; + + m_ctx->RSSetScissorRects(1, r); + } +#endif +} diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h new file mode 100644 index 0000000000..a18d2c3156 --- /dev/null +++ b/plugins/GSdx/GSDeviceOGL.h @@ -0,0 +1,242 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma once + +#include "GSDevice.h" +#include "GSTextureOGL.h" +#include "GSdx.h" + +struct GSBlendStateOGL { + // Note: You can also select the index of the draw buffer for which to set the blend setting + // We will keep basic the first try + bool m_enable; + GLenum m_equation_RGB; + GLenum m_equation_ALPHA; + GLenum m_func_RGB; + GLenum m_func_ALPHA; +}; + +struct GSDepthStencilOGL { + bool m_depth_enable; + GLenum m_depth_func; + // Note front face and back can be split might. But it seems they have same parameter configuration + bool m_stencil_enable; + GLuint m_stencil_mask; + GLuint m_stencil_func; + GLuint m_stencil_ref; + GLuint m_stencil_sfail_op; + GLuint m_stencil_spass_dfail_op; + GLuint m_stencil_spass_dpass_op; +}; + +struct GSUniformBufferOGL { + GLuint buffer; + GLuint index; +}; + +class GSDeviceOGL : public GSDevice +{ + uint32 m_msaa; + + // Vertex buffer: glGenBuffers, glBindBuffer GL_ARRAY_BUFFER + GLuint m_vb; // buffer object + + struct { + GLuint ps[2]; // program object + GSUniformBufferOGL* cb; // uniform buffer object + GSBlendStateOGL* bs; + } m_merge; + + struct { + GLuint ps[4]; // program object + GSUniformBufferOGL* cb; // uniform buffer object + } m_interlace; + + //struct + //{ + // CComPtr il; + // CComPtr vs; // program object + // CComPtr ps[8]; // program object + // CComPtr ln; + // CComPtr pt; + // CComPtr dss; + // CComPtr bs; // no equivalent + //} m_convert; + struct + { + // Hum I think this one is useless. As far as I understand + // it only get the index name of GLSL-equivalent input attribut + // ??? CComPtr il; + GLuint vs; // program object + GLuint ps[8]; // program object + GLuint ln; // sampler object + GLuint pt; // sampler object + GSDepthStencilOGL* dss; + GSBlendStateOGL* bs; + } m_convert; + + // struct + // { + // CComPtr dss; + // CComPtr bs; + // } m_date; + struct + { + GSDepthStencilOGL* dss; + GSBlendStateOGL* bs; + } m_date; + + // struct + // { + // ID3D11Buffer* vb; + // size_t vb_stride; + // ID3D11InputLayout* layout; + // D3D11_PRIMITIVE_TOPOLOGY topology; + // ID3D11VertexShader* vs; + // ID3D11Buffer* vs_cb; + // ID3D11GeometryShader* gs; + // ID3D11ShaderResourceView* ps_srv[3]; + // ID3D11PixelShader* ps; + // ID3D11Buffer* ps_cb; + // ID3D11SamplerState* ps_ss[3]; + // GSVector2i viewport; + // GSVector4i scissor; + // ID3D11DepthStencilState* dss; + // uint8 sref; + // ID3D11BlendState* bs; + // float bf; + // ID3D11RenderTargetView* rtv; + // ID3D11DepthStencilView* dsv; + // } m_state; + struct + { + GLuint vb; + // Hum I think those things can be dropped on OGL. It probably need an others architecture (see glVertexAttribPointer) + // size_t vb_stride; + // ID3D11InputLayout* layout; + GLenum topology; // (ie GL_TRIANGLES...) + GLuint vs; // program + GSUniformBufferOGL* vs_cb; // uniform buffer + GLuint gs; // program + // FIXME texture binding. Maybe not equivalent for the state but the best I could find. + GSTextureOGL* ps_srv[3]; + // ID3D11ShaderResourceView* ps_srv[3]; + GLuint ps; // program + GSUniformBufferOGL* ps_cb; // uniform buffer + GLuint ps_ss[3]; // sampler + GSVector2i viewport; + GSVector4i scissor; + GSDepthStencilOGL* dss; + uint8 sref; + GSBlendStateOGL* bs; + float bf; + // FIXME texture attachment in the FBO + // ID3D11RenderTargetView* rtv; + // ID3D11DepthStencilView* dsv; + } m_state; + + bool m_srv_changed; + bool m_ss_changed; + +#if 0 + CComPtr m_dev; + CComPtr m_ctx; + CComPtr m_swapchain; + + CComPtr m_rs; + + struct + { + CComPtr ps; + CComPtr cb; + } m_fxaa; + + + // Shaders... + + hash_map m_vs; + CComPtr m_vs_cb; + hash_map > m_gs; + hash_map > m_ps; + CComPtr m_ps_cb; + hash_map > m_ps_ss; + CComPtr m_palette_ss; + CComPtr m_rt_ss; + hash_map > m_om_dss; + hash_map > m_om_bs; + + VSConstantBuffer m_vs_cb_cache; + PSConstantBuffer m_ps_cb_cache; +#endif + + + protected: + GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); + GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); + void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c); + void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0); + + public: + GSDeviceOGL(); + virtual ~GSDeviceOGL(); + + bool Create(GSWnd* wnd); + bool Reset(int w, int h); + void Flip(); + + void DrawPrimitive(); + + void ClearRenderTarget(GSTexture* t, const GSVector4& c); + void ClearRenderTarget(GSTexture* t, uint32 c); + void ClearDepth(GSTexture* t, float c); + void ClearStencil(GSTexture* t, uint8 c); + + GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0); + GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0); + GSTexture* CreateTexture(int w, int h, int format = 0); + GSTexture* CreateOffscreen(int w, int h, int format = 0); + + GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0); + + void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL ps_cb, GSBlendStateOGL* bs, bool linear); + + GSTexture* Resolve(GSTexture* t); + + void IASetVertexBuffer(const void* vertices, size_t stride, size_t count); + + void VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb); + void GSSetShader(GLuint gs); + + void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); + void PSSetShaderResource(int i, GSTexture* sr); + void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2); + void PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb); + + void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); + void OMSetBlendState(GSBlendStateOGL* bs, float bf); + void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL); + + +}; diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 271b8e2619..7384a76a2a 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -42,6 +42,7 @@ static void SysMessage(const char *fmt, ...) bool RunLinuxDialog() { + // FIXME need to add msaa option configuration GtkWidget *dialog; GtkWidget *main_frame, *main_box; GtkWidget *render_label, *render_combo_box; @@ -76,10 +77,25 @@ bool RunLinuxDialog() if(!s.note.empty()) label += format(" (%s)", s.note.c_str()); + // (dev only) for any NULL stuff + if (i >= 7 && i <= 9) label += " (debug only)"; + // (experimental) for opengl stuff + if (i == 10 || i == 11) label += " (experimental)"; + gtk_combo_box_append_text(GTK_COMBO_BOX(render_combo_box), label.c_str()); } - gtk_combo_box_set_active(GTK_COMBO_BOX(render_combo_box), 0); + int renderer_box_position = 0; + switch (theApp.GetConfig("renderer", 0)) { + // Note the value are based on m_gs_renderers vector on GSdx.cpp + case 7 : renderer_box_position = 0; break; + case 8 : renderer_box_position = 1; break; + case 10: renderer_box_position = 2; break; + case 11: renderer_box_position = 3; break; + case 12: renderer_box_position = 4; break; + case 13: renderer_box_position = 5; break; + } + gtk_combo_box_set_active(GTK_COMBO_BOX(render_combo_box), renderer_box_position ); gtk_container_add(GTK_CONTAINER(main_box), render_label); gtk_container_add(GTK_CONTAINER(main_box), render_combo_box); @@ -142,12 +158,22 @@ bool RunLinuxDialog() if (return_value == GTK_RESPONSE_ACCEPT) { // Get all the settings from the dialog box. + if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) { + // FIXME test current opengl version supported through glxinfo (OpenGL version string:) + // Warn the user if 4.2 is not supported and switch back to basic SDL renderer + switch (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box))) { + // Note the value are based on m_gs_renderers vector on GSdx.cpp + case 0: theApp.SetConfig("renderer", 7); break; + case 1: theApp.SetConfig("renderer", 8); break; + case 2: theApp.SetConfig("renderer", 10); break; + case 3: theApp.SetConfig("renderer", 11); break; + case 4: theApp.SetConfig("renderer", 12); break; + case 5: theApp.SetConfig("renderer", 13); break; + } + } #if 0 // I'll put the right variable names in later. - if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) - renderer = gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)); - // Crash, for some interlace options if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1) theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) ); diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp new file mode 100644 index 0000000000..df1474c6d2 --- /dev/null +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "GSRendererOGL.h" +#include "GSRenderer.h" + + +GSRendererOGL::GSRendererOGL() + // FIXME + //: GSRendererHW(new GSTextureCacheOGL(this)) + : GSRendererHW(new GSTextureCacheOGL(this)) +{ + // TODO must be implementer with macro InitVertexKick(GSRendererOGL) + // template void VertexKick(bool skip); + InitVertexKick(GSRendererOGL); +} + +GSRendererOGL::~GSRendererOGL() { /* TODO */ } + +bool GSRendererOGL::CreateDevice(GSDevice* dev) { /* TODO */ } + +template +void GSRendererOGL::VertexKick(bool skip) { /* TODO */ } + +void GSRendererOGL::Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) { /* TODO */ } diff --git a/plugins/GSdx/GSRendererOGL.h b/plugins/GSdx/GSRendererOGL.h new file mode 100644 index 0000000000..0c75556a7f --- /dev/null +++ b/plugins/GSdx/GSRendererOGL.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma once + +#include "GSRendererHW.h" + +#include "GSRenderer.h" +#include "GSTextureCacheOGL.h" +#include "GSVertexHW.h" + +// FIXME does it need a GSVertexHWOGL ??? Data order can be easily programmed on opengl (the only potential +// issue is the unsupported praga push/pop +// Note it impact GSVertexTrace.cpp => void GSVertexTrace::Update(const GSVertexHWOGL* v, int count, GS_PRIM_CLASS primclass) +class GSRendererOGL : public GSRendererHW +//class GSRendererOGL : public GSRendererHW +{ + private: + + protected: + GSTextureCache* m_tc; + + void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); + + public: + GSRendererOGL(); + virtual ~GSRendererOGL(); + + template void VertexKick(bool skip); + + bool CreateDevice(GSDevice* dev); +}; diff --git a/plugins/GSdx/GSSetting.h b/plugins/GSdx/GSSetting.h index 503b535bb8..1f8264c771 100644 --- a/plugins/GSdx/GSSetting.h +++ b/plugins/GSdx/GSSetting.h @@ -21,6 +21,8 @@ #pragma once +#include "stdafx.h" + struct GSSetting { uint32 id; diff --git a/plugins/GSdx/GSTextureCacheOGL.cpp b/plugins/GSdx/GSTextureCacheOGL.cpp new file mode 100644 index 0000000000..5b4605a2c3 --- /dev/null +++ b/plugins/GSdx/GSTextureCacheOGL.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * http://www.gabest.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "stdafx.h" +#include "GSTextureCacheOGL.h" + +GSTextureCacheOGL::GSTextureCacheOGL(GSRenderer* r) + : GSTextureCache(r) +{ +} + +void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) +{ + // Except format (CopyOffscreen method), everything else seem portable +#if 0 + if(t->m_type != RenderTarget) + { + // TODO + + return; + } + + const GIFRegTEX0& TEX0 = t->m_TEX0; + + if(TEX0.PSM != PSM_PSMCT32 + && TEX0.PSM != PSM_PSMCT24 + && TEX0.PSM != PSM_PSMCT16 + && TEX0.PSM != PSM_PSMCT16S) + { + //ASSERT(0); + + return; + } + + if(!t->m_dirty.empty()) + { + return; + } + + // printf("GSRenderTarget::Read %d,%d - %d,%d (%08x)\n", r.left, r.top, r.right, r.bottom, TEX0.TBP0); + + int w = r.width(); + int h = r.height(); + + GSVector4 src = GSVector4(r) * GSVector4(t->m_texture->GetScale()).xyxy() / GSVector4(t->m_texture->GetSize()).xyxy(); + + DXGI_FORMAT format = TEX0.PSM == PSM_PSMCT16 || TEX0.PSM == PSM_PSMCT16S ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R8G8B8A8_UNORM; + + if(GSTexture* offscreen = m_renderer->m_dev->CopyOffscreen(t->m_texture, src, w, h, format)) + { + GSTexture::GSMap m; + + if(offscreen->Map(m)) + { + // TODO: block level write + + GSOffset* o = m_renderer->m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM); + + switch(TEX0.PSM) + { + case PSM_PSMCT32: + m_renderer->m_mem.WritePixel32(m.bits, m.pitch, o, r); + break; + case PSM_PSMCT24: + m_renderer->m_mem.WritePixel24(m.bits, m.pitch, o, r); + break; + case PSM_PSMCT16: + case PSM_PSMCT16S: + m_renderer->m_mem.WritePixel16(m.bits, m.pitch, o, r); + break; + default: + ASSERT(0); + } + + offscreen->Unmap(); + } + + m_renderer->m_dev->Recycle(offscreen); + } +#endif +} + diff --git a/plugins/GSdx/GSTextureCacheOGL.h b/plugins/GSdx/GSTextureCacheOGL.h new file mode 100644 index 0000000000..11bf6210ad --- /dev/null +++ b/plugins/GSdx/GSTextureCacheOGL.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * http://www.gabest.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma once + +#include "GSTextureCache.h" +#include "GSDeviceOGL.h" + +class GSTextureCacheOGL : public GSTextureCache +{ +protected: + int Get8bitFormat() {/* TODO return DXGI_FORMAT_A8_UNORM;*/} + + void Read(Target* t, const GSVector4i& r); + +public: + GSTextureCacheOGL(GSRenderer* r); +}; diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp new file mode 100644 index 0000000000..d1b0eb5912 --- /dev/null +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma once + +#include "GSTextureOGL.h" + +GSTextureOGL::GSTextureOGL(/* ID3D11Texture2D* texture */ ) +{ + // ************************************************************* + // Opengl world + + // http://www.opengl.org/wiki/Renderbuffer_Object + // render: constructor -> glGenRenderbuffers, glDeleteRenderbuffers + // info -> glGetRenderbufferParameteriv, glIsRenderbuffer + // binding -> glBindRenderbuffer (only 1 target), glFramebufferRenderbuffer (attach actually) + // setup param -> glRenderbufferStorageMultisample (after this call the buffer is unitialized) + // + // the only way to use a renderbuffer object is to attach it to a Framebuffer Object. After you bind that + // FBO to the context, and set up the draw or read buffers appropriately, you can use pixel transfer operations + // to read and write to it. Of course, you can also render to it. The standard glClear function will also clear the appropriate buffer. + // + // Render work in parallal with framebuffer object (FBO) http://www.opengl.org/wiki/Framebuffer_Objects + // render are attached to FBO through : glFramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS + // FBO : constructor -> glGenFramebuffers, glDeleteFramebuffers + // binding -> glBindFramebuffer (target can be read/write/both) + // blit -> glBlitFramebuffer (read FB to draw FB) + // info -> glIsFramebuffer, glGetFramebufferAttachmentParameter, glCheckFramebufferStatus + // + // There are two types of framebuffer-attachable images; texture images and renderbuffer images. + // If an image of a texture object is attached to a framebuffer, OpenGL performs "render to texture". + // And if an image of a renderbuffer object is attached to a framebuffer, then OpenGL performs "offscreen rendering". + // Blitting: + // glDrawBuffers + // glReadBuffer + // glBlitFramebuffer + + // ************************************************************* + // Doc + // It might need a texture structure to replace ID3D11Texture2D. + // + // == The function need to set (from parameter) + // : m_size.x + // : m_size.y + // : m_type + // : m_format + // : m_msaa + // == Might be useful to save + // : m_texture_target (like GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE etc...) + // : m_texture_id (return by glGen*) + // + // == Then generate the texture or buffer. + // D3D11_BIND_RENDER_TARGET: Bind a texture as a render target for the output-merger stage. + // => glGenRenderbuffers with GL_COLOR_ATTACHMENTi (Hum glGenTextures might work too) + // D3D11_BIND_DEPTH_STENCIL: Bind a texture as a depth-stencil target for the output-merger stage. + // => glGenRenderbuffers with GL_DEPTH_STENCIL_ATTACHMENT + // D3D11_BIND_SHADER_RESOURCE: Bind a buffer or texture to a shader stage + // => glGenTextures + // D3D11_USAGE_STAGING: A resource that supports data transfer (copy) from the GPU to the CPU. + // glGenTextures + // glReadPixels seems to use a framebuffer. In this case you can setup the source + // with glReadBuffer(GL_COLOR_ATTACHMENTi) + // glGetTexImage: read pixels of a bound texture + // => To allow map/unmap. I think we can use a pixel buffer (target GL_PIXEL_UNPACK_BUFFER) + // http://www.opengl.org/wiki/Pixel_Buffer_Objects + // == Enable texture Unit + // EnableUnit(); + // == Allocate space + // glRenderbufferStorageMultisample or glTexStorage2D + + +#if 0 + m_texture->GetDevice(&m_dev); + m_texture->GetDesc(&m_desc); + + m_dev->GetImmediateContext(&m_ctx); + + m_size.x = (int)m_desc.Width; + m_size.y = (int)m_desc.Height; + + if(m_desc.BindFlags & D3D11_BIND_RENDER_TARGET) m_type = RenderTarget; + else if(m_desc.BindFlags & D3D11_BIND_DEPTH_STENCIL) m_type = DepthStencil; + else if(m_desc.BindFlags & D3D11_BIND_SHADER_RESOURCE) m_type = Texture; + else if(m_desc.Usage == D3D11_USAGE_STAGING) m_type = Offscreen; + + m_format = (int)m_desc.Format; + + m_msaa = m_desc.SampleDesc.Count > 1; +#endif +} + +GSTextureOGL::~GSTextureOGL() +{ + // glDeleteTextures or glDeleteRenderbuffers +} + +void GSTextureOGL::EnableUnit() +{ + // == For texture, the Unit must be selected + // glActiveTexture + // !!!!!!!!!! VERY BIG ISSUE, how to ensure that the different texture use different texture unit. + // I think we need to create a pool on GSdevice. + // 1/ this->m_device_ogl + // 2/ int GSDeviceOGL::get_free_texture_unit() called from GSTextureOGL constructor + // 3/ void GSDeviceOGL::release_texture_unit(int) called from GSDeviceOGL destructor + // Another (better) idea, will be to create a global static pool + // + // == Bind the texture or buffer + // glBindRenderbuffer or glBindTexture + // + // !!!!!!!!!! Maybe attach to the FBO but where to manage the FBO!!! + // Create a separare public method for attachment ??? +} + +bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) +{ + // To update only a part of the texture you can use: + // glTexSubImage2D — specify a two-dimensional texture subimage +#if 0 + if(m_dev && m_texture) + { + D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; + + m_ctx->UpdateSubresource(m_texture, 0, &box, data, pitch, 0); + + return true; + } + + return false; +#endif +} + +bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) +{ + // The function allow to modify the texture from the CPU + // Set m.bits <- pointer to the data + // Set m.pitch <- size of a row + // I think in opengl we need to copy back the data to the RAM: glReadPixels — read a block of pixels from the frame buffer + // + // glMapBuffer — map a buffer object's data store +#if 0 + if(r != NULL) + { + // ASSERT(0); // not implemented + + return false; + } + + if(m_texture && m_desc.Usage == D3D11_USAGE_STAGING) + { + D3D11_MAPPED_SUBRESOURCE map; + + if(SUCCEEDED(m_ctx->Map(m_texture, 0, D3D11_MAP_READ_WRITE, 0, &map))) + { + m.bits = (uint8*)map.pData; + m.pitch = (int)map.RowPitch; + + return true; + } + } + + return false; +#endif +} + +void GSTextureOGL::Unmap() +{ + // copy the texture to the GPU + // GLboolean glUnmapBuffer(GLenum target); +#if 0 + if(m_texture) + { + m_ctx->Unmap(m_texture, 0); + } +#endif +} + +// If I'm correct, this function only dump some buffer. Debug only, still very useful! +// Note: check zzogl implementation +bool GSTextureOGL::Save(const string& fn, bool dds) +{ +#if 0 + CComPtr res; + + if(m_desc.BindFlags & D3D11_BIND_DEPTH_STENCIL) + { + HRESULT hr; + + D3D11_TEXTURE2D_DESC desc; + + memset(&desc, 0, sizeof(desc)); + + m_texture->GetDesc(&desc); + + desc.Usage = D3D11_USAGE_STAGING; + desc.BindFlags = 0; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + + CComPtr src, dst; + + hr = m_dev->CreateTexture2D(&desc, NULL, &src); + + m_ctx->CopyResource(src, m_texture); + + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + hr = m_dev->CreateTexture2D(&desc, NULL, &dst); + + D3D11_MAPPED_SUBRESOURCE sm, dm; + + hr = m_ctx->Map(src, 0, D3D11_MAP_READ, 0, &sm); + hr = m_ctx->Map(dst, 0, D3D11_MAP_WRITE, 0, &dm); + + uint8* s = (uint8*)sm.pData; + uint8* d = (uint8*)dm.pData; + + for(uint32 y = 0; y < desc.Height; y++, s += sm.RowPitch, d += dm.RowPitch) + { + for(uint32 x = 0; x < desc.Width; x++) + { + ((uint32*)d)[x] = (uint32)(ldexpf(((float*)s)[x*2], 32)); + } + } + + m_ctx->Unmap(src, 0); + m_ctx->Unmap(dst, 0); + + res = dst; + } + else + { + res = m_texture; + } + + return SUCCEEDED(D3DX11SaveTextureToFile(m_ctx, res, dds ? D3DX11_IFF_DDS : D3DX11_IFF_BMP, fn.c_str())); +#endif +} + diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h new file mode 100644 index 0000000000..6df0d212dc --- /dev/null +++ b/plugins/GSdx/GSTextureOGL.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma once + +#include "GSTexture.h" + +class GSTextureOGL : public GSTexture +{ + private: + GLenum m_texture_target; // texture target: 2D, rectangle etc... + GLuint m_texture_id; // the texture id + int m_texture_unit; // the texture unit offset + + void EnableUnit(); + + public: + explicit GSTextureOGL(); + virtual ~GSTextureOGL(); + + bool Update(const GSVector4i& r, const void* data, int pitch); + bool Map(GSMap& m, const GSVector4i* r = NULL); + void Unmap(); + bool Save(const string& fn, bool dds = false); +}; diff --git a/plugins/GSdx/GSVertexList.h b/plugins/GSdx/GSVertexList.h index adc6efda1d..e300ab88f1 100644 --- a/plugins/GSdx/GSVertexList.h +++ b/plugins/GSdx/GSVertexList.h @@ -33,7 +33,7 @@ public: { m_base = _aligned_malloc(sizeof(Vertex) * countof(m_v), 32); - for(int i = 0; i < countof(m_v); i++) + for(uint i = 0; i < countof(m_v); i++) { m_v[i] = &((Vertex*)m_base)[i]; } diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 02afc92ad7..b306932a51 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -376,6 +376,22 @@ bool GSWnd::Create(const string& title, int w, int h) #endif m_managed = true; + + // If the user request OpenGL acceleration, we take recent OGL version (4.2) + // We keep the default 2.1 version in SW mode (only DX11 capable card, are compatible with OGL4) + if ( theApp.GetConfig("renderer", 0) / 3 == 4 ) { + // Setup visual attribute + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 ); + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 ); + // Ask for an advance opengl version + SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); + SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 ); + } + m_window = SDL_CreateWindow(title.c_str(), 100, 100, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); // Get the X window from the newly created window diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 88885b0a0d..f518d666c1 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -116,6 +116,8 @@ GSdxApp::GSdxApp() m_gs_renderers.push_back(GSSetting(8, "SDL 1.3", "Null")); m_gs_renderers.push_back(GSSetting(10, "Null", "Software")); m_gs_renderers.push_back(GSSetting(11, "Null", "Null")); + m_gs_renderers.push_back(GSSetting(12, "OpenGL", "Hardware")); + m_gs_renderers.push_back(GSSetting(13, "OpenGL", "Software")); m_gs_interlace.push_back(GSSetting(0, "None", "")); m_gs_interlace.push_back(GSSetting(1, "Weave tff", "saw-tooth")); diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index cc28f6ca91..0fb788ba93 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -111,6 +111,10 @@ using namespace stdext; //#include //#include +#include +#include +#include + //using namespace __gnu_cxx; #define DIRECTORY_SEPARATOR '/' @@ -333,4 +337,4 @@ extern void vmfree(void* ptr, size_t size); //#define NO_CRC_HACKS // Disable all game specific hacks #ifdef HW_NO_TEXTURE_CACHE #define NO_CRC_HACKS -#endif \ No newline at end of file +#endif From 6125baa578e58a5caf9f02b0d28ba410e32cc51f Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Mon, 21 Nov 2011 22:36:03 +0000 Subject: [PATCH 03/56] gsdx-ogl: * make a rough implementation of most of the opengl device interface. Only a savestate nothing to expect yet. * depend of libglew 1.6 (normally 1.7 but I manually defined the only missing function) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4971 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 3 + plugins/GSdx/GSDeviceOGL.cpp | 745 ++++++++++++++++++++++++-------- plugins/GSdx/GSDeviceOGL.h | 70 +-- plugins/GSdx/GSLinuxDialog.cpp | 7 +- plugins/GSdx/GSTextureOGL.cpp | 148 +++++-- plugins/GSdx/GSTextureOGL.h | 9 +- plugins/GSdx/GSWnd.cpp | 18 + plugins/GSdx/res/convert.glsl | 142 ++++++ plugins/GSdx/res/interlace.glsl | 46 ++ plugins/GSdx/res/merge.glsl | 31 ++ plugins/GSdx/stdafx.h | 6 + 11 files changed, 984 insertions(+), 241 deletions(-) create mode 100644 plugins/GSdx/res/convert.glsl create mode 100644 plugins/GSdx/res/interlace.glsl create mode 100644 plugins/GSdx/res/merge.glsl diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 35bc667776..264ca8ce99 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -186,6 +186,9 @@ target_link_libraries(${Output} ${X11_LIBRARIES}) # link target with SDL target_link_libraries(${Output} ${SDL_LIBRARY}) +# link target with glew +target_link_libraries(${Output} ${GLEW_LIBRARY}) + # User flags options if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}") diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 576fe1d68e..05fcd3feb6 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -54,21 +54,52 @@ GSDeviceOGL::GSDeviceOGL() + : m_free_window(false) + , m_window(NULL) + , m_vb(0) + , m_pipeline(0) + , m_srv_changed(false) + , m_ss_changed(false) { - /* TODO */ m_msaa = theApp.GetConfig("msaa", 0); + memset(&m_merge, 0, sizeof(m_merge)); + memset(&m_interlace, 0, sizeof(m_interlace)); + memset(&m_convert, 0, sizeof(m_convert)); + memset(&m_date, 0, sizeof(m_date)); + memset(&m_state, 0, sizeof(m_state)); } -GSDeviceOGL::~GSDeviceOGL() { /* TODO */ } +GSDeviceOGL::~GSDeviceOGL() +{ + if(m_window != NULL && m_free_window) + { + SDL_DestroyWindow(m_window); + } +} GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) { // A wrapper to call GSTextureOGL, with the different kind of parameter + GSTextureOGL* t = NULL; + t = new GSTextureOGL(type, w, h, msaa, format); + + switch(type) + { + case GSTexture::RenderTarget: + ClearRenderTarget(t, 0); + break; + case GSTexture::DepthStencil: + ClearDepth(t, 0); + //FIXME might be need to clear the stencil too + break; + } + return t; } GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int format) { // FIXME: keep DX code. Do not know how work msaa but not important for the moment + // Current config give only 0 or 1 #if 0 if(m_msaa < 2) { msaa = false; @@ -81,39 +112,394 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int form bool GSDeviceOGL::Create(GSWnd* wnd) { - /* TODO */ + if (m_window == NULL) { +#if SDL_VERSION_ATLEAST(1,3,0) + m_window = SDL_CreateWindowFrom(wnd->GetHandle()); +#else + assert(0); +#endif + m_free_window = true; + } + +#ifdef __LINUX__ + // In GSopen2, sdl failed to received any resize event. GSWnd::GetClientRect need to manually + // set the window size... So we send the m_window to the wnd object to allow some manipulation on it. + wnd->SetWindow(m_window); +#endif + + // **************************************************************** + // Various object + // **************************************************************** + glGenProgramPipelines(1, &m_pipeline); + glBindProgramPipeline(m_pipeline); + + glGenFramebuffers(1, &m_fbo); + // **************************************************************** + // convert + // **************************************************************** + + GSInputLayout il_convert[2] = + { + {0, 4, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, p) }, + {1, 2, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, + }; + + m_convert.il[0] = il_convert[0]; + m_convert.il[1] = il_convert[1]; + + CompileShaderFromSource("convert.glsl", "vs_main", GL_VERTEX_SHADER, &m_convert.vs); + for(int i = 0; i < countof(m_convert.ps); i++) + CompileShaderFromSource("convert.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_convert.ps[i]); + + // Note the following object are initialized to 0 so disabled. + // Note: maybe enable blend with a factor of 1 + // m_convert.dss, m_convert.bs + +#if 0 + memset(&dsd, 0, sizeof(dsd)); + + dsd.DepthEnable = false; + dsd.StencilEnable = false; + + hr = m_dev->CreateDepthStencilState(&dsd, &m_convert.dss); + + memset(&bsd, 0, sizeof(bsd)); + + bsd.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + hr = m_dev->CreateBlendState(&bsd, &m_convert.bs); +#endif + glGenSamplers(1, &m_convert.ln); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + // FIXME which value for GL_TEXTURE_MIN_LOD + glSamplerParameteri(m_convert.ln, GL_TEXTURE_MAX_LOD, FLT_MAX); + // FIXME: seems there is 2 possibility in opengl + // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; + // glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_NONE); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + + + glGenSamplers(1, &m_convert.pt); + glGenSamplers(1, &m_convert.pt); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + // FIXME which value for GL_TEXTURE_MIN_LOD + glSamplerParameteri(m_convert.pt, GL_TEXTURE_MAX_LOD, FLT_MAX); + // FIXME: seems there is 2 possibility in opengl + // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; + // glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_NONE); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + + // **************************************************************** + // merge + // **************************************************************** + + m_merge.cb->index = 1; + m_merge.cb->byte_size = sizeof(MergeConstantBuffer); + glGenBuffers(1, &m_merge.cb->buffer); + glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); + glBufferData(GL_UNIFORM_BUFFER, m_merge.cb->byte_size, NULL, GL_DYNAMIC_DRAW); + + for(int i = 0; i < countof(m_merge.ps); i++) + CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge.ps[i]); + + m_merge.bs->m_enable = true; + m_merge.bs->m_equation_RGB = GL_FUNC_ADD; + m_merge.bs->m_equation_ALPHA = GL_FUNC_ADD; + m_merge.bs->m_func_sRGB = GL_SRC_ALPHA; + m_merge.bs->m_func_dRGB = GL_ONE_MINUS_SRC_ALPHA; + m_merge.bs->m_func_sALPHA = GL_ONE; + m_merge.bs->m_func_dALPHA = GL_ZERO; + + // **************************************************************** + // interlace + // **************************************************************** + m_interlace.cb->index = 2; + m_interlace.cb->byte_size = sizeof(InterlaceConstantBuffer); + glGenBuffers(1, &m_interlace.cb->buffer); + glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); + glBufferData(GL_UNIFORM_BUFFER, m_interlace.cb->byte_size, NULL, GL_DYNAMIC_DRAW); + + for(int i = 0; i < countof(m_interlace.ps); i++) + CompileShaderFromSource("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_interlace.ps[i]); + + // **************************************************************** + // rasterization configuration + // **************************************************************** + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDisable(GL_CULL_FACE); + glEnable(GL_SCISSOR_TEST); + // FIXME enable it when multisample code will be here + // DX: rd.MultisampleEnable = true; + glDisable(GL_MULTISAMPLE); + // Hum I don't know for those options but let's hope there are not activated +#if 0 + rd.FrontCounterClockwise = false; + rd.DepthBias = false; + rd.DepthBiasClamp = 0; + rd.SlopeScaledDepthBias = 0; + rd.DepthClipEnable = false; // ??? + rd.AntialiasedLineEnable = false; +#endif + + GSVector4i rect = wnd->GetClientRect(); + Reset(rect.z, rect.w); + +#if 0 + HRESULT hr = E_FAIL; + + DXGI_SWAP_CHAIN_DESC scd; + D3D11_BUFFER_DESC bd; + D3D11_SAMPLER_DESC sd; + D3D11_DEPTH_STENCIL_DESC dsd; + D3D11_RASTERIZER_DESC rd; + D3D11_BLEND_DESC bsd; + + memset(&scd, 0, sizeof(scd)); + + scd.BufferCount = 2; + scd.BufferDesc.Width = 1; + scd.BufferDesc.Height = 1; + scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + //scd.BufferDesc.RefreshRate.Numerator = 60; + //scd.BufferDesc.RefreshRate.Denominator = 1; + scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + scd.OutputWindow = (HWND)m_wnd->GetHandle(); + scd.SampleDesc.Count = 1; + scd.SampleDesc.Quality = 0; + + // Always start in Windowed mode. According to MS, DXGI just "prefers" this, and it's more or less + // required if we want to add support for dual displays later on. The fullscreen/exclusive flip + // will be issued after all other initializations are complete. + + scd.Windowed = TRUE; + + // NOTE : D3D11_CREATE_DEVICE_SINGLETHREADED + // This flag is safe as long as the DXGI's internal message pump is disabled or is on the + // same thread as the GS window (which the emulator makes sure of, if it utilizes a + // multithreaded GS). Setting the flag is a nice and easy 5% speedup on GS-intensive scenes. + + uint32 flags = D3D11_CREATE_DEVICE_SINGLETHREADED; + +#ifdef DEBUG + flags |= D3D11_CREATE_DEVICE_DEBUG; +#endif + + D3D_FEATURE_LEVEL level; + + const D3D_FEATURE_LEVEL levels[] = + { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + }; + + hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, levels, countof(levels), D3D11_SDK_VERSION, &scd, &m_swapchain, &m_dev, &level, &m_ctx); + // hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, flags, NULL, 0, D3D11_SDK_VERSION, &scd, &m_swapchain, &m_dev, &level, &m_ctx); +#endif + + // **************************************************************** + // The check of capability is done when context is created on openGL + // For the moment don't bother with extension, I just ask the most recent openGL version + // **************************************************************** +#if 0 + if(FAILED(hr)) return false; + + if(!SetFeatureLevel(level, true)) + { + return false; + } + + D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS options; + + hr = m_dev->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &options, sizeof(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS)); + + // msaa + + for(uint32 i = 2; i <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; i++) + { + uint32 quality[2] = {0, 0}; + + if(SUCCEEDED(m_dev->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, i, &quality[0])) && quality[0] > 0 + && SUCCEEDED(m_dev->CheckMultisampleQualityLevels(DXGI_FORMAT_D32_FLOAT_S8X24_UINT, i, &quality[1])) && quality[1] > 0) + { + m_msaa_desc.Count = i; + m_msaa_desc.Quality = std::min(quality[0] - 1, quality[1] - 1); + + if(i >= m_msaa) break; + } + } + + if(m_msaa_desc.Count == 1) + { + m_msaa = 0; + } +#endif + + // TODO Later + // **************************************************************** + // fxaa + // **************************************************************** +#if 0 + + memset(&bd, 0, sizeof(bd)); + + bd.ByteWidth = sizeof(FXAAConstantBuffer); + bd.Usage = D3D11_USAGE_DEFAULT; + bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + + hr = m_dev->CreateBuffer(&bd, NULL, &m_fxaa.cb); + + hr = CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps); +#endif + + + // TODO later +#if 0 + CreateTextureFX(); + + // + + memset(&dsd, 0, sizeof(dsd)); + + dsd.DepthEnable = false; + dsd.StencilEnable = true; + dsd.StencilReadMask = 1; + dsd.StencilWriteMask = 1; + dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + dsd.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + dsd.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + + m_dev->CreateDepthStencilState(&dsd, &m_date.dss); + + D3D11_BLEND_DESC blend; + + memset(&blend, 0, sizeof(blend)); + + m_dev->CreateBlendState(&blend, &m_date.bs); +#endif } bool GSDeviceOGL::Reset(int w, int h) { - // Hum map, m_backbuffer to a GSTexture + if(!GSDevice::Reset(w, h)) + return false; + + // TODO + // Opengl allocate the backbuffer with the window. The render is done in the backbuffer when + // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done + // in the backbuffer + m_backbuffer = new GSTextureOGL(0, w, h, false, 0); + +#if 0 + if(m_swapchain) + { + DXGI_SWAP_CHAIN_DESC scd; + + memset(&scd, 0, sizeof(scd)); + + m_swapchain->GetDesc(&scd); + m_swapchain->ResizeBuffers(scd.BufferCount, w, h, scd.BufferDesc.Format, 0); + + CComPtr backbuffer; + + if(FAILED(m_swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&backbuffer))) + { + return false; + } + + m_backbuffer = new GSTexture11(backbuffer); + } +#endif + + return true; } -// Swap buffer (back buffer, front buffer) -// Warning it is not OGL dependent but application dependant (glx and so not portable) -void GSDeviceOGL::Flip() { /* TODO */ } +void GSDeviceOGL::Flip() +{ + // Warning it is not OGL dependent but application dependant (glx and so not portable) +#if SDL_VERSION_ATLEAST(1,3,0) + SDL_GL_SwapWindow(m_window); +#else + SDL_GL_SwapBuffers(); +#endif -// glDrawArrays -void GSDeviceOGL::DrawPrimitive() { /* TODO */ } +} -// Just a wrapper around glClear* functions -void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { /* TODO */ } -void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) { /* TODO */ } -void GSDeviceOGL::ClearDepth(GSTexture* t, float c) { /* TODO */ } -void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) { /* TODO */ } +void GSDeviceOGL::DrawPrimitive() +{ + glDrawArrays(m_state.topology, m_vertices.start, m_vertices.count); +} -// the 4 next functions are only used to set some default value for the format. -// Need to find the default format... -// depth_stencil => GL_DEPTH32F_STENCIL8 -// others => (need 4* 8bits unsigned normalized integer) (GL_RGBA8 ) -GSTexture* GSDeviceOGL::CreateRenderTarget(int w, int h, bool msaa, int format) { /* TODO */ } -GSTexture* GSDeviceOGL::CreateDepthStencil(int w, int h, bool msaa, int format) { /* TODO */ } -GSTexture* GSDeviceOGL::CreateTexture(int w, int h, int format) { /* TODO */ } -GSTexture* GSDeviceOGL::CreateOffscreen(int w, int h, int format) { /* TODO */ } +void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) +{ + GSTextureOGL* t_ogl = (GSTextureOGL*)t; + // FIXME I need to clarify this FBO attachment stuff + // I would like to avoid FBO for a basic clean operation + //glClearBufferfv(GL_COLOR, t_ogl->attachment(), c.v); +} + +void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) +{ + GSTextureOGL* t_ogl = (GSTextureOGL*)t; + GSVector4 color = GSVector4::rgba32(c) * (1.0f / 255); + // FIXME I need to clarify this FBO attachment stuff + // I would like to avoid FBO for a basic clean operation + //glClearBufferfv(GL_COLOR, t_ogl->attachment(), color.v); +} + +void GSDeviceOGL::ClearDepth(GSTexture* t, float c) +{ + glClearBufferfv(GL_DEPTH, 0, &c); +} + +void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) +{ + GLint color = c; + glClearBufferiv(GL_STENCIL, 0, &color); +} + +GSTexture* GSDeviceOGL::CreateRenderTarget(int w, int h, bool msaa, int format) +{ + return GSDevice::CreateRenderTarget(w, h, msaa, format ? format : GL_RGBA8); +} + +GSTexture* GSDeviceOGL::CreateDepthStencil(int w, int h, bool msaa, int format) +{ + return GSDevice::CreateDepthStencil(w, h, msaa, format ? format : GL_DEPTH32F_STENCIL8); +} + +GSTexture* GSDeviceOGL::CreateTexture(int w, int h, int format) +{ + return GSDevice::CreateTexture(w, h, format ? format : GL_RGBA8); +} + +GSTexture* GSDeviceOGL::CreateOffscreen(int w, int h, int format) +{ + return GSDevice::CreateOffscreen(w, h, format ? format : GL_RGBA8); +} // blit a texture into an offscreen buffer GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format) { + // I'm not sure about the object type for offscreen buffer + // TODO later; + assert(0); + // Need to find format equivalent. Then I think it will be straight forward // A four-component, 32-bit unsigned-normalized-integer format that supports 8 bits per channel including alpha. @@ -167,34 +553,49 @@ GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w // From a sub-part to a full texture void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) { -#if 0 if(!st || !dt) { ASSERT(0); return; } - D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; + assert(0); + // FIXME attach the texture to the FBO + GSTextureOGL* st_ogl = (GSTextureOGL*) st; + GSTextureOGL* dt_ogl = (GSTextureOGL*) dt; + dt_ogl->Attach(GL_COLOR_ATTACHMENT0); + st_ogl->Attach(GL_COLOR_ATTACHMENT1); + glReadBuffer(GL_COLOR_ATTACHMENT1); + // FIXME I'not sure how to select the destination + // const GLenum draw_buffer[1] = { GL_COLOR_ATTACHMENT0 }; + // glDrawBuffers(draw_buffer); + dt_ogl->EnableUnit(0); + // FIXME need acess of target and it probably need to be same for both + //glCopyTexSubImage2D(dt_ogl.m_texture_target, 0, 0, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom); + // FIXME I'm not sure GL_TEXTURE_RECTANGLE is supported!!! + //glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom); +#if 0 + D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, 0, 0, 0, *(GSTexture11*)st, 0, &box); #endif } - -// Raster flow to resize a texture -// Note just call the StretchRect hardware accelerated void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear) { - /* TODO */ + StretchRect(st, sr, dt, dr, m_convert.ps[shader], NULL, linear); } + void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear) { - // TODO + StretchRect(st, sr, dt, dr, ps, ps_cb, m_convert.bs, linear); } // probably no difficult to convert when all helpers function will be done -void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL ps_cb, GSBlendStateOGL* bs, bool linear) +void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, GSBlendStateOGL* bs, bool linear) { + //TODO later + assert(0); #if 0 if(!st || !dt) { @@ -259,7 +660,6 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c) { -#if 0 ClearRenderTarget(dt, c); if(st[1] && !slbg) @@ -269,16 +669,20 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect if(st[0]) { + if (m_state.cb != m_merge.cb->buffer) { + m_state.cb = m_merge.cb->buffer; + glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); + } + glBufferSubData(GL_UNIFORM_BUFFER, 0, m_merge.cb->byte_size, &c.v); +#if 0 m_ctx->UpdateSubresource(m_merge.cb, 0, NULL, &c, 0, 0); - +#endif StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.cb, m_merge.bs, true); } -#endif } void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) { -#if 0 GSVector4 s = GSVector4(dt->GetSize()); GSVector4 sr(0, 0, 1, 1); @@ -289,18 +693,25 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin cb.ZrH = GSVector2(0, 1.0f / s.y); cb.hH = s.y / 2; + if (m_state.cb != m_interlace.cb->buffer) { + m_state.cb = m_interlace.cb->buffer; + glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); + } + // FIXME I'm not sure it will be happy with InterlaceConstantBuffer type + glBufferSubData(GL_UNIFORM_BUFFER, 0, m_interlace.cb->byte_size, &cb); +#if 0 m_ctx->UpdateSubresource(m_interlace.cb, 0, NULL, &cb, 0, 0); +#endif StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); -#endif } // copy a multisample texture to a non-texture multisample. On opengl you need 2 FBO with different level of // sample and then do a blit. Headach expected to for the moment just drop MSAA... GSTexture* GSDeviceOGL::Resolve(GSTexture* t) { -#if 0 ASSERT(t != NULL && t->IsMSAA()); +#if 0 if(GSTexture* dst = CreateRenderTarget(t->GetWidth(), t->GetHeight(), false, t->GetFormat())) { @@ -323,151 +734,78 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t if(count * stride > m_vertices.limit * m_vertices.stride) { // Current GPU buffer is too small need to realocate a new one -#if 0 - m_vb_old = m_vb; - m_vb = NULL; + if (m_vb) { + glDeleteBuffers(1, &m_vb); + m_vb = 0; + } m_vertices.start = 0; m_vertices.count = 0; m_vertices.limit = std::max(count * 3 / 2, 11000); -#endif } - if(m_vb == NULL) + if(!m_vb) { - // Allocate a GPU buffer: GL_DYNAMIC_DRAW vs GL_STREAM_DRAW !!! - // glBufferData(GL_ARRAY_BUFFER, m_vertices.limit, NULL, GL_DYNAMIC_DRAW) -#if 0 - D3D11_BUFFER_DESC bd; - - memset(&bd, 0, sizeof(bd)); - - bd.Usage = D3D11_USAGE_DYNAMIC; - bd.ByteWidth = m_vertices.limit * stride; - bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - - HRESULT hr; - - hr = m_dev->CreateBuffer(&bd, NULL, &m_vb); - - if(FAILED(hr)) return; -#endif + glGenBuffers(1, &m_vb); + // FIXME: GL_DYNAMIC_DRAW vs GL_STREAM_DRAW !!! + glBindBuffer(GL_ARRAY_BUFFER, m_vb); + glBufferData(GL_ARRAY_BUFFER, m_vertices.limit, NULL, GL_DYNAMIC_DRAW); } // append data or go back to the beginning // Hum why we don't always go back to the beginning !!! -#if 0 - D3D11_MAP type = D3D11_MAP_WRITE_NO_OVERWRITE; - if(m_vertices.start + count > m_vertices.limit || stride != m_vertices.stride) - { m_vertices.start = 0; - type = D3D11_MAP_WRITE_DISCARD; - } -#endif - // Allocate the buffer // glBufferSubData -#if 0 - D3D11_MAPPED_SUBRESOURCE m; - - if(SUCCEEDED(m_ctx->Map(m_vb, 0, type, 0, &m))) - { - GSVector4i::storent((uint8*)m.pData + m_vertices.start * stride, vertices, count * stride); - - m_ctx->Unmap(m_vb, 0); - } -#endif + glBufferSubData(GL_ARRAY_BUFFER, m_vertices.start * stride, count * stride, vertices); m_vertices.count = count; m_vertices.stride = stride; - -// Useless ? -// binding of the buffer must be done anyway before glBufferSubData or glBufferData calls. -#if 0 - IASetVertexBuffer(m_vb, stride); -#endif } -// Useless ? -#if 0 -void GSDeviceOGL::IASetVertexBuffer(GLuint vb, size_t stride) -{ - if(m_state.vb != vb || m_state.vb_stride != stride) - { - m_state.vb = vb; - m_state.vb_stride = stride; - - uint32 stride2 = stride; - uint32 offset = 0; - - m_ctx->IASetVertexBuffers(0, 1, &vb, &stride2, &offset); - } -} -#endif - -// Useless ? -#if 0 -void GSDeviceOGL::IASetInputLayout(ID3D11InputLayout* layout) +void GSDeviceOGL::IASetInputLayout(GSInputLayout* layout, int layout_nbr) { if(m_state.layout != layout) { m_state.layout = layout; - m_ctx->IASetInputLayout(layout); + for (int i = 0; i < layout_nbr; i++) + glVertexAttribPointer(layout->index, layout->size, layout->type, GL_FALSE, layout->stride, layout->offset); } } -#endif -// Useless ? -#if 0 void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) { if(m_state.topology != topology) { m_state.topology = topology; - - m_ctx->IASetPrimitiveTopology(topology); } } -#endif void GSDeviceOGL::VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb) { - // glUseProgramStage -#if 0 if(m_state.vs != vs) { m_state.vs = vs; - - m_ctx->VSSetShader(vs, NULL, 0); + glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs); } -#endif - // glBindBufferBase -#if 0 if(m_state.vs_cb != vs_cb) { m_state.vs_cb = vs_cb; - - m_ctx->VSSetConstantBuffers(0, 1, &vs_cb); + glBindBufferBase(GL_UNIFORM_BUFFER, vs_cb->index, vs_cb->buffer); } -#endif } void GSDeviceOGL::GSSetShader(GLuint gs) { - // glUseProgramStage -#if 0 if(m_state.gs != gs) { m_state.gs = gs; - - m_ctx->GSSetShader(gs, NULL, 0); + glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs); } -#endif } void GSDeviceOGL::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) @@ -479,10 +817,9 @@ void GSDeviceOGL::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr) { -#if 0 - ID3D11ShaderResourceView* srv = NULL; + GSTextureOGL* srv = NULL; - if(sr) srv = *(GSTexture11*)sr; + if(sr) srv = (GSTextureOGL*)sr; if(m_state.ps_srv[i] != srv) { @@ -490,12 +827,10 @@ void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr) m_srv_changed = true; } -#endif } void GSDeviceOGL::PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2) { -#if 0 if(m_state.ps_ss[0] != ss0 || m_state.ps_ss[1] != ss1 || m_state.ps_ss[2] != ss2) { m_state.ps_ss[0] = ss0; @@ -504,21 +839,16 @@ void GSDeviceOGL::PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2) m_ss_changed = true; } -#endif } void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) { - // glUseProgramStage -#if 0 if(m_state.ps != ps) { m_state.ps = ps; - - m_ctx->PSSetShader(ps, NULL, 0); + glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps); } -#endif // Sampler and texture must be set at the same time // 1/ select the texture unit @@ -529,6 +859,12 @@ void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) // glUniform1i(brickSamplerId , 1); // 4/ set the sampler state // glBindSampler(1 , sampler); + if (m_srv_changed || m_ss_changed) { + for (uint i=0 ; i < 3; i++) { + m_state.ps_srv[i]->EnableUnit(i); + glBindSampler(i, m_state.ps_ss[i]); + } + } #if 0 if (m_srv_changed) { @@ -545,29 +881,36 @@ void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) } #endif - // glBindBufferBase -#if 0 if(m_state.ps_cb != ps_cb) { m_state.ps_cb = ps_cb; - - m_ctx->PSSetConstantBuffers(0, 1, &ps_cb); + glBindBufferBase(GL_UNIFORM_BUFFER, ps_cb->index, ps_cb->buffer); } -#endif } void GSDeviceOGL::OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref) { - // Setup the stencil object. sref can be set by glStencilFunc (note remove it from the structure) -#if 0 + uint ref = sref; + if(m_state.dss != dss || m_state.sref != sref) { m_state.dss = dss; m_state.sref = sref; - m_ctx->OMSetDepthStencilState(dss, sref); + if (dss->m_depth_enable) { + glEnable(GL_DEPTH_TEST); + glDepthFunc(dss->m_depth_func); + glDepthMask(dss->m_depth_mask); + } else + glDisable(GL_DEPTH_TEST); + + if (dss->m_stencil_enable) { + glEnable(GL_STENCIL_TEST); + glStencilFunc(dss->m_stencil_func, ref, dss->m_stencil_mask); + glStencilOp(dss->m_stencil_sfail_op, dss->m_stencil_spass_dfail_op, dss->m_stencil_spass_dpass_op); + } else + glDisable(GL_STENCIL_TEST); } -#endif } void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) @@ -575,23 +918,26 @@ void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) // DX:Blend factor D3D11_BLEND_BLEND_FACTOR | D3D11_BLEND_INV_BLEND_FACTOR // OPENGL: GL_CONSTANT_COLOR | GL_ONE_MINUS_CONSTANT_COLOR // Note factor must be set before by glBlendColor -#if 0 if(m_state.bs != bs || m_state.bf != bf) { m_state.bs = bs; m_state.bf = bf; - float BlendFactor[] = {bf, bf, bf, 0}; + // FIXME: double check when blend stuff is complete + if (bs->m_func_sRGB == GL_CONSTANT_COLOR || bs->m_func_sRGB == GL_ONE_MINUS_CONSTANT_COLOR + || bs->m_func_dRGB == GL_CONSTANT_COLOR || bs->m_func_dRGB == GL_ONE_MINUS_CONSTANT_COLOR) + glBlendColor(bf, bf, bf, 0); - m_ctx->OMSetBlendState(bs, BlendFactor, 0xffffffff); + glBlendEquationSeparate(bs->m_equation_RGB, bs->m_equation_ALPHA); + glBlendFuncSeparate(bs->m_func_sRGB, bs->m_func_dRGB, bs->m_func_sALPHA, bs->m_func_dALPHA); } -#endif } void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor) { - // set the attachment inside the FBO - + // attach render&depth to the FBO + // Hum, need to separate 2 case, Render target fbo and render target backbuffer + // Or maybe blit final result to the backbuffer #if 0 ID3D11RenderTargetView* rtv = NULL; ID3D11DepthStencilView* dsv = NULL; @@ -607,37 +953,98 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto m_ctx->OMSetRenderTargets(1, &rtv, dsv); } #endif + GSTextureOGL* rt_ogl = (GSTextureOGL*)rt; + GSTextureOGL* ds_ogl = (GSTextureOGL*)ds; + + if (m_backbuffer == rt_ogl) { + if (m_state.fbo) { + m_state.fbo = 0; + glBindFramebuffer(GL_FRAMEBUFFER, 0); // render in the backbuffer + } + + assert(ds_ogl == NULL); // no depth-stencil without FBO + } else { + if (m_state.fbo != m_fbo) { + m_state.fbo = m_fbo; + glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); + } + + assert(rt_ogl != NULL); // a render target must exists + rt_ogl->Attach(GL_COLOR_ATTACHMENT0); + if (ds_ogl != NULL) + ds_ogl->Attach(GL_DEPTH_STENCIL_ATTACHMENT); + } // Viewport -> glViewport -#if 0 if(m_state.viewport != rt->GetSize()) { m_state.viewport = rt->GetSize(); - - D3D11_VIEWPORT vp; - - memset(&vp, 0, sizeof(vp)); - - vp.TopLeftX = 0; - vp.TopLeftY = 0; - vp.Width = (float)rt->GetWidth(); - vp.Height = (float)rt->GetHeight(); - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - - m_ctx->RSSetViewports(1, &vp); + glViewport(0, 0, rt->GetWidth(), rt->GetHeight()); } -#endif // Scissor -> glScissor (note must be enabled) -#if 0 GSVector4i r = scissor ? *scissor : GSVector4i(rt->GetSize()).zwxy(); if(!m_state.scissor.eq(r)) { m_state.scissor = r; - + // FIXME check position + glScissor(r.x, r.w, r.z-r.x, r.y-r.w); +#if 0 m_ctx->RSSetScissorRects(1, r); - } #endif + } +} + +void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program) +{ + // Could be useful to filter ubber shader + std::string shader_type; + switch (type) { + case GL_VERTEX_SHADER: + shader_type = "#define VERTEX_SHADER 1\n"; + case GL_GEOMETRY_SHADER: + shader_type = "#define GEOMETRY_SHADER 1\n"; + case GL_FRAGMENT_SHADER: + shader_type = "#define FRAGMENT_SHADER 1\n"; + } + + // Select the entry point + std::string entry_main = format("#define %s main\n", entry.c_str()); + + // Read the source file + std::string source; + std::string line; + // Each linux distributions have his rules for path so we give them the possibility to + // change it with compilation flags. -- Gregory +#ifdef PLUGIN_DIR_COMPILATION +#define xPLUGIN_DIR_str(s) PLUGIN_DIR_str(s) +#define PLUGIN_DIR_str(s) #s + const std::string shader_file = string(xPLUGIN_DIR_str(PLUGIN_DIR_COMPILATION)) + '/' + glsl_file; +#else + const std::string shader_file = string("plugins/") + glsl_file; +#endif + std::ifstream myfile(shader_file.c_str()); + if (myfile.is_open()) { + while ( myfile.good() ) + { + getline (myfile,line); + source += line; + source += '\n'; + } + myfile.close(); + } else { + fprintf(stderr, "Error opening %s: ", shader_file.c_str()); + } + + // Create a giant string with everythings + std::string full_source = shader_type + entry_main + source; + + char* sources = (char*)malloc(full_source.size()); + strncpy(sources, full_source.c_str(), full_source.size()); + sources[full_source.size()] = '\0'; + + *program = glCreateShaderProgramv(type, 1, (const char**)&sources); + + free(sources); } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index a18d2c3156..e6dd1288ef 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -21,9 +21,11 @@ #pragma once +#include #include "GSDevice.h" #include "GSTextureOGL.h" #include "GSdx.h" +#include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" struct GSBlendStateOGL { // Note: You can also select the index of the draw buffer for which to set the blend setting @@ -31,13 +33,16 @@ struct GSBlendStateOGL { bool m_enable; GLenum m_equation_RGB; GLenum m_equation_ALPHA; - GLenum m_func_RGB; - GLenum m_func_ALPHA; + GLenum m_func_sRGB; + GLenum m_func_dRGB; + GLenum m_func_sALPHA; + GLenum m_func_dALPHA; }; struct GSDepthStencilOGL { bool m_depth_enable; GLenum m_depth_func; + GLboolean m_depth_mask; // Note front face and back can be split might. But it seems they have same parameter configuration bool m_stencil_enable; GLuint m_stencil_mask; @@ -49,43 +54,46 @@ struct GSDepthStencilOGL { }; struct GSUniformBufferOGL { - GLuint buffer; - GLuint index; + GLuint buffer; // data object + GLuint index; // GLSL slot + uint byte_size; // size of the data +}; + +struct GSInputLayout { + GLuint index; + GLint size; + GLenum type; + GLsizei stride; + const GLvoid* offset; }; class GSDeviceOGL : public GSDevice { - uint32 m_msaa; + uint32 m_msaa; // Level of Msaa - // Vertex buffer: glGenBuffers, glBindBuffer GL_ARRAY_BUFFER - GLuint m_vb; // buffer object + bool m_free_window; + SDL_Window* m_window; // pointer to the SDL window + + GLuint m_vb; // vertex buffer object + GLuint m_pipeline; // pipeline to attach program shader + GLuint m_fbo; // frame buffer container struct { - GLuint ps[2]; // program object - GSUniformBufferOGL* cb; // uniform buffer object + GLuint ps[2]; // program object + GSUniformBufferOGL* cb; // uniform buffer object GSBlendStateOGL* bs; } m_merge; struct { - GLuint ps[4]; // program object + GLuint ps[4]; // program object GSUniformBufferOGL* cb; // uniform buffer object } m_interlace; - //struct - //{ - // CComPtr il; - // CComPtr vs; // program object - // CComPtr ps[8]; // program object - // CComPtr ln; - // CComPtr pt; - // CComPtr dss; - // CComPtr bs; // no equivalent - //} m_convert; - struct - { + struct { // Hum I think this one is useless. As far as I understand // it only get the index name of GLSL-equivalent input attribut // ??? CComPtr il; + GSInputLayout il[2]; // description of the vertex array GLuint vs; // program object GLuint ps[8]; // program object GLuint ln; // sampler object @@ -94,11 +102,6 @@ class GSDeviceOGL : public GSDevice GSBlendStateOGL* bs; } m_convert; - // struct - // { - // CComPtr dss; - // CComPtr bs; - // } m_date; struct { GSDepthStencilOGL* dss; @@ -133,8 +136,10 @@ class GSDeviceOGL : public GSDevice // Hum I think those things can be dropped on OGL. It probably need an others architecture (see glVertexAttribPointer) // size_t vb_stride; // ID3D11InputLayout* layout; + GSInputLayout* layout; GLenum topology; // (ie GL_TRIANGLES...) GLuint vs; // program + GLuint cb; // uniform current buffer GSUniformBufferOGL* vs_cb; // uniform buffer GLuint gs; // program // FIXME texture binding. Maybe not equivalent for the state but the best I could find. @@ -152,6 +157,9 @@ class GSDeviceOGL : public GSDevice // FIXME texture attachment in the FBO // ID3D11RenderTargetView* rtv; // ID3D11DepthStencilView* dsv; + GSTextureOGL* rtv; + GSTextureOGL* dsv; + GLuint fbo; } m_state; bool m_srv_changed; @@ -219,11 +227,15 @@ class GSDeviceOGL : public GSDevice void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r); void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL ps_cb, GSBlendStateOGL* bs, bool linear); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear = true); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, GSBlendStateOGL* bs, bool linear = true); GSTexture* Resolve(GSTexture* t); + void CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program); + + void IASetPrimitiveTopology(GLenum topology); + void IASetInputLayout(GSInputLayout* layout, int layout_nbr); void IASetVertexBuffer(const void* vertices, size_t stride, size_t count); void VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb); diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 7384a76a2a..5cc66831e9 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -42,13 +42,12 @@ static void SysMessage(const char *fmt, ...) bool RunLinuxDialog() { - // FIXME need to add msaa option configuration GtkWidget *dialog; GtkWidget *main_frame, *main_box; GtkWidget *render_label, *render_combo_box; GtkWidget *interlace_label, *interlace_combo_box; GtkWidget *swthreads_label, *swthreads_text; - GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *win_check; + GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *win_check, *msaa_check; int return_value; /* Create the widgets */ @@ -134,6 +133,7 @@ bool RunLinuxDialog() fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)"); aa_check = gtk_check_button_new_with_label("Edge anti-aliasing"); win_check = gtk_check_button_new_with_label("Disable Effects Processing"); + msaa_check = gtk_check_button_new_with_label("Enable MultiSample AA (not yet implemented)"); gtk_container_add(GTK_CONTAINER(main_box), filter_check); gtk_container_add(GTK_CONTAINER(main_box), logz_check); @@ -141,6 +141,7 @@ bool RunLinuxDialog() gtk_container_add(GTK_CONTAINER(main_box), fba_check); gtk_container_add(GTK_CONTAINER(main_box), aa_check); gtk_container_add(GTK_CONTAINER(main_box), win_check); + gtk_container_add(GTK_CONTAINER(main_box), msaa_check); // Filter should be 3 states, not 2. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filter_check), theApp.GetConfig("filter", 1)); @@ -149,6 +150,7 @@ bool RunLinuxDialog() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win_check), theApp.GetConfig("windowed", 1)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msaa_check), theApp.GetConfig("msaa", 0)); gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); gtk_widget_show_all (dialog); @@ -188,6 +190,7 @@ bool RunLinuxDialog() theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); theApp.SetConfig("windowed", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win_check))); + theApp.SetConfig("msaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msaa_check))); gtk_widget_destroy (dialog); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index d1b0eb5912..ebc782440f 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -23,7 +23,8 @@ #include "GSTextureOGL.h" -GSTextureOGL::GSTextureOGL(/* ID3D11Texture2D* texture */ ) +GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) + : m_texture_unit(0) { // ************************************************************* // Opengl world @@ -63,6 +64,12 @@ GSTextureOGL::GSTextureOGL(/* ID3D11Texture2D* texture */ ) // : m_type // : m_format // : m_msaa + m_size.x = w; + m_size.y = h; + m_format = format; + m_type = type; + m_msaa = msaa; + // == Might be useful to save // : m_texture_target (like GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE etc...) // : m_texture_id (return by glGen*) @@ -81,30 +88,68 @@ GSTextureOGL::GSTextureOGL(/* ID3D11Texture2D* texture */ ) // glGetTexImage: read pixels of a bound texture // => To allow map/unmap. I think we can use a pixel buffer (target GL_PIXEL_UNPACK_BUFFER) // http://www.opengl.org/wiki/Pixel_Buffer_Objects - // == Enable texture Unit - // EnableUnit(); - // == Allocate space - // glRenderbufferStorageMultisample or glTexStorage2D + // Generate the buffer + switch (m_type) { + case GSTexture::RenderTarget: + // FIXME what is the real use case of this texture + // Maybe a texture will be better + glGenRenderbuffers(1, &m_texture_id); + m_texture_target = GL_RENDERBUFFER; + break; + case GSTexture::DepthStencil: + glGenRenderbuffers(1, &m_texture_id); + m_texture_target = GL_RENDERBUFFER; + break; + case GSTexture::Texture: + glGenTextures(1, &m_texture_id); + // FIXME, do we need rectangle (or better to use 2D texture) + //m_texture_target = GL_TEXTURE_2D; + m_texture_target = GL_TEXTURE_RECTANGLE; + // == For texture, the Unit must be selected + break; + case GSTexture::Offscreen: + //FIXME I not sure we need a pixel buffer object. It seems more a texture + // glGenBuffers(1, &m_texture_id); + // m_texture_target = GL_PIXEL_UNPACK_BUFFER; + assert(0); + // Note there is also a buffer texture!!! + // http://www.opengl.org/wiki/Buffer_Texture + // Note: in this case it must use in GLSL + // gvec texelFetch(gsampler sampler, ivec texCoord, int lod[, int sample]); + // corollary we can maybe use it for multisample stuff + break; + default: break; + } -#if 0 - m_texture->GetDevice(&m_dev); - m_texture->GetDesc(&m_desc); + uint msaa_level; + if (m_msaa) { + // FIXME which level of MSAA + msaa_level = 1; + } else { + msaa_level = 0; + } - m_dev->GetImmediateContext(&m_ctx); - - m_size.x = (int)m_desc.Width; - m_size.y = (int)m_desc.Height; - - if(m_desc.BindFlags & D3D11_BIND_RENDER_TARGET) m_type = RenderTarget; - else if(m_desc.BindFlags & D3D11_BIND_DEPTH_STENCIL) m_type = DepthStencil; - else if(m_desc.BindFlags & D3D11_BIND_SHADER_RESOURCE) m_type = Texture; - else if(m_desc.Usage == D3D11_USAGE_STAGING) m_type = Offscreen; - - m_format = (int)m_desc.Format; - - m_msaa = m_desc.SampleDesc.Count > 1; -#endif + // Allocate the buffer + switch (m_type) { + case GSTexture::RenderTarget: + case GSTexture::DepthStencil: + glBindRenderbuffer(m_texture_target, m_texture_id); + glRenderbufferStorageMultisample(m_texture_target, msaa_level, m_format, m_size.y, m_size.x); + break; + case GSTexture::Texture: + // FIXME + // Howto allocate the texture unit !!! + // In worst case the HW renderer seems to use 3 texture unit + // For the moment SW renderer only use 1 so don't bother + EnableUnit(0); + glTexStorage2D_glew17(m_texture_target, 0, m_format, m_size.y, m_size.x); + break; + case GSTexture::Offscreen: + assert(0); + break; + default: break; + } } GSTextureOGL::~GSTextureOGL() @@ -112,28 +157,36 @@ GSTextureOGL::~GSTextureOGL() // glDeleteTextures or glDeleteRenderbuffers } -void GSTextureOGL::EnableUnit() +void GSTextureOGL::Attach(GLenum attachment) { - // == For texture, the Unit must be selected - // glActiveTexture - // !!!!!!!!!! VERY BIG ISSUE, how to ensure that the different texture use different texture unit. - // I think we need to create a pool on GSdevice. - // 1/ this->m_device_ogl - // 2/ int GSDeviceOGL::get_free_texture_unit() called from GSTextureOGL constructor - // 3/ void GSDeviceOGL::release_texture_unit(int) called from GSDeviceOGL destructor - // Another (better) idea, will be to create a global static pool - // - // == Bind the texture or buffer - // glBindRenderbuffer or glBindTexture - // - // !!!!!!!!!! Maybe attach to the FBO but where to manage the FBO!!! - // Create a separare public method for attachment ??? + if (m_type == GSTexture::DepthStencil) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id); + else + glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); } bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) { // To update only a part of the texture you can use: // glTexSubImage2D — specify a two-dimensional texture subimage + switch (m_type) { + case GSTexture::Texture: + // glTexSubImage2D specifies a two-dimensional subtexture for the current texture unit, specified with glActiveTexture. + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target + //(see glBindBuffer) while a texture image is + // specified, data is treated as a byte offset into the buffer object's data store + // FIXME warning order of the y axis + // FIXME I'm not confident with GL_UNSIGNED_BYTE type + // FIXME add a state check + glBindTexture(m_texture_target, m_texture_id); + glTexSubImage2D(m_texture_target, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom, m_format, GL_UNSIGNED_BYTE, data); + break; + case GSTexture::RenderTarget: + case GSTexture::DepthStencil: + case GSTexture::Offscreen: + assert(0); + break; + } #if 0 if(m_dev && m_texture) { @@ -148,6 +201,25 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) #endif } +void GSTextureOGL::EnableUnit(uint unit) +{ + switch (m_type) { + case GSTexture::RenderTarget: + case GSTexture::DepthStencil: + case GSTexture::Offscreen: + assert(0); + break; + case GSTexture::Texture: + // FIXME + // Howto allocate the texture unit !!! + // In worst case the HW renderer seems to use 3 texture unit + // For the moment SW renderer only use 1 so don't bother + glActiveTexture(GL_TEXTURE0 + unit); + glBindTexture(m_texture_target, m_texture_id); + break; + } +} + bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) { // The function allow to modify the texture from the CPU @@ -156,6 +228,8 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) // I think in opengl we need to copy back the data to the RAM: glReadPixels — read a block of pixels from the frame buffer // // glMapBuffer — map a buffer object's data store + // Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER + return false; #if 0 if(r != NULL) { diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 6df0d212dc..f2d66b3c8c 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -28,16 +28,17 @@ class GSTextureOGL : public GSTexture private: GLenum m_texture_target; // texture target: 2D, rectangle etc... GLuint m_texture_id; // the texture id - int m_texture_unit; // the texture unit offset - - void EnableUnit(); + uint m_texture_unit; // the texture unit offset public: - explicit GSTextureOGL(); + explicit GSTextureOGL(int type, int w, int h, bool msaa, int format); virtual ~GSTextureOGL(); bool Update(const GSVector4i& r, const void* data, int pitch); bool Map(GSMap& m, const GSVector4i* r = NULL); void Unmap(); bool Save(const string& fn, bool dds = false); + + void EnableUnit(uint unit); + void Attach(GLenum attachment); }; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index b306932a51..8a8633c80c 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -352,6 +352,8 @@ void GSWnd::Detach() } } +PFNGLTEXSTORAGE2DPROC glTexStorage2D_glew17 = NULL; + bool GSWnd::Create(const string& title, int w, int h) { if(m_window != NULL) return false; @@ -405,6 +407,22 @@ bool GSWnd::Create(const string& title, int w, int h) SDL_GetWindowWMInfo(m_window, &wminfo); m_Xwindow = wminfo.info.x11.window; + // OpenGL mode + // FIXME : be sure that the window is map + if ( theApp.GetConfig("renderer", 0) / 3 == 4 ) { + // FIXME...... + // GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch the function pointers. The solution is for GLEW to use glGetStringi instead. + // The current version of GLEW is 1.7.0 but they still haven't corrected it. The only fix is to use glewExperimental for now : + glewExperimental=true; + const int glew_ok = glewInit(); + if (glew_ok != GLEW_OK) + { + // FIXME:proper logging + fprintf(stderr, "Failed to init glew\n"); + return false; + } + glTexStorage2D_glew17 = (PFNGLTEXSTORAGE2DPROC)glXGetProcAddressARB((const GLubyte*)"glTexStorage2D"); + } return (m_window != NULL); } diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl new file mode 100644 index 0000000000..62adf6dbe4 --- /dev/null +++ b/plugins/GSdx/res/convert.glsl @@ -0,0 +1,142 @@ +#if 0 +struct VS_INPUT +{ + float4 p : POSITION; + float2 t : TEXCOORD0; +}; + +struct VS_OUTPUT +{ + float4 p : SV_Position; + float2 t : TEXCOORD0; +}; + +Texture2D Texture; +SamplerState TextureSampler; + +float4 sample_c(float2 uv) +{ + return Texture.Sample(TextureSampler, uv); +} + +struct PS_INPUT +{ + float4 p : SV_Position; + float2 t : TEXCOORD0; +}; + +struct PS_OUTPUT +{ + float4 c : SV_Target0; +}; + +VS_OUTPUT vs_main(VS_INPUT input) +{ + VS_OUTPUT output; + + output.p = input.p; + output.t = input.t; + + return output; +} + +PS_OUTPUT ps_main0(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = sample_c(input.t); + + return output; +} + +PS_OUTPUT ps_main7(PS_INPUT input) +{ + PS_OUTPUT output; + + float4 c = sample_c(input.t); + + c.a = dot(c.rgb, float3(0.299, 0.587, 0.114)); + + output.c = c; + + return output; +} + +float4 ps_crt(PS_INPUT input, int i) +{ + float4 mask[4] = + { + float4(1, 0, 0, 0), + float4(0, 1, 0, 0), + float4(0, 0, 1, 0), + float4(1, 1, 1, 0) + }; + + return sample_c(input.t) * saturate(mask[i] + 0.5f); +} + +uint ps_main1(PS_INPUT input) : SV_Target0 +{ + float4 c = sample_c(input.t); + + c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 + + uint4 i = c * float4(0x001f, 0x03e0, 0x7c00, 0x8000); + + return (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); +} + +PS_OUTPUT ps_main2(PS_INPUT input) +{ + PS_OUTPUT output; + + clip(sample_c(input.t).a - 128.0f / 255); // >= 0x80 pass + + output.c = 0; + + return output; +} + +PS_OUTPUT ps_main3(PS_INPUT input) +{ + PS_OUTPUT output; + + clip(127.95f / 255 - sample_c(input.t).a); // < 0x80 pass (== 0x80 should not pass) + + output.c = 0; + + return output; +} + +PS_OUTPUT ps_main4(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255; + + return output; +} + +PS_OUTPUT ps_main5(PS_INPUT input) // triangular +{ + PS_OUTPUT output; + + uint4 p = (uint4)input.p; + + // output.c = ps_crt(input, ((p.x + (p.y & 1) * 3) >> 1) % 3); + output.c = ps_crt(input, ((p.x + ((p.y >> 1) & 1) * 3) >> 1) % 3); + + return output; +} + +PS_OUTPUT ps_main6(PS_INPUT input) // diagonal +{ + PS_OUTPUT output; + + uint4 p = (uint4)input.p; + + output.c = ps_crt(input, (p.x + (p.y % 3)) % 3); + + return output; +} +#endif diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl new file mode 100644 index 0000000000..b7245a7f32 --- /dev/null +++ b/plugins/GSdx/res/interlace.glsl @@ -0,0 +1,46 @@ +#if 0 + +Texture2D Texture; +SamplerState Sampler; + +cbuffer cb0 +{ + float2 ZrH; + float hH; +}; + +struct PS_INPUT +{ + float4 p : SV_Position; + float2 t : TEXCOORD0; +}; + +float4 ps_main0(PS_INPUT input) : SV_Target0 +{ + clip(frac(input.t.y * hH) - 0.5); + + return Texture.Sample(Sampler, input.t); +} + +float4 ps_main1(PS_INPUT input) : SV_Target0 +{ + clip(0.5 - frac(input.t.y * hH)); + + return Texture.Sample(Sampler, input.t); +} + +float4 ps_main2(PS_INPUT input) : SV_Target0 +{ + float4 c0 = Texture.Sample(Sampler, input.t - ZrH); + float4 c1 = Texture.Sample(Sampler, input.t); + float4 c2 = Texture.Sample(Sampler, input.t + ZrH); + + return (c0 + c1 * 2 + c2) / 4; +} + +float4 ps_main3(PS_INPUT input) : SV_Target0 +{ + return Texture.Sample(Sampler, input.t); +} + +#endif diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl new file mode 100644 index 0000000000..74f47377ad --- /dev/null +++ b/plugins/GSdx/res/merge.glsl @@ -0,0 +1,31 @@ +#if 0 + +Texture2D Texture; +SamplerState Sampler; + +cbuffer cb0 +{ + float4 BGColor; +}; + +struct PS_INPUT +{ + float4 p : SV_Position; + float2 t : TEXCOORD0; +}; + +float4 ps_main0(PS_INPUT input) : SV_Target0 +{ + float4 c = Texture.Sample(Sampler, input.t); + c.a = min(c.a * 2, 1); + return c; +} + +float4 ps_main1(PS_INPUT input) : SV_Target0 +{ + float4 c = Texture.Sample(Sampler, input.t); + c.a = BGColor.a; + return c; +} + +#endif diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 0fb788ba93..7112ea16b6 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -113,8 +113,14 @@ using namespace stdext; #include #include +#include #include +// Need to have glew 1.7 but Debian/Ubuntu is only 1.6 +// We will see later for the upgrade +typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +extern PFNGLTEXSTORAGE2DPROC glTexStorage2D_glew17; + //using namespace __gnu_cxx; #define DIRECTORY_SEPARATOR '/' From 133847e8a233f0c84107faa7eb85f939ce06dc18 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 26 Nov 2011 11:46:51 +0000 Subject: [PATCH 04/56] gsdx-ogl: * Properly allocate/delete opengl object * Request a debug context in SDL, add some code to log opengl error * Fix context creation. For the moment only request ogl4.1 (AMD does not support yet 4.2 and it needs libglew1.7 too...) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4973 96395faa-99c1-11dd-bbfe-3dabce05a288 --- .../src/video/x11/SDL_x11opengl.c | 3 + plugins/GSdx/GSDeviceOGL.cpp | 207 ++++++++++++++++-- plugins/GSdx/GSDeviceOGL.h | 37 ++++ plugins/GSdx/GSWnd.cpp | 34 --- 4 files changed, 232 insertions(+), 49 deletions(-) diff --git a/3rdparty/SDL-1.3.0-5387/src/video/x11/SDL_x11opengl.c b/3rdparty/SDL-1.3.0-5387/src/video/x11/SDL_x11opengl.c index f424615642..2c6e2e7b3b 100644 --- a/3rdparty/SDL-1.3.0-5387/src/video/x11/SDL_x11opengl.c +++ b/3rdparty/SDL-1.3.0-5387/src/video/x11/SDL_x11opengl.c @@ -410,6 +410,9 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) _this->gl_config.major_version, GLX_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version, + //FIXME GREGORY + // Request a debug context to ease opengl development + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, 0 }; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 05fcd3feb6..c0ba73f696 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -31,22 +31,22 @@ // void UseProgramStages( uint pipeline, bitfield stages, uint program ); // ... // ... -// 5/ Before the use of the program, we can validate it. (mandatory or not ?) +// 5/ Before the use of the program, we can validate it. (mandatory or not ?) // glValidateProgramPipeline // // ************************** BUILD METHOD 2 // Humm, there is another solutions. You can setup function pointer in GLSL and configure them with OPENGL. shader_subroutine. glUseProgram must be replace with glUseProgramInstance in this case (and instance must be managed) //GL EXT: Overview -//GL EXT: -//GL EXT: This extension adds support to shaders for "indirect subroutine calls", +//GL EXT: +//GL EXT: This extension adds support to shaders for "indirect subroutine calls", //GL EXT: where a single shader can include many subroutines and dynamically select -//GL EXT: through the API which subroutine is called from each call site. -//GL EXT: Switching subroutines dynamically in this fashion can avoid the cost of +//GL EXT: through the API which subroutine is called from each call site. +//GL EXT: Switching subroutines dynamically in this fashion can avoid the cost of //GL EXT: recompiling and managing multiple shaders, while still retaining most of //GL EXT: the performance of specialized shaders. // // ************************** Uniform buffer -// // Note don't know how to chose block_binding_point (probably managed like texture unit +// // Note don't know how to chose block_binding_point (probably managed like texture unit // maybe any number will be fine) // index=glGetUniformBlockIndex(program, "BlockName"); // glBindBufferBase(GL_UNIFORM_BUFFER, block_binding_point, some_buffer_object); @@ -56,6 +56,8 @@ GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) + //, m_context(0) + , m_dummy_renderer(NULL) , m_vb(0) , m_pipeline(0) , m_srv_changed(false) @@ -71,10 +73,42 @@ GSDeviceOGL::GSDeviceOGL() GSDeviceOGL::~GSDeviceOGL() { + // Clean m_merge + for (uint i = 0; i < 2; i++) + glDeleteProgram(m_merge.ps[i]); + delete (m_merge.cb); + delete (m_merge.bs); + + // Clean m_interlace + for (uint i = 0; i < 2; i++) + glDeleteProgram(m_interlace.ps[i]); + delete (m_interlace.cb); + + // Clean m_convert + glDeleteProgram(m_convert.vs); + for (uint i = 0; i < 2; i++) + glDeleteProgram(m_convert.ps[i]); + glDeleteSamplers(1, &m_convert.ln); + glDeleteSamplers(1, &m_convert.pt); + delete m_convert.dss; + delete m_convert.bs; + + // Clean m_date + delete m_date.dss; + delete m_date.bs; + + // Clean various opengl allocation + glDeleteBuffers(1, &m_vb); + glDeleteProgramPipelines(1, &m_pipeline); + glDeleteFramebuffers(1, &m_fbo); + + // if(m_context) + // SDL_GL_DeleteContext(m_context); + if(m_dummy_renderer) + SDL_DestroyRenderer(m_dummy_renderer); + if(m_window != NULL && m_free_window) - { SDL_DestroyWindow(m_window); - } } GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) @@ -110,6 +144,8 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int form return GSDevice::FetchSurface(type, w, h, msaa, format); } +PFNGLTEXSTORAGE2DPROC glTexStorage2D_glew17 = NULL; + bool GSDeviceOGL::Create(GSWnd* wnd) { if (m_window == NULL) { @@ -119,6 +155,51 @@ bool GSDeviceOGL::Create(GSWnd* wnd) assert(0); #endif m_free_window = true; + + // If the user request OpenGL acceleration, we take recent OGL version (4.2) + // We keep the default 2.1 version in SW mode (only DX11 capable card, are compatible with OGL4) if ( theApp.GetConfig("renderer", 0) / 3 == 4 ) { + // Setup visual attribute + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 ); + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 ); + // Ask for an advance opengl version + SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); + // FIXME AMD does not support yet 4.2... + //SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); + SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); + + // Window must be recreated to gain Opengl feature... + //SDL_RecreateWindow(m_window, SDL_GetWindowFlags(m_window) | SDL_WINDOW_OPENGL ); + // Well actually you need to generate a full renderer to only have a context... + m_dummy_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); // SDL_RENDERER_PRESENTVSYNC + // At least create the opengl context + // m_context = SDL_GL_CreateContext(m_window); + + + // FIXME...... + // GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch the function pointers. The solution is for GLEW to use glGetStringi instead. + // The current version of GLEW is 1.7.0 but they still haven't corrected it. The only fix is to use glewExperimental for now : + //NOTE: I'm not sure experimental work on 1.6 ... + glewExperimental=true; + const int glew_ok = glewInit(); + if (glew_ok != GLEW_OK) + { + // FIXME:proper logging + fprintf(stderr, "Error: Failed to init glew :%s\n", glewGetErrorString(glew_ok)); + return false; + } + // FIXME upgrade to 4.2 when AMD drivers are ready + // Note need glew 1.7 too + if (!GLEW_VERSION_4_1) { + fprintf(stderr, "4.1 is not supported!\n"); + return false; + } + + // Not yet supported by glew1.6 + glTexStorage2D_glew17 = (PFNGLTEXSTORAGE2DPROC)glXGetProcAddressARB((const GLubyte*)"glTexStorage2D"); } #ifdef __LINUX__ @@ -127,6 +208,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd) wnd->SetWindow(m_window); #endif + // FIXME disable it when code is ready + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + // **************************************************************** // Various object // **************************************************************** @@ -138,7 +222,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // convert // **************************************************************** - GSInputLayout il_convert[2] = + GSInputLayout il_convert[2] = { {0, 4, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, p) }, {1, 2, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, @@ -199,12 +283,15 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + m_convert.dss = new GSDepthStencilOGL(); + m_convert.bs = new GSBlendStateOGL(); + // **************************************************************** // merge // **************************************************************** - - m_merge.cb->index = 1; - m_merge.cb->byte_size = sizeof(MergeConstantBuffer); + m_merge.cb = new GSUniformBufferOGL(1, sizeof(MergeConstantBuffer)); + //m_merge.cb->index = 1; + //m_merge.cb->byte_size = sizeof(MergeConstantBuffer); glGenBuffers(1, &m_merge.cb->buffer); glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); glBufferData(GL_UNIFORM_BUFFER, m_merge.cb->byte_size, NULL, GL_DYNAMIC_DRAW); @@ -212,6 +299,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) for(int i = 0; i < countof(m_merge.ps); i++) CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge.ps[i]); + m_merge.bs = new GSBlendStateOGL(); m_merge.bs->m_enable = true; m_merge.bs->m_equation_RGB = GL_FUNC_ADD; m_merge.bs->m_equation_ALPHA = GL_FUNC_ADD; @@ -223,8 +311,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** // interlace // **************************************************************** - m_interlace.cb->index = 2; - m_interlace.cb->byte_size = sizeof(InterlaceConstantBuffer); + m_interlace.cb = new GSUniformBufferOGL(2, sizeof(InterlaceConstantBuffer)); + //m_interlace.cb->index = 2; + //m_interlace.cb->byte_size = sizeof(InterlaceConstantBuffer); glGenBuffers(1, &m_interlace.cb->buffer); glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); glBufferData(GL_UNIFORM_BUFFER, m_interlace.cb->byte_size, NULL, GL_DYNAMIC_DRAW); @@ -251,6 +340,13 @@ bool GSDeviceOGL::Create(GSWnd* wnd) rd.AntialiasedLineEnable = false; #endif + + // **************************************************************** + // Finish window setup and backbuffer + // **************************************************************** + if(!GSDevice::Create(wnd)) + return false; + GSVector4i rect = wnd->GetClientRect(); Reset(rect.z, rect.w); @@ -401,7 +497,7 @@ bool GSDeviceOGL::Reset(int w, int h) // TODO // Opengl allocate the backbuffer with the window. The render is done in the backbuffer when - // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done + // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done // in the backbuffer m_backbuffer = new GSTextureOGL(0, w, h, false, 0); @@ -431,6 +527,8 @@ bool GSDeviceOGL::Reset(int w, int h) void GSDeviceOGL::Flip() { + // FIXME: disable it when code is working + CheckDebugLog(); // Warning it is not OGL dependent but application dependant (glx and so not portable) #if SDL_VERSION_ATLEAST(1,3,0) SDL_GL_SwapWindow(m_window); @@ -1048,3 +1146,82 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st free(sources); } + +void GSDeviceOGL::CheckDebugLog() +{ + unsigned int count = 64; // max. num. of messages that will be read from the log + int bufsize = 2048; + unsigned int* sources = new unsigned int[count]; + unsigned int* types = new unsigned int[count]; + unsigned int* ids = new unsigned int[count]; + unsigned int* severities = new unsigned int[count]; + int* lengths = new int[count]; + char* messageLog = new char[bufsize]; + + unsigned int retVal = glGetDebugMessageLogARB(count, bufsize, sources, types, ids, severities, lengths, messageLog); + + if(retVal > 0) + { + unsigned int pos = 0; + for(unsigned int i=0; i Date: Wed, 30 Nov 2011 21:42:41 +0000 Subject: [PATCH 05/56] gsdx-ogl: * implement shader code (subset that seem to be used in SW mode) * some hack to fix some alignment issue with GSVertexPT1 structure * Lots of various opengl fixes. Remaining unsupported GL feature are inside SDL. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4974 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 105 +++++++++++----- plugins/GSdx/GSDeviceOGL.h | 5 +- plugins/GSdx/GSTextureOGL.cpp | 34 +++-- plugins/GSdx/GSVertex.h | 4 + plugins/GSdx/res/convert.glsl | 215 ++++++++++++++++---------------- plugins/GSdx/res/interlace.glsl | 56 +++++---- plugins/GSdx/res/merge.glsl | 32 ++--- 7 files changed, 261 insertions(+), 190 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index c0ba73f696..e3248b8dd7 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -658,6 +658,8 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) } assert(0); + // GL_NV_copy_image seem like the good extension but not supported on AMD... + // FIXME attach the texture to the FBO GSTextureOGL* st_ogl = (GSTextureOGL*) st; GSTextureOGL* dt_ogl = (GSTextureOGL*) dt; @@ -692,9 +694,6 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // probably no difficult to convert when all helpers function will be done void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, GSBlendStateOGL* bs, bool linear) { - //TODO later - assert(0); -#if 0 if(!st || !dt) { ASSERT(0); @@ -718,7 +717,8 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, float right = dr.z * 2 / ds.x - 1.0f; float bottom = 1.0f - dr.w * 2 / ds.y; - GSVertexPT1 vertices[] = + //FIXME aligment issue + GSVertexPT1 vertices[] __attribute__ ((aligned (16))) = { {GSVector4(left, top, 0.5f, 1.0f), GSVector2(sr.x, sr.y)}, {GSVector4(right, top, 0.5f, 1.0f), GSVector2(sr.z, sr.y)}, @@ -727,8 +727,8 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, }; IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices)); - IASetInputLayout(m_convert.il); - IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + IASetInputLayout(m_convert.il, 2); + IASetPrimitiveTopology(GL_TRIANGLE_STRIP); // vs @@ -736,12 +736,12 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // gs - GSSetShader(NULL); + GSSetShader(0); // ps PSSetShaderResources(st, NULL); - PSSetSamplerState(linear ? m_convert.ln : m_convert.pt, NULL); + PSSetSamplerState(linear ? m_convert.ln : m_convert.pt, 0); PSSetShader(ps, ps_cb); // @@ -753,7 +753,9 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, EndScene(); PSSetShaderResources(NULL, NULL); -#endif + + // FIXME: disable it when code is working + CheckDebugLog(); } void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c) @@ -847,7 +849,7 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t glGenBuffers(1, &m_vb); // FIXME: GL_DYNAMIC_DRAW vs GL_STREAM_DRAW !!! glBindBuffer(GL_ARRAY_BUFFER, m_vb); - glBufferData(GL_ARRAY_BUFFER, m_vertices.limit, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * stride, NULL, GL_DYNAMIC_DRAW); } // append data or go back to the beginning @@ -959,8 +961,10 @@ void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) // glBindSampler(1 , sampler); if (m_srv_changed || m_ss_changed) { for (uint i=0 ; i < 3; i++) { - m_state.ps_srv[i]->EnableUnit(i); - glBindSampler(i, m_state.ps_ss[i]); + if (m_state.ps_srv[i] != NULL) { + m_state.ps_srv[i]->EnableUnit(i); + glBindSampler(i, m_state.ps_ss[i]); + } } } #if 0 @@ -1021,13 +1025,17 @@ void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) m_state.bs = bs; m_state.bf = bf; - // FIXME: double check when blend stuff is complete - if (bs->m_func_sRGB == GL_CONSTANT_COLOR || bs->m_func_sRGB == GL_ONE_MINUS_CONSTANT_COLOR - || bs->m_func_dRGB == GL_CONSTANT_COLOR || bs->m_func_dRGB == GL_ONE_MINUS_CONSTANT_COLOR) - glBlendColor(bf, bf, bf, 0); + if (bs->m_enable) { + glEnable(GL_BLEND); + // FIXME: double check when blend stuff is complete + if (bs->m_func_sRGB == GL_CONSTANT_COLOR || bs->m_func_sRGB == GL_ONE_MINUS_CONSTANT_COLOR + || bs->m_func_dRGB == GL_CONSTANT_COLOR || bs->m_func_dRGB == GL_ONE_MINUS_CONSTANT_COLOR) + glBlendColor(bf, bf, bf, 0); - glBlendEquationSeparate(bs->m_equation_RGB, bs->m_equation_ALPHA); - glBlendFuncSeparate(bs->m_func_sRGB, bs->m_func_dRGB, bs->m_func_sALPHA, bs->m_func_dALPHA); + glBlendEquationSeparate(bs->m_equation_RGB, bs->m_equation_ALPHA); + glBlendFuncSeparate(bs->m_func_sRGB, bs->m_func_dRGB, bs->m_func_sALPHA, bs->m_func_dALPHA); + } else + glDisable(GL_BLEND); } } @@ -1087,7 +1095,11 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto { m_state.scissor = r; // FIXME check position - glScissor(r.x, r.w, r.z-r.x, r.y-r.w); + // x = 0, + // y = 0, + // z = 512, + // w = 512 + glScissor(r.x, r.y, r.z-r.x, r.w-r.y); #if 0 m_ctx->RSSetScissorRects(1, r); #endif @@ -1096,21 +1108,35 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program) { - // Could be useful to filter ubber shader + // ***************************************************** + // Build a header string + // ***************************************************** + // First select the version (must be the first line so we need to generate it + std::string version = "#version 410\n#extension GL_ARB_shading_language_420pack: enable\n"; + + // Allow to puts several shader in 1 files std::string shader_type; switch (type) { case GL_VERTEX_SHADER: shader_type = "#define VERTEX_SHADER 1\n"; + break; case GL_GEOMETRY_SHADER: shader_type = "#define GEOMETRY_SHADER 1\n"; + break; case GL_FRAGMENT_SHADER: shader_type = "#define FRAGMENT_SHADER 1\n"; + break; + default: assert(0); } - // Select the entry point + // Select the entry point ie the main function std::string entry_main = format("#define %s main\n", entry.c_str()); + std::string header = version + shader_type + entry_main; + + // ***************************************************** // Read the source file + // ***************************************************** std::string source; std::string line; // Each linux distributions have his rules for path so we give them the possibility to @@ -1135,16 +1161,34 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st fprintf(stderr, "Error opening %s: ", shader_file.c_str()); } - // Create a giant string with everythings - std::string full_source = shader_type + entry_main + source; - char* sources = (char*)malloc(full_source.size()); - strncpy(sources, full_source.c_str(), full_source.size()); - sources[full_source.size()] = '\0'; + // Note it is better to separate header and source file to have the good line number + // in the glsl compiler report + const char** sources_array = (const char**)malloc(2*sizeof(char*)); + char* source_str = (char*)malloc(source.size() + 1); + char* header_str = (char*)malloc(header.size() + 1); + sources_array[0] = header_str; + sources_array[1] = source_str; - *program = glCreateShaderProgramv(type, 1, (const char**)&sources); + source.copy(source_str, source.size(), 0); + source_str[source.size()] = '\0'; + header.copy(header_str, header.size(), 0); + header_str[header.size()] = '\0'; - free(sources); + *program = glCreateShaderProgramv(type, 2, sources_array); + free(source_str); + free(header_str); + free(sources_array); + + // Print a nice debug log + GLint log_length = 0; + glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length); + + char* log = (char*)malloc(log_length); + glGetProgramInfoLog(*program, log_length, NULL, log); + + fprintf(stderr, "%s", log); + free(log); } void GSDeviceOGL::CheckDebugLog() @@ -1199,6 +1243,9 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi strcpy(debSource, "Application"); else if(source == GL_DEBUG_SOURCE_OTHER_ARB) strcpy(debSource, "Other"); + else + strcpy(debSource, "UNKNOW"); + if(type == GL_DEBUG_TYPE_ERROR_ARB) strcpy(debType, "Error"); @@ -1212,6 +1259,8 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi strcpy(debType, "Performance"); else if(type == GL_DEBUG_TYPE_OTHER_ARB) strcpy(debType, "Other"); + else + strcpy(debType, "UNKNOW"); if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) strcpy(debSev, "High"); diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index a8fbaddc15..d131fe6db0 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -86,8 +86,7 @@ struct GSUniformBufferOGL { {} ~GSUniformBufferOGL() { - if (buffer) - glDeleteBuffers(1, &buffer); + glDeleteBuffers(1, &buffer); } }; @@ -280,7 +279,7 @@ class GSDeviceOGL : public GSDevice void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void PSSetShaderResource(int i, GSTexture* sr); - void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2); + void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2 = 0); void PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb); void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index ebc782440f..9c3a679e38 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -94,8 +94,12 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) case GSTexture::RenderTarget: // FIXME what is the real use case of this texture // Maybe a texture will be better - glGenRenderbuffers(1, &m_texture_id); - m_texture_target = GL_RENDERBUFFER; + // glGenRenderbuffers(1, &m_texture_id); + // m_texture_target = GL_RENDERBUFFER; + // Buffer can not be read by shader and must be blit before. I see no point to use a render buffer + // when you can directly render on the texture. It said it could be faster... + glGenTextures(1, &m_texture_id); + m_texture_target = GL_TEXTURE_2D; break; case GSTexture::DepthStencil: glGenRenderbuffers(1, &m_texture_id); @@ -104,8 +108,8 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) case GSTexture::Texture: glGenTextures(1, &m_texture_id); // FIXME, do we need rectangle (or better to use 2D texture) - //m_texture_target = GL_TEXTURE_2D; - m_texture_target = GL_TEXTURE_RECTANGLE; + m_texture_target = GL_TEXTURE_2D; + //m_texture_target = GL_TEXTURE_RECTANGLE; // == For texture, the Unit must be selected break; case GSTexture::Offscreen: @@ -132,18 +136,25 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // Allocate the buffer switch (m_type) { - case GSTexture::RenderTarget: case GSTexture::DepthStencil: glBindRenderbuffer(m_texture_target, m_texture_id); glRenderbufferStorageMultisample(m_texture_target, msaa_level, m_format, m_size.y, m_size.x); break; + case GSTexture::RenderTarget: case GSTexture::Texture: // FIXME // Howto allocate the texture unit !!! // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother EnableUnit(0); - glTexStorage2D_glew17(m_texture_target, 0, m_format, m_size.y, m_size.x); + // FIXME glTexStorage2D does not work yet on my system (4.2) extension but glTexImage2D seems ok + // glTexStorage2D_glew17(m_texture_target, 1, m_format, m_size.y, m_size.x); + // fprintf(stderr, "texture storage %d, %d\n", w, h); + if (m_format == GL_RGBA8) { + glTexImage2D(m_texture_target, 0, m_format, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + else + assert(0); break; case GSTexture::Offscreen: assert(0); @@ -170,6 +181,7 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // To update only a part of the texture you can use: // glTexSubImage2D — specify a two-dimensional texture subimage switch (m_type) { + case GSTexture::RenderTarget: case GSTexture::Texture: // glTexSubImage2D specifies a two-dimensional subtexture for the current texture unit, specified with glActiveTexture. // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target @@ -179,9 +191,13 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // FIXME I'm not confident with GL_UNSIGNED_BYTE type // FIXME add a state check glBindTexture(m_texture_target, m_texture_id); - glTexSubImage2D(m_texture_target, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom, m_format, GL_UNSIGNED_BYTE, data); + //void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * data); + // fprintf(stderr, "texture coord %d, %d, %d, %d\n", r.x, r.y, r.z, r.w); + if (m_format == GL_RGBA8) + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.z-r.x, r.w-r.y, GL_RGBA, GL_UNSIGNED_BYTE, data); + else + assert(0); break; - case GSTexture::RenderTarget: case GSTexture::DepthStencil: case GSTexture::Offscreen: assert(0); @@ -204,11 +220,11 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) void GSTextureOGL::EnableUnit(uint unit) { switch (m_type) { - case GSTexture::RenderTarget: case GSTexture::DepthStencil: case GSTexture::Offscreen: assert(0); break; + case GSTexture::RenderTarget: case GSTexture::Texture: // FIXME // Howto allocate the texture unit !!! diff --git a/plugins/GSdx/GSVertex.h b/plugins/GSdx/GSVertex.h index 6df8fcd3aa..4daa85bdd5 100644 --- a/plugins/GSdx/GSVertex.h +++ b/plugins/GSdx/GSVertex.h @@ -50,6 +50,10 @@ struct GSVertexPT1 { GSVector4 p; GSVector2 t; +#ifdef _LINUX + //FIXME aligment issue + GSVector2 pad; +#endif }; struct GSVertexPT2 diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 62adf6dbe4..33a1b1113a 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -1,142 +1,137 @@ -#if 0 -struct VS_INPUT -{ - float4 p : POSITION; - float2 t : TEXCOORD0; -}; +//#version 420 // Keep it for editor detection -struct VS_OUTPUT -{ - float4 p : SV_Position; - float2 t : TEXCOORD0; -}; +#ifdef VERTEX_SHADER -Texture2D Texture; -SamplerState TextureSampler; +layout(location = 0) in vec4 POSITION; +layout(location = 1) in vec2 TEXCOORD0; -float4 sample_c(float2 uv) +// FIXME set the interpolation (don't know what dx do) +// flat means that there is no interpolation. The value given to the fragment shader is based on the provoking vertex conventions. +// +// noperspective means that there will be linear interpolation in window-space. This is usually not what you want, but it can have its uses. +// +// smooth, the default, means to do perspective-correct interpolation. +// +// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area. +// FIXME gl_Position +smooth layout(location = 0) out vec4 POSITION_OUT; +smooth layout(location = 1) out vec2 TEXCOORD0_OUT; + +void vs_main() { - return Texture.Sample(TextureSampler, uv); + POSITION_OUT = POSITION; + TEXCOORD0_OUT = TEXCOORD0_OUT; + gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position } -struct PS_INPUT +#endif + +#ifdef FRAGMENT_SHADER +// NOTE: pixel can be clip with "discard" + +layout(location = 0) in vec4 SV_Position; +layout(location = 1) in vec2 TEXCOORD0; + +out vec4 SV_Target0; + +layout(binding = 0) uniform sampler2D TextureSampler; + +vec4 sample_c(vec2 uv) { - float4 p : SV_Position; - float2 t : TEXCOORD0; -}; - -struct PS_OUTPUT -{ - float4 c : SV_Target0; -}; - -VS_OUTPUT vs_main(VS_INPUT input) -{ - VS_OUTPUT output; - - output.p = input.p; - output.t = input.t; - - return output; + return texture(TextureSampler, uv); } -PS_OUTPUT ps_main0(PS_INPUT input) +vec4 ps_crt(vec2 uv, uint i) { - PS_OUTPUT output; - - output.c = sample_c(input.t); - - return output; -} - -PS_OUTPUT ps_main7(PS_INPUT input) -{ - PS_OUTPUT output; - - float4 c = sample_c(input.t); - - c.a = dot(c.rgb, float3(0.299, 0.587, 0.114)); - - output.c = c; - - return output; -} - -float4 ps_crt(PS_INPUT input, int i) -{ - float4 mask[4] = + vec4 mask[4] = { - float4(1, 0, 0, 0), - float4(0, 1, 0, 0), - float4(0, 0, 1, 0), - float4(1, 1, 1, 0) + vec4(1, 0, 0, 0), + vec4(0, 1, 0, 0), + vec4(0, 0, 1, 0), + vec4(1, 1, 1, 0) }; - - return sample_c(input.t) * saturate(mask[i] + 0.5f); + + return sample_c(uv) * clamp((mask[i] + 0.5f), 0.0f, 1.0f); } -uint ps_main1(PS_INPUT input) : SV_Target0 +void ps_main0() { - float4 c = sample_c(input.t); - - c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 - - uint4 i = c * float4(0x001f, 0x03e0, 0x7c00, 0x8000); - - return (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); + SV_Target0 = sample_c(TEXCOORD0); } -PS_OUTPUT ps_main2(PS_INPUT input) +void ps_main7() { - PS_OUTPUT output; - - clip(sample_c(input.t).a - 128.0f / 255); // >= 0x80 pass - - output.c = 0; + vec4 c = sample_c(TEXCOORD0); - return output; + c.a = dot(c.rgb, vec3(0.299, 0.587, 0.114)); + + SV_Target0 = c; } -PS_OUTPUT ps_main3(PS_INPUT input) +void ps_main5() // triangular { - PS_OUTPUT output; - - clip(127.95f / 255 - sample_c(input.t).a); // < 0x80 pass (== 0x80 should not pass) - - output.c = 0; - - return output; -} - -PS_OUTPUT ps_main4(PS_INPUT input) -{ - PS_OUTPUT output; - - output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255; - - return output; -} - -PS_OUTPUT ps_main5(PS_INPUT input) // triangular -{ - PS_OUTPUT output; - - uint4 p = (uint4)input.p; + //uint4 p = (uint4)input.p; + highp uvec4 p = uvec4(SV_Position); // output.c = ps_crt(input, ((p.x + (p.y & 1) * 3) >> 1) % 3); - output.c = ps_crt(input, ((p.x + ((p.y >> 1) & 1) * 3) >> 1) % 3); + vec4 c = ps_crt(TEXCOORD0, ((p.x + ((p.y >> 1) & 1) * 3) >> 1) % 3); - return output; + SV_Target0 = c; } -PS_OUTPUT ps_main6(PS_INPUT input) // diagonal +void ps_main6() // diagonal { - PS_OUTPUT output; - - uint4 p = (uint4)input.p; + uvec4 p = uvec4(SV_Position); - output.c = ps_crt(input, (p.x + (p.y % 3)) % 3); + vec4 c = ps_crt(TEXCOORD0, (p.x + (p.y % 3)) % 3); - return output; + SV_Target0 = c; } + +// Texture2D Texture; +// SamplerState TextureSampler; +// +// uint ps_main1(PS_INPUT input) : SV_Target0 +// { +// float4 c = sample_c(input.t); +// +// c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 +// +// uint4 i = c * float4(0x001f, 0x03e0, 0x7c00, 0x8000); +// +// return (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); +// } +// +// PS_OUTPUT ps_main2(PS_INPUT input) +// { +// PS_OUTPUT output; +// +// clip(sample_c(input.t).a - 128.0f / 255); // >= 0x80 pass +// +// output.c = 0; +// +// return output; +// } +// +// PS_OUTPUT ps_main3(PS_INPUT input) +// { +// PS_OUTPUT output; +// +// clip(127.95f / 255 - sample_c(input.t).a); // < 0x80 pass (== 0x80 should not pass) +// +// output.c = 0; +// +// return output; +// } +// +// PS_OUTPUT ps_main4(PS_INPUT input) +// { +// PS_OUTPUT output; +// +// output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255; +// +// return output; +// } +// + #endif diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index b7245a7f32..9933fe3b5e 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -1,46 +1,54 @@ -#if 0 +//#version 420 // Keep it for editor detection -Texture2D Texture; -SamplerState Sampler; +#ifdef FRAGMENT_SHADER +layout(location = 0) in vec4 SV_Position; +layout(location = 1) in vec2 TEXCOORD0; -cbuffer cb0 +out vec4 SV_Target0; + +layout(std140, binding = 1) uniform cb0 { - float2 ZrH; - float hH; + vec2 ZrH; + float hH; }; -struct PS_INPUT -{ - float4 p : SV_Position; - float2 t : TEXCOORD0; -}; +layout(binding = 0) uniform sampler2D TextureSampler; -float4 ps_main0(PS_INPUT input) : SV_Target0 +// TODO ensure that clip (discard) is < 0 and not <= 0 ??? +void ps_main0() { - clip(frac(input.t.y * hH) - 0.5); + // I'm not sure it impact us but be safe to lookup texture before conditional if + // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control + vec4 c = texture(TextureSampler, TEXCOORD0); + if (fract(TEXCOORD0.y * hH) - 0.5 < 0.0) + discard; - return Texture.Sample(Sampler, input.t); + SV_Target0 = c; } -float4 ps_main1(PS_INPUT input) : SV_Target0 +void ps_main1() { - clip(0.5 - frac(input.t.y * hH)); + // I'm not sure it impact us but be safe to lookup texture before conditional if + // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control + vec4 c = texture(TextureSampler, TEXCOORD0); + if (0.5 - fract(TEXCOORD0.y * hH) < 0.0) + discard; - return Texture.Sample(Sampler, input.t); + SV_Target0 = c; } -float4 ps_main2(PS_INPUT input) : SV_Target0 +void ps_main2() { - float4 c0 = Texture.Sample(Sampler, input.t - ZrH); - float4 c1 = Texture.Sample(Sampler, input.t); - float4 c2 = Texture.Sample(Sampler, input.t + ZrH); + vec4 c0 = texture(TextureSampler, TEXCOORD0 - ZrH); + vec4 c1 = texture(TextureSampler, TEXCOORD0); + vec4 c2 = texture(TextureSampler, TEXCOORD0 + ZrH); - return (c0 + c1 * 2 + c2) / 4; + SV_Target0 = (c0 + c1 * 2 + c2) / 4; } -float4 ps_main3(PS_INPUT input) : SV_Target0 +void ps_main3() { - return Texture.Sample(Sampler, input.t); + SV_Target0 = texture(TextureSampler, TEXCOORD0); } #endif diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index 74f47377ad..b46ac7d4ed 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -1,31 +1,31 @@ -#if 0 +//#version 420 // Keep it for editor detection -Texture2D Texture; -SamplerState Sampler; +#ifdef FRAGMENT_SHADER -cbuffer cb0 +layout(location = 0) in vec4 SV_Position; +layout(location = 1) in vec2 TEXCOORD0; + +out vec4 SV_Target0; + +layout(std140, binding = 1) uniform cb0 { - float4 BGColor; + vec4 BGColor; }; -struct PS_INPUT -{ - float4 p : SV_Position; - float2 t : TEXCOORD0; -}; +layout(binding = 0) uniform sampler2D TextureSampler; -float4 ps_main0(PS_INPUT input) : SV_Target0 +void ps_main0() { - float4 c = Texture.Sample(Sampler, input.t); + vec4 c = texture(TextureSampler, TEXCOORD0); c.a = min(c.a * 2, 1); - return c; + SV_Target0 = c; } -float4 ps_main1(PS_INPUT input) : SV_Target0 +void ps_main1() { - float4 c = Texture.Sample(Sampler, input.t); + vec4 c = texture(TextureSampler, TEXCOORD0); c.a = BGColor.a; - return c; + SV_Target0 = c; } #endif From a835de0af706a65c4da6719ff16d38de5f571d06 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 7 Dec 2011 22:05:46 +0000 Subject: [PATCH 06/56] gsdx-ogl: LINUX-ONLY * implement the saving of texture (take bmp SW code) * fix the missing "enable attribute code" and the typo in glsl. It works now !!! * rework a little texture to pack texture into a temporay buffer when src pitch != dst pitch * try to replace sdl with pure xlib (not yet enabled by default but it seems to work) Note there still a minor issue, coordinate are different between DX and OGL (upper-left vs lower-left) so the image is inversed. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4981 96395faa-99c1-11dd-bbfe-3dabce05a288 --- cmake/BuildParameters.cmake | 2 +- plugins/GSdx/CMakeLists.txt | 7 ++ plugins/GSdx/GSDeviceOGL.cpp | 98 +++++++++++------- plugins/GSdx/GSDeviceOGL.h | 11 ++ plugins/GSdx/GSTextureOGL.cpp | 174 +++++++++++++++++++++++++++----- plugins/GSdx/GSTextureOGL.h | 2 + plugins/GSdx/GSVertex.h | 6 +- plugins/GSdx/GSWnd.cpp | 105 +++++++++++++++++-- plugins/GSdx/GSWnd.h | 5 + plugins/GSdx/res/convert.glsl | 25 ++++- plugins/GSdx/res/interlace.glsl | 2 +- plugins/GSdx/res/merge.glsl | 6 +- 12 files changed, 358 insertions(+), 85 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 764cdc8748..64625089f5 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -119,7 +119,7 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") #------------------------------------------------------------------------------- # Set some default compiler flags #------------------------------------------------------------------------------- -set(DEFAULT_WARNINGS "-Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing") +set(DEFAULT_WARNINGS "-w -Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing") set(DEFAULT_GCC_FLAG "-m32 -msse -msse2 -march=i686 -pthread ${DEFAULT_WARNINGS}") set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof") diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 264ca8ce99..57aa7d1531 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -16,6 +16,7 @@ set(CommonFlags -mfpmath=sse #-Wstrict-aliasing # Allow to track strict aliasing issue. -Wunused-variable + -DKEEP_SDL ) set(OptimizationFlags @@ -196,6 +197,12 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") if(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR}) else(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) endif(PACKAGE_MODE) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index e3248b8dd7..9aae22efba 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -62,8 +62,13 @@ GSDeviceOGL::GSDeviceOGL() , m_pipeline(0) , m_srv_changed(false) , m_ss_changed(false) + , m_vb_changed(false) { m_msaa = theApp.GetConfig("msaa", 0); + + m_frag_back_buffer[0] = GL_BACK_LEFT; + m_frag_rt_buffer[0] = GL_COLOR_ATTACHMENT0; + memset(&m_merge, 0, sizeof(m_merge)); memset(&m_interlace, 0, sizeof(m_interlace)); memset(&m_convert, 0, sizeof(m_convert)); @@ -102,13 +107,17 @@ GSDeviceOGL::~GSDeviceOGL() glDeleteProgramPipelines(1, &m_pipeline); glDeleteFramebuffers(1, &m_fbo); + // glXMakeCurrent(m_XDisplay, m_Xwindow, 0); + // if (m_context) glXDestroyContext(m_XDisplay, m_context); // if(m_context) // SDL_GL_DeleteContext(m_context); +#ifdef KEEP_SDL if(m_dummy_renderer) SDL_DestroyRenderer(m_dummy_renderer); if(m_window != NULL && m_free_window) SDL_DestroyWindow(m_window); +#endif } GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) @@ -149,11 +158,8 @@ PFNGLTEXSTORAGE2DPROC glTexStorage2D_glew17 = NULL; bool GSDeviceOGL::Create(GSWnd* wnd) { if (m_window == NULL) { -#if SDL_VERSION_ATLEAST(1,3,0) +#ifdef KEEP_SDL m_window = SDL_CreateWindowFrom(wnd->GetHandle()); -#else - assert(0); -#endif m_free_window = true; // If the user request OpenGL acceleration, we take recent OGL version (4.2) @@ -168,7 +174,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // Ask for an advance opengl version SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); // FIXME AMD does not support yet 4.2... - //SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); + //SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); // Window must be recreated to gain Opengl feature... @@ -177,7 +183,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) m_dummy_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); // SDL_RENDERER_PRESENTVSYNC // At least create the opengl context // m_context = SDL_GL_CreateContext(m_window); - +#endif // FIXME...... // GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch the function pointers. The solution is for GLEW to use glGetStringi instead. @@ -202,10 +208,12 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glTexStorage2D_glew17 = (PFNGLTEXSTORAGE2DPROC)glXGetProcAddressARB((const GLubyte*)"glTexStorage2D"); } -#ifdef __LINUX__ +#ifdef KEEP_SDL // In GSopen2, sdl failed to received any resize event. GSWnd::GetClientRect need to manually // set the window size... So we send the m_window to the wnd object to allow some manipulation on it. wnd->SetWindow(m_window); +#else + m_window = wnd; #endif // FIXME disable it when code is ready @@ -529,13 +537,7 @@ void GSDeviceOGL::Flip() { // FIXME: disable it when code is working CheckDebugLog(); - // Warning it is not OGL dependent but application dependant (glx and so not portable) -#if SDL_VERSION_ATLEAST(1,3,0) - SDL_GL_SwapWindow(m_window); -#else - SDL_GL_SwapBuffers(); -#endif - + m_wnd->Flip(); } void GSDeviceOGL::DrawPrimitive() @@ -546,18 +548,29 @@ void GSDeviceOGL::DrawPrimitive() void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { GSTextureOGL* t_ogl = (GSTextureOGL*)t; - // FIXME I need to clarify this FBO attachment stuff - // I would like to avoid FBO for a basic clean operation - //glClearBufferfv(GL_COLOR, t_ogl->attachment(), c.v); + if (t == m_backbuffer) { + // FIXME need an assert + if (m_state.fbo) { + m_state.fbo = 0; + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } + glClearBufferfv(GL_COLOR, GL_BACK, c.v); + } else { + // FIXME I need to clarify this FBO attachment stuff + // I would like to avoid FBO for a basic clean operation + if (!m_state.fbo) { + m_state.fbo = m_fbo; + glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); + } + t_ogl->Attach(GL_COLOR_ATTACHMENT0); + glClearBufferfv(GL_COLOR, 0, c.v); + } } void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) { - GSTextureOGL* t_ogl = (GSTextureOGL*)t; GSVector4 color = GSVector4::rgba32(c) * (1.0f / 255); - // FIXME I need to clarify this FBO attachment stuff - // I would like to avoid FBO for a basic clean operation - //glClearBufferfv(GL_COLOR, t_ogl->attachment(), color.v); + ClearRenderTarget(t, color); } void GSDeviceOGL::ClearDepth(GSTexture* t, float c) @@ -691,9 +704,9 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, StretchRect(st, sr, dt, dr, ps, ps_cb, m_convert.bs, linear); } -// probably no difficult to convert when all helpers function will be done void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, GSBlendStateOGL* bs, bool linear) { + if(!st || !dt) { ASSERT(0); @@ -717,8 +730,7 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, float right = dr.z * 2 / ds.x - 1.0f; float bottom = 1.0f - dr.w * 2 / ds.y; - //FIXME aligment issue - GSVertexPT1 vertices[] __attribute__ ((aligned (16))) = + GSVertexPT1 vertices[] = { {GSVector4(left, top, 0.5f, 1.0f), GSVector2(sr.x, sr.y)}, {GSVector4(right, top, 0.5f, 1.0f), GSVector2(sr.z, sr.y)}, @@ -745,6 +757,12 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, PSSetShader(ps, ps_cb); // + // FIXME: disable it when code is working + glValidateProgramPipeline(m_pipeline); + GLint status; + glGetProgramPipelineiv(m_pipeline, GL_VALIDATE_STATUS, &status); + if (status != GL_TRUE) + fprintf(stderr, "Failed to validate the pipeline\n"); DrawPrimitive(); @@ -797,7 +815,6 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin m_state.cb = m_interlace.cb->buffer; glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); } - // FIXME I'm not sure it will be happy with InterlaceConstantBuffer type glBufferSubData(GL_UNIFORM_BUFFER, 0, m_interlace.cb->byte_size, &cb); #if 0 m_ctx->UpdateSubresource(m_interlace.cb, 0, NULL, &cb, 0, 0); @@ -842,6 +859,7 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t m_vertices.start = 0; m_vertices.count = 0; m_vertices.limit = std::max(count * 3 / 2, 11000); + } if(!m_vb) @@ -850,6 +868,7 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t // FIXME: GL_DYNAMIC_DRAW vs GL_STREAM_DRAW !!! glBindBuffer(GL_ARRAY_BUFFER, m_vb); glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * stride, NULL, GL_DYNAMIC_DRAW); + m_vb_changed = true; } // append data or go back to the beginning @@ -867,12 +886,21 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t void GSDeviceOGL::IASetInputLayout(GSInputLayout* layout, int layout_nbr) { - if(m_state.layout != layout) + if(m_state.layout != layout || m_state.layout_nbr != layout_nbr || m_vb_changed) { - m_state.layout = layout; + // Remove old configuration. + for (int i = m_state.layout_nbr ; i > (m_state.layout_nbr - layout_nbr) ; i--) { + glDisableVertexAttribArray(i); + } - for (int i = 0; i < layout_nbr; i++) - glVertexAttribPointer(layout->index, layout->size, layout->type, GL_FALSE, layout->stride, layout->offset); + for (int i = 0; i < layout_nbr; i++) { + glEnableVertexAttribArray(layout[i].index); + glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, GL_FALSE, layout[i].stride, layout[i].offset); + } + + m_vb_changed = false; + m_state.layout = layout; + m_state.layout_nbr = layout_nbr; } } @@ -1066,6 +1094,7 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto if (m_state.fbo) { m_state.fbo = 0; glBindFramebuffer(GL_FRAMEBUFFER, 0); // render in the backbuffer + glDrawBuffers(1, m_frag_back_buffer); } assert(ds_ogl == NULL); // no depth-stencil without FBO @@ -1073,6 +1102,7 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto if (m_state.fbo != m_fbo) { m_state.fbo = m_fbo; glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); + glDrawBuffers(1, m_frag_rt_buffer); } assert(rt_ogl != NULL); // a render target must exists @@ -1094,12 +1124,7 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto if(!m_state.scissor.eq(r)) { m_state.scissor = r; - // FIXME check position - // x = 0, - // y = 0, - // z = 512, - // w = 512 - glScissor(r.x, r.y, r.z-r.x, r.w-r.y); + glScissor( r.x, r.y, r.width(), r.height() ); #if 0 m_ctx->RSSetScissorRects(1, r); #endif @@ -1187,7 +1212,8 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st char* log = (char*)malloc(log_length); glGetProgramInfoLog(*program, log_length, NULL, log); - fprintf(stderr, "%s", log); + fprintf(stderr, "%s (%s) :", glsl_file.c_str(), entry.c_str()); + fprintf(stderr, "%s\n", log); free(log); } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index d131fe6db0..b734390fdc 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -103,7 +103,11 @@ class GSDeviceOGL : public GSDevice uint32 m_msaa; // Level of Msaa bool m_free_window; +#ifdef KEEP_SDL SDL_Window* m_window; // pointer to the SDL window +#else + GSWnd* m_window; // pointer to the SDL window +#endif //SDL_GLContext m_context; // current opengl context SDL_Renderer* m_dummy_renderer; // ... crappy API ... @@ -111,6 +115,9 @@ class GSDeviceOGL : public GSDevice GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container + GLenum m_frag_back_buffer[1]; + GLenum m_frag_rt_buffer[1]; + struct { GLuint ps[2]; // program object GSUniformBufferOGL* cb; // uniform buffer object @@ -170,6 +177,7 @@ class GSDeviceOGL : public GSDevice // size_t vb_stride; // ID3D11InputLayout* layout; GSInputLayout* layout; + uint32 layout_nbr; GLenum topology; // (ie GL_TRIANGLES...) GLuint vs; // program GLuint cb; // uniform current buffer @@ -197,6 +205,7 @@ class GSDeviceOGL : public GSDevice bool m_srv_changed; bool m_ss_changed; + bool m_vb_changed; #if 0 CComPtr m_dev; @@ -229,6 +238,8 @@ class GSDeviceOGL : public GSDevice PSConstantBuffer m_ps_cb_cache; #endif + //GLenum frag_back[1] = { GL_BACK }; + //GLenum frag_target[1] = { GL_COLOR_ATTACHMENT0 }: void CheckDebugLog(); void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 9c3a679e38..21b6518828 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -24,7 +24,9 @@ #include "GSTextureOGL.h" GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) - : m_texture_unit(0) + : m_texture_unit(0), + m_extra_buffer_id(0), + m_extra_buffer_allocated(false) { // ************************************************************* // Opengl world @@ -123,8 +125,11 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // gvec texelFetch(gsampler sampler, ivec texCoord, int lod[, int sample]); // corollary we can maybe use it for multisample stuff break; - default: break; + default: + break; } + // Extra buffer to handle various pixel transfer + glGenBuffers(1, &m_extra_buffer_id); uint msaa_level; if (m_msaa) { @@ -178,31 +183,51 @@ void GSTextureOGL::Attach(GLenum attachment) bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) { + // static int update_count = 0; + // update_count++; // To update only a part of the texture you can use: // glTexSubImage2D — specify a two-dimensional texture subimage - switch (m_type) { - case GSTexture::RenderTarget: - case GSTexture::Texture: - // glTexSubImage2D specifies a two-dimensional subtexture for the current texture unit, specified with glActiveTexture. - // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target - //(see glBindBuffer) while a texture image is - // specified, data is treated as a byte offset into the buffer object's data store - // FIXME warning order of the y axis - // FIXME I'm not confident with GL_UNSIGNED_BYTE type - // FIXME add a state check - glBindTexture(m_texture_target, m_texture_id); - //void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * data); - // fprintf(stderr, "texture coord %d, %d, %d, %d\n", r.x, r.y, r.z, r.w); - if (m_format == GL_RGBA8) - glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.z-r.x, r.w-r.y, GL_RGBA, GL_UNSIGNED_BYTE, data); - else - assert(0); - break; - case GSTexture::DepthStencil: - case GSTexture::Offscreen: - assert(0); - break; + if (m_type == GSTexture::DepthStencil || m_type == GSTexture::Offscreen) assert(0); + + // glTexSubImage2D specifies a two-dimensional subtexture for the current texture unit, specified with glActiveTexture. + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target + //(see glBindBuffer) while a texture image is + // specified, data is treated as a byte offset into the buffer object's data store + // FIXME warning order of the y axis + // FIXME I'm not confident with GL_UNSIGNED_BYTE type + // FIXME add a state check + + EnableUnit(0); + + if (m_format != GL_RGBA8) assert(0); + + // FIXME. That suck but I don't know how to do better for now. I think we need to create a texture buffer and directly upload the copy + // The case appears on SW mode. Src pitch is 2x dst pitch. + int rowbytes = r.width() << 2; + if (pitch != rowbytes) { + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_extra_buffer_id); + + if (!m_extra_buffer_allocated) { + glBufferData(GL_PIXEL_UNPACK_BUFFER, m_size.x * m_size.y * 4, NULL, GL_STREAM_DRAW); + m_extra_buffer_allocated = true; + } + + uint8* src = (uint8*) data; + uint8* dst = (uint8*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + for(int h = r.height(); h > 0; h--, src += pitch, dst += rowbytes) + { + memcpy(dst, src, rowbytes); + } + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, 0 /* offset in UNPACK BUFFER */); + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + + } else { + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); } + #if 0 if(m_dev && m_texture) { @@ -283,10 +308,107 @@ void GSTextureOGL::Unmap() #endif } -// If I'm correct, this function only dump some buffer. Debug only, still very useful! -// Note: check zzogl implementation +#ifndef _WINDOWS + +#pragma pack(push, 1) + +struct BITMAPFILEHEADER +{ + uint16 bfType; + uint32 bfSize; + uint16 bfReserved1; + uint16 bfReserved2; + uint32 bfOffBits; +}; + +struct BITMAPINFOHEADER +{ + uint32 biSize; + int32 biWidth; + int32 biHeight; + uint16 biPlanes; + uint16 biBitCount; + uint32 biCompression; + uint32 biSizeImage; + int32 biXPelsPerMeter; + int32 biYPelsPerMeter; + uint32 biClrUsed; + uint32 biClrImportant; +}; + +#define BI_RGB 0 + +#pragma pack(pop) + +#endif + bool GSTextureOGL::Save(const string& fn, bool dds) { + switch (m_type) { + case GSTexture::DepthStencil: + case GSTexture::Offscreen: + ASSERT(0); + break; + default: break; + } + + // Collect the texture data + char* image = (char*)malloc(4 * m_size.x * m_size.y); + if (m_type) { + EnableUnit(0); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); + } else { + // TODO backbuffer + glReadBuffer(GL_BACK); + glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); + } + + // Build a BMP file + if(FILE* fp = fopen(fn.c_str(), "wb")) + { + BITMAPINFOHEADER bih; + + memset(&bih, 0, sizeof(bih)); + + bih.biSize = sizeof(bih); + bih.biWidth = m_size.x; + bih.biHeight = m_size.y; + bih.biPlanes = 1; + bih.biBitCount = 32; + bih.biCompression = BI_RGB; + bih.biSizeImage = m_size.x * m_size.y << 2; + + BITMAPFILEHEADER bfh; + + memset(&bfh, 0, sizeof(bfh)); + + uint8* bfType = (uint8*)&bfh.bfType; + + // bfh.bfType = 'MB'; + bfType[0] = 0x42; + bfType[1] = 0x4d; + bfh.bfOffBits = sizeof(bfh) + sizeof(bih); + bfh.bfSize = bfh.bfOffBits + bih.biSizeImage; + bfh.bfReserved1 = bfh.bfReserved2 = 0; + + fwrite(&bfh, 1, sizeof(bfh), fp); + fwrite(&bih, 1, sizeof(bih), fp); + + uint32 pitch = 4 * m_size.x; + uint8* data = (uint8*)image + (m_size.y - 1) * pitch; + + for(int h = m_size.y; h > 0; h--, data -= pitch) + { + fwrite(data, 1, m_size.x << 2, fp); // TODO: swap red-blue? + } + + fclose(fp); + + free(image); + return true; + } + + return false; #if 0 CComPtr res; diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index f2d66b3c8c..4e55225048 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -29,6 +29,8 @@ class GSTextureOGL : public GSTexture GLenum m_texture_target; // texture target: 2D, rectangle etc... GLuint m_texture_id; // the texture id uint m_texture_unit; // the texture unit offset + uint m_extra_buffer_id; + bool m_extra_buffer_allocated; public: explicit GSTextureOGL(int type, int w, int h, bool msaa, int format); diff --git a/plugins/GSdx/GSVertex.h b/plugins/GSdx/GSVertex.h index 4daa85bdd5..111217148e 100644 --- a/plugins/GSdx/GSVertex.h +++ b/plugins/GSdx/GSVertex.h @@ -46,14 +46,10 @@ struct GSVertexP GSVector4 p; }; -struct GSVertexPT1 +__aligned(struct, 32) GSVertexPT1 { GSVector4 p; GSVector2 t; -#ifdef _LINUX - //FIXME aligment issue - GSVector2 pad; -#endif }; struct GSVertexPT2 diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index a9d67b989e..0ee8cce34a 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -314,6 +314,11 @@ void GSWnd::HideFrame() GSWnd::GSWnd() : m_window(NULL), m_Xwindow(0), m_XDisplay(NULL) { +#ifdef KEEP_SDL + m_renderer = 2; +#else + m_renderer = theApp.GetConfig("renderer", 0) / 3; +#endif } GSWnd::~GSWnd() @@ -334,6 +339,53 @@ bool GSWnd::Attach(void* handle, bool managed) m_Xwindow = *(Window*)handle; m_managed = managed; + if (m_renderer != 2) { + m_XDisplay = XOpenDisplay(NULL); + + // Get visual information + int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_DEPTH_SIZE, 24, + None + }; + + PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig"); + int fbcount = 0; + GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount); + if (!fbc || fbcount < 1) return false; + + glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0; + glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB"); + if (!glXCreateContextAttribsARB) return false; + + // Create a context + int context_attribs[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 4, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + // FIXME : Request a debug context to ease opengl development + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + 0 + }; + m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); + XSync( m_XDisplay, false); + + if (!m_context) return false; + glXMakeCurrent(m_XDisplay, m_Xwindow, m_context); + + // Check the status + int glxMajorVersion, glxMinorVersion; + glXQueryVersion(m_XDisplay, &glxMajorVersion, &glxMinorVersion); + if (glXIsDirect(m_XDisplay, m_context)) + fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion); + else + fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It will be slow\n", glxMajorVersion, glxMinorVersion); + + } + + return true; } @@ -341,10 +393,15 @@ void GSWnd::Detach() { // Actually the destructor is not called when there is only a GSclose/GSshutdown // The window still need to be closed - if(m_window != NULL && m_managed) - { - SDL_DestroyWindow(m_window); - m_window = NULL; + if (m_renderer == 2) { + if(m_window != NULL && m_managed) + { + SDL_DestroyWindow(m_window); + m_window = NULL; + } + } else { + glXMakeCurrent(m_XDisplay, m_Xwindow, 0); + if (m_context) glXDestroyContext(m_XDisplay, m_context); } if (m_XDisplay) { XCloseDisplay(m_XDisplay); @@ -425,7 +482,8 @@ GSVector4i GSWnd::GetClientRect() // In real world...: if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL); XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy); - SDL_SetWindowSize(m_window, w, h); + if (m_renderer == 2) + SDL_SetWindowSize(m_window, w, h); return GSVector4i(0, 0, (int)w, (int)h); } @@ -445,23 +503,48 @@ bool GSWnd::SetWindowText(const char* title) // but we not use this function anyway. // FIXME: it does not feel a good solution -- Gregory // NOte: it might be more thread safe to use a call to XGetGeometry - SDL_PumpEvents(); int x,y = 0; - SDL_GetWindowPosition(m_window, &x, &y); - if ( x && y ) - SDL_SetWindowTitle(m_window, title); + if (m_renderer == 2) { + SDL_PumpEvents(); + SDL_GetWindowPosition(m_window, &x, &y); + if ( x && y ) + SDL_SetWindowTitle(m_window, title); + } return true; } +void GSWnd::Flip() +{ + if (m_renderer == 2) { +#if SDL_VERSION_ATLEAST(1,3,0) + SDL_GL_SwapWindow(m_window); +#else + SDL_GL_SwapBuffers(); +#endif + } else { + glXSwapBuffers(m_XDisplay, m_Xwindow); + } +} + void GSWnd::Show() { - SDL_ShowWindow(m_window); + if (m_renderer == 2) { + SDL_ShowWindow(m_window); + } else { + XMapRaised(m_XDisplay, m_Xwindow); + XFlush(m_XDisplay); + } } void GSWnd::Hide() { - SDL_HideWindow(m_window); + if (m_renderer == 2) { + SDL_HideWindow(m_window); + } else { + XUnmapWindow(m_XDisplay, m_Xwindow); + XFlush(m_XDisplay); + } } void GSWnd::HideFrame() diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index 9969638361..2c14b0794e 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -91,12 +91,16 @@ public: #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL_syswm.h" +typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, bool, const int*); + class GSWnd { SDL_Window* m_window; Window m_Xwindow; Display* m_XDisplay; bool m_managed; + int m_renderer; + GLXContext m_context; public: GSWnd(); @@ -116,6 +120,7 @@ public: void Show(); void Hide(); void HideFrame(); + void Flip(); }; #endif diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 33a1b1113a..861191a97b 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -2,6 +2,12 @@ #ifdef VERTEX_SHADER +out gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + layout(location = 0) in vec4 POSITION; layout(location = 1) in vec2 TEXCOORD0; @@ -20,7 +26,7 @@ smooth layout(location = 1) out vec2 TEXCOORD0_OUT; void vs_main() { POSITION_OUT = POSITION; - TEXCOORD0_OUT = TEXCOORD0_OUT; + TEXCOORD0_OUT = TEXCOORD0; gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position } @@ -32,7 +38,7 @@ void vs_main() layout(location = 0) in vec4 SV_Position; layout(location = 1) in vec2 TEXCOORD0; -out vec4 SV_Target0; +layout(location = 0) out vec4 SV_Target0; layout(binding = 0) uniform sampler2D TextureSampler; @@ -88,6 +94,21 @@ void ps_main6() // diagonal SV_Target0 = c; } +//void ps_main1() +//{ +// vec4 c = sample_c(TEXCOORD); +// +// c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 +// +// uvec4 i = uvec4(c * vec4(0x001f, 0x03e0, 0x7c00, 0x8000)); +// +//#ifdef DEBUG_FRAG +// SV_Target0 = vec4(0.5,0.5,0.5,1.0); +//#else +// SV_Target0 = (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); +//#endif +//} + // Texture2D Texture; // SamplerState TextureSampler; // diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index 9933fe3b5e..5b04be378d 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -4,7 +4,7 @@ layout(location = 0) in vec4 SV_Position; layout(location = 1) in vec2 TEXCOORD0; -out vec4 SV_Target0; +layout(location = 0) out vec4 SV_Target0; layout(std140, binding = 1) uniform cb0 { diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index b46ac7d4ed..8f6ca11f09 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -1,11 +1,10 @@ //#version 420 // Keep it for editor detection #ifdef FRAGMENT_SHADER - layout(location = 0) in vec4 SV_Position; layout(location = 1) in vec2 TEXCOORD0; -out vec4 SV_Target0; +layout(location = 0) out vec4 SV_Target0; layout(std140, binding = 1) uniform cb0 { @@ -16,8 +15,9 @@ layout(binding = 0) uniform sampler2D TextureSampler; void ps_main0() { + vec4 c = texture(TextureSampler, TEXCOORD0); - c.a = min(c.a * 2, 1); + c.a = min(c.a * 2, 1.0); SV_Target0 = c; } From 2be037d78fa3ed199316742f95733147f0fde45b Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 8 Dec 2011 11:17:59 +0000 Subject: [PATCH 07/56] gsdx-ogl: LINUX-ONLY * flip y-axis in merge stage * default to xlib window managment (the dynamic switch between sdl and xlib crashi but SDL will probably dropped later) * improve management of FBO, draw buffer * try to fix some issue with glClearBuffer but spec is not clear. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4982 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 1 - plugins/GSdx/GSDeviceOGL.cpp | 177 +++++++++------------------------- plugins/GSdx/GSDeviceOGL.h | 13 +-- plugins/GSdx/GSTextureOGL.cpp | 3 - plugins/GSdx/GSWnd.cpp | 6 +- plugins/GSdx/res/merge.glsl | 6 +- plugins/GSdx/stdafx.h | 5 - 7 files changed, 54 insertions(+), 157 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 57aa7d1531..cbf97f3b37 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -16,7 +16,6 @@ set(CommonFlags -mfpmath=sse #-Wstrict-aliasing # Allow to track strict aliasing issue. -Wunused-variable - -DKEEP_SDL ) set(OptimizationFlags diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 9aae22efba..8f7150a8b7 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -56,8 +56,6 @@ GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) - //, m_context(0) - , m_dummy_renderer(NULL) , m_vb(0) , m_pipeline(0) , m_srv_changed(false) @@ -66,9 +64,6 @@ GSDeviceOGL::GSDeviceOGL() { m_msaa = theApp.GetConfig("msaa", 0); - m_frag_back_buffer[0] = GL_BACK_LEFT; - m_frag_rt_buffer[0] = GL_COLOR_ATTACHMENT0; - memset(&m_merge, 0, sizeof(m_merge)); memset(&m_interlace, 0, sizeof(m_interlace)); memset(&m_convert, 0, sizeof(m_convert)); @@ -106,18 +101,6 @@ GSDeviceOGL::~GSDeviceOGL() glDeleteBuffers(1, &m_vb); glDeleteProgramPipelines(1, &m_pipeline); glDeleteFramebuffers(1, &m_fbo); - - // glXMakeCurrent(m_XDisplay, m_Xwindow, 0); - // if (m_context) glXDestroyContext(m_XDisplay, m_context); - // if(m_context) - // SDL_GL_DeleteContext(m_context); -#ifdef KEEP_SDL - if(m_dummy_renderer) - SDL_DestroyRenderer(m_dummy_renderer); - - if(m_window != NULL && m_free_window) - SDL_DestroyWindow(m_window); -#endif } GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) @@ -153,38 +136,9 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int form return GSDevice::FetchSurface(type, w, h, msaa, format); } -PFNGLTEXSTORAGE2DPROC glTexStorage2D_glew17 = NULL; - bool GSDeviceOGL::Create(GSWnd* wnd) { if (m_window == NULL) { -#ifdef KEEP_SDL - m_window = SDL_CreateWindowFrom(wnd->GetHandle()); - m_free_window = true; - - // If the user request OpenGL acceleration, we take recent OGL version (4.2) - // We keep the default 2.1 version in SW mode (only DX11 capable card, are compatible with OGL4) if ( theApp.GetConfig("renderer", 0) / 3 == 4 ) { - // Setup visual attribute - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 ); - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 ); - // Ask for an advance opengl version - SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); - // FIXME AMD does not support yet 4.2... - //SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 ); - SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 ); - - // Window must be recreated to gain Opengl feature... - //SDL_RecreateWindow(m_window, SDL_GetWindowFlags(m_window) | SDL_WINDOW_OPENGL ); - // Well actually you need to generate a full renderer to only have a context... - m_dummy_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); // SDL_RENDERER_PRESENTVSYNC - // At least create the opengl context - // m_context = SDL_GL_CreateContext(m_window); -#endif - // FIXME...... // GLEW's problem is that it calls glGetString(GL_EXTENSIONS) which causes GL_INVALID_ENUM on GL 3.2 forward compatible context as soon as glewInit() is called. It also doesn't fetch the function pointers. The solution is for GLEW to use glGetStringi instead. // The current version of GLEW is 1.7.0 but they still haven't corrected it. The only fix is to use glewExperimental for now : @@ -203,18 +157,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd) fprintf(stderr, "4.1 is not supported!\n"); return false; } - - // Not yet supported by glew1.6 - glTexStorage2D_glew17 = (PFNGLTEXSTORAGE2DPROC)glXGetProcAddressARB((const GLubyte*)"glTexStorage2D"); } -#ifdef KEEP_SDL - // In GSopen2, sdl failed to received any resize event. GSWnd::GetClientRect need to manually - // set the window size... So we send the m_window to the wnd object to allow some manipulation on it. - wnd->SetWindow(m_window); -#else m_window = wnd; -#endif // FIXME disable it when code is ready glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); @@ -226,6 +171,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glBindProgramPipeline(m_pipeline); glGenFramebuffers(1, &m_fbo); + // Setup FBO fragment output + OMSetFBO(m_fbo); + glDrawBuffer(GL_COLOR_ATTACHMENT0); + OMSetFBO(0); // **************************************************************** // convert // **************************************************************** @@ -549,19 +498,13 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { GSTextureOGL* t_ogl = (GSTextureOGL*)t; if (t == m_backbuffer) { - // FIXME need an assert - if (m_state.fbo) { - m_state.fbo = 0; - glBindFramebuffer(GL_FRAMEBUFFER, 0); - } - glClearBufferfv(GL_COLOR, GL_BACK, c.v); + // FIXME I really not sure + OMSetFBO(0); + glClearBufferfv(GL_COLOR, GL_LEFT, c.v); } else { // FIXME I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation - if (!m_state.fbo) { - m_state.fbo = m_fbo; - glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); - } + OMSetFBO(m_fbo); t_ogl->Attach(GL_COLOR_ATTACHMENT0); glClearBufferfv(GL_COLOR, 0, c.v); } @@ -757,12 +700,6 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, PSSetShader(ps, ps_cb); // - // FIXME: disable it when code is working - glValidateProgramPipeline(m_pipeline); - GLint status; - glGetProgramPipelineiv(m_pipeline, GL_VALIDATE_STATUS, &status); - if (status != GL_TRUE) - fprintf(stderr, "Failed to validate the pipeline\n"); DrawPrimitive(); @@ -771,9 +708,6 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, EndScene(); PSSetShaderResources(NULL, NULL); - - // FIXME: disable it when code is working - CheckDebugLog(); } void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c) @@ -865,9 +799,8 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t if(!m_vb) { glGenBuffers(1, &m_vb); - // FIXME: GL_DYNAMIC_DRAW vs GL_STREAM_DRAW !!! glBindBuffer(GL_ARRAY_BUFFER, m_vb); - glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * stride, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * stride, NULL, GL_STREAM_DRAW); m_vb_changed = true; } @@ -1018,6 +951,14 @@ void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) } } +void GSDeviceOGL::OMSetFBO(GLuint fbo) +{ + if (m_state.fbo != fbo) { + m_state.fbo = fbo; + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + } +} + void GSDeviceOGL::OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref) { uint ref = sref; @@ -1091,19 +1032,11 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto GSTextureOGL* ds_ogl = (GSTextureOGL*)ds; if (m_backbuffer == rt_ogl) { - if (m_state.fbo) { - m_state.fbo = 0; - glBindFramebuffer(GL_FRAMEBUFFER, 0); // render in the backbuffer - glDrawBuffers(1, m_frag_back_buffer); - } + OMSetFBO(0); assert(ds_ogl == NULL); // no depth-stencil without FBO } else { - if (m_state.fbo != m_fbo) { - m_state.fbo = m_fbo; - glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); - glDrawBuffers(1, m_frag_rt_buffer); - } + OMSetFBO(m_fbo); assert(rt_ogl != NULL); // a render target must exists rt_ogl->Attach(GL_COLOR_ATTACHMENT0); @@ -1251,52 +1184,36 @@ void GSDeviceOGL::CheckDebugLog() void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message) { - FILE* f; - // FIXME properly log error - f = fopen("Debug.txt","a"); + char debType[20], debSev[5]; + + if(type == GL_DEBUG_TYPE_ERROR_ARB) + strcpy(debType, "Error"); + else if(type == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) + strcpy(debType, "Deprecated behavior"); + else if(type == GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) + strcpy(debType, "Undefined behavior"); + else if(type == GL_DEBUG_TYPE_PORTABILITY_ARB) + strcpy(debType, "Portability"); + else if(type == GL_DEBUG_TYPE_PERFORMANCE_ARB) + strcpy(debType, "Performance"); + else if(type == GL_DEBUG_TYPE_OTHER_ARB) + strcpy(debType, "Other"); + else + strcpy(debType, "UNKNOW"); + + if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) + strcpy(debSev, "High"); + else if(severity == GL_DEBUG_SEVERITY_MEDIUM_ARB) + strcpy(debSev, "Med"); + else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) + strcpy(debSev, "Low"); + + //fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + + FILE* f = fopen("Debug.txt","a"); if(f) { - char debSource[16], debType[20], debSev[5]; - if(source == GL_DEBUG_SOURCE_API_ARB) - strcpy(debSource, "OpenGL"); - else if(source == GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) - strcpy(debSource, "Windows"); - else if(source == GL_DEBUG_SOURCE_SHADER_COMPILER_ARB) - strcpy(debSource, "Shader Compiler"); - else if(source == GL_DEBUG_SOURCE_THIRD_PARTY_ARB) - strcpy(debSource, "Third Party"); - else if(source == GL_DEBUG_SOURCE_APPLICATION_ARB) - strcpy(debSource, "Application"); - else if(source == GL_DEBUG_SOURCE_OTHER_ARB) - strcpy(debSource, "Other"); - else - strcpy(debSource, "UNKNOW"); - - - if(type == GL_DEBUG_TYPE_ERROR_ARB) - strcpy(debType, "Error"); - else if(type == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) - strcpy(debType, "Deprecated behavior"); - else if(type == GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) - strcpy(debType, "Undefined behavior"); - else if(type == GL_DEBUG_TYPE_PORTABILITY_ARB) - strcpy(debType, "Portability"); - else if(type == GL_DEBUG_TYPE_PERFORMANCE_ARB) - strcpy(debType, "Performance"); - else if(type == GL_DEBUG_TYPE_OTHER_ARB) - strcpy(debType, "Other"); - else - strcpy(debType, "UNKNOW"); - - if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) - strcpy(debSev, "High"); - else if(severity == GL_DEBUG_SEVERITY_MEDIUM_ARB) - strcpy(debSev, "Med"); - else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) - strcpy(debSev, "Low"); - - //fprintf(stderr,"Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debSource,debType,id,debSev,message); - fprintf(f,"Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debSource,debType,id,debSev,message); + fprintf(f,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); fclose(f); } } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index b734390fdc..4cdc3cc9d4 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -25,7 +25,6 @@ #include "GSDevice.h" #include "GSTextureOGL.h" #include "GSdx.h" -#include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" struct GSBlendStateOGL { // Note: You can also select the index of the draw buffer for which to set the blend setting @@ -103,21 +102,12 @@ class GSDeviceOGL : public GSDevice uint32 m_msaa; // Level of Msaa bool m_free_window; -#ifdef KEEP_SDL - SDL_Window* m_window; // pointer to the SDL window -#else - GSWnd* m_window; // pointer to the SDL window -#endif - //SDL_GLContext m_context; // current opengl context - SDL_Renderer* m_dummy_renderer; // ... crappy API ... + GSWnd* m_window; GLuint m_vb; // vertex buffer object GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container - GLenum m_frag_back_buffer[1]; - GLenum m_frag_rt_buffer[1]; - struct { GLuint ps[2]; // program object GSUniformBufferOGL* cb; // uniform buffer object @@ -293,6 +283,7 @@ class GSDeviceOGL : public GSDevice void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2 = 0); void PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb); + void OMSetFBO(GLuint fbo); void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); void OMSetBlendState(GSBlendStateOGL* bs, float bf); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 21b6518828..1336334ddd 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -152,9 +152,6 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother EnableUnit(0); - // FIXME glTexStorage2D does not work yet on my system (4.2) extension but glTexImage2D seems ok - // glTexStorage2D_glew17(m_texture_target, 1, m_format, m_size.y, m_size.x); - // fprintf(stderr, "texture storage %d, %d\n", w, h); if (m_format == GL_RGBA8) { glTexImage2D(m_texture_target, 0, m_format, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); } diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 0ee8cce34a..f1a93b37ea 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -314,11 +314,6 @@ void GSWnd::HideFrame() GSWnd::GSWnd() : m_window(NULL), m_Xwindow(0), m_XDisplay(NULL) { -#ifdef KEEP_SDL - m_renderer = 2; -#else - m_renderer = theApp.GetConfig("renderer", 0) / 3; -#endif } GSWnd::~GSWnd() @@ -339,6 +334,7 @@ bool GSWnd::Attach(void* handle, bool managed) m_Xwindow = *(Window*)handle; m_managed = managed; + m_renderer = theApp.GetConfig("renderer", 0) / 3; if (m_renderer != 2) { m_XDisplay = XOpenDisplay(NULL); diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index 8f6ca11f09..ea2cf51c3a 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -16,14 +16,16 @@ layout(binding = 0) uniform sampler2D TextureSampler; void ps_main0() { - vec4 c = texture(TextureSampler, TEXCOORD0); + vec4 c = texture(TextureSampler, vec2(TEXCOORD0.x, 1.0 -TEXCOORD0.y)); + //vec4 c = texture(TextureSampler, TEXCOORD0); c.a = min(c.a * 2, 1.0); SV_Target0 = c; } void ps_main1() { - vec4 c = texture(TextureSampler, TEXCOORD0); + vec4 c = texture(TextureSampler, vec2(TEXCOORD0.x, 1.0 -TEXCOORD0.y)); + //vec4 c = texture(TextureSampler, TEXCOORD0); c.a = BGColor.a; SV_Target0 = c; } diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 7112ea16b6..96562613f3 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -116,11 +116,6 @@ using namespace stdext; #include #include -// Need to have glew 1.7 but Debian/Ubuntu is only 1.6 -// We will see later for the upgrade -typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -extern PFNGLTEXSTORAGE2DPROC glTexStorage2D_glew17; - //using namespace __gnu_cxx; #define DIRECTORY_SEPARATOR '/' From afdb2dadc39894b0689da0555d5569431fed6756 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 8 Dec 2011 16:39:14 +0000 Subject: [PATCH 08/56] gsdx-ogl: LINUX-ONLY * add a callback for GLERROR. Allow to breakpoint on GSDeviceOGL::DebugCallback (gdb is completely lost on amd driver, hope it is better on nvidia) * Add some empty glsl convert to shutup some useless debugging error * request an advance opengl context without pre 3.0 feature. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4983 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GS.cpp | 3 ++- plugins/GSdx/GSDeviceOGL.cpp | 11 +++++++++-- plugins/GSdx/GSDeviceOGL.h | 11 +++++------ plugins/GSdx/GSWnd.cpp | 5 +++-- plugins/GSdx/res/convert.glsl | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index d18be7fb2f..6b46facbc4 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -289,7 +289,8 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) #ifdef __LINUX__ // Get the Xwindow from dsp. - s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false); + if( !s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false) ) + return -1; #else s_gs->m_wnd.Attach(*dsp, false); #endif diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 8f7150a8b7..591aafd6a7 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -159,10 +159,11 @@ bool GSDeviceOGL::Create(GSWnd* wnd) } } - m_window = wnd; - // FIXME disable it when code is ready glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + glDebugMessageCallbackARB(&GSDeviceOGL::DebugCallback, NULL); + + m_window = wnd; // **************************************************************** // Various object @@ -1150,6 +1151,12 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st free(log); } +void GSDeviceOGL::DebugCallback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, void* userParam) +{ + DebugOutputToFile(source, type, id, severity, message); +} + + void GSDeviceOGL::CheckDebugLog() { unsigned int count = 64; // max. num. of messages that will be read from the log diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 4cdc3cc9d4..d6e081db12 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -228,12 +228,6 @@ class GSDeviceOGL : public GSDevice PSConstantBuffer m_ps_cb_cache; #endif - //GLenum frag_back[1] = { GL_BACK }; - //GLenum frag_target[1] = { GL_COLOR_ATTACHMENT0 }: - - void CheckDebugLog(); - void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); - protected: GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); @@ -244,6 +238,11 @@ class GSDeviceOGL : public GSDevice GSDeviceOGL(); virtual ~GSDeviceOGL(); + static void DebugCallback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, void* userParam); + void CheckDebugLog(); + static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); + + bool Create(GSWnd* wnd); bool Reset(int w, int h); void Flip(); diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index f1a93b37ea..27aedd894a 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -361,8 +361,9 @@ bool GSWnd::Attach(void* handle, bool managed) { GLX_CONTEXT_MAJOR_VERSION_ARB, 4, GLX_CONTEXT_MINOR_VERSION_ARB, 1, - // FIXME : Request a debug context to ease opengl development - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + // FIXME : Request a debug context to ease opengl development + // Note: don't support deprecated feature (pre openg 3.1) + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, 0 }; m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 861191a97b..32a91074c0 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -94,6 +94,20 @@ void ps_main6() // diagonal SV_Target0 = c; } +// Avoid to log useless error compilation failure +void ps_main1() +{ +} +void ps_main2() +{ +} +void ps_main3() +{ +} +void ps_main4() +{ +} + //void ps_main1() //{ // vec4 c = sample_c(TEXCOORD); From e6057b765f480a4caba0a0e7f0d44b70e17c7824 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 10 Dec 2011 11:56:34 +0000 Subject: [PATCH 09/56] gsdx-ogl: LINUX-ONLY * Fix context creation. Get opengl working with nvidia graphics cards. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4984 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 13 ++++++++++--- plugins/GSdx/GSWnd.cpp | 32 +++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 591aafd6a7..950c83ff86 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -52,7 +52,7 @@ // glBindBufferBase(GL_UNIFORM_BUFFER, block_binding_point, some_buffer_object); // glUniformBlockBinding(program, block_index, block_binding_point); - +//#define LOUD_DEBUGGING GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) @@ -179,6 +179,11 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** // convert // **************************************************************** + + // There isn't a default VAO in newer versions of OpenGL, so create one. + unsigned int vao = 0; + glGenVertexArrays(1,&vao); + glBindVertexArray(vao); GSInputLayout il_convert[2] = { @@ -1206,7 +1211,7 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi else if(type == GL_DEBUG_TYPE_OTHER_ARB) strcpy(debType, "Other"); else - strcpy(debType, "UNKNOW"); + strcpy(debType, "UNKNOWN"); if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) strcpy(debSev, "High"); @@ -1215,7 +1220,9 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) strcpy(debSev, "Low"); - //fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + #ifdef LOUD_DEBUGGING + fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + #endif FILE* f = fopen("Debug.txt","a"); if(f) diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 27aedd894a..8873ac2bcb 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -338,15 +338,26 @@ bool GSWnd::Attach(void* handle, bool managed) if (m_renderer != 2) { m_XDisplay = XOpenDisplay(NULL); - // Get visual information - int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_DEPTH_SIZE, 24, - None - }; - + if ( !m_XDisplay ) + { + fprintf( stderr, "Failed to open X display\n" ); + exit(1); + } + + // Get visual information + static int attrListDbl[] = + { + GLX_X_RENDERABLE , True, + GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT, + GLX_RENDER_TYPE , GLX_RGBA_BIT, + GLX_RED_SIZE , 8, + GLX_GREEN_SIZE , 8, + GLX_BLUE_SIZE , 8, + GLX_DEPTH_SIZE , 24, + GLX_DOUBLEBUFFER , True, + None + }; + PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig"); int fbcount = 0; GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount); @@ -364,7 +375,7 @@ bool GSWnd::Attach(void* handle, bool managed) // FIXME : Request a debug context to ease opengl development // Note: don't support deprecated feature (pre openg 3.1) GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, - 0 + None }; m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); XSync( m_XDisplay, false); @@ -382,7 +393,6 @@ bool GSWnd::Attach(void* handle, bool managed) } - return true; } From daf3c436810932a2167ddd974d7c7ae573e82906 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 10 Dec 2011 19:19:44 +0000 Subject: [PATCH 10/56] gsdx-ogl: LINUX-ONLY * improve vertex management with a vertex array. Decorrelate vertex from strech rec and others func (later for the HW renderer) * fix the crash on nvidia when closing the window * clean some texture management code git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4985 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 94 +++++++++++++++++++++++++++-------- plugins/GSdx/GSDeviceOGL.h | 18 ++++--- plugins/GSdx/GSTextureOGL.cpp | 30 ++++++----- plugins/GSdx/GSWnd.cpp | 5 +- plugins/GSdx/GSWnd.h | 2 - 5 files changed, 101 insertions(+), 48 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 950c83ff86..c15aa0779f 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -57,10 +57,11 @@ GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) , m_vb(0) + , m_fbo(0) + , m_sr_vb_offset(0) , m_pipeline(0) , m_srv_changed(false) , m_ss_changed(false) - , m_vb_changed(false) { m_msaa = theApp.GetConfig("msaa", 0); @@ -85,6 +86,8 @@ GSDeviceOGL::~GSDeviceOGL() delete (m_interlace.cb); // Clean m_convert + glDeleteVertexArrays(1, &m_convert.va); + glDeleteBuffers(1, &m_convert.vb); glDeleteProgram(m_convert.vs); for (uint i = 0; i < 2; i++) glDeleteProgram(m_convert.ps[i]); @@ -176,14 +179,17 @@ bool GSDeviceOGL::Create(GSWnd* wnd) OMSetFBO(m_fbo); glDrawBuffer(GL_COLOR_ATTACHMENT0); OMSetFBO(0); + // **************************************************************** // convert // **************************************************************** - // There isn't a default VAO in newer versions of OpenGL, so create one. - unsigned int vao = 0; - glGenVertexArrays(1,&vao); - glBindVertexArray(vao); + glGenVertexArrays(1, &m_convert.va); + IASetVertexArrray(m_convert.va); + + glGenBuffers(1, &m_convert.vb); + IASetVertexBufferBind(m_convert.vb); + glBufferData(GL_ARRAY_BUFFER, 4 * 4 * sizeof(GSVertexPT1), NULL, GL_STREAM_DRAW); GSInputLayout il_convert[2] = { @@ -191,8 +197,14 @@ bool GSDeviceOGL::Create(GSWnd* wnd) {1, 2, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, }; - m_convert.il[0] = il_convert[0]; - m_convert.il[1] = il_convert[1]; + for (int i = 0; i < 2; i++) { + // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer + glEnableVertexAttribArray(il_convert[i].index); + glVertexAttribPointer(il_convert[i].index, il_convert[i].size, il_convert[i].type, GL_FALSE, il_convert[i].stride, il_convert[i].offset); + } + // Unbind to avoid issue with the setup of others parameters + IASetVertexArrray(0); + IASetVertexBufferBind(0); CompileShaderFromSource("convert.glsl", "vs_main", GL_VERTEX_SHADER, &m_convert.vs); for(int i = 0; i < countof(m_convert.ps); i++) @@ -662,17 +674,25 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, return; } + // ************************************ + // Init + // ************************************ + BeginScene(); GSVector2i ds = dt->GetSize(); + // ************************************ // om + // ************************************ OMSetDepthStencilState(m_convert.dss, 0); OMSetBlendState(bs, 0); OMSetRenderTargets(dt, NULL); + // ************************************ // ia + // ************************************ float left = dr.x * 2 / ds.x - 1.0f; float top = 1.0f - dr.y * 2 / ds.y; @@ -687,29 +707,44 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, {GSVector4(right, bottom, 0.5f, 1.0f), GSVector2(sr.z, sr.w)}, }; - IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices)); - IASetInputLayout(m_convert.il, 2); - IASetPrimitiveTopology(GL_TRIANGLE_STRIP); + IASetVertexArrray(m_convert.va); + IASetVertexBufferBind(m_convert.vb); + // FIXME it will worth some benchmark. + // What is the faster always use the same. Or pack to difference emplacement. I'm afraid + // that in all case the GPU will be stall to wait the data + // Note maybe create a new buffer can be faster. + // m_sr_vb_offset = 0; + glBufferSubData(GL_ARRAY_BUFFER, m_sr_vb_offset * 4 * sizeof(GSVertexPT1) , sizeof(GSVertexPT1) * 4, vertices); + // ************************************ // vs + // ************************************ VSSetShader(m_convert.vs, NULL); + // ************************************ // gs + // ************************************ GSSetShader(0); + // ************************************ // ps + // ************************************ PSSetShaderResources(st, NULL); PSSetSamplerState(linear ? m_convert.ln : m_convert.pt, 0); PSSetShader(ps, ps_cb); - // + // ************************************ + // Draw + // ************************************ + glDrawArrays(GL_TRIANGLE_STRIP, m_sr_vb_offset * 4, 4); + m_sr_vb_offset = (m_sr_vb_offset + 1) & 0x3; - DrawPrimitive(); - - // + // ************************************ + // End + // ************************************ EndScene(); @@ -784,6 +819,22 @@ GSTexture* GSDeviceOGL::Resolve(GSTexture* t) return NULL; } +void GSDeviceOGL::IASetVertexArrray(GLuint va) +{ + if (m_state.va != va) { + glBindVertexArray(va); + m_state.va = va; + } +} + +void GSDeviceOGL::IASetVertexBufferBind(GLuint vb) +{ + if (m_state.vb != vb) { + glBindBuffer(GL_ARRAY_BUFFER, vb); + m_state.vb = vb; + } +} + void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t count) { ASSERT(m_vertices.count == 0); @@ -799,15 +850,16 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t m_vertices.start = 0; m_vertices.count = 0; m_vertices.limit = std::max(count * 3 / 2, 11000); - + m_vertices.stride = stride; } if(!m_vb) { glGenBuffers(1, &m_vb); - glBindBuffer(GL_ARRAY_BUFFER, m_vb); - glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * stride, NULL, GL_STREAM_DRAW); - m_vb_changed = true; + IASetVertexBufferBind(m_vb); + // Allocate the buffer + glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * m_vertices.stride, NULL, GL_STREAM_DRAW); + //m_vb_changed = true; } // append data or go back to the beginning @@ -815,14 +867,13 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t if(m_vertices.start + count > m_vertices.limit || stride != m_vertices.stride) m_vertices.start = 0; - // Allocate the buffer - // glBufferSubData + // Fill the buffer glBufferSubData(GL_ARRAY_BUFFER, m_vertices.start * stride, count * stride, vertices); m_vertices.count = count; - m_vertices.stride = stride; } +#if 0 void GSDeviceOGL::IASetInputLayout(GSInputLayout* layout, int layout_nbr) { if(m_state.layout != layout || m_state.layout_nbr != layout_nbr || m_vb_changed) @@ -842,6 +893,7 @@ void GSDeviceOGL::IASetInputLayout(GSInputLayout* layout, int layout_nbr) m_state.layout_nbr = layout_nbr; } } +#endif void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) { diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index d6e081db12..d89f6db671 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -107,6 +107,7 @@ class GSDeviceOGL : public GSDevice GLuint m_vb; // vertex buffer object GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container + uint32 m_sr_vb_offset; struct { GLuint ps[2]; // program object @@ -123,7 +124,9 @@ class GSDeviceOGL : public GSDevice // Hum I think this one is useless. As far as I understand // it only get the index name of GLSL-equivalent input attribut // ??? CComPtr il; - GSInputLayout il[2]; // description of the vertex array + //GSInputLayout il[2]; // description of the vertex array + GLuint va; // vertex array object + GLuint vb; // vertex buffer GLuint vs; // program object GLuint ps[8]; // program object GLuint ln; // sampler object @@ -162,12 +165,13 @@ class GSDeviceOGL : public GSDevice // } m_state; struct { - GLuint vb; + GLuint vb; // vertex buffer // Hum I think those things can be dropped on OGL. It probably need an others architecture (see glVertexAttribPointer) // size_t vb_stride; // ID3D11InputLayout* layout; - GSInputLayout* layout; - uint32 layout_nbr; + //GSInputLayout* layout; + //uint32 layout_nbr; + GLuint va; // vertex array GLenum topology; // (ie GL_TRIANGLES...) GLuint vs; // program GLuint cb; // uniform current buffer @@ -195,7 +199,7 @@ class GSDeviceOGL : public GSDevice bool m_srv_changed; bool m_ss_changed; - bool m_vb_changed; + //bool m_vb_changed; #if 0 CComPtr m_dev; @@ -271,8 +275,10 @@ class GSDeviceOGL : public GSDevice void CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program); void IASetPrimitiveTopology(GLenum topology); - void IASetInputLayout(GSInputLayout* layout, int layout_nbr); + //void IASetInputLayout(GSInputLayout* layout, int layout_nbr); void IASetVertexBuffer(const void* vertices, size_t stride, size_t count); + void IASetVertexBufferBind(GLuint vb); + void IASetVertexArrray(GLuint va); void VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb); void GSSetShader(GLuint gs); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 1336334ddd..f94c1b4f3d 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -22,6 +22,8 @@ #pragma once #include "GSTextureOGL.h" +static uint g_state_texture_unit = 0; +static uint g_state_texture_id = 0; GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) : m_texture_unit(0), @@ -93,13 +95,8 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // Generate the buffer switch (m_type) { + case GSTexture::Texture: case GSTexture::RenderTarget: - // FIXME what is the real use case of this texture - // Maybe a texture will be better - // glGenRenderbuffers(1, &m_texture_id); - // m_texture_target = GL_RENDERBUFFER; - // Buffer can not be read by shader and must be blit before. I see no point to use a render buffer - // when you can directly render on the texture. It said it could be faster... glGenTextures(1, &m_texture_id); m_texture_target = GL_TEXTURE_2D; break; @@ -107,13 +104,6 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) glGenRenderbuffers(1, &m_texture_id); m_texture_target = GL_RENDERBUFFER; break; - case GSTexture::Texture: - glGenTextures(1, &m_texture_id); - // FIXME, do we need rectangle (or better to use 2D texture) - m_texture_target = GL_TEXTURE_2D; - //m_texture_target = GL_TEXTURE_RECTANGLE; - // == For texture, the Unit must be selected - break; case GSTexture::Offscreen: //FIXME I not sure we need a pixel buffer object. It seems more a texture // glGenBuffers(1, &m_texture_id); @@ -156,7 +146,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) glTexImage2D(m_texture_target, 0, m_format, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); } else - assert(0); + assert(0); // TODO Later break; case GSTexture::Offscreen: assert(0); @@ -252,8 +242,16 @@ void GSTextureOGL::EnableUnit(uint unit) // Howto allocate the texture unit !!! // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother - glActiveTexture(GL_TEXTURE0 + unit); - glBindTexture(m_texture_target, m_texture_id); + if (g_state_texture_unit != unit) { + g_state_texture_unit = unit; + glActiveTexture(GL_TEXTURE0 + unit); + // When you change the texture unit, texture must be rebinded + g_state_texture_id = m_texture_id; + glBindTexture(m_texture_target, m_texture_id); + } else if (g_state_texture_id != m_texture_id) { + g_state_texture_id = m_texture_id; + glBindTexture(m_texture_target, m_texture_id); + } break; } } diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 8873ac2bcb..2b10f67825 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -363,8 +363,7 @@ bool GSWnd::Attach(void* handle, bool managed) GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount); if (!fbc || fbcount < 1) return false; - glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0; - glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB"); + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB"); if (!glXCreateContextAttribsARB) return false; // Create a context @@ -407,7 +406,7 @@ void GSWnd::Detach() m_window = NULL; } } else { - glXMakeCurrent(m_XDisplay, m_Xwindow, 0); + glXMakeCurrent(m_XDisplay, None, NULL); if (m_context) glXDestroyContext(m_XDisplay, m_context); } if (m_XDisplay) { diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index 2c14b0794e..44fcc844db 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -91,8 +91,6 @@ public: #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL_syswm.h" -typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, bool, const int*); - class GSWnd { SDL_Window* m_window; From fbb224837d5c7b417fb35f4e085cbf63321113d2 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 11 Dec 2011 19:09:08 +0000 Subject: [PATCH 11/56] gsdx-ogl: LINUX-ONLY * Enable interlace feature. (note I'm well aware that interlace crashes with SDL) * remove useless callback debug function * handle the y axis differently. Move vertex to follow right-hand system (render everything in reverse) then flip the y-axis for the screen rendering git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4987 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 42 +++++++++++++++------------------ plugins/GSdx/GSDeviceOGL.h | 5 ++-- plugins/GSdx/GSLinuxDialog.cpp | 4 ---- plugins/GSdx/res/convert.glsl | 20 +++++++--------- plugins/GSdx/res/interlace.glsl | 2 +- plugins/GSdx/res/merge.glsl | 7 ++---- 6 files changed, 33 insertions(+), 47 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index c15aa0779f..20873108a2 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -57,9 +57,9 @@ GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) , m_vb(0) + , m_pipeline(0) , m_fbo(0) , m_sr_vb_offset(0) - , m_pipeline(0) , m_srv_changed(false) , m_ss_changed(false) { @@ -164,7 +164,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // FIXME disable it when code is ready glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); - glDebugMessageCallbackARB(&GSDeviceOGL::DebugCallback, NULL); m_window = wnd; @@ -265,8 +264,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // merge // **************************************************************** m_merge.cb = new GSUniformBufferOGL(1, sizeof(MergeConstantBuffer)); - //m_merge.cb->index = 1; - //m_merge.cb->byte_size = sizeof(MergeConstantBuffer); glGenBuffers(1, &m_merge.cb->buffer); glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); glBufferData(GL_UNIFORM_BUFFER, m_merge.cb->byte_size, NULL, GL_DYNAMIC_DRAW); @@ -287,8 +284,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // interlace // **************************************************************** m_interlace.cb = new GSUniformBufferOGL(2, sizeof(InterlaceConstantBuffer)); - //m_interlace.cb->index = 2; - //m_interlace.cb->byte_size = sizeof(InterlaceConstantBuffer); glGenBuffers(1, &m_interlace.cb->buffer); glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); glBufferData(GL_UNIFORM_BUFFER, m_interlace.cb->byte_size, NULL, GL_DYNAMIC_DRAW); @@ -694,17 +689,29 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // ia // ************************************ + float left = dr.x * 2 / ds.x - 1.0f; float top = 1.0f - dr.y * 2 / ds.y; float right = dr.z * 2 / ds.x - 1.0f; float bottom = 1.0f - dr.w * 2 / ds.y; + // Flip y axis only when we render in the backbuffer + // By default everything is render in the wrong order (ie dx). + // 1/ consistency between several pass rendering (interlace) + // 2/ in case some GSdx code expect thing in dx order. + // Only flipping the backbuffer is transparent (I hope)... + GSVector4 flip_sr = sr; + if (dt == m_backbuffer) { + flip_sr.y = 1.0f - sr.y; + flip_sr.w = 1.0f - sr.w; + } + GSVertexPT1 vertices[] = { - {GSVector4(left, top, 0.5f, 1.0f), GSVector2(sr.x, sr.y)}, - {GSVector4(right, top, 0.5f, 1.0f), GSVector2(sr.z, sr.y)}, - {GSVector4(left, bottom, 0.5f, 1.0f), GSVector2(sr.x, sr.w)}, - {GSVector4(right, bottom, 0.5f, 1.0f), GSVector2(sr.z, sr.w)}, + {GSVector4(left, bottom, 0.5f, 1.0f), GSVector2(flip_sr.x, flip_sr.y)}, + {GSVector4(right, bottom, 0.5f, 1.0f), GSVector2(flip_sr.z, flip_sr.y)}, + {GSVector4(left, top, 0.5f, 1.0f), GSVector2(flip_sr.x, flip_sr.w)}, + {GSVector4(right, top, 0.5f, 1.0f), GSVector2(flip_sr.z, flip_sr.w)}, }; IASetVertexArrray(m_convert.va); @@ -767,9 +774,7 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); } glBufferSubData(GL_UNIFORM_BUFFER, 0, m_merge.cb->byte_size, &c.v); -#if 0 - m_ctx->UpdateSubresource(m_merge.cb, 0, NULL, &c, 0, 0); -#endif + StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.cb, m_merge.bs, true); } } @@ -791,9 +796,6 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); } glBufferSubData(GL_UNIFORM_BUFFER, 0, m_interlace.cb->byte_size, &cb); -#if 0 - m_ctx->UpdateSubresource(m_interlace.cb, 0, NULL, &cb, 0, 0); -#endif StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); } @@ -1002,7 +1004,7 @@ void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) } #endif - if(m_state.ps_cb != ps_cb) + if(m_state.ps_cb != ps_cb && ps_cb != NULL) { m_state.ps_cb = ps_cb; glBindBufferBase(GL_UNIFORM_BUFFER, ps_cb->index, ps_cb->buffer); @@ -1208,12 +1210,6 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st free(log); } -void GSDeviceOGL::DebugCallback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, void* userParam) -{ - DebugOutputToFile(source, type, id, severity, message); -} - - void GSDeviceOGL::CheckDebugLog() { unsigned int count = 64; // max. num. of messages that will be read from the log diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index d89f6db671..6ec611e649 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -110,8 +110,8 @@ class GSDeviceOGL : public GSDevice uint32 m_sr_vb_offset; struct { - GLuint ps[2]; // program object - GSUniformBufferOGL* cb; // uniform buffer object + GLuint ps[2]; // program object + GSUniformBufferOGL* cb; // uniform buffer object GSBlendStateOGL* bs; } m_merge; @@ -242,7 +242,6 @@ class GSDeviceOGL : public GSDevice GSDeviceOGL(); virtual ~GSDeviceOGL(); - static void DebugCallback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, void* userParam); void CheckDebugLog(); static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 5cc66831e9..4f772e82a9 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -174,12 +174,8 @@ bool RunLinuxDialog() } } - #if 0 - // I'll put the right variable names in later. - // Crash, for some interlace options if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1) theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) ); - #endif theApp.SetConfig("swthreads", atoi((char*)gtk_entry_get_text(GTK_ENTRY(swthreads_text))) ); diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 32a91074c0..ed9494a28e 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -42,12 +42,12 @@ layout(location = 0) out vec4 SV_Target0; layout(binding = 0) uniform sampler2D TextureSampler; -vec4 sample_c(vec2 uv) +vec4 sample_c() { - return texture(TextureSampler, uv); + return texture(TextureSampler, vec2(TEXCOORD0.x,TEXCOORD0.y) ); } -vec4 ps_crt(vec2 uv, uint i) +vec4 ps_crt(uint i) { vec4 mask[4] = { @@ -57,17 +57,17 @@ vec4 ps_crt(vec2 uv, uint i) vec4(1, 1, 1, 0) }; - return sample_c(uv) * clamp((mask[i] + 0.5f), 0.0f, 1.0f); + return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f); } void ps_main0() { - SV_Target0 = sample_c(TEXCOORD0); + SV_Target0 = sample_c(); } void ps_main7() { - vec4 c = sample_c(TEXCOORD0); + vec4 c = sample_c(); c.a = dot(c.rgb, vec3(0.299, 0.587, 0.114)); @@ -76,11 +76,9 @@ void ps_main7() void ps_main5() // triangular { - //uint4 p = (uint4)input.p; highp uvec4 p = uvec4(SV_Position); - // output.c = ps_crt(input, ((p.x + (p.y & 1) * 3) >> 1) % 3); - vec4 c = ps_crt(TEXCOORD0, ((p.x + ((p.y >> 1) & 1) * 3) >> 1) % 3); + vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) % 3u); SV_Target0 = c; } @@ -89,7 +87,7 @@ void ps_main6() // diagonal { uvec4 p = uvec4(SV_Position); - vec4 c = ps_crt(TEXCOORD0, (p.x + (p.y % 3)) % 3); + vec4 c = ps_crt((p.x + (p.y % 3)) % 3); SV_Target0 = c; } @@ -110,7 +108,7 @@ void ps_main4() //void ps_main1() //{ -// vec4 c = sample_c(TEXCOORD); +// vec4 c = sample_c(); // // c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 // diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index 5b04be378d..2792ea60a6 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -6,7 +6,7 @@ layout(location = 1) in vec2 TEXCOORD0; layout(location = 0) out vec4 SV_Target0; -layout(std140, binding = 1) uniform cb0 +layout(std140, binding = 2) uniform cb0 { vec2 ZrH; float hH; diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index ea2cf51c3a..2e438d4055 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -15,17 +15,14 @@ layout(binding = 0) uniform sampler2D TextureSampler; void ps_main0() { - - vec4 c = texture(TextureSampler, vec2(TEXCOORD0.x, 1.0 -TEXCOORD0.y)); - //vec4 c = texture(TextureSampler, TEXCOORD0); + vec4 c = texture(TextureSampler, TEXCOORD0); c.a = min(c.a * 2, 1.0); SV_Target0 = c; } void ps_main1() { - vec4 c = texture(TextureSampler, vec2(TEXCOORD0.x, 1.0 -TEXCOORD0.y)); - //vec4 c = texture(TextureSampler, TEXCOORD0); + vec4 c = texture(TextureSampler, TEXCOORD0); c.a = BGColor.a; SV_Target0 = c; } From 4029cc5195b24d11adc66505b860ccb8dea6f371 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 11 Dec 2011 19:11:01 +0000 Subject: [PATCH 12/56] gsdx-ogl: LINUX-ONLY * constant buffer are attached to contexts not programs. So do it only once! git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4988 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 36 +++++++++++++----------------------- plugins/GSdx/GSDeviceOGL.h | 10 ++++------ 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 20873108a2..06bc2027ad 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -267,6 +267,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glGenBuffers(1, &m_merge.cb->buffer); glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); glBufferData(GL_UNIFORM_BUFFER, m_merge.cb->byte_size, NULL, GL_DYNAMIC_DRAW); + glBindBufferBase(GL_UNIFORM_BUFFER, m_merge.cb->index, m_merge.cb->buffer); for(int i = 0; i < countof(m_merge.ps); i++) CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge.ps[i]); @@ -287,6 +288,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glGenBuffers(1, &m_interlace.cb->buffer); glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); glBufferData(GL_UNIFORM_BUFFER, m_interlace.cb->byte_size, NULL, GL_DYNAMIC_DRAW); + glBindBufferBase(GL_UNIFORM_BUFFER, m_interlace.cb->index, m_interlace.cb->buffer); for(int i = 0; i < countof(m_interlace.ps); i++) CompileShaderFromSource("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_interlace.ps[i]); @@ -652,15 +654,15 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear) { - StretchRect(st, sr, dt, dr, m_convert.ps[shader], NULL, linear); + StretchRect(st, sr, dt, dr, m_convert.ps[shader], linear); } -void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear) +void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, bool linear) { - StretchRect(st, sr, dt, dr, ps, ps_cb, m_convert.bs, linear); + StretchRect(st, sr, dt, dr, ps, m_convert.bs, linear); } -void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, GSBlendStateOGL* bs, bool linear) +void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSBlendStateOGL* bs, bool linear) { if(!st || !dt) @@ -727,7 +729,7 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // vs // ************************************ - VSSetShader(m_convert.vs, NULL); + VSSetShader(m_convert.vs); // ************************************ // gs @@ -741,7 +743,7 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, PSSetShaderResources(st, NULL); PSSetSamplerState(linear ? m_convert.ln : m_convert.pt, 0); - PSSetShader(ps, ps_cb); + PSSetShader(ps); // ************************************ // Draw @@ -764,7 +766,7 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect if(st[1] && !slbg) { - StretchRect(st[1], sr[1], dt, dr[1], m_merge.ps[0], NULL, true); + StretchRect(st[1], sr[1], dt, dr[1], m_merge.ps[0]); } if(st[0]) @@ -775,7 +777,7 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect } glBufferSubData(GL_UNIFORM_BUFFER, 0, m_merge.cb->byte_size, &c.v); - StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.cb, m_merge.bs, true); + StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.bs); } } @@ -797,7 +799,7 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin } glBufferSubData(GL_UNIFORM_BUFFER, 0, m_interlace.cb->byte_size, &cb); - StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); + StretchRect(st, sr, dt, dr, m_interlace.ps[shader], linear); } // copy a multisample texture to a non-texture multisample. On opengl you need 2 FBO with different level of @@ -905,19 +907,13 @@ void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) } } -void GSDeviceOGL::VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb) +void GSDeviceOGL::VSSetShader(GLuint vs) { if(m_state.vs != vs) { m_state.vs = vs; glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs); } - - if(m_state.vs_cb != vs_cb) - { - m_state.vs_cb = vs_cb; - glBindBufferBase(GL_UNIFORM_BUFFER, vs_cb->index, vs_cb->buffer); - } } void GSDeviceOGL::GSSetShader(GLuint gs) @@ -962,7 +958,7 @@ void GSDeviceOGL::PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2) } } -void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) +void GSDeviceOGL::PSSetShader(GLuint ps) { if(m_state.ps != ps) @@ -1003,12 +999,6 @@ void GSDeviceOGL::PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb) m_ss_changed = false; } #endif - - if(m_state.ps_cb != ps_cb && ps_cb != NULL) - { - m_state.ps_cb = ps_cb; - glBindBufferBase(GL_UNIFORM_BUFFER, ps_cb->index, ps_cb->buffer); - } } void GSDeviceOGL::OMSetFBO(GLuint fbo) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 6ec611e649..9c0d210b8f 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -175,13 +175,11 @@ class GSDeviceOGL : public GSDevice GLenum topology; // (ie GL_TRIANGLES...) GLuint vs; // program GLuint cb; // uniform current buffer - GSUniformBufferOGL* vs_cb; // uniform buffer GLuint gs; // program // FIXME texture binding. Maybe not equivalent for the state but the best I could find. GSTextureOGL* ps_srv[3]; // ID3D11ShaderResourceView* ps_srv[3]; GLuint ps; // program - GSUniformBufferOGL* ps_cb; // uniform buffer GLuint ps_ss[3]; // sampler GSVector2i viewport; GSVector4i scissor; @@ -266,8 +264,8 @@ class GSDeviceOGL : public GSDevice void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r); void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, bool linear = true); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSUniformBufferOGL* ps_cb, GSBlendStateOGL* bs, bool linear = true); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, bool linear = true); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSBlendStateOGL* bs, bool linear = true); GSTexture* Resolve(GSTexture* t); @@ -279,13 +277,13 @@ class GSDeviceOGL : public GSDevice void IASetVertexBufferBind(GLuint vb); void IASetVertexArrray(GLuint va); - void VSSetShader(GLuint vs, GSUniformBufferOGL* vs_cb); + void VSSetShader(GLuint vs); void GSSetShader(GLuint gs); void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void PSSetShaderResource(int i, GSTexture* sr); void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2 = 0); - void PSSetShader(GLuint ps, GSUniformBufferOGL* ps_cb); + void PSSetShader(GLuint ps); void OMSetFBO(GLuint fbo); void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); From ab01926ed59a875fb2f119894b1b34f9f799e6e0 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 15 Dec 2011 18:27:58 +0000 Subject: [PATCH 13/56] gsdx-ogl: LINUX-ONLY * rewrite the vertex management with a nice GSVertexBufferState object * extend GSUniformBufferOGL to use a better object interface * properly delete texture * manage buffer with glMap* instead of glBufferSubData git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4990 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 201 ++++++++++------------------------ plugins/GSdx/GSDeviceOGL.h | 145 +++++++++++++++--------- plugins/GSdx/GSTextureOGL.cpp | 26 ++++- 3 files changed, 176 insertions(+), 196 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 06bc2027ad..47a2cab7ae 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -56,10 +56,9 @@ GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) - , m_vb(0) , m_pipeline(0) , m_fbo(0) - , m_sr_vb_offset(0) + , m_vb_sr(NULL) , m_srv_changed(false) , m_ss_changed(false) { @@ -74,6 +73,9 @@ GSDeviceOGL::GSDeviceOGL() GSDeviceOGL::~GSDeviceOGL() { + // Clean vertex buffer state + delete (m_vb_sr); + // Clean m_merge for (uint i = 0; i < 2; i++) glDeleteProgram(m_merge.ps[i]); @@ -86,8 +88,6 @@ GSDeviceOGL::~GSDeviceOGL() delete (m_interlace.cb); // Clean m_convert - glDeleteVertexArrays(1, &m_convert.va); - glDeleteBuffers(1, &m_convert.vb); glDeleteProgram(m_convert.vs); for (uint i = 0; i < 2; i++) glDeleteProgram(m_convert.ps[i]); @@ -101,7 +101,6 @@ GSDeviceOGL::~GSDeviceOGL() delete m_date.bs; // Clean various opengl allocation - glDeleteBuffers(1, &m_vb); glDeleteProgramPipelines(1, &m_pipeline); glDeleteFramebuffers(1, &m_fbo); } @@ -180,31 +179,18 @@ bool GSDeviceOGL::Create(GSWnd* wnd) OMSetFBO(0); // **************************************************************** - // convert + // Vertex buffer state // **************************************************************** - - glGenVertexArrays(1, &m_convert.va); - IASetVertexArrray(m_convert.va); - - glGenBuffers(1, &m_convert.vb); - IASetVertexBufferBind(m_convert.vb); - glBufferData(GL_ARRAY_BUFFER, 4 * 4 * sizeof(GSVertexPT1), NULL, GL_STREAM_DRAW); - GSInputLayout il_convert[2] = { {0, 4, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, p) }, {1, 2, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, }; + m_vb_sr = new GSVertexBufferState(sizeof(GSVertexPT1), il_convert, countof(il_convert)); - for (int i = 0; i < 2; i++) { - // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer - glEnableVertexAttribArray(il_convert[i].index); - glVertexAttribPointer(il_convert[i].index, il_convert[i].size, il_convert[i].type, GL_FALSE, il_convert[i].stride, il_convert[i].offset); - } - // Unbind to avoid issue with the setup of others parameters - IASetVertexArrray(0); - IASetVertexBufferBind(0); - + // **************************************************************** + // convert + // **************************************************************** CompileShaderFromSource("convert.glsl", "vs_main", GL_VERTEX_SHADER, &m_convert.vs); for(int i = 0; i < countof(m_convert.ps); i++) CompileShaderFromSource("convert.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_convert.ps[i]); @@ -264,10 +250,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // merge // **************************************************************** m_merge.cb = new GSUniformBufferOGL(1, sizeof(MergeConstantBuffer)); - glGenBuffers(1, &m_merge.cb->buffer); - glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); - glBufferData(GL_UNIFORM_BUFFER, m_merge.cb->byte_size, NULL, GL_DYNAMIC_DRAW); - glBindBufferBase(GL_UNIFORM_BUFFER, m_merge.cb->index, m_merge.cb->buffer); for(int i = 0; i < countof(m_merge.ps); i++) CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge.ps[i]); @@ -285,10 +267,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // interlace // **************************************************************** m_interlace.cb = new GSUniformBufferOGL(2, sizeof(InterlaceConstantBuffer)); - glGenBuffers(1, &m_interlace.cb->buffer); - glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); - glBufferData(GL_UNIFORM_BUFFER, m_interlace.cb->byte_size, NULL, GL_DYNAMIC_DRAW); - glBindBufferBase(GL_UNIFORM_BUFFER, m_interlace.cb->index, m_interlace.cb->buffer); for(int i = 0; i < countof(m_interlace.ps); i++) CompileShaderFromSource("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_interlace.ps[i]); @@ -473,27 +451,6 @@ bool GSDeviceOGL::Reset(int w, int h) // in the backbuffer m_backbuffer = new GSTextureOGL(0, w, h, false, 0); -#if 0 - if(m_swapchain) - { - DXGI_SWAP_CHAIN_DESC scd; - - memset(&scd, 0, sizeof(scd)); - - m_swapchain->GetDesc(&scd); - m_swapchain->ResizeBuffers(scd.BufferCount, w, h, scd.BufferDesc.Format, 0); - - CComPtr backbuffer; - - if(FAILED(m_swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&backbuffer))) - { - return false; - } - - m_backbuffer = new GSTexture11(backbuffer); - } -#endif - return true; } @@ -506,7 +463,7 @@ void GSDeviceOGL::Flip() void GSDeviceOGL::DrawPrimitive() { - glDrawArrays(m_state.topology, m_vertices.start, m_vertices.count); + glDrawArrays(m_state.topology, m_state.vb_state->start, m_state.vb_state->count); } void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) @@ -716,14 +673,9 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, {GSVector4(right, top, 0.5f, 1.0f), GSVector2(flip_sr.z, flip_sr.w)}, }; - IASetVertexArrray(m_convert.va); - IASetVertexBufferBind(m_convert.vb); - // FIXME it will worth some benchmark. - // What is the faster always use the same. Or pack to difference emplacement. I'm afraid - // that in all case the GPU will be stall to wait the data - // Note maybe create a new buffer can be faster. - // m_sr_vb_offset = 0; - glBufferSubData(GL_ARRAY_BUFFER, m_sr_vb_offset * 4 * sizeof(GSVertexPT1) , sizeof(GSVertexPT1) * 4, vertices); + IASetVertexState(m_vb_sr); + IASetVertexBuffer(vertices, 4); + IASetPrimitiveTopology(GL_TRIANGLE_STRIP); // ************************************ // vs @@ -748,8 +700,7 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // ************************************ // Draw // ************************************ - glDrawArrays(GL_TRIANGLE_STRIP, m_sr_vb_offset * 4, 4); - m_sr_vb_offset = (m_sr_vb_offset + 1) & 0x3; + DrawPrimitive(); // ************************************ // End @@ -771,11 +722,11 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect if(st[0]) { - if (m_state.cb != m_merge.cb->buffer) { - m_state.cb = m_merge.cb->buffer; - glBindBuffer(GL_UNIFORM_BUFFER, m_merge.cb->buffer); + if (m_state.cb != m_merge.cb) { + m_state.cb = m_merge.cb; + m_state.cb->bind(); } - glBufferSubData(GL_UNIFORM_BUFFER, 0, m_merge.cb->byte_size, &c.v); + m_state.cb->upload(&c.v); StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.bs); } @@ -793,11 +744,11 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin cb.ZrH = GSVector2(0, 1.0f / s.y); cb.hH = s.y / 2; - if (m_state.cb != m_interlace.cb->buffer) { - m_state.cb = m_interlace.cb->buffer; - glBindBuffer(GL_UNIFORM_BUFFER, m_interlace.cb->buffer); + if (m_state.cb != m_interlace.cb) { + m_state.cb = m_interlace.cb; + m_state.cb->bind(); } - glBufferSubData(GL_UNIFORM_BUFFER, 0, m_interlace.cb->byte_size, &cb); + m_state.cb->upload(&cb); StretchRect(st, sr, dt, dr, m_interlace.ps[shader], linear); } @@ -823,88 +774,52 @@ GSTexture* GSDeviceOGL::Resolve(GSTexture* t) return NULL; } -void GSDeviceOGL::IASetVertexArrray(GLuint va) +void GSDeviceOGL::EndScene() { - if (m_state.va != va) { - glBindVertexArray(va); - m_state.va = va; + m_state.vb_state->start += m_state.vb_state->count; + m_state.vb_state->count = 0; +} + +void GSDeviceOGL::IASetVertexState(GSVertexBufferState* vb_state) +{ + if (m_state.vb_state != vb_state) { + m_state.vb_state = vb_state; + vb_state->bind(); } } -void GSDeviceOGL::IASetVertexBufferBind(GLuint vb) +void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count) { - if (m_state.vb != vb) { - glBindBuffer(GL_ARRAY_BUFFER, vb); - m_state.vb = vb; + // Note: For an explanation of the map flag + // see http://www.opengl.org/wiki/Buffer_Object_Streaming + uint32 map_flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; + + GSVertexBufferState* vb = m_state.vb_state; + vb->count = count; + + // Current GPU buffer is really too small need to realocate a new one + if (count > vb->limit) { + vb->allocate(std::max(count * 3 / 2, 60000)); + + } else if (count > (vb->limit - vb->start) ) { + // Not enough left free room. Just go back at the beginning + vb->start = 0; + + // Tell the driver that it can orphan previous buffer and restart from a scratch buffer. + // Technically the buffer will not be accessible by the application anymore but the + // GL will effectively remove it when draws call are finised. + map_flags |= GL_MAP_INVALIDATE_BUFFER_BIT; + } else { + // Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map + map_flags |= GL_MAP_INVALIDATE_RANGE_BIT; } + + vb->upload(vertices, map_flags); } -void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t stride, size_t count) -{ - ASSERT(m_vertices.count == 0); - - if(count * stride > m_vertices.limit * m_vertices.stride) - { - // Current GPU buffer is too small need to realocate a new one - if (m_vb) { - glDeleteBuffers(1, &m_vb); - m_vb = 0; - } - - m_vertices.start = 0; - m_vertices.count = 0; - m_vertices.limit = std::max(count * 3 / 2, 11000); - m_vertices.stride = stride; - } - - if(!m_vb) - { - glGenBuffers(1, &m_vb); - IASetVertexBufferBind(m_vb); - // Allocate the buffer - glBufferData(GL_ARRAY_BUFFER, m_vertices.limit * m_vertices.stride, NULL, GL_STREAM_DRAW); - //m_vb_changed = true; - } - - // append data or go back to the beginning - // Hum why we don't always go back to the beginning !!! - if(m_vertices.start + count > m_vertices.limit || stride != m_vertices.stride) - m_vertices.start = 0; - - // Fill the buffer - glBufferSubData(GL_ARRAY_BUFFER, m_vertices.start * stride, count * stride, vertices); - - m_vertices.count = count; -} - -#if 0 -void GSDeviceOGL::IASetInputLayout(GSInputLayout* layout, int layout_nbr) -{ - if(m_state.layout != layout || m_state.layout_nbr != layout_nbr || m_vb_changed) - { - // Remove old configuration. - for (int i = m_state.layout_nbr ; i > (m_state.layout_nbr - layout_nbr) ; i--) { - glDisableVertexAttribArray(i); - } - - for (int i = 0; i < layout_nbr; i++) { - glEnableVertexAttribArray(layout[i].index); - glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, GL_FALSE, layout[i].stride, layout[i].offset); - } - - m_vb_changed = false; - m_state.layout = layout; - m_state.layout_nbr = layout_nbr; - } -} -#endif - void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) { - if(m_state.topology != topology) - { - m_state.topology = topology; - } + m_state.topology = topology; } void GSDeviceOGL::VSSetShader(GLuint vs) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 9c0d210b8f..d48461b8eb 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -74,15 +74,43 @@ struct GSDepthStencilOGL { {} }; -struct GSUniformBufferOGL { +class GSUniformBufferOGL { GLuint buffer; // data object GLuint index; // GLSL slot - uint byte_size; // size of the data + uint size; // size of the data - GSUniformBufferOGL(GLuint index, uint byte_size) : buffer(0) - , index(index) - , byte_size(byte_size) - {} +public: + GSUniformBufferOGL(GLuint index, uint size) : index(index) + , size(size) + { + glGenBuffers(1, &buffer); + bind(); + allocate(); + attach(); + } + + void bind() + { + glBindBuffer(GL_UNIFORM_BUFFER, buffer); + } + + void allocate() + { + glBufferData(GL_UNIFORM_BUFFER, size, NULL, GL_STREAM_DRAW); + } + + void attach() + { + glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer); + } + + void upload(const void* src) + { + uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT; + uint8* dst = (uint8*) glMapBufferRange(GL_UNIFORM_BUFFER, 0, size, flags); + memcpy(dst, src, size); + glUnmapBuffer(GL_UNIFORM_BUFFER); + } ~GSUniformBufferOGL() { glDeleteBuffers(1, &buffer); @@ -97,6 +125,60 @@ struct GSInputLayout { const GLvoid* offset; }; +struct GSVertexBufferState { + size_t stride; + size_t start; + size_t count; + size_t limit; + GLuint vb; + GLuint va; + + GSVertexBufferState(size_t stride, GSInputLayout* layout, uint32 layout_nbr) : stride(stride) + , count(0) + { + glGenBuffers(1, &vb); + glGenVertexArrays(1, &va); + bind(); + allocate(60000); // Opengl works best with 1-4MB buffer. 60k element seems a good value. + set_internal_format(layout, layout_nbr); + } + + void allocate(size_t new_limit) + { + start = 0; + limit = new_limit; + glBufferData(GL_ARRAY_BUFFER, limit * stride, NULL, GL_STREAM_DRAW); + } + + void bind() + { + glBindVertexArray(va); + glBindBuffer(GL_ARRAY_BUFFER, vb); + } + + void upload(const void* src, uint32 flags) + { + uint8* dst = (uint8*) glMapBufferRange(GL_ARRAY_BUFFER, stride*start, stride*count, flags); + memcpy(dst, src, stride*count); + glUnmapBuffer(GL_ARRAY_BUFFER); + } + + void set_internal_format(GSInputLayout* layout, uint32 layout_nbr) + { + for (int i = 0; i < layout_nbr; i++) { + // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer + glEnableVertexAttribArray(layout[i].index); + glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, GL_FALSE, layout[i].stride, layout[i].offset); + } + } + + ~GSVertexBufferState() + { + glDeleteBuffers(1, &vb); + glDeleteVertexArrays(1, &va); + } +}; + class GSDeviceOGL : public GSDevice { uint32 m_msaa; // Level of Msaa @@ -104,10 +186,10 @@ class GSDeviceOGL : public GSDevice bool m_free_window; GSWnd* m_window; - GLuint m_vb; // vertex buffer object GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container - uint32 m_sr_vb_offset; + + GSVertexBufferState* m_vb_sr; // vb_state for StretchRect struct { GLuint ps[2]; // program object @@ -121,12 +203,6 @@ class GSDeviceOGL : public GSDevice } m_interlace; struct { - // Hum I think this one is useless. As far as I understand - // it only get the index name of GLSL-equivalent input attribut - // ??? CComPtr il; - //GSInputLayout il[2]; // description of the vertex array - GLuint va; // vertex array object - GLuint vb; // vertex buffer GLuint vs; // program object GLuint ps[8]; // program object GLuint ln; // sampler object @@ -141,40 +217,12 @@ class GSDeviceOGL : public GSDevice GSBlendStateOGL* bs; } m_date; - // struct - // { - // ID3D11Buffer* vb; - // size_t vb_stride; - // ID3D11InputLayout* layout; - // D3D11_PRIMITIVE_TOPOLOGY topology; - // ID3D11VertexShader* vs; - // ID3D11Buffer* vs_cb; - // ID3D11GeometryShader* gs; - // ID3D11ShaderResourceView* ps_srv[3]; - // ID3D11PixelShader* ps; - // ID3D11Buffer* ps_cb; - // ID3D11SamplerState* ps_ss[3]; - // GSVector2i viewport; - // GSVector4i scissor; - // ID3D11DepthStencilState* dss; - // uint8 sref; - // ID3D11BlendState* bs; - // float bf; - // ID3D11RenderTargetView* rtv; - // ID3D11DepthStencilView* dsv; - // } m_state; struct { - GLuint vb; // vertex buffer - // Hum I think those things can be dropped on OGL. It probably need an others architecture (see glVertexAttribPointer) - // size_t vb_stride; - // ID3D11InputLayout* layout; - //GSInputLayout* layout; - //uint32 layout_nbr; - GLuint va; // vertex array + GSVertexBufferState* vb_state; GLenum topology; // (ie GL_TRIANGLES...) GLuint vs; // program - GLuint cb; // uniform current buffer + GSUniformBufferOGL* cb; // uniform current buffer GLuint gs; // program // FIXME texture binding. Maybe not equivalent for the state but the best I could find. GSTextureOGL* ps_srv[3]; @@ -197,7 +245,6 @@ class GSDeviceOGL : public GSDevice bool m_srv_changed; bool m_ss_changed; - //bool m_vb_changed; #if 0 CComPtr m_dev; @@ -271,11 +318,11 @@ class GSDeviceOGL : public GSDevice void CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program); + void EndScene(); + void IASetPrimitiveTopology(GLenum topology); - //void IASetInputLayout(GSInputLayout* layout, int layout_nbr); - void IASetVertexBuffer(const void* vertices, size_t stride, size_t count); - void IASetVertexBufferBind(GLuint vb); - void IASetVertexArrray(GLuint va); + void IASetVertexBuffer(const void* vertices, size_t count); + void IASetVertexState(GSVertexBufferState* vb_state); void VSSetShader(GLuint vs); void GSSetShader(GLuint gs); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index f94c1b4f3d..e99b555a80 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -157,7 +157,21 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) GSTextureOGL::~GSTextureOGL() { - // glDeleteTextures or glDeleteRenderbuffers + glDeleteBuffers(1, &m_extra_buffer_id); + switch (m_type) { + case GSTexture::Texture: + case GSTexture::RenderTarget: + glDeleteTextures(1, &m_texture_id); + break; + case GSTexture::DepthStencil: + glDeleteRenderbuffers(1, &m_texture_id); + break; + case GSTexture::Offscreen: + assert(0); + break; + default: + break; + } } void GSTextureOGL::Attach(GLenum attachment) @@ -192,15 +206,19 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // The case appears on SW mode. Src pitch is 2x dst pitch. int rowbytes = r.width() << 2; if (pitch != rowbytes) { - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_extra_buffer_id); + uint32 pbo_size = m_size.x * m_size.y * 4; + uint32 map_flags = GL_MAP_WRITE_BIT; + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_extra_buffer_id); if (!m_extra_buffer_allocated) { - glBufferData(GL_PIXEL_UNPACK_BUFFER, m_size.x * m_size.y * 4, NULL, GL_STREAM_DRAW); + glBufferData(GL_PIXEL_UNPACK_BUFFER, pbo_size, NULL, GL_STREAM_DRAW); m_extra_buffer_allocated = true; + } else { + GL_MAP_INVALIDATE_BUFFER_BIT; } uint8* src = (uint8*) data; - uint8* dst = (uint8*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); + uint8* dst = (uint8*) glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, pbo_size, map_flags); for(int h = r.height(); h > 0; h--, src += pitch, dst += rowbytes) { memcpy(dst, src, rowbytes); From 83ad63a8a77b25158cdc32f8fec361caf99855b2 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Mon, 19 Dec 2011 21:03:23 +0000 Subject: [PATCH 14/56] gsdx-ogl: LINUX-ONLY * lay the foundation for the HW renderer on OGL git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4996 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 5 +- plugins/GSdx/GSDeviceOGL.cpp | 277 +++++++++++++++++---- plugins/GSdx/GSDeviceOGL.h | 403 ++++++++++++++++++++++++++----- plugins/GSdx/GSRendererOGL.cpp | 189 ++++++++++++++- plugins/GSdx/GSRendererOGL.h | 425 ++++++++++++++++++++++++++++++++- plugins/GSdx/res/convert.glsl | 4 +- 6 files changed, 1175 insertions(+), 128 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index cbf97f3b37..3208a45ff0 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -16,6 +16,7 @@ set(CommonFlags -mfpmath=sse #-Wstrict-aliasing # Allow to track strict aliasing issue. -Wunused-variable + -std=c++0x ) set(OptimizationFlags @@ -91,6 +92,7 @@ set(GSdxSources GSTextureCache.cpp GSTextureCacheSW.cpp GSTextureCacheOGL.cpp + GSTextureFXOGL.cpp GSTextureOGL.cpp GSTextureNull.cpp GSTextureSW.cpp @@ -199,9 +201,10 @@ if(PACKAGE_MODE) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${PLUGIN_DIR}) else(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) endif(PACKAGE_MODE) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 47a2cab7ae..6b7d8b82b0 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -183,8 +183,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** GSInputLayout il_convert[2] = { - {0, 4, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, p) }, - {1, 2, GL_FLOAT, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, + {0, 4, GL_FLOAT, GL_FALSE, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, p) }, + {1, 2, GL_FLOAT, GL_FALSE, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, }; m_vb_sr = new GSVertexBufferState(sizeof(GSVertexPT1), il_convert, countof(il_convert)); @@ -226,9 +226,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_NONE); glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // FIXME: need ogl extension sd.MaxAnisotropy = 16; - glGenSamplers(1, &m_convert.pt); glGenSamplers(1, &m_convert.pt); glSamplerParameteri(m_convert.pt, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glSamplerParameteri(m_convert.pt, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -242,6 +242,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_NONE); glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // FIXME: need ogl extension sd.MaxAnisotropy = 16; m_convert.dss = new GSDepthStencilOGL(); m_convert.bs = new GSBlendStateOGL(); @@ -393,51 +394,48 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // TODO Later // **************************************************************** - // fxaa + // fxaa (bonus) // **************************************************************** -#if 0 + // FIXME need to define FXAA_GLSL_130 for the shader + // FIXME need to manually set the index... + // FIXME need dofxaa interface too + // m_fxaa.cb = new GSUniformBufferOGL(3, sizeof(FXAAConstantBuffer)); + //CompileShaderFromSource("fxaa.fx", format("ps_main", i), GL_FRAGMENT_SHADER, &m_fxaa.ps); - memset(&bd, 0, sizeof(bd)); + // **************************************************************** + // date + // **************************************************************** - bd.ByteWidth = sizeof(FXAAConstantBuffer); - bd.Usage = D3D11_USAGE_DEFAULT; - bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + m_date.dss = new GSDepthStencilOGL(); + m_date.dss->m_stencil_enable = true; + m_date.dss->m_stencil_func = GL_ALWAYS; + m_date.dss->m_stencil_spass_dpass_op = GL_REPLACE; + //memset(&dsd, 0, sizeof(dsd)); - hr = m_dev->CreateBuffer(&bd, NULL, &m_fxaa.cb); + //dsd.DepthEnable = false; + //dsd.StencilEnable = true; + //dsd.StencilReadMask = 1; + //dsd.StencilWriteMask = 1; - hr = CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps); -#endif + //dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + //dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + //dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + //dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + //m_dev->CreateDepthStencilState(&dsd, &m_date.dss); - // TODO later -#if 0 + // FIXME are the blend state really empty + m_date.bs = new GSBlendStateOGL(); + //D3D11_BLEND_DESC blend; + + //memset(&blend, 0, sizeof(blend)); + + //m_dev->CreateBlendState(&blend, &m_date.bs); + + // **************************************************************** + // HW renderer shader + // **************************************************************** CreateTextureFX(); - - // - - memset(&dsd, 0, sizeof(dsd)); - - dsd.DepthEnable = false; - dsd.StencilEnable = true; - dsd.StencilReadMask = 1; - dsd.StencilWriteMask = 1; - dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - dsd.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - dsd.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - - m_dev->CreateDepthStencilState(&dsd, &m_date.dss); - - D3D11_BLEND_DESC blend; - - memset(&blend, 0, sizeof(blend)); - - m_dev->CreateBlendState(&blend, &m_date.bs); -#endif } bool GSDeviceOGL::Reset(int w, int h) @@ -472,7 +470,8 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) if (t == m_backbuffer) { // FIXME I really not sure OMSetFBO(0); - glClearBufferfv(GL_COLOR, GL_LEFT, c.v); + //glClearBufferfv(GL_COLOR, GL_LEFT, c.v); + glClearBufferfv(GL_COLOR, 0, c.v); } else { // FIXME I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation @@ -722,11 +721,8 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect if(st[0]) { - if (m_state.cb != m_merge.cb) { - m_state.cb = m_merge.cb; - m_state.cb->bind(); - } - m_state.cb->upload(&c.v); + SetUniformBuffer(m_merge.cb); + m_merge.cb->upload(&c.v); StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.bs); } @@ -744,15 +740,68 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin cb.ZrH = GSVector2(0, 1.0f / s.y); cb.hH = s.y / 2; - if (m_state.cb != m_interlace.cb) { - m_state.cb = m_interlace.cb; - m_state.cb->bind(); - } - m_state.cb->upload(&cb); + SetUniformBuffer(m_interlace.cb); + m_interlace.cb->upload(&cb); StretchRect(st, sr, dt, dr, m_interlace.ps[shader], linear); } +void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm) +{ + assert(0); + + const GSVector2i& size = rt->GetSize(); + + if(GSTexture* t = CreateRenderTarget(size.x, size.y, rt->IsMSAA())) + { + // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows + + BeginScene(); + + ClearStencil(ds, 0); + + // om + + OMSetDepthStencilState(m_date.dss, 1); + OMSetBlendState(m_date.bs, 0); + OMSetRenderTargets(t, ds); + + // ia + + IASetVertexState(m_vb_sr); + IASetVertexBuffer(vertices, 4); + IASetPrimitiveTopology(GL_TRIANGLE_STRIP); + + // vs + + VSSetShader(m_convert.vs); + + // gs + + GSSetShader(NULL); + + // ps + + GSTexture* rt2 = rt->IsMSAA() ? Resolve(rt) : rt; + + PSSetShaderResources(rt2, NULL); + PSSetSamplerState(m_convert.pt, 0); + PSSetShader(m_convert.ps[datm ? 2 : 3]); + + // + + DrawPrimitive(); + + // + + EndScene(); + + Recycle(t); + + if(rt2 != rt) Recycle(rt2); + } +} + // copy a multisample texture to a non-texture multisample. On opengl you need 2 FBO with different level of // sample and then do a blit. Headach expected to for the moment just drop MSAA... GSTexture* GSDeviceOGL::Resolve(GSTexture* t) @@ -780,6 +829,14 @@ void GSDeviceOGL::EndScene() m_state.vb_state->count = 0; } +void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) +{ + if (m_state.cb != cb) { + m_state.cb = cb; + cb->bind(); + } +} + void GSDeviceOGL::IASetVertexState(GSVertexBufferState* vb_state) { if (m_state.vb_state != vb_state) { @@ -959,6 +1016,8 @@ void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) m_state.bs = bs; m_state.bf = bf; + glColorMask(bs->m_r_msk, bs->m_g_msk, bs->m_b_msk, bs->m_a_msk); + if (bs->m_enable) { glEnable(GL_BLEND); // FIXME: double check when blend stuff is complete @@ -1029,7 +1088,7 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto } } -void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program) +void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program, const std::string& macro_sel) { // ***************************************************** // Build a header string @@ -1184,3 +1243,117 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi fclose(f); } } + +// (A - B) * C + D +// A: Cs/Cd/0 +// B: Cs/Cd/0 +// C: As/Ad/FIX +// D: Cs/Cd/0 + +// bogus: 0100, 0110, 0120, 0200, 0210, 0220, 1001, 1011, 1021 +// tricky: 1201, 1211, 1221 + +// Source.rgb = float3(1, 1, 1); +// 1201 Cd*(1 + As) => Source * Dest color + Dest * Source alpha +// 1211 Cd*(1 + Ad) => Source * Dest color + Dest * Dest alpha +// 1221 Cd*(1 + F) => Source * Dest color + Dest * Factor + +// Copy Dx blend table and convert it to ogl +#define D3DBLENDOP_ADD GL_FUNC_ADD +#define D3DBLENDOP_SUBTRACT GL_FUNC_SUBTRACT +#define D3DBLENDOP_REVSUBTRACT GL_FUNC_REVERSE_SUBTRACT + +#define D3DBLEND_ONE GL_ONE +#define D3DBLEND_ZERO GL_ZERO +#define D3DBLEND_SRCALPHA GL_SRC1_ALPHA +#define D3DBLEND_INVDESTALPHA GL_ONE_MINUS_DST_ALPHA +#define D3DBLEND_DESTALPHA GL_DST_ALPHA +#define D3DBLEND_DESTCOLOR GL_DST_COLOR +#define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC1_ALPHA +#define D3DBLEND_BLENDFACTOR GL_CONSTANT_COLOR +#define D3DBLEND_INVBLENDFACTOR GL_ONE_MINUS_CONSTANT_COLOR + +const GSDeviceOGL::D3D9Blend GSDeviceOGL::m_blendMapD3D9[3*3*3*3] = +{ + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 0000: (Cs - Cs)*As + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 0001: (Cs - Cs)*As + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 0002: (Cs - Cs)*As + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 0010: (Cs - Cs)*Ad + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 0011: (Cs - Cs)*Ad + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 0012: (Cs - Cs)*Ad + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 0020: (Cs - Cs)*F + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 0021: (Cs - Cs)*F + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 0022: (Cs - Cs)*F + 0 ==> 0 + {1, D3DBLENDOP_SUBTRACT, D3DBLEND_SRCALPHA, D3DBLEND_SRCALPHA}, //*0100: (Cs - Cd)*As + Cs ==> Cs*(As + 1) - Cd*As + {0, D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA}, // 0101: (Cs - Cd)*As + Cd ==> Cs*As + Cd*(1 - As) + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_SRCALPHA, D3DBLEND_SRCALPHA}, // 0102: (Cs - Cd)*As + 0 ==> Cs*As - Cd*As + {1, D3DBLENDOP_SUBTRACT, D3DBLEND_DESTALPHA, D3DBLEND_DESTALPHA}, //*0110: (Cs - Cd)*Ad + Cs ==> Cs*(Ad + 1) - Cd*Ad + {0, D3DBLENDOP_ADD, D3DBLEND_DESTALPHA, D3DBLEND_INVDESTALPHA}, // 0111: (Cs - Cd)*Ad + Cd ==> Cs*Ad + Cd*(1 - Ad) + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_DESTALPHA, D3DBLEND_DESTALPHA}, // 0112: (Cs - Cd)*Ad + 0 ==> Cs*Ad - Cd*Ad + {1, D3DBLENDOP_SUBTRACT, D3DBLEND_BLENDFACTOR, D3DBLEND_BLENDFACTOR}, //*0120: (Cs - Cd)*F + Cs ==> Cs*(F + 1) - Cd*F + {0, D3DBLENDOP_ADD, D3DBLEND_BLENDFACTOR, D3DBLEND_INVBLENDFACTOR}, // 0121: (Cs - Cd)*F + Cd ==> Cs*F + Cd*(1 - F) + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_BLENDFACTOR, D3DBLEND_BLENDFACTOR}, // 0122: (Cs - Cd)*F + 0 ==> Cs*F - Cd*F + {1, D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_ZERO}, //*0200: (Cs - 0)*As + Cs ==> Cs*(As + 1) + {0, D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_ONE}, // 0201: (Cs - 0)*As + Cd ==> Cs*As + Cd + {0, D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_ZERO}, // 0202: (Cs - 0)*As + 0 ==> Cs*As + {1, D3DBLENDOP_ADD, D3DBLEND_DESTALPHA, D3DBLEND_ZERO}, //*0210: (Cs - 0)*Ad + Cs ==> Cs*(Ad + 1) + {0, D3DBLENDOP_ADD, D3DBLEND_DESTALPHA, D3DBLEND_ONE}, // 0211: (Cs - 0)*Ad + Cd ==> Cs*Ad + Cd + {0, D3DBLENDOP_ADD, D3DBLEND_DESTALPHA, D3DBLEND_ZERO}, // 0212: (Cs - 0)*Ad + 0 ==> Cs*Ad + {1, D3DBLENDOP_ADD, D3DBLEND_BLENDFACTOR, D3DBLEND_ZERO}, //*0220: (Cs - 0)*F + Cs ==> Cs*(F + 1) + {0, D3DBLENDOP_ADD, D3DBLEND_BLENDFACTOR, D3DBLEND_ONE}, // 0221: (Cs - 0)*F + Cd ==> Cs*F + Cd + {0, D3DBLENDOP_ADD, D3DBLEND_BLENDFACTOR, D3DBLEND_ZERO}, // 0222: (Cs - 0)*F + 0 ==> Cs*F + {0, D3DBLENDOP_ADD, D3DBLEND_INVSRCALPHA, D3DBLEND_SRCALPHA}, // 1000: (Cd - Cs)*As + Cs ==> Cd*As + Cs*(1 - As) + {1, D3DBLENDOP_REVSUBTRACT, D3DBLEND_SRCALPHA, D3DBLEND_SRCALPHA}, //*1001: (Cd - Cs)*As + Cd ==> Cd*(As + 1) - Cs*As + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_SRCALPHA, D3DBLEND_SRCALPHA}, // 1002: (Cd - Cs)*As + 0 ==> Cd*As - Cs*As + {0, D3DBLENDOP_ADD, D3DBLEND_INVDESTALPHA, D3DBLEND_DESTALPHA}, // 1010: (Cd - Cs)*Ad + Cs ==> Cd*Ad + Cs*(1 - Ad) + {1, D3DBLENDOP_REVSUBTRACT, D3DBLEND_DESTALPHA, D3DBLEND_DESTALPHA}, //*1011: (Cd - Cs)*Ad + Cd ==> Cd*(Ad + 1) - Cs*Ad + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_DESTALPHA, D3DBLEND_DESTALPHA}, // 1012: (Cd - Cs)*Ad + 0 ==> Cd*Ad - Cs*Ad + {0, D3DBLENDOP_ADD, D3DBLEND_INVBLENDFACTOR, D3DBLEND_BLENDFACTOR}, // 1020: (Cd - Cs)*F + Cs ==> Cd*F + Cs*(1 - F) + {1, D3DBLENDOP_REVSUBTRACT, D3DBLEND_BLENDFACTOR, D3DBLEND_BLENDFACTOR},//*1021: (Cd - Cs)*F + Cd ==> Cd*(F + 1) - Cs*F + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_BLENDFACTOR, D3DBLEND_BLENDFACTOR},// 1022: (Cd - Cs)*F + 0 ==> Cd*F - Cs*F + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 1100: (Cd - Cd)*As + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 1101: (Cd - Cd)*As + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 1102: (Cd - Cd)*As + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 1110: (Cd - Cd)*Ad + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 1111: (Cd - Cd)*Ad + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 1112: (Cd - Cd)*Ad + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 1120: (Cd - Cd)*F + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 1121: (Cd - Cd)*F + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 1122: (Cd - Cd)*F + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_SRCALPHA}, // 1200: (Cd - 0)*As + Cs ==> Cs + Cd*As + {2, D3DBLENDOP_ADD, D3DBLEND_DESTCOLOR, D3DBLEND_SRCALPHA}, //#1201: (Cd - 0)*As + Cd ==> Cd*(1 + As) // ffxii main menu background glow effect + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_SRCALPHA}, // 1202: (Cd - 0)*As + 0 ==> Cd*As + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_DESTALPHA}, // 1210: (Cd - 0)*Ad + Cs ==> Cs + Cd*Ad + {2, D3DBLENDOP_ADD, D3DBLEND_DESTCOLOR, D3DBLEND_DESTALPHA}, //#1211: (Cd - 0)*Ad + Cd ==> Cd*(1 + Ad) + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_DESTALPHA}, // 1212: (Cd - 0)*Ad + 0 ==> Cd*Ad + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_BLENDFACTOR}, // 1220: (Cd - 0)*F + Cs ==> Cs + Cd*F + {2, D3DBLENDOP_ADD, D3DBLEND_DESTCOLOR, D3DBLEND_BLENDFACTOR}, //#1221: (Cd - 0)*F + Cd ==> Cd*(1 + F) + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_BLENDFACTOR}, // 1222: (Cd - 0)*F + 0 ==> Cd*F + {0, D3DBLENDOP_ADD, D3DBLEND_INVSRCALPHA, D3DBLEND_ZERO}, // 2000: (0 - Cs)*As + Cs ==> Cs*(1 - As) + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_SRCALPHA, D3DBLEND_ONE}, // 2001: (0 - Cs)*As + Cd ==> Cd - Cs*As + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_SRCALPHA, D3DBLEND_ZERO}, // 2002: (0 - Cs)*As + 0 ==> 0 - Cs*As + {0, D3DBLENDOP_ADD, D3DBLEND_INVDESTALPHA, D3DBLEND_ZERO}, // 2010: (0 - Cs)*Ad + Cs ==> Cs*(1 - Ad) + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_DESTALPHA, D3DBLEND_ONE}, // 2011: (0 - Cs)*Ad + Cd ==> Cd - Cs*Ad + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_DESTALPHA, D3DBLEND_ZERO}, // 2012: (0 - Cs)*Ad + 0 ==> 0 - Cs*Ad + {0, D3DBLENDOP_ADD, D3DBLEND_INVBLENDFACTOR, D3DBLEND_ZERO}, // 2020: (0 - Cs)*F + Cs ==> Cs*(1 - F) + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_BLENDFACTOR, D3DBLEND_ONE}, // 2021: (0 - Cs)*F + Cd ==> Cd - Cs*F + {0, D3DBLENDOP_REVSUBTRACT, D3DBLEND_BLENDFACTOR, D3DBLEND_ZERO}, // 2022: (0 - Cs)*F + 0 ==> 0 - Cs*F + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_ONE, D3DBLEND_SRCALPHA}, // 2100: (0 - Cd)*As + Cs ==> Cs - Cd*As + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_INVSRCALPHA}, // 2101: (0 - Cd)*As + Cd ==> Cd*(1 - As) + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_ZERO, D3DBLEND_SRCALPHA}, // 2102: (0 - Cd)*As + 0 ==> 0 - Cd*As + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_ONE, D3DBLEND_DESTALPHA}, // 2110: (0 - Cd)*Ad + Cs ==> Cs - Cd*Ad + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_INVDESTALPHA}, // 2111: (0 - Cd)*Ad + Cd ==> Cd*(1 - Ad) + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_ONE, D3DBLEND_DESTALPHA}, // 2112: (0 - Cd)*Ad + 0 ==> 0 - Cd*Ad + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_ONE, D3DBLEND_BLENDFACTOR}, // 2120: (0 - Cd)*F + Cs ==> Cs - Cd*F + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_INVBLENDFACTOR}, // 2121: (0 - Cd)*F + Cd ==> Cd*(1 - F) + {0, D3DBLENDOP_SUBTRACT, D3DBLEND_ONE, D3DBLEND_BLENDFACTOR}, // 2122: (0 - Cd)*F + 0 ==> 0 - Cd*F + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 2200: (0 - 0)*As + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 2201: (0 - 0)*As + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 2202: (0 - 0)*As + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 2210: (0 - 0)*Ad + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 2211: (0 - 0)*Ad + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 2212: (0 - 0)*Ad + 0 ==> 0 + {0, D3DBLENDOP_ADD, D3DBLEND_ONE, D3DBLEND_ZERO}, // 2220: (0 - 0)*F + Cs ==> Cs + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ONE}, // 2221: (0 - 0)*F + Cd ==> Cd + {0, D3DBLENDOP_ADD, D3DBLEND_ZERO, D3DBLEND_ZERO}, // 2222: (0 - 0)*F + 0 ==> 0 +}; diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index d48461b8eb..e07d716696 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -36,14 +36,22 @@ struct GSBlendStateOGL { GLenum m_func_dRGB; GLenum m_func_sALPHA; GLenum m_func_dALPHA; + bool m_r_msk; + bool m_b_msk; + bool m_g_msk; + bool m_a_msk; GSBlendStateOGL() : m_enable(false) , m_equation_RGB(0) - , m_equation_ALPHA(0) + , m_equation_ALPHA(GL_FUNC_ADD) , m_func_sRGB(0) , m_func_dRGB(0) - , m_func_sALPHA(0) - , m_func_dALPHA(0) + , m_func_sALPHA(GL_ONE) + , m_func_dALPHA(GL_ZERO) + , m_r_msk(GL_TRUE) + , m_b_msk(GL_TRUE) + , m_g_msk(GL_TRUE) + , m_a_msk(GL_TRUE) {} }; @@ -52,7 +60,7 @@ struct GSDepthStencilOGL { bool m_depth_enable; GLenum m_depth_func; GLboolean m_depth_mask; - // Note front face and back can be split might. But it seems they have same parameter configuration + // Note front face and back might be split but it seems they have same parameter configuration bool m_stencil_enable; GLuint m_stencil_mask; GLuint m_stencil_func; @@ -65,13 +73,14 @@ struct GSDepthStencilOGL { , m_depth_func(0) , m_depth_mask(0) , m_stencil_enable(false) - , m_stencil_mask(0) + , m_stencil_mask(1) , m_stencil_func(0) , m_stencil_ref(0) - , m_stencil_sfail_op(0) - , m_stencil_spass_dfail_op(0) - , m_stencil_spass_dpass_op(0) + , m_stencil_sfail_op(GL_KEEP) + , m_stencil_spass_dfail_op(GL_KEEP) + , m_stencil_spass_dpass_op(GL_KEEP) {} + }; class GSUniformBufferOGL { @@ -121,6 +130,7 @@ struct GSInputLayout { GLuint index; GLint size; GLenum type; + GLboolean normalize; GLsizei stride; const GLvoid* offset; }; @@ -168,7 +178,7 @@ struct GSVertexBufferState { for (int i = 0; i < layout_nbr; i++) { // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer glEnableVertexAttribArray(layout[i].index); - glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, GL_FALSE, layout[i].stride, layout[i].offset); + glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); } } @@ -181,6 +191,241 @@ struct GSVertexBufferState { class GSDeviceOGL : public GSDevice { + public: + __aligned(struct, 32) VSConstantBuffer + { + GSVector4 VertexScale; + GSVector4 VertexOffset; + GSVector4 TextureScale; + + VSConstantBuffer() + { + VertexScale = GSVector4::zero(); + VertexOffset = GSVector4::zero(); + TextureScale = GSVector4::zero(); + } + + __forceinline bool Update(const VSConstantBuffer* cb) + { + GSVector4i* a = (GSVector4i*)this; + GSVector4i* b = (GSVector4i*)cb; + + GSVector4i b0 = b[0]; + GSVector4i b1 = b[1]; + GSVector4i b2 = b[2]; + + if(!((a[0] == b0) & (a[1] == b1) & (a[2] == b2)).alltrue()) + { + a[0] = b0; + a[1] = b1; + a[2] = b2; + + return true; + } + + return false; + } + }; + + struct VSSelector + { + union + { + struct + { + uint32 bppz:2; + uint32 tme:1; + uint32 fst:1; + uint32 logz:1; + uint32 rtcopy:1; + }; + + uint32 key; + }; + + operator uint32() {return key & 0x3f;} + + VSSelector() : key(0) {} + }; + + __aligned(struct, 32) PSConstantBuffer + { + GSVector4 FogColor_AREF; + GSVector4 HalfTexel; + GSVector4 WH; + GSVector4 MinMax; + GSVector4 MinF_TA; + GSVector4i MskFix; + + PSConstantBuffer() + { + FogColor_AREF = GSVector4::zero(); + HalfTexel = GSVector4::zero(); + WH = GSVector4::zero(); + MinMax = GSVector4::zero(); + MinF_TA = GSVector4::zero(); + MskFix = GSVector4i::zero(); + } + + __forceinline bool Update(const PSConstantBuffer* cb) + { + GSVector4i* a = (GSVector4i*)this; + GSVector4i* b = (GSVector4i*)cb; + + GSVector4i b0 = b[0]; + GSVector4i b1 = b[1]; + GSVector4i b2 = b[2]; + GSVector4i b3 = b[3]; + GSVector4i b4 = b[4]; + GSVector4i b5 = b[5]; + + if(!((a[0] == b0) /*& (a[1] == b1)*/ & (a[2] == b2) & (a[3] == b3) & (a[4] == b4) & (a[5] == b5)).alltrue()) // if WH matches HalfTexel does too + { + a[0] = b0; + a[1] = b1; + a[2] = b2; + a[3] = b3; + a[4] = b4; + a[5] = b5; + + return true; + } + + return false; + } + }; + + struct GSSelector + { + union + { + struct + { + uint32 iip:1; + uint32 prim:2; + }; + + uint32 key; + }; + + operator uint32() {return key & 0x7;} + + GSSelector() : key(0) {} + }; + + struct PSSelector + { + union + { + struct + { + uint32 fst:1; + uint32 wms:2; + uint32 wmt:2; + uint32 fmt:3; + uint32 aem:1; + uint32 tfx:3; + uint32 tcc:1; + uint32 atst:3; + uint32 fog:1; + uint32 clr1:1; + uint32 fba:1; + uint32 aout:1; + uint32 rt:1; + uint32 ltf:1; + uint32 colclip:2; + uint32 date:2; + }; + + uint32 key; + }; + + operator uint32() {return key & 0x3ffffff;} + + PSSelector() : key(0) {} + }; + + struct PSSamplerSelector + { + union + { + struct + { + uint32 tau:1; + uint32 tav:1; + uint32 ltf:1; + }; + + uint32 key; + }; + + operator uint32() {return key & 0x7;} + + PSSamplerSelector() : key(0) {} + }; + + struct OMDepthStencilSelector + { + union + { + struct + { + uint32 ztst:2; + uint32 zwe:1; + uint32 date:1; + uint32 fba:1; + }; + + uint32 key; + }; + + operator uint32() {return key & 0x1f;} + + OMDepthStencilSelector() : key(0) {} + }; + + struct OMBlendSelector + { + union + { + struct + { + uint32 abe:1; + uint32 a:2; + uint32 b:2; + uint32 c:2; + uint32 d:2; + uint32 wr:1; + uint32 wg:1; + uint32 wb:1; + uint32 wa:1; + uint32 negative:1; + }; + + struct + { + uint32 _pad:1; + uint32 abcd:8; + uint32 wrgba:4; + }; + + uint32 key; + }; + + operator uint32() {return key & 0x3fff;} + + OMBlendSelector() : key(0) {} + + bool IsCLR1() const + { + return (key & 0x19f) == 0x93; // abe == 1 && a == 1 && b == 2 && d == 1 + } + }; + + struct D3D9Blend {int bogus, op, src, dst;}; + static const D3D9Blend m_blendMapD3D9[3*3*3*3]; + + private: uint32 m_msaa; // Level of Msaa bool m_free_window; @@ -189,6 +434,7 @@ class GSDeviceOGL : public GSDevice GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container + GSVertexBufferState* m_vb; // vb_state for HW renderer GSVertexBufferState* m_vb_sr; // vb_state for StretchRect struct { @@ -211,6 +457,12 @@ class GSDeviceOGL : public GSDevice GSBlendStateOGL* bs; } m_convert; + struct + { + GLuint ps; + GSUniformBufferOGL *cb; + } m_fxaa; + struct { GSDepthStencilOGL* dss; @@ -253,89 +505,110 @@ class GSDeviceOGL : public GSDevice CComPtr m_rs; - struct - { - CComPtr ps; - CComPtr cb; - } m_fxaa; - // Shaders... - hash_map m_vs; - CComPtr m_vs_cb; - hash_map > m_gs; - hash_map > m_ps; - CComPtr m_ps_cb; - hash_map > m_ps_ss; CComPtr m_palette_ss; CComPtr m_rt_ss; - hash_map > m_om_dss; - hash_map > m_om_bs; + +#endif + // hash_map m_vs; + // hash_map > m_gs; + // hash_map > m_ps; + // hash_map > m_ps_ss; + // hash_map > m_om_dss; + // hash_map > m_om_bs; + hash_map m_vs; + hash_map m_gs; + hash_map m_ps; + hash_map m_ps_ss; + hash_map m_om_dss; + hash_map m_om_bs; + + //CComPtr m_palette_ss; + //CComPtr m_rt_ss; + GLuint m_palette_ss; + GLuint m_rt_ss; + + //CComPtr m_vs_cb; + //CComPtr m_ps_cb; + GSUniformBufferOGL* m_vs_cb; + GSUniformBufferOGL* m_ps_cb; VSConstantBuffer m_vs_cb_cache; PSConstantBuffer m_ps_cb_cache; -#endif protected: - GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); - GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); - void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c); - void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0); + GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); + GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); + void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c); + void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0); public: - GSDeviceOGL(); - virtual ~GSDeviceOGL(); + GSDeviceOGL(); + virtual ~GSDeviceOGL(); - void CheckDebugLog(); - static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); + void CheckDebugLog(); + static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); + bool HasStencil() { return true; } + bool HasDepth32() { return true; } - bool Create(GSWnd* wnd); - bool Reset(int w, int h); - void Flip(); + bool Create(GSWnd* wnd); + bool Reset(int w, int h); + void Flip(); - void DrawPrimitive(); + void DrawPrimitive(); - void ClearRenderTarget(GSTexture* t, const GSVector4& c); - void ClearRenderTarget(GSTexture* t, uint32 c); - void ClearDepth(GSTexture* t, float c); - void ClearStencil(GSTexture* t, uint8 c); + void ClearRenderTarget(GSTexture* t, const GSVector4& c); + void ClearRenderTarget(GSTexture* t, uint32 c); + void ClearDepth(GSTexture* t, float c); + void ClearStencil(GSTexture* t, uint8 c); - GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0); - GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0); - GSTexture* CreateTexture(int w, int h, int format = 0); - GSTexture* CreateOffscreen(int w, int h, int format = 0); + GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0); + GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0); + GSTexture* CreateTexture(int w, int h, int format = 0); + GSTexture* CreateOffscreen(int w, int h, int format = 0); - GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0); + GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0); - void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, bool linear = true); - void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSBlendStateOGL* bs, bool linear = true); + void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, bool linear = true); + void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSBlendStateOGL* bs, bool linear = true); - GSTexture* Resolve(GSTexture* t); + void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm); - void CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program); + GSTexture* Resolve(GSTexture* t); - void EndScene(); + void CompileShaderFromSource(const std::string& glsl_file, const std::string& entry, GLenum type, GLuint* program, const std::string& macro_sel = ""); - void IASetPrimitiveTopology(GLenum topology); - void IASetVertexBuffer(const void* vertices, size_t count); - void IASetVertexState(GSVertexBufferState* vb_state); + void EndScene(); - void VSSetShader(GLuint vs); - void GSSetShader(GLuint gs); + void IASetPrimitiveTopology(GLenum topology); + void IASetVertexBuffer(const void* vertices, size_t count); + void IASetVertexState(GSVertexBufferState* vb_state); - void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); - void PSSetShaderResource(int i, GSTexture* sr); - void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2 = 0); - void PSSetShader(GLuint ps); + void SetUniformBuffer(GSUniformBufferOGL* cb); - void OMSetFBO(GLuint fbo); - void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); - void OMSetBlendState(GSBlendStateOGL* bs, float bf); - void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL); + void VSSetShader(GLuint vs); + void GSSetShader(GLuint gs); + + void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); + void PSSetShaderResource(int i, GSTexture* sr); + void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2 = 0); + void PSSetShader(GLuint ps); + + void OMSetFBO(GLuint fbo); + void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); + void OMSetBlendState(GSBlendStateOGL* bs, float bf); + void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL); + void CreateTextureFX(); + void SetupIA(const void* vertices, int count, GLenum prim); + void SetupVS(VSSelector sel, const VSConstantBuffer* cb); + void SetupGS(GSSelector sel); + void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel); + void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix); }; diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index df1474c6d2..77842ca707 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -27,17 +27,198 @@ GSRendererOGL::GSRendererOGL() // FIXME //: GSRendererHW(new GSTextureCacheOGL(this)) : GSRendererHW(new GSTextureCacheOGL(this)) + , m_topology(0) { + m_logz = !!theApp.GetConfig("logz", 0); + m_fba = !!theApp.GetConfig("fba", 1); + UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0); + m_pixelcenter = GSVector2(-0.5f, -0.5f); + // TODO must be implementer with macro InitVertexKick(GSRendererOGL) // template void VertexKick(bool skip); InitVertexKick(GSRendererOGL); } -GSRendererOGL::~GSRendererOGL() { /* TODO */ } +bool GSRendererOGL::CreateDevice(GSDevice* dev) +{ + if(!GSRenderer::CreateDevice(dev)) + return false; -bool GSRendererOGL::CreateDevice(GSDevice* dev) { /* TODO */ } + return true; +} template -void GSRendererOGL::VertexKick(bool skip) { /* TODO */ } +void GSRendererOGL::VertexKick(bool skip) +{ + GSVertexHW11& dst = m_vl.AddTail(); -void GSRendererOGL::Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) { /* TODO */ } + dst = *(GSVertexHW11*)&m_v; + +#ifdef USE_UPSCALE_HACKS + + if(tme && fst) + { + //GSVector4::storel(&dst.ST, m_v.GetUV()); + + int Udiff = 0; + int Vdiff = 0; + int Uadjust = 0; + int Vadjust = 0; + + int multiplier = GetUpscaleMultiplier(); + + if(multiplier > 1) + { + Udiff = m_v.UV.U & 4095; + Vdiff = m_v.UV.V & 4095; + + if(Udiff != 0) + { + if (Udiff >= 4080) {/*printf("U+ %d %d\n", Udiff, m_v.UV.U);*/ Uadjust = -1; } + else if (Udiff <= 16) {/*printf("U- %d %d\n", Udiff, m_v.UV.U);*/ Uadjust = 1; } + } + + if(Vdiff != 0) + { + if (Vdiff >= 4080) {/*printf("V+ %d %d\n", Vdiff, m_v.UV.V);*/ Vadjust = -1; } + else if (Vdiff <= 16) {/*printf("V- %d %d\n", Vdiff, m_v.UV.V);*/ Vadjust = 1; } + } + + Udiff = m_v.UV.U & 255; + Vdiff = m_v.UV.V & 255; + + if(Udiff != 0) + { + if (Udiff >= 248) { Uadjust = -1; } + else if (Udiff <= 8) { Uadjust = 1; } + } + + if(Vdiff != 0) + { + if (Vdiff >= 248) { Vadjust = -1; } + else if (Vdiff <= 8) { Vadjust = 1; } + } + + Udiff = m_v.UV.U & 15; + Vdiff = m_v.UV.V & 15; + + if(Udiff != 0) + { + if (Udiff >= 15) { Uadjust = -1; } + else if (Udiff <= 1) { Uadjust = 1; } + } + + if(Vdiff != 0) + { + if (Vdiff >= 15) { Vadjust = -1; } + else if (Vdiff <= 1) { Vadjust = 1; } + } + } + + dst.ST.S = (float)m_v.UV.U - Uadjust; + dst.ST.T = (float)m_v.UV.V - Vadjust; + } + else if(tme) + { + // Wip :p + //dst.XYZ.X += 5; + //dst.XYZ.Y += 5; + } + +#else + + if(tme && fst) + { + GSVector4::storel(&dst.ST, m_v.GetUV()); + } + +#endif + + int count = 0; + + if(GSVertexHW11* v = DrawingKick(skip, count)) + { + GSVector4i scissor = m_context->scissor.dx10; + + GSVector4i pmin, pmax; + + #if _M_SSE >= 0x401 + + GSVector4i v0, v1, v2; + + switch(prim) + { + case GS_POINTLIST: + v0 = GSVector4i::load((int)v[0].p.xy).upl16(); + pmin = v0; + pmax = v0; + break; + case GS_LINELIST: + case GS_LINESTRIP: + case GS_SPRITE: + v0 = GSVector4i::load((int)v[0].p.xy); + v1 = GSVector4i::load((int)v[1].p.xy); + pmin = v0.min_u16(v1).upl16(); + pmax = v0.max_u16(v1).upl16(); + break; + case GS_TRIANGLELIST: + case GS_TRIANGLESTRIP: + case GS_TRIANGLEFAN: + v0 = GSVector4i::load((int)v[0].p.xy); + v1 = GSVector4i::load((int)v[1].p.xy); + v2 = GSVector4i::load((int)v[2].p.xy); + pmin = v0.min_u16(v1).min_u16(v2).upl16(); + pmax = v0.max_u16(v1).max_u16(v2).upl16(); + break; + } + + #else + + switch(prim) + { + case GS_POINTLIST: + pmin.x = v[0].p.x; + pmin.y = v[0].p.y; + pmax.x = v[0].p.x; + pmax.y = v[0].p.y; + break; + case GS_LINELIST: + case GS_LINESTRIP: + case GS_SPRITE: + pmin.x = std::min(v[0].p.x, v[1].p.x); + pmin.y = std::min(v[0].p.y, v[1].p.y); + pmax.x = std::max(v[0].p.x, v[1].p.x); + pmax.y = std::max(v[0].p.y, v[1].p.y); + break; + case GS_TRIANGLELIST: + case GS_TRIANGLESTRIP: + case GS_TRIANGLEFAN: + pmin.x = std::min(std::min(v[0].p.x, v[1].p.x), v[2].p.x); + pmin.y = std::min(std::min(v[0].p.y, v[1].p.y), v[2].p.y); + pmax.x = std::max(std::max(v[0].p.x, v[1].p.x), v[2].p.x); + pmax.y = std::max(std::max(v[0].p.y, v[1].p.y), v[2].p.y); + break; + } + + #endif + + GSVector4i test = (pmax < scissor) | (pmin > scissor.zwxy()); + + switch(prim) + { + case GS_TRIANGLELIST: + case GS_TRIANGLESTRIP: + case GS_TRIANGLEFAN: + case GS_SPRITE: + test |= pmin == pmax; + break; + } + + if(test.mask() & 0xff) + { + return; + } + + m_count += count; + } +} diff --git a/plugins/GSdx/GSRendererOGL.h b/plugins/GSdx/GSRendererOGL.h index 0c75556a7f..6e1cb1f582 100644 --- a/plugins/GSdx/GSRendererOGL.h +++ b/plugins/GSdx/GSRendererOGL.h @@ -34,17 +34,434 @@ class GSRendererOGL : public GSRendererHW //class GSRendererOGL : public GSRendererHW { private: + GSVector2 m_pixelcenter; + bool m_logz; + bool m_fba; + bool UserHacks_AlphaHack; protected: - GSTextureCache* m_tc; - - void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); + GLenum m_topology; public: GSRendererOGL(); - virtual ~GSRendererOGL(); + virtual ~GSRendererOGL() {}; template void VertexKick(bool skip); bool CreateDevice(GSDevice* dev); + + void UpdateFBA(GSTexture* rt) {} + + void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) + { + + switch(m_vt.m_primclass) + { + case GS_POINT_CLASS: + m_topology = GL_POINTS; + m_perfmon.Put(GSPerfMon::Prim, m_count); + break; + case GS_LINE_CLASS: + case GS_SPRITE_CLASS: + m_topology = GL_LINES; + m_perfmon.Put(GSPerfMon::Prim, m_count / 2); + break; + case GS_TRIANGLE_CLASS: + m_topology = GL_TRIANGLES; + m_perfmon.Put(GSPerfMon::Prim, m_count / 3); + break; + default: + __assume(0); + } + + + GSDrawingEnvironment& env = m_env; + GSDrawingContext* context = m_context; + + const GSVector2i& rtsize = rt->GetSize(); + const GSVector2& rtscale = rt->GetScale(); + + bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24; + + GSTexture *rtcopy = NULL; + + ASSERT(m_dev != NULL); + + GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; + + if(DATE) + { + if(dev->HasStencil()) + { + GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); + GSVector4 o = GSVector4(-1.0f, 1.0f); + + GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); + GSVector4 dst = src * 2.0f + o.xxxx(); + + GSVertexPT1 vertices[] = + { + {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, + {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, + {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, + {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, + }; + + dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); + } + else + { + rtcopy = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); + + // I'll use VertexTrace when I consider it more trustworthy + + dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); + } + } + + // + + dev->BeginScene(); + + // om + + GSDeviceOGL::OMDepthStencilSelector om_dssel; + + if(context->TEST.ZTE) + { + om_dssel.ztst = context->TEST.ZTST; + om_dssel.zwe = !context->ZBUF.ZMSK; + } + else + { + om_dssel.ztst = ZTST_ALWAYS; + } + + if(m_fba) + { + om_dssel.fba = context->FBA.FBA; + } + + GSDeviceOGL::OMBlendSelector om_bsel; + + if(!IsOpaque()) + { + om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS; + + om_bsel.a = context->ALPHA.A; + om_bsel.b = context->ALPHA.B; + om_bsel.c = context->ALPHA.C; + om_bsel.d = context->ALPHA.D; + + if(env.PABE.PABE) + { + if(om_bsel.a == 0 && om_bsel.b == 1 && om_bsel.c == 0 && om_bsel.d == 1) + { + // this works because with PABE alpha blending is on when alpha >= 0x80, but since the pixel shader + // cannot output anything over 0x80 (== 1.0) blending with 0x80 or turning it off gives the same result + + om_bsel.abe = 0; + } + else + { + //Breath of Fire Dragon Quarter triggers this in battles. Graphics are fine though. + //ASSERT(0); + } + } + } + + om_bsel.wrgba = ~GSVector4i::load((int)context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask(); + + // vs + + GSDeviceOGL::VSSelector vs_sel; + + vs_sel.tme = PRIM->TME; + vs_sel.fst = PRIM->FST; + vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0; + vs_sel.rtcopy = !!rtcopy; + + // The real GS appears to do no masking based on the Z buffer format and writing larger Z values + // than the buffer supports seems to be an error condition on the real GS, causing it to crash. + // We are probably receiving bad coordinates from VU1 in these cases. + + if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe) + { + if(context->ZBUF.PSM == PSM_PSMZ24) + { + if(m_vt.m_max.p.z > 0xffffff) + { + ASSERT(m_vt.m_min.p.z > 0xffffff); + // Fixme :Following conditional fixes some dialog frame in Wild Arms 3, but may not be what was intended. + if (m_vt.m_min.p.z > 0xffffff) + { + vs_sel.bppz = 1; + om_dssel.ztst = ZTST_ALWAYS; + } + } + } + else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) + { + if(m_vt.m_max.p.z > 0xffff) + { + ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo + // Fixme : Same as above, I guess. + if (m_vt.m_min.p.z > 0xffff) + { + vs_sel.bppz = 2; + om_dssel.ztst = ZTST_ALWAYS; + } + } + } + } + + GSDeviceOGL::VSConstantBuffer vs_cb; + + float sx = 2.0f * rtscale.x / (rtsize.x << 4); + float sy = 2.0f * rtscale.y / (rtsize.y << 4); + float ox = (float)(int)context->XYOFFSET.OFX; + float oy = (float)(int)context->XYOFFSET.OFY; + float ox2 = 2.0f * m_pixelcenter.x / rtsize.x; + float oy2 = 2.0f * m_pixelcenter.y / rtsize.y; + + //This hack subtracts around half a pixel from OFX and OFY. (Cannot do this directly, + //because DX10 and DX9 have a different pixel center.) + // + //The resulting shifted output aligns better with common blending / corona / blurring effects, + //but introduces a few bad pixels on the edges. + + if(rt->LikelyOffset) + { + // DX9 has pixelcenter set to 0.0, so give it some value here + + if(m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } + + ox2 *= rt->OffsetHack_modx; + oy2 *= rt->OffsetHack_mody; + } + + vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); + vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); + + // gs + + GSDeviceOGL::GSSelector gs_sel; + + gs_sel.iip = PRIM->IIP; + gs_sel.prim = m_vt.m_primclass; + + // ps + + GSDeviceOGL::PSSelector ps_sel; + GSDeviceOGL::PSSamplerSelector ps_ssel; + GSDeviceOGL::PSConstantBuffer ps_cb; + + if(DATE) + { + if(dev->HasStencil()) + { + om_dssel.date = 1; + } + else + { + ps_sel.date = 1 + context->TEST.DATM; + } + } + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + ps_sel.colclip = 1; + } + + ps_sel.clr1 = om_bsel.IsCLR1(); + ps_sel.fba = context->FBA.FBA; + ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0; + + if(UserHacks_AlphaHack) ps_sel.aout = 1; + + if(PRIM->FGE) + { + ps_sel.fog = 1; + + ps_cb.FogColor_AREF = GSVector4::rgba32(env.FOGCOL.u32[0]) / 255; + } + + if(context->TEST.ATE) + { + ps_sel.atst = context->TEST.ATST; + + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + } + else + { + ps_sel.atst = ATST_ALWAYS; + } + + if(tex) + { + ps_sel.wms = context->CLAMP.WMS; + ps_sel.wmt = context->CLAMP.WMT; + ps_sel.fmt = tex->m_fmt; + ps_sel.aem = env.TEXA.AEM; + ps_sel.tfx = context->TEX0.TFX; + ps_sel.tcc = context->TEX0.TCC; + ps_sel.ltf = m_filter == 2 ? m_vt.IsLinear() : m_filter; + ps_sel.rt = tex->m_target; + + int w = tex->m_texture->GetWidth(); + int h = tex->m_texture->GetHeight(); + + int tw = (int)(1 << context->TEX0.TW); + int th = (int)(1 << context->TEX0.TH); + + GSVector4 WH(tw, th, w, h); + + if(PRIM->FST) + { + vs_cb.TextureScale = GSVector4(1.0f / 16) / WH.xyxy(); + //Maybe better? + //vs_cb.TextureScale = GSVector4(1.0f / 16) * GSVector4(tex->m_texture->GetScale()).xyxy() / WH.zwzw(); + ps_sel.fst = 1; + } + + ps_cb.WH = WH; + ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw(); + ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV); + + GSVector4 clamp(ps_cb.MskFix); + GSVector4 ta(env.TEXA & GSVector4i::x000000ff()); + + ps_cb.MinMax = clamp / WH.xyxy(); + ps_cb.MinF_TA = (clamp + 0.5f).xyxy(ta) / WH.xyxy(GSVector4(255, 255)); + + ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; + ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; + ps_ssel.ltf = ps_sel.ltf; + } + else + { + ps_sel.tfx = 4; + } + + // rs + + GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy()); + + dev->OMSetRenderTargets(rt, ds, &scissor); + dev->PSSetShaderResource(0, tex ? tex->m_texture : 0); + dev->PSSetShaderResource(1, tex ? tex->m_palette : 0); + dev->PSSetShaderResource(2, rtcopy); + + uint8 afix = context->ALPHA.FIX; + + dev->SetupOM(om_dssel, om_bsel, afix); + dev->SetupIA(m_vertices, m_count, m_topology); + dev->SetupVS(vs_sel, &vs_cb); + dev->SetupGS(gs_sel); + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); + + // draw + + if(context->TEST.DoFirstPass()) + { + dev->DrawPrimitive(); + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); + GSDeviceOGL::PSSelector ps_selneg(ps_sel); + + om_bselneg.negative = 1; + ps_selneg.colclip = 2; + + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); + + dev->DrawPrimitive(); + } + } + + if(context->TEST.DoSecondPass()) + { + ASSERT(!env.PABE.PABE); + + static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; + + ps_sel.atst = iatst[ps_sel.atst]; + + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); + + bool z = om_dssel.zwe; + bool r = om_bsel.wr; + bool g = om_bsel.wg; + bool b = om_bsel.wb; + bool a = om_bsel.wa; + + switch(context->TEST.AFAIL) + { + case 0: z = r = g = b = a = false; break; // none + case 1: z = false; break; // rgba + case 2: r = g = b = a = false; break; // z + case 3: z = a = false; break; // rgb + default: __assume(0); + } + + if(z || r || g || b || a) + { + om_dssel.zwe = z; + om_bsel.wr = r; + om_bsel.wg = g; + om_bsel.wb = b; + om_bsel.wa = a; + + dev->SetupOM(om_dssel, om_bsel, afix); + + dev->DrawPrimitive(); + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); + GSDeviceOGL::PSSelector ps_selneg(ps_sel); + + om_bselneg.negative = 1; + ps_selneg.colclip = 2; + + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); + + dev->DrawPrimitive(); + } + } + } + + dev->EndScene(); + + dev->Recycle(rtcopy); + + if(om_dssel.fba) UpdateFBA(rt); + } }; diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index ed9494a28e..b12bf4ec96 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -20,8 +20,8 @@ layout(location = 1) in vec2 TEXCOORD0; // // The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area. // FIXME gl_Position -smooth layout(location = 0) out vec4 POSITION_OUT; -smooth layout(location = 1) out vec2 TEXCOORD0_OUT; +layout(location = 0) out vec4 POSITION_OUT; +layout(location = 1) out vec2 TEXCOORD0_OUT; void vs_main() { From e4c70ad229ab26f827cf6518def95bf300213191 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Mon, 19 Dec 2011 21:04:16 +0000 Subject: [PATCH 15/56] gsdx-ogl: LINUX-ONLY Forgot the shader file... git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4997 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/res/tfx.glsl | 640 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 640 insertions(+) create mode 100644 plugins/GSdx/res/tfx.glsl diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl new file mode 100644 index 0000000000..600444594a --- /dev/null +++ b/plugins/GSdx/res/tfx.glsl @@ -0,0 +1,640 @@ +//#version 420 // Keep it for text editor detection + +// note lerp => mix + +#define FMT_32 0 +#define FMT_24 1 +#define FMT_16 2 +#define FMT_8H 3 +#define FMT_4HL 4 +#define FMT_4HH 5 +#define FMT_8 6 + +#ifndef VS_BPPZ +#define VS_BPPZ 0 +#define VS_TME 1 +#define VS_FST 1 +#endif + +#ifndef GS_IIP +#define GS_IIP 0 +#define GS_PRIM 3 +#endif + +#ifndef PS_FST +#define PS_FST 0 +#define PS_WMS 0 +#define PS_WMT 0 +#define PS_FMT FMT_8 +#define PS_AEM 0 +#define PS_TFX 0 +#define PS_TCC 1 +#define PS_ATST 1 +#define PS_FOG 0 +#define PS_CLR1 0 +#define PS_FBA 0 +#define PS_AOUT 0 +#define PS_LTF 1 +#define PS_COLCLIP 0 +#define PS_DATE 0 +#endif + +#ifdef VERTEX_SHADER +layout(location = 0) in vec2 i_t; +layout(location = 1) in vec4 i_c; +layout(location = 2) in float i_q; +layout(location = 3) in uvec2 i_p; +layout(location = 4) in uint i_z; +layout(location = 5) in vec4 i_f; + +layout(location = 0) out VSout +{ + vec4 o_p; + vec4 o_t; + vec4 o_tp; + vec4 o_c; +}; + +out gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + +layout(std140, binding = 4) uniform cb0 +{ + vec4 VertexScale; + vec4 VertexOffset; + vec2 TextureScale; +}; + +void vs_main() +{ + uint z; + if(VS_BPPZ == 1) // 24 + { + z = i_z & 0xffffff; + } + else if(VS_BPPZ == 2) // 16 + { + z = i_z & 0xffff; + } + + // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) + // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty + // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel + // example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133 + + vec4 p = vec4(i_p, z, 0) - vec4(0.05f, 0.05f, 0, 0); + + o_p = p * VertexScale - VertexOffset; +#if VS_RTCOPY + o_tp = (p * VertexScale - VertexOffset) * vec4(0.5, -0.5, 0, 0) + 0.5; +#endif + gl_Position = p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position + + if(VS_TME != 0) + { + if(VS_FST != 0) + { + o_t.xy = i_t * TextureScale; + o_t.w = 1.0f; + } + else + { + o_t.xy = i_t; + o_t.w = i_q; + } + } + else + { + o_t.xy = vec2(0.0f, 0.0f); + o_t.w = 1.0f; + } + + o_c = i_c; + o_t.z = i_f.a; +} + +#endif + +#ifdef GEOMETRY_SHADER +in gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +} gl_in[]; + +out gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + +layout(location = 0) in GSin +{ + vec4 p; + vec4 t; + vec4 tp; + vec4 c; +} GSin[]; + +layout(location = 0) out GSout +{ + vec4 p; + vec4 t; + vec4 tp; + vec4 c; +} GSout; + +#if GS_PRIM == 0 +layout(points) in; +layout(points, max_vertices = 1) out; + +void gs_main() +{ + for(int i = 0; i < gl_in.length(); i++) { + gl_Position = gl_in[i].gl_Position; // FIXME is it useful + GSout = GSin[i]; + EmitVertex(); + } + EndPrimitive(); +} + +#elif GS_PRIM == 1 +layout(lines) in; +layout(line_strip, max_vertices = 2) out; + +void gs_main() +{ + for(int i = 0; i < gl_in.length(); i++) { + gl_Position = gl_in[i].gl_Position; // FIXME is it useful + GSout = GSin[i]; +#if GS_IIP == 0 + if (i == 0) + GSout.c = GSin[1].c; +#endif + EmitVertex(); + } + EndPrimitive(); +} + +#elif GS_PRIM == 2 +layout(triangles) in; +layout(triangle_strip, max_vertices = 3) out; + +void gs_main() +{ + for(int i = 0; i < gl_in.length(); i++) { + gl_Position = gl_in[i].gl_Position; // FIXME is it useful + GSout = GSin[i]; +#if GS_IIP == 0 + if (i == 0 || i == 1) + GSout.c = GSin[2].c; +#endif + EmitVertex(); + } + EndPrimitive(); +} + +#elif GS_PRIM == 3 +layout(lines) in; +layout(triangle_strip, max_vertices = 4) out; + +void set_output(uint i) +{ + GSout.p = GSin[i].p; + GSout.t = GSin[i].t; + GSout.tp = GSin[i].tp; + GSout.c = GSin[i].c; +} + +void gs_main() +{ + // left top => GSin[0]; + // right bottom => GSin[1]; + + + // left top + set_output(0); + + GSout.p.z = GSin[1].p.z; + GSout.t.zw = GSin[1].t.zw; + gl_Position = GSout.p; // FIXME is it useful + #if GS_IIP == 0 + GSout.c = GSin[1].c; + #endif + EmitVertex(); + + // left bottom + set_output(1); + gl_Position = gl_in[1].gl_Position; // FIXME is it useful + gl_Position.x = GSin[0].p.x; + GSout.p.x = GSin[0].p.x; + GSout.t.x = GSin[0].t.x; + EmitVertex(); + + // rigth top + set_output(1); + gl_Position = gl_in[1].gl_Position; // FIXME is it useful + gl_Position.y = GSin[0].p.y; + GSout.p.y = GSin[0].p.y; + GSout.t.y = GSin[0].t.y; + EmitVertex(); + + // rigth bottom + set_output(1); + gl_Position = GSin[1].p; // FIXME is it useful + EmitVertex(); + +} + +#endif + +#endif + +#ifdef FRAGMENT_SHADER +layout(location = 0) in PSin +{ + vec4 p; + vec4 t; + vec4 tp; + vec4 c; +} PSin; + +// Same buffer but 2 colors for dual source blending +layout(location = 0, index = 0) out vec4 SV_Target0; +layout(location = 0, index = 1) out vec4 SV_Target1; + +layout(binding = 0) uniform sampler2D TextureSampler; +layout(binding = 1) uniform sampler2D PaletteSampler; +layout(binding = 2) uniform sampler2D RTCopySampler; + +layout(std140, binding = 5) uniform cb1 +{ + vec3 FogColor; + float AREF; + vec4 HalfTexel; + vec4 WH; + vec4 MinMax; + vec2 MinF; + vec2 TA; + uvec4 MskFix; +}; + +vec4 sample_c(vec2 uv) +{ + return texture(TextureSampler, uv); +} + +vec4 sample_p(float u) +{ + //FIXME do we need a 1D sampler. Big impact on opengl to find 1 dim + // So for the moment cheat with 0.0f dunno if it work + return texture(PaletteSampler, vec2(u, 0.0f)); +} + +vec4 sample_rt(vec2 uv) +{ + return texture(RTCopySampler, uv); +} + +vec4 wrapuv(vec4 uv) +{ + vec4 uv_out = uv; + + if(PS_WMS == PS_WMT) + { + if(PS_WMS == 2) + { + uv_out = clamp(uv, MinMax.xyxy, MinMax.zwzw); + } + else if(PS_WMS == 3) + { + uv_out = vec4(((ivec4(uv * WH.xyxy) & MskFix.xyxy) | MskFix.zwzw) / WH.xyxy); + } + } + else + { + if(PS_WMS == 2) + { + uv_out.xz = clamp(uv.xz, MinMax.xx, MinMax.zz); + } + else if(PS_WMS == 3) + { + uv_out.xz = vec2(((ivec2(uv.xz * WH.xx) & MskFix.xx) | MskFix.zz) / WH.xx); + } + if(PS_WMT == 2) + { + uv_out.yw = clamp(uv.yw, MinMax.yy, MinMax.ww); + } + else if(PS_WMT == 3) + { + uv_out.yw = vec2(((ivec2(uv.yw * WH.yy) & MskFix.yy) | MskFix.ww) / WH.yy); + } + } + + return uv_out; +} + +vec2 clampuv(vec2 uv) +{ + vec2 uv_out = uv; + + if(PS_WMS == 2 && PS_WMT == 2) + { + uv_out = clamp(uv, MinF, MinMax.zw); + } + else if(PS_WMS == 2) + { + uv_out.x = clamp(uv.x, MinF.x, MinMax.z); + } + else if(PS_WMT == 2) + { + uv_out.y = clamp(uv.y, MinF.y, MinMax.w); + } + + return uv_out; +} + +mat4 sample_4c(vec4 uv) +{ + mat4 c; + + c[0] = sample_c(uv.xy); + c[1] = sample_c(uv.zy); + c[2] = sample_c(uv.xw); + c[3] = sample_c(uv.zw); + + return c; +} + +vec4 sample_4a(vec4 uv) +{ + vec4 c; + + c.x = sample_c(uv.xy).a; + c.y = sample_c(uv.zy).a; + c.z = sample_c(uv.xw).a; + c.w = sample_c(uv.zw).a; + + return c; +} + +mat4 sample_4p(vec4 u) +{ + mat4 c; + + c[0] = sample_p(u.x); + c[1] = sample_p(u.y); + c[2] = sample_p(u.z); + c[3] = sample_p(u.w); + + return c; +} + +vec4 sample_color(vec2 st, float q) +{ + if(!PS_FST) + { + st /= q; + } + + vec4 t; + if(PS_FMT <= FMT_16 && PS_WMS < 3 && PS_WMT < 3) + { + t = sample_c(clampuv(st)); + } + else + { + vec4 uv; + vec2 dd; + + if(PS_LTF != 0) + { + uv = st.xyxy + HalfTexel; + dd = fract(uv.xy * WH.zw); + } + else + { + uv = st.xyxy; + } + + uv = wrapuv(uv); + + mat4 c; + + if(PS_FMT == FMT_8H) + { + c = sample_4p(sample_4a(uv)); + } + else if(PS_FMT == FMT_4HL) + { + // FIXME mod and fmod are different when value are negative + c = sample_4p(mod(sample_4a(uv), 1.0f / 16)); + } + else if(PS_FMT == FMT_4HH) + { + // FIXME mod and fmod are different when value are negative + c = sample_4p(mod(sample_4a(uv) * 16, 1.0f / 16)); + } + else if(PS_FMT == FMT_8) + { + c = sample_4p(sample_4a(uv)); + } + else + { + c = sample_4c(uv); + } + + if(PS_LTF != 0) + { + t = mix(mix(c[0], c[1], dd.x), mix(c[2], c[3], dd.x), dd.y); + } + else + { + t = c[0]; + } + } + + if(PS_FMT == FMT_32) + { + ; + } + else if(PS_FMT == FMT_24) + { + // FIXME GLSL any only support bvec so try to mix it with notEqual + bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) ); + t.a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f; + } + else if(PS_FMT == FMT_16) + { + // a bit incompatible with up-scaling because the 1 bit alpha is interpolated + // FIXME GLSL any only support bvec so try to mix it with notEqual + bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) ); + t.a = t.a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f; + } + + return t; +} + +vec4 tfx(vec4 t, vec4 c) +{ + vec4 c_out = c; + if(PS_TFX == 0) + { + if(PS_TCC != 0) + { + c_out = c * t * 255.0f / 128; + } + else + { + c_out.rgb = c.rgb * t.rgb * 255.0f / 128; + } + } + else if(PS_TFX == 1) + { + if(PS_TCC != 0) + { + c_out = t; + } + else + { + c_out.rgb = t.rgb; + } + } + else if(PS_TFX == 2) + { + c_out.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; + + if(PS_TCC != 0) + { + c_out.a += t.a; + } + } + else if(PS_TFX == 3) + { + c_out.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; + + if(PS_TCC != 0) + { + c_out.a = t.a; + } + } + + return clamp(c_out, vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(1.0f, 1.0f, 1.0f, 1.0f)); +} + +void datst() +{ +#if PS_DATE > 0 + float alpha = sample_rt(PSin.tp.xy).a; + float alpha0x80 = 128. / 255; + + if (PS_DATE == 1 && alpha >= alpha0x80) + discard; + else if (PS_DATE == 2 && alpha < alpha0x80) + discard; +#endif +} + +void atst(vec4 c) +{ + float a = trunc(c.a * 255); + + if(PS_ATST == 0) // never + { + discard; + } + else if(PS_ATST == 1) // always + { + // nothing to do + } + else if(PS_ATST == 2 || PS_ATST == 3) // l, le + { + if ((AREF - a) < 0.0f) + discard; + } + else if(PS_ATST == 4) // e + { + if ((0.5f - abs(a - AREF)) < 0.0f) + discard; + } + else if(PS_ATST == 5 || PS_ATST == 6) // ge, g + { + if ((a-AREF) < 0.0f) + discard; + } + else if(PS_ATST == 7) // ne + { + if ((abs(a - AREF) - 0.5f) < 0.0f) + discard; + } +} + +vec4 fog(vec4 c, float f) +{ + vec4 c_out = c; + if(PS_FOG != 0) + { + c_out.rgb = mix(FogColor, c.rgb, f); + } + + return c_out; +} + +vec4 ps_color() +{ + datst(); + + vec4 t = sample_color(PSin.t.xy, PSin.t.w); + + vec4 c = tfx(t, PSin.c); + + atst(c); + + c = fog(c, PSin.t.z); + + if (PS_COLCLIP == 2) + { + c.rgb = 256.0f/255.0f - c.rgb; + } + if (PS_COLCLIP > 0) + { + // FIXME !!!! + //c.rgb *= c.rgb < 128./255; + } + + if(PS_CLR1 != 0) // needed for Cd * (As/Ad/F + 1) blending modes + { + // FIXME: I'm not sure about the value of others field + //c.rgb = 1.0f; + c.rgb = vec3(1.0f, 1.0f, 1.0f); + } + + return c; +} + +void ps_main() +{ + vec4 c = ps_color(); + + + // FIXME: I'm not sure about the value of others field + // output.c1 = c.a * 2; // used for alpha blending + SV_Target1 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2); + + if(PS_AOUT != 0) // 16 bit output + { + float a = 128.0f / 255; // alpha output will be 0x80 + + c.a = (PS_FBA != 0) ? a : step(0.5, c.a) * a; + } + else if(PS_FBA != 0) + { + if(c.a < 0.5) c.a += 0.5; + } + + SV_Target0 = c; +} +#endif From 9272be182efea2e0342f7772789c9465480101bb Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 21 Dec 2011 19:08:31 +0000 Subject: [PATCH 16/56] gsdx-ogl: LINUX-ONLY * add the forgotten hardware renderer object. Oh my gosh! Opengl is 20% faster than Dx!!! git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5000 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 109 ++++++---- plugins/GSdx/GSTextureFXOGL.cpp | 353 ++++++++++++++++++++++++++++++++ 2 files changed, 418 insertions(+), 44 deletions(-) create mode 100644 plugins/GSdx/GSTextureFXOGL.cpp diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 6b7d8b82b0..a5b45123a7 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -103,6 +103,23 @@ GSDeviceOGL::~GSDeviceOGL() // Clean various opengl allocation glDeleteProgramPipelines(1, &m_pipeline); glDeleteFramebuffers(1, &m_fbo); + + // Delete HW FX + delete m_vs_cb; + delete m_ps_cb; + glDeleteSamplers(1, &m_rt_ss); + delete m_vb; + + for (auto it : m_vs) glDeleteProgram(it.second); + for (auto it : m_gs) glDeleteProgram(it.second); + for (auto it : m_ps) glDeleteProgram(it.second); + for (auto it : m_ps_ss) glDeleteSamplers(1, &it.second); + m_vs.clear(); + m_gs.clear(); + m_ps.clear(); + m_ps_ss.clear(); + m_om_dss.clear(); + m_om_bs.clear(); } GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) @@ -291,6 +308,50 @@ bool GSDeviceOGL::Create(GSWnd* wnd) rd.AntialiasedLineEnable = false; #endif + // TODO Later + // **************************************************************** + // fxaa (bonus) + // **************************************************************** + // FIXME need to define FXAA_GLSL_130 for the shader + // FIXME need to manually set the index... + // FIXME need dofxaa interface too + // m_fxaa.cb = new GSUniformBufferOGL(3, sizeof(FXAAConstantBuffer)); + //CompileShaderFromSource("fxaa.fx", format("ps_main", i), GL_FRAGMENT_SHADER, &m_fxaa.ps); + + // **************************************************************** + // date + // **************************************************************** + + m_date.dss = new GSDepthStencilOGL(); + m_date.dss->m_stencil_enable = true; + m_date.dss->m_stencil_func = GL_ALWAYS; + m_date.dss->m_stencil_spass_dpass_op = GL_REPLACE; + //memset(&dsd, 0, sizeof(dsd)); + + //dsd.DepthEnable = false; + //dsd.StencilEnable = true; + //dsd.StencilReadMask = 1; + //dsd.StencilWriteMask = 1; + + //dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + //dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + //dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + //dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + + //m_dev->CreateDepthStencilState(&dsd, &m_date.dss); + + // FIXME are the blend state really empty + m_date.bs = new GSBlendStateOGL(); + //D3D11_BLEND_DESC blend; + + //memset(&blend, 0, sizeof(blend)); + + //m_dev->CreateBlendState(&blend, &m_date.bs); + + // **************************************************************** + // HW renderer shader + // **************************************************************** + CreateTextureFX(); // **************************************************************** // Finish window setup and backbuffer @@ -392,50 +453,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) } #endif - // TODO Later - // **************************************************************** - // fxaa (bonus) - // **************************************************************** - // FIXME need to define FXAA_GLSL_130 for the shader - // FIXME need to manually set the index... - // FIXME need dofxaa interface too - // m_fxaa.cb = new GSUniformBufferOGL(3, sizeof(FXAAConstantBuffer)); - //CompileShaderFromSource("fxaa.fx", format("ps_main", i), GL_FRAGMENT_SHADER, &m_fxaa.ps); - - // **************************************************************** - // date - // **************************************************************** - - m_date.dss = new GSDepthStencilOGL(); - m_date.dss->m_stencil_enable = true; - m_date.dss->m_stencil_func = GL_ALWAYS; - m_date.dss->m_stencil_spass_dpass_op = GL_REPLACE; - //memset(&dsd, 0, sizeof(dsd)); - - //dsd.DepthEnable = false; - //dsd.StencilEnable = true; - //dsd.StencilReadMask = 1; - //dsd.StencilWriteMask = 1; - - //dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - //dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - //dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - //dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - - //m_dev->CreateDepthStencilState(&dsd, &m_date.dss); - - // FIXME are the blend state really empty - m_date.bs = new GSBlendStateOGL(); - //D3D11_BLEND_DESC blend; - - //memset(&blend, 0, sizeof(blend)); - - //m_dev->CreateBlendState(&blend, &m_date.bs); - - // **************************************************************** - // HW renderer shader - // **************************************************************** - CreateTextureFX(); + return true; } bool GSDeviceOGL::Reset(int w, int h) @@ -472,6 +490,9 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) OMSetFBO(0); //glClearBufferfv(GL_COLOR, GL_LEFT, c.v); glClearBufferfv(GL_COLOR, 0, c.v); + // code for the old interface + // glClearColor(c.x, c.y, c.z, c.w); + // glClear(GL_COLOR_BUFFER_BIT); } else { // FIXME I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp new file mode 100644 index 0000000000..28a02602eb --- /dev/null +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -0,0 +1,353 @@ +/* + * Copyright (C) 2011-2011 Gregory hainaut + * Copyright (C) 2007-2009 Gabest + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "stdafx.h" +#include "GSDeviceOGL.h" +#include "GSTables.h" + +void GSDeviceOGL::CreateTextureFX() +{ + m_vs_cb = new GSUniformBufferOGL(4, sizeof(VSConstantBuffer)); + m_ps_cb = new GSUniformBufferOGL(5, sizeof(PSConstantBuffer)); + + glGenSamplers(1, &m_rt_ss); + // FIXME, seem to have no difference between sampler !!! + m_palette_ss = m_rt_ss; + + glSamplerParameteri(m_rt_ss, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + // FIXME which value for GL_TEXTURE_MIN_LOD + glSamplerParameteri(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX); + // FIXME: seems there is 2 possibility in opengl + // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; + // glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // FIXME: need ogl extension sd.MaxAnisotropy = 16; + + //{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + //{"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}, + //float2 t : TEXCOORD0; + //float q : TEXCOORD1; + // + //{"POSITION", 0, DXGI_FORMAT_R16G16_UINT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0}, + //{"POSITION", 1, DXGI_FORMAT_R32_UINT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0}, + //uint2 p : POSITION0; + //uint z : POSITION1; + // + //{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, + //{"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0}, + //float4 c : COLOR0; + //float4 f : COLOR1; + + GSInputLayout vert_format[6] = + { + // FIXME + {0 , 2 , GL_FLOAT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(0) } , + {1 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertexHW11) , (const GLvoid*)(8) } , + {2 , 1 , GL_FLOAT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(12) } , + {3 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(16) } , + {4 , 1 , GL_UNSIGNED_INT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(20) } , + // note: there is a 32 bits pad + {5 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertexHW11) , (const GLvoid*)(28) } , + }; + m_vb = new GSVertexBufferState(sizeof(GSVertexHW11), vert_format, countof(vert_format)); +} + +void GSDeviceOGL::SetupIA(const void* vertices, int count, GLenum prim) +{ + IASetVertexState(m_vb); + IASetVertexBuffer(vertices, count); + IASetPrimitiveTopology(prim); +} + +void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb) +{ + // ************************************************************* + // Static + // ************************************************************* + auto i = m_vs.find(sel); + + if(i == m_vs.end()) + { + std::string macro = format("#define VS_BPPZ %d\n", sel.bppz) + + format("#define VS_TME %d\n", sel.tme) + + format("#define VS_FST %d\n", sel.fst) + + format("#define VS_RTCOPY %d\n", sel.rtcopy); + + GLuint vs; + CompileShaderFromSource("tfx.glsl", "vs_main", GL_VERTEX_SHADER, &vs, macro); + + m_vs[sel] = vs; + i = m_vs.find(sel); + } + + // ************************************************************* + // Dynamic + // ************************************************************* + if(m_vs_cb_cache.Update(cb)) + { + SetUniformBuffer(m_vs_cb); + m_vs_cb->upload(&cb); + } + + VSSetShader(i->second); +} + +void GSDeviceOGL::SetupGS(GSSelector sel) +{ + // ************************************************************* + // Static + // ************************************************************* + GLuint gs = 0; + if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) { + auto i = m_gs.find(sel); + + if(i == m_gs.end()) { + std::string macro = format("#define GS_IIP %d\n", sel.iip) + + format("#define GS_PRIM %d\n", sel.prim); + + CompileShaderFromSource("tfx.glsl", "gs_main", GL_GEOMETRY_SHADER, &gs, macro); + + m_gs[sel] = gs; + } else { + gs = i->second; + } + } + // ************************************************************* + // Dynamic + // ************************************************************* + GSSetShader(gs); +} + +void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) +{ + // ************************************************************* + // Static + // ************************************************************* + GLuint ps; + auto i = m_ps.find(sel); + + if (i == m_ps.end()) + { + std::string macro = format("#define PS_FST %d\n", sel.fst) + + format("#define PS_WMS %d\n", sel.wms) + + format("#define PS_WMT %d\n", sel.wmt) + + format("#define PS_FMT %d\n", sel.fmt) + + format("#define PS_AEM %d\n", sel.aem) + + format("#define PS_TFX %d\n", sel.tfx) + + format("#define PS_TCC %d\n", sel.tcc) + + format("#define PS_ATST %d\n", sel.atst) + + format("#define PS_FOG %d\n", sel.fog) + + format("#define PS_CLR1 %d\n", sel.clr1) + + format("#define PS_FBA %d\n", sel.fba) + + format("#define PS_AOUT %d\n", sel.aout) + + format("#define PS_LTF %d\n", sel.ltf) + + format("#define PS_COLCLIP %d\n", sel.colclip) + + format("#define PS_DATE %d\n", sel.date); + + CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &ps, macro); + + m_ps[sel] = ps; + i = m_ps.find(sel); + } else { + ps = i->second; + } + + // ************************************************************* + // Dynamic + // ************************************************************* + if(m_ps_cb_cache.Update(cb)) + { + SetUniformBuffer(m_ps_cb); + m_ps_cb->upload(&cb); + } + + GLuint ss0, ss1; + ss0 = ss1 = 0; + if(sel.tfx != 4) + { + if(!(sel.fmt < 3 && sel.wms < 3 && sel.wmt < 3)) + { + ssel.ltf = 0; + } + + auto i = m_ps_ss.find(ssel); + + if(i != m_ps_ss.end()) + { + ss0 = i->second; + } + else + { + // ************************************************************* + // Static + // ************************************************************* + glGenSamplers(1, &ss0); + if (ssel.ltf) { + glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } else { + glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + + // FIXME ensure U -> S, V -> T and W->R + if (ssel.tau) + glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_REPEAT); + else + glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + + if (ssel.tav) + glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_REPEAT); + else + glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glSamplerParameteri(ss0, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + + // FIXME which value for GL_TEXTURE_MIN_LOD + glSamplerParameteri(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX); + // FIXME: seems there is 2 possibility in opengl + // DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER; + // glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER); + // FIXME: need ogl extension sd.MaxAnisotropy = 16; + + m_ps_ss[ssel] = ss0; + } + + if(sel.fmt >= 3) + { + ss1 = m_palette_ss; + } + } + + PSSetSamplerState(ss0, ss1, sel.date ? m_rt_ss : 0); + + PSSetShader(ps); +} + +void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) +{ + auto i = m_om_dss.find(dssel); + + // ************************************************************* + // Static + // ************************************************************* + if (i == m_om_dss.end()) + { + GSDepthStencilOGL* dss = new GSDepthStencilOGL(); + + if (dssel.date) + { + dss->m_stencil_enable = true; + dss->m_stencil_func = GL_EQUAL; + dss->m_stencil_spass_dpass_op = GL_KEEP; + } + + if(dssel.ztst != ZTST_ALWAYS || dssel.zwe) + { + static const GLenum ztst[] = + { + GL_NEVER, + GL_ALWAYS, + GL_GEQUAL, + GL_GREATER + }; + dss->m_depth_enable = true; + dss->m_depth_mask = dssel.zwe ? GL_TRUE : GL_FALSE; + dss->m_depth_func = ztst[dssel.ztst]; + } + + m_om_dss[dssel] = dss; + i = m_om_dss.find(dssel); + } + + // ************************************************************* + // Dynamic + // ************************************************************* + OMSetDepthStencilState(i->second, 1); + + // ************************************************************* + // Static + // ************************************************************* + auto j = m_om_bs.find(bsel); + + if(j == m_om_bs.end()) + { + GSBlendStateOGL* bs = new GSBlendStateOGL(); + + bs->m_enable = bsel.abe; + + if(bsel.abe) + { + int i = ((bsel.a * 3 + bsel.b) * 3 + bsel.c) * 3 + bsel.d; + bs->m_equation_RGB = m_blendMapD3D9[i].op; + bs->m_func_sRGB = m_blendMapD3D9[i].src; + bs->m_func_dRGB = m_blendMapD3D9[i].dst; + + // Not very good but I don't wanna write another 81 row table + if(bsel.negative) + { + if(bs->m_equation_RGB == GL_FUNC_ADD) + bs->m_equation_RGB = GL_FUNC_REVERSE_SUBTRACT; + else if(bs->m_equation_RGB == GL_FUNC_REVERSE_SUBTRACT) + bs->m_equation_RGB = GL_FUNC_ADD; + else + ; // god knows, best just not to mess with it for now + } + + if(m_blendMapD3D9[i].bogus == 1) + { + if (bsel.a == 0) + bs->m_func_sRGB = GL_ONE; + else + bs->m_func_dRGB = GL_ONE; + + const string afixstr = format("%d >> 7", afix); + const char *col[3] = {"Cs", "Cd", "0"}; + const char *alpha[3] = {"As", "Ad", afixstr.c_str()}; + + // FIXME, need to investigate OGL capabilities. Maybe for OGL5 ;) + fprintf(stderr, "Impossible blend for D3D: (%s - %s) * %s + %s\n", col[bsel.a], col[bsel.b], alpha[bsel.c], col[bsel.d]); + } + + + } + + bs->m_r_msk = bsel.wr; + bs->m_g_msk = bsel.wg; + bs->m_b_msk = bsel.wb; + bs->m_a_msk = bsel.wa; + + m_om_bs[bsel] = bs; + j = m_om_bs.find(bsel); + } + + // ************************************************************* + // Dynamic + // ************************************************************* + OMSetBlendState(j->second, (float)(int)afix / 0x80); +} From f604ba8d7f137ef2a24fd6de7446687731db4a42 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 21 Dec 2011 20:37:24 +0000 Subject: [PATCH 17/56] gsdx-ogl: LINUX-ONLY Remove foreach feature not supported on old compiler git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5002 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index a5b45123a7..c683aed0b7 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -110,10 +110,10 @@ GSDeviceOGL::~GSDeviceOGL() glDeleteSamplers(1, &m_rt_ss); delete m_vb; - for (auto it : m_vs) glDeleteProgram(it.second); - for (auto it : m_gs) glDeleteProgram(it.second); - for (auto it : m_ps) glDeleteProgram(it.second); - for (auto it : m_ps_ss) glDeleteSamplers(1, &it.second); + for (auto it = m_vs.begin(); it != m_vs.end() ; it++) glDeleteProgram(it->second); + for (auto it = m_gs.begin(); it != m_gs.end() ; it++) glDeleteProgram(it->second); + for (auto it = m_ps.begin(); it != m_ps.end() ; it++) glDeleteProgram(it->second); + for (auto it = m_ps_ss.begin(); it != m_ps_ss.end() ; it++) glDeleteSamplers(1, &it->second); m_vs.clear(); m_gs.clear(); m_ps.clear(); From a9927a6e33bcf408b63e8f8ea57aa2e87633003a Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 21 Dec 2011 23:09:36 +0000 Subject: [PATCH 18/56] gsdx-ogl: LINUX-ONLY * rework a little the shader to be hopefully compatible with nvidia * request a pure 4.2 context (all gpu 4.1 capable support 4.2 anyway) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5003 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 1 + plugins/GSdx/GSDeviceOGL.cpp | 54 ++++++++++++++--------- plugins/GSdx/GSTexture.h | 2 +- plugins/GSdx/GSTextureOGL.cpp | 14 +----- plugins/GSdx/GSTextureOGL.h | 2 + plugins/GSdx/GSWnd.cpp | 2 +- plugins/GSdx/res/tfx.glsl | 81 +++++++++++++---------------------- 7 files changed, 68 insertions(+), 88 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 3208a45ff0..18694b7f40 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -206,5 +206,6 @@ else(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) endif(PACKAGE_MODE) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index c683aed0b7..690c5a8039 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -170,12 +170,26 @@ bool GSDeviceOGL::Create(GSWnd* wnd) fprintf(stderr, "Error: Failed to init glew :%s\n", glewGetErrorString(glew_ok)); return false; } - // FIXME upgrade to 4.2 when AMD drivers are ready - // Note need glew 1.7 too - if (!GLEW_VERSION_4_1) { - fprintf(stderr, "4.1 is not supported!\n"); - return false; - } + // Note: don't rely on glew to avoid to pull glew1.7 + // Instead we just copy/adapt the 10 lines of code + // if (!GLEW_VERSION_4_2) { + // fprintf(stderr, "4.2 is not supported!\n"); + // return false; + // } + const GLubyte* s; + s = glGetString(GL_VERSION); + if (s == NULL) return false; + + GLuint dot; + while (s[dot] != '\0' && s[dot] != '.') dot++; + if (dot == 0) return false; + + GLuint major = s[dot-1]-'0'; + GLuint minor = s[dot+1]-'0'; + if ( (major < 4) || ( major == 4 && minor < 2 ) ) return false; + + + } // FIXME disable it when code is ready @@ -465,7 +479,7 @@ bool GSDeviceOGL::Reset(int w, int h) // Opengl allocate the backbuffer with the window. The render is done in the backbuffer when // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done // in the backbuffer - m_backbuffer = new GSTextureOGL(0, w, h, false, 0); + m_backbuffer = new GSTextureOGL(0, w, h, false, GSTextureOGL::Backbuffer); return true; } @@ -484,8 +498,7 @@ void GSDeviceOGL::DrawPrimitive() void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { - GSTextureOGL* t_ogl = (GSTextureOGL*)t; - if (t == m_backbuffer) { + if (static_cast(t)->IsBackbuffer()) { // FIXME I really not sure OMSetFBO(0); //glClearBufferfv(GL_COLOR, GL_LEFT, c.v); @@ -497,7 +510,7 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) // FIXME I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); - t_ogl->Attach(GL_COLOR_ATTACHMENT0); + static_cast(t)->Attach(GL_COLOR_ATTACHMENT0); glClearBufferfv(GL_COLOR, 0, c.v); } } @@ -544,6 +557,7 @@ GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w { // I'm not sure about the object type for offscreen buffer // TODO later; + assert(0); // Need to find format equivalent. Then I think it will be straight forward @@ -680,7 +694,7 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // 2/ in case some GSdx code expect thing in dx order. // Only flipping the backbuffer is transparent (I hope)... GSVector4 flip_sr = sr; - if (dt == m_backbuffer) { + if (static_cast(dt)->IsBackbuffer()) { flip_sr.y = 1.0f - sr.y; flip_sr.w = 1.0f - sr.w; } @@ -1073,20 +1087,17 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto m_ctx->OMSetRenderTargets(1, &rtv, dsv); } #endif - GSTextureOGL* rt_ogl = (GSTextureOGL*)rt; - GSTextureOGL* ds_ogl = (GSTextureOGL*)ds; - - if (m_backbuffer == rt_ogl) { + if (static_cast(rt)->IsBackbuffer()) { OMSetFBO(0); - assert(ds_ogl == NULL); // no depth-stencil without FBO + assert(ds == NULL); // no depth-stencil without FBO } else { OMSetFBO(m_fbo); - assert(rt_ogl != NULL); // a render target must exists - rt_ogl->Attach(GL_COLOR_ATTACHMENT0); - if (ds_ogl != NULL) - ds_ogl->Attach(GL_DEPTH_STENCIL_ATTACHMENT); + assert(rt != NULL); // a render target must exists + static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); + if (ds != NULL) + static_cast(ds)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); } // Viewport -> glViewport @@ -1115,7 +1126,8 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st // Build a header string // ***************************************************** // First select the version (must be the first line so we need to generate it - std::string version = "#version 410\n#extension GL_ARB_shading_language_420pack: enable\n"; + //std::string version = "#version 410\n#extension GL_ARB_shading_language_420pack: enable\n"; + std::string version = "#version 420\n"; // Allow to puts several shader in 1 files std::string shader_type; diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index 43ac3f6bfa..cd779c4c8c 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -35,7 +35,7 @@ protected: public: struct GSMap {uint8* bits; int pitch;}; - enum {RenderTarget = 1, DepthStencil, Texture, Offscreen}; + enum {RenderTarget = 1, DepthStencil, Texture, Offscreen, Backbuffer}; public: GSTexture(); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index e99b555a80..1f398f638d 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -58,26 +58,14 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // glReadBuffer // glBlitFramebuffer + // TODO: we can render directly into a texture so I'm not sure rendertarget are useful anymore !!! // ************************************************************* - // Doc - // It might need a texture structure to replace ID3D11Texture2D. - // - // == The function need to set (from parameter) - // : m_size.x - // : m_size.y - // : m_type - // : m_format - // : m_msaa m_size.x = w; m_size.y = h; m_format = format; m_type = type; m_msaa = msaa; - // == Might be useful to save - // : m_texture_target (like GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE etc...) - // : m_texture_id (return by glGen*) - // // == Then generate the texture or buffer. // D3D11_BIND_RENDER_TARGET: Bind a texture as a render target for the output-merger stage. // => glGenRenderbuffers with GL_COLOR_ATTACHMENTi (Hum glGenTextures might work too) diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 4e55225048..ba9f3bab53 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -43,4 +43,6 @@ class GSTextureOGL : public GSTexture void EnableUnit(uint unit); void Attach(GLenum attachment); + + bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); } }; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 2b10f67825..3ef9cf3c2b 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -370,7 +370,7 @@ bool GSWnd::Attach(void* handle, bool managed) int context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 4, - GLX_CONTEXT_MINOR_VERSION_ARB, 1, + GLX_CONTEXT_MINOR_VERSION_ARB, 2, // FIXME : Request a debug context to ease opengl development // Note: don't support deprecated feature (pre openg 3.1) GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 600444594a..11f50b8b98 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -39,6 +39,14 @@ #define PS_DATE 0 #endif +struct vertex +{ + vec4 p; + vec4 t; + vec4 tp; + vec4 c; +}; + #ifdef VERTEX_SHADER layout(location = 0) in vec2 i_t; layout(location = 1) in vec4 i_c; @@ -47,13 +55,7 @@ layout(location = 3) in uvec2 i_p; layout(location = 4) in uint i_z; layout(location = 5) in vec4 i_f; -layout(location = 0) out VSout -{ - vec4 o_p; - vec4 o_t; - vec4 o_tp; - vec4 o_c; -}; +layout(location = 0) out vertex OUT; out gl_PerVertex { vec4 gl_Position; @@ -87,9 +89,9 @@ void vs_main() vec4 p = vec4(i_p, z, 0) - vec4(0.05f, 0.05f, 0, 0); - o_p = p * VertexScale - VertexOffset; + OUT.p = p * VertexScale - VertexOffset; #if VS_RTCOPY - o_tp = (p * VertexScale - VertexOffset) * vec4(0.5, -0.5, 0, 0) + 0.5; + OUT.tp = (p * VertexScale - VertexOffset) * vec4(0.5, -0.5, 0, 0) + 0.5; #endif gl_Position = p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position @@ -97,23 +99,23 @@ void vs_main() { if(VS_FST != 0) { - o_t.xy = i_t * TextureScale; - o_t.w = 1.0f; + OUT.t.xy = i_t * TextureScale; + OUT.t.w = 1.0f; } else { - o_t.xy = i_t; - o_t.w = i_q; + OUT.t.xy = i_t; + OUT.t.w = i_q; } } else { - o_t.xy = vec2(0.0f, 0.0f); - o_t.w = 1.0f; + OUT.t.xy = vec2(0.0f, 0.0f); + OUT.t.w = 1.0f; } - o_c = i_c; - o_t.z = i_f.a; + OUT.c = i_c; + OUT.t.z = i_f.a; } #endif @@ -131,21 +133,9 @@ out gl_PerVertex { float gl_ClipDistance[]; }; -layout(location = 0) in GSin -{ - vec4 p; - vec4 t; - vec4 tp; - vec4 c; -} GSin[]; +layout(location = 0) in vertex GSin[]; -layout(location = 0) out GSout -{ - vec4 p; - vec4 t; - vec4 tp; - vec4 c; -} GSout; +layout(location = 0) out vertex GSout; #if GS_PRIM == 0 layout(points) in; @@ -201,14 +191,6 @@ void gs_main() layout(lines) in; layout(triangle_strip, max_vertices = 4) out; -void set_output(uint i) -{ - GSout.p = GSin[i].p; - GSout.t = GSin[i].t; - GSout.tp = GSin[i].tp; - GSout.c = GSin[i].c; -} - void gs_main() { // left top => GSin[0]; @@ -216,7 +198,7 @@ void gs_main() // left top - set_output(0); + GSout = GSin[0]; GSout.p.z = GSin[1].p.z; GSout.t.zw = GSin[1].t.zw; @@ -227,7 +209,7 @@ void gs_main() EmitVertex(); // left bottom - set_output(1); + GSout = GSin[1]; gl_Position = gl_in[1].gl_Position; // FIXME is it useful gl_Position.x = GSin[0].p.x; GSout.p.x = GSin[0].p.x; @@ -235,7 +217,7 @@ void gs_main() EmitVertex(); // rigth top - set_output(1); + GSout = GSin[1]; gl_Position = gl_in[1].gl_Position; // FIXME is it useful gl_Position.y = GSin[0].p.y; GSout.p.y = GSin[0].p.y; @@ -243,7 +225,7 @@ void gs_main() EmitVertex(); // rigth bottom - set_output(1); + GSout = GSin[1]; gl_Position = GSin[1].p; // FIXME is it useful EmitVertex(); @@ -254,13 +236,7 @@ void gs_main() #endif #ifdef FRAGMENT_SHADER -layout(location = 0) in PSin -{ - vec4 p; - vec4 t; - vec4 tp; - vec4 c; -} PSin; +layout(location = 0) in vertex PSin; // Same buffer but 2 colors for dual source blending layout(location = 0, index = 0) out vec4 SV_Target0; @@ -401,7 +377,7 @@ vec4 sample_color(vec2 st, float q) } vec4 t; - if(PS_FMT <= FMT_16 && PS_WMS < 3 && PS_WMT < 3) + if((PS_FMT <= FMT_16) && (PS_WMS < 3) && (PS_WMT < 3)) { t = sample_c(clampuv(st)); } @@ -603,6 +579,8 @@ vec4 ps_color() { // FIXME !!!! //c.rgb *= c.rgb < 128./255; + bvec3 factor = bvec3(128.0f/255.0f, 128.0f/255.0f, 128.0f/255.0f); + c.rgb *= vec3(factor); } if(PS_CLR1 != 0) // needed for Cd * (As/Ad/F + 1) blending modes @@ -619,7 +597,6 @@ void ps_main() { vec4 c = ps_color(); - // FIXME: I'm not sure about the value of others field // output.c1 = c.a * 2; // used for alpha blending SV_Target1 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2); From 6f5ac7b7886b80ee70233cfb56c0588362d87add Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 22 Dec 2011 14:12:12 +0000 Subject: [PATCH 19/56] gsdx-ogl: LINUX-ONLY * go back to opengl 4.1 (nvidia driver is buggy with 4.1). * fix the backbuffer allocation. bad order of parameter * fix remaining glsl error git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5006 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 10 ++++++++-- plugins/GSdx/GSTextureOGL.cpp | 3 +++ plugins/GSdx/GSWnd.cpp | 6 ++++-- plugins/GSdx/res/tfx.glsl | 8 +++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 690c5a8039..fd47ee0b5f 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -186,7 +186,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd) GLuint major = s[dot-1]-'0'; GLuint minor = s[dot+1]-'0'; - if ( (major < 4) || ( major == 4 && minor < 2 ) ) return false; + // Note: 4.2 crash on latest nvidia drivers! + // So only check 4.1 + // if ( (major < 4) || ( major == 4 && minor < 2 ) ) return false; + if ( (major < 4) || ( major == 4 && minor < 1 ) ) return false; @@ -479,7 +482,7 @@ bool GSDeviceOGL::Reset(int w, int h) // Opengl allocate the backbuffer with the window. The render is done in the backbuffer when // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done // in the backbuffer - m_backbuffer = new GSTextureOGL(0, w, h, false, GSTextureOGL::Backbuffer); + m_backbuffer = new GSTextureOGL(GSTextureOGL::Backbuffer, w, h, false, 0); return true; } @@ -619,8 +622,11 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) return; } + // This function is useless on opengl. The only call I found copy the whole texture data to another one assert(0); + // GL_NV_copy_image seem like the good extension but not supported on AMD... + // Maybe opengl 4.3 ! // FIXME attach the texture to the FBO GSTextureOGL* st_ogl = (GSTextureOGL*) st; diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 1f398f638d..f38c6ad7f7 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -103,6 +103,9 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // gvec texelFetch(gsampler sampler, ivec texCoord, int lod[, int sample]); // corollary we can maybe use it for multisample stuff break; + case GSTexture::Backbuffer: + m_texture_target = 0; + m_texture_id = 0; default: break; } diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 3ef9cf3c2b..cefeba6e55 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -370,10 +370,12 @@ bool GSWnd::Attach(void* handle, bool managed) int context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 4, - GLX_CONTEXT_MINOR_VERSION_ARB, 2, + // Note: 4.2 crash on latest nvidia drivers! + GLX_CONTEXT_MINOR_VERSION_ARB, 1, // FIXME : Request a debug context to ease opengl development // Note: don't support deprecated feature (pre openg 3.1) - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + //GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, None }; m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 11f50b8b98..1a47366e48 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -74,13 +74,11 @@ void vs_main() { uint z; if(VS_BPPZ == 1) // 24 - { z = i_z & 0xffffff; - } else if(VS_BPPZ == 2) // 16 - { z = i_z & 0xffff; - } + else + z = i_z; // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty @@ -371,7 +369,7 @@ mat4 sample_4p(vec4 u) vec4 sample_color(vec2 st, float q) { - if(!PS_FST) + if(PS_FST == 0) { st /= q; } From 33a9ac370ac47a9103e693eadd6fe4459fdf66d8 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 23 Dec 2011 12:32:40 +0000 Subject: [PATCH 20/56] gsdx-ogl: LINUX-ONLY * implement offscreen and cache (mostly a copy past of dx) * add the missing macro selector of the shader... git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5009 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 61 +++++++++++++----------- plugins/GSdx/GSTextureCacheOGL.cpp | 10 ++-- plugins/GSdx/GSTextureOGL.cpp | 75 +++++++++++++++++++----------- plugins/GSdx/GSTextureOGL.h | 2 +- 4 files changed, 87 insertions(+), 61 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index fd47ee0b5f..7b3a74fd7f 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -526,12 +526,22 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) void GSDeviceOGL::ClearDepth(GSTexture* t, float c) { + // FIXME I need to clarify this FBO attachment stuff + // I would like to avoid FBO for a basic clean operation + OMSetFBO(m_fbo); + static_cast(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); + // FIXME can you clean depth and stencil separately glClearBufferfv(GL_DEPTH, 0, &c); } void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) { + // FIXME I need to clarify this FBO attachment stuff + // I would like to avoid FBO for a basic clean operation + OMSetFBO(m_fbo); + static_cast(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); GLint color = c; + // FIXME can you clean depth and stencil separately glClearBufferiv(GL_STENCIL, 0, &color); } @@ -558,56 +568,45 @@ GSTexture* GSDeviceOGL::CreateOffscreen(int w, int h, int format) // blit a texture into an offscreen buffer GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format) { - // I'm not sure about the object type for offscreen buffer - // TODO later; - - assert(0); - - // Need to find format equivalent. Then I think it will be straight forward - - // A four-component, 32-bit unsigned-normalized-integer format that supports 8 bits per channel including alpha. - // DXGI_FORMAT_R8G8B8A8_UNORM <=> GL_RGBA8 - - // A single-component, 16-bit unsigned-integer format that supports 16 bits for the red channel - // DXGI_FORMAT_R16_UINT <=> GL_R16 -#if 0 GSTexture* dst = NULL; - if(format == 0) - { - format = DXGI_FORMAT_R8G8B8A8_UNORM; - } + if(format == 0) format = GL_RGBA8; - if(format != DXGI_FORMAT_R8G8B8A8_UNORM && format != DXGI_FORMAT_R16_UINT) + if(format != GL_RGBA8 && format != GL_R16UI) { ASSERT(0); return false; } - if(GSTexture* rt = CreateRenderTarget(w, h, false, format)) + // FIXME: I used directly an offscreen texture because they are the same on Opengl + //if(GSTexture* rt = CreateRenderTarget(w, h, false, format)) + GSTexture* rt = CreateRenderTarget(w, h, false, format); + if(rt) { GSVector4 dr(0, 0, w, h); if(GSTexture* src2 = src->IsMSAA() ? Resolve(src) : src) { - StretchRect(src2, sr, rt, dr, m_convert.ps[format == DXGI_FORMAT_R16_UINT ? 1 : 0], NULL); + StretchRect(src2, sr, rt, dr, m_convert.ps[format == GL_R16UI ? 1 : 0]); if(src2 != src) Recycle(src2); } +#if 0 dst = CreateOffscreen(w, h, format); if(dst) { m_ctx->CopyResource(*(GSTexture11*)dst, *(GSTexture11*)rt); } +#endif Recycle(rt); } - return dst; -#endif + //return dst; + return rt; } // Copy a sub part of a texture into another @@ -622,12 +621,19 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) return; } - // This function is useless on opengl. The only call I found copy the whole texture data to another one - assert(0); - // GL_NV_copy_image seem like the good extension but not supported on AMD... // Maybe opengl 4.3 ! + // FIXME check those function work as expected + // Set the input of glCopyTexSubImage2D + static_cast(st)->Attach(GL_COLOR_ATTACHMENT1); + glReadBuffer(GL_COLOR_ATTACHMENT1); + + // Copy the full image + static_cast(dt)->EnableUnit(0); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, dt->GetWidth(), dt->GetHeight()); + +#if 0 // FIXME attach the texture to the FBO GSTextureOGL* st_ogl = (GSTextureOGL*) st; GSTextureOGL* dt_ogl = (GSTextureOGL*) dt; @@ -643,6 +649,7 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) //glCopyTexSubImage2D(dt_ogl.m_texture_target, 0, 0, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom); // FIXME I'm not sure GL_TEXTURE_RECTANGLE is supported!!! //glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom); +#endif #if 0 D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, 0, 0, 0, *(GSTexture11*)st, 0, &box); @@ -819,7 +826,7 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver // gs - GSSetShader(NULL); + GSSetShader(0); // ps @@ -1153,7 +1160,7 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st // Select the entry point ie the main function std::string entry_main = format("#define %s main\n", entry.c_str()); - std::string header = version + shader_type + entry_main; + std::string header = version + shader_type + entry_main + macro_sel; // ***************************************************** // Read the source file diff --git a/plugins/GSdx/GSTextureCacheOGL.cpp b/plugins/GSdx/GSTextureCacheOGL.cpp index 5b4605a2c3..b248d1dcf1 100644 --- a/plugins/GSdx/GSTextureCacheOGL.cpp +++ b/plugins/GSdx/GSTextureCacheOGL.cpp @@ -30,11 +30,9 @@ GSTextureCacheOGL::GSTextureCacheOGL(GSRenderer* r) void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) { - // Except format (CopyOffscreen method), everything else seem portable -#if 0 if(t->m_type != RenderTarget) { - // TODO + assert(0); return; } @@ -63,7 +61,10 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) GSVector4 src = GSVector4(r) * GSVector4(t->m_texture->GetScale()).xyxy() / GSVector4(t->m_texture->GetSize()).xyxy(); + GLuint format = TEX0.PSM == PSM_PSMCT16 || TEX0.PSM == PSM_PSMCT16S ? GL_R16UI : GL_RGBA8; +#if 0 DXGI_FORMAT format = TEX0.PSM == PSM_PSMCT16 || TEX0.PSM == PSM_PSMCT16S ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R8G8B8A8_UNORM; +#endif if(GSTexture* offscreen = m_renderer->m_dev->CopyOffscreen(t->m_texture, src, w, h, format)) { @@ -94,8 +95,7 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) offscreen->Unmap(); } - m_renderer->m_dev->Recycle(offscreen); + //m_renderer->m_dev->Recycle(offscreen); } -#endif } diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index f38c6ad7f7..bf52cb4bfb 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -28,7 +28,7 @@ static uint g_state_texture_id = 0; GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) : m_texture_unit(0), m_extra_buffer_id(0), - m_extra_buffer_allocated(false) + m_pbo_size(0) { // ************************************************************* // Opengl world @@ -83,6 +83,16 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // Generate the buffer switch (m_type) { + case GSTexture::Offscreen: + //FIXME I not sure we need a pixel buffer object. It seems more a texture + // glGenBuffers(1, &m_texture_id); + // m_texture_target = GL_PIXEL_UNPACK_BUFFER; + // assert(0); + // Note there is also a buffer texture!!! + // http://www.opengl.org/wiki/Buffer_Texture + // Note: in this case it must use in GLSL + // gvec texelFetch(gsampler sampler, ivec texCoord, int lod[, int sample]); + // corollary we can maybe use it for multisample stuff case GSTexture::Texture: case GSTexture::RenderTarget: glGenTextures(1, &m_texture_id); @@ -92,16 +102,6 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) glGenRenderbuffers(1, &m_texture_id); m_texture_target = GL_RENDERBUFFER; break; - case GSTexture::Offscreen: - //FIXME I not sure we need a pixel buffer object. It seems more a texture - // glGenBuffers(1, &m_texture_id); - // m_texture_target = GL_PIXEL_UNPACK_BUFFER; - assert(0); - // Note there is also a buffer texture!!! - // http://www.opengl.org/wiki/Buffer_Texture - // Note: in this case it must use in GLSL - // gvec texelFetch(gsampler sampler, ivec texCoord, int lod[, int sample]); - // corollary we can maybe use it for multisample stuff break; case GSTexture::Backbuffer: m_texture_target = 0; @@ -140,7 +140,12 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) assert(0); // TODO Later break; case GSTexture::Offscreen: - assert(0); + if (m_type == GL_RGBA8) m_pbo_size = m_size.x * m_size.y * 4; + else if (m_type == GL_R16UI) m_pbo_size = m_size.x * m_size.y * 2; + else assert(0); + + glBindBuffer(GL_PIXEL_PACK_BUFFER, m_extra_buffer_id); + glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); break; default: break; } @@ -197,19 +202,18 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // The case appears on SW mode. Src pitch is 2x dst pitch. int rowbytes = r.width() << 2; if (pitch != rowbytes) { - uint32 pbo_size = m_size.x * m_size.y * 4; uint32 map_flags = GL_MAP_WRITE_BIT; glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_extra_buffer_id); - if (!m_extra_buffer_allocated) { - glBufferData(GL_PIXEL_UNPACK_BUFFER, pbo_size, NULL, GL_STREAM_DRAW); - m_extra_buffer_allocated = true; + if (!m_pbo_size) { + m_pbo_size = m_size.x * m_size.y * 4; + glBufferData(GL_PIXEL_UNPACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); } else { GL_MAP_INVALIDATE_BUFFER_BIT; } uint8* src = (uint8*) data; - uint8* dst = (uint8*) glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, pbo_size, map_flags); + uint8* dst = (uint8*) glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_pbo_size, map_flags); for(int h = r.height(); h > 0; h--, src += pitch, dst += rowbytes) { memcpy(dst, src, rowbytes); @@ -274,6 +278,26 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) // // glMapBuffer — map a buffer object's data store // Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER + if (m_type == GSTexture::Offscreen) { + glBindBuffer(GL_PIXEL_PACK_BUFFER, m_extra_buffer_id); + // FIXME It might be possible to only map a subrange of the texture based on r object + + // Load the PBO + if (m_format == GL_R16UI) + glReadPixels(0, 0, m_size.x, m_size.y, GL_RED, GL_UNSIGNED_SHORT, 0); + else if (m_format == GL_RGBA8) + glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0); + else + assert(0); + + // Give access from the CPU + uint32 map_flags = GL_MAP_READ_BIT; + m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, map_flags); + m.pitch = m_size.x; + + return true; + } + return false; #if 0 if(r != NULL) @@ -302,14 +326,9 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) void GSTextureOGL::Unmap() { - // copy the texture to the GPU - // GLboolean glUnmapBuffer(GLenum target); -#if 0 - if(m_texture) - { - m_ctx->Unmap(m_texture, 0); + if (m_type == GSTexture::Offscreen) { + glUnmapBuffer(GL_PIXEL_PACK_BUFFER); } -#endif } #ifndef _WINDOWS @@ -358,13 +377,13 @@ bool GSTextureOGL::Save(const string& fn, bool dds) // Collect the texture data char* image = (char*)malloc(4 * m_size.x * m_size.y); - if (m_type) { - EnableUnit(0); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); - } else { + if (IsBackbuffer()) { // TODO backbuffer glReadBuffer(GL_BACK); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); + } else { + EnableUnit(0); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); } // Build a BMP file diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index ba9f3bab53..81614385cb 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -30,7 +30,7 @@ class GSTextureOGL : public GSTexture GLuint m_texture_id; // the texture id uint m_texture_unit; // the texture unit offset uint m_extra_buffer_id; - bool m_extra_buffer_allocated; + int m_pbo_size; public: explicit GSTextureOGL(int type, int w, int h, bool msaa, int format); From aa499f4bfd3bcad0eae846a857986e50125d736b Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 29 Dec 2011 14:24:26 +0000 Subject: [PATCH 21/56] gsdx-ogl: LINUX-ONLY * fix vertex shader for HW renderer :) Remains the fragment part... * add some dumping infrastucture (DUMP_START and DUMP_LENGTH) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5030 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 77 ++++++++++++++++++++++++--------- plugins/GSdx/GSDeviceOGL.h | 19 +++++--- plugins/GSdx/GSRendererOGL.h | 2 + plugins/GSdx/GSTextureFXOGL.cpp | 10 ++--- plugins/GSdx/GSTextureOGL.cpp | 41 +++++++++++++----- plugins/GSdx/GSTextureOGL.h | 1 + plugins/GSdx/res/convert.glsl | 29 +++++-------- plugins/GSdx/res/tfx.glsl | 26 ++++++++--- 8 files changed, 138 insertions(+), 67 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 7b3a74fd7f..74a3ecd720 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -53,6 +53,15 @@ // glUniformBlockBinding(program, block_index, block_binding_point); //#define LOUD_DEBUGGING +//#define DUMP_START (380) +#define DUMP_LENGTH (20) + +#ifdef DUMP_START +static uint32 g_draw_count = 0; +static uint32 g_frame_count = 0; +#endif + + GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) @@ -492,11 +501,43 @@ void GSDeviceOGL::Flip() // FIXME: disable it when code is working CheckDebugLog(); m_wnd->Flip(); +#ifdef DUMP_START + g_frame_count++; +#endif } void GSDeviceOGL::DrawPrimitive() { glDrawArrays(m_state.topology, m_state.vb_state->start, m_state.vb_state->count); +#ifdef DUMP_START + if (g_draw_count > DUMP_START && g_draw_count < (DUMP_START+DUMP_LENGTH)) { + for (auto i = 0 ; i < 3 ; i++) { + if (m_state.ps_srv[i] != NULL) { + m_state.ps_srv[i]->Save(format("/tmp/in_%d__%d.bmp", g_draw_count, i),false); + } + } + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_%d.bmp", g_draw_count),false); + if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/out_%d_ds.bmp", g_draw_count),false); + + string topo; + switch (m_state.topology) { + case GL_TRIANGLE_STRIP: topo = "triangle_strip"; break; + case GL_TRIANGLES: topo = "triangle"; break; + case GL_LINES: topo = "line"; break; + case GL_POINTS: topo = "point"; break; + default: topo = "!!!!"; + } + fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, m_state.vb_state->count, topo.c_str() ); + fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); + fprintf(stderr, "Blend: %d, Depth: %d, Stencil: %d \n",m_state.bs->m_enable, m_state.dss->m_depth_enable, m_state.dss->m_stencil_enable); + + //fprintf(stderr, "type: %d, format: 0x%x\n", m_state.rtv->GetType(), m_state.rtv->GetFormat()); + fprintf(stderr, "\n"); + + } + + g_draw_count++; +#endif } void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) @@ -941,6 +982,7 @@ void GSDeviceOGL::GSSetShader(GLuint gs) if(m_state.gs != gs) { m_state.gs = gs; + // FIXME AMD driver bug !!!!!!!! glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs); } } @@ -954,9 +996,7 @@ void GSDeviceOGL::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr) { - GSTextureOGL* srv = NULL; - - if(sr) srv = (GSTextureOGL*)sr; + GSTextureOGL* srv = static_cast(sr); if(m_state.ps_srv[i] != srv) { @@ -1082,24 +1122,11 @@ void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor) { - // attach render&depth to the FBO // Hum, need to separate 2 case, Render target fbo and render target backbuffer // Or maybe blit final result to the backbuffer -#if 0 - ID3D11RenderTargetView* rtv = NULL; - ID3D11DepthStencilView* dsv = NULL; + m_state.rtv = static_cast(rt); + m_state.dsv = static_cast(ds); - if(rt) rtv = *(GSTexture11*)rt; - if(ds) dsv = *(GSTexture11*)ds; - - if(m_state.rtv != rtv || m_state.dsv != dsv) - { - m_state.rtv = rtv; - m_state.dsv = dsv; - - m_ctx->OMSetRenderTargets(1, &rtv, dsv); - } -#endif if (static_cast(rt)->IsBackbuffer()) { OMSetFBO(0); @@ -1108,7 +1135,16 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto OMSetFBO(m_fbo); assert(rt != NULL); // a render target must exists - static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); + + // FIXME DEBUG special case for GL_R16UI + if (rt->GetFormat() == GL_R16UI) { + glDrawBuffer(GL_COLOR_ATTACHMENT1); + static_cast(rt)->Attach(GL_COLOR_ATTACHMENT1); + } else { + glDrawBuffer(GL_COLOR_ATTACHMENT0); + static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); + } + if (ds != NULL) static_cast(ds)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); } @@ -1215,7 +1251,8 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st char* log = (char*)malloc(log_length); glGetProgramInfoLog(*program, log_length, NULL, log); - fprintf(stderr, "%s (%s) :", glsl_file.c_str(), entry.c_str()); + fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), *program); + fprintf(stderr, "\n%s", macro_sel.c_str()); fprintf(stderr, "%s\n", log); free(log); } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index e07d716696..cc3da91b60 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -87,10 +87,12 @@ class GSUniformBufferOGL { GLuint buffer; // data object GLuint index; // GLSL slot uint size; // size of the data + const GLenum target; public: GSUniformBufferOGL(GLuint index, uint size) : index(index) - , size(size) + , size(size) + ,target(GL_UNIFORM_BUFFER) { glGenBuffers(1, &buffer); bind(); @@ -100,25 +102,25 @@ public: void bind() { - glBindBuffer(GL_UNIFORM_BUFFER, buffer); + glBindBuffer(target, buffer); } void allocate() { - glBufferData(GL_UNIFORM_BUFFER, size, NULL, GL_STREAM_DRAW); + glBufferData(target, size, NULL, GL_STREAM_DRAW); } void attach() { - glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer); + glBindBufferBase(target, index, buffer); } void upload(const void* src) { uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT; - uint8* dst = (uint8*) glMapBufferRange(GL_UNIFORM_BUFFER, 0, size, flags); + uint8* dst = (uint8*) glMapBufferRange(target, 0, size, flags); memcpy(dst, src, size); - glUnmapBuffer(GL_UNIFORM_BUFFER); + glUnmapBuffer(target); } ~GSUniformBufferOGL() { @@ -178,7 +180,10 @@ struct GSVertexBufferState { for (int i = 0; i < layout_nbr; i++) { // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer glEnableVertexAttribArray(layout[i].index); - glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); + if (layout[i].type == GL_UNSIGNED_INT || layout[i].type == GL_UNSIGNED_SHORT) + glVertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset); + else + glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); } } diff --git a/plugins/GSdx/GSRendererOGL.h b/plugins/GSdx/GSRendererOGL.h index 6e1cb1f582..32109a6f5e 100644 --- a/plugins/GSdx/GSRendererOGL.h +++ b/plugins/GSdx/GSRendererOGL.h @@ -215,6 +215,7 @@ class GSRendererOGL : public GSRendererHW } } + // FIXME Opengl support half pixel center (as dx10). Code could be easier!!! GSDeviceOGL::VSConstantBuffer vs_cb; float sx = 2.0f * rtscale.x / (rtsize.x << 4); @@ -242,6 +243,7 @@ class GSRendererOGL : public GSRendererHW vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); + // END of FIXME // gs diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 28a02602eb..9560cb5b96 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -106,10 +106,9 @@ void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb) // ************************************************************* // Dynamic // ************************************************************* - if(m_vs_cb_cache.Update(cb)) - { + if(m_vs_cb_cache.Update(cb)) { SetUniformBuffer(m_vs_cb); - m_vs_cb->upload(&cb); + m_vs_cb->upload(cb); } VSSetShader(i->second); @@ -178,10 +177,9 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS // ************************************************************* // Dynamic // ************************************************************* - if(m_ps_cb_cache.Update(cb)) - { + if(m_ps_cb_cache.Update(cb)) { SetUniformBuffer(m_ps_cb); - m_ps_cb->upload(&cb); + m_ps_cb->upload(cb); } GLuint ss0, ss1; diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index bf52cb4bfb..2cf2510196 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -146,6 +146,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) glBindBuffer(GL_PIXEL_PACK_BUFFER, m_extra_buffer_id); glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); break; default: break; } @@ -295,6 +296,8 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, map_flags); m.pitch = m_size.x; + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + return true; } @@ -367,20 +370,21 @@ struct BITMAPINFOHEADER bool GSTextureOGL::Save(const string& fn, bool dds) { - switch (m_type) { - case GSTexture::DepthStencil: - case GSTexture::Offscreen: - ASSERT(0); - break; - default: break; - } + // Code not yet working + if (IsDss()) return false; // Collect the texture data - char* image = (char*)malloc(4 * m_size.x * m_size.y); + uint32 pitch = 4 * m_size.x; + if (IsDss()) pitch *= 2; + char* image = (char*)malloc(pitch * m_size.y); + if (IsBackbuffer()) { // TODO backbuffer glReadBuffer(GL_BACK); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); + } else if(IsDss()) { + Attach(GL_DEPTH_STENCIL_ATTACHMENT); + glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image); } else { EnableUnit(0); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); @@ -417,12 +421,29 @@ bool GSTextureOGL::Save(const string& fn, bool dds) fwrite(&bfh, 1, sizeof(bfh), fp); fwrite(&bih, 1, sizeof(bih), fp); - uint32 pitch = 4 * m_size.x; uint8* data = (uint8*)image + (m_size.y - 1) * pitch; for(int h = m_size.y; h > 0; h--, data -= pitch) { - fwrite(data, 1, m_size.x << 2, fp); // TODO: swap red-blue? + if (IsDss()) { + // Only get the depth and convert it to an integer + uint8* better_data = data; + for (int w = m_size.x; w > 0; w--, better_data += 8) { + float* input = (float*)better_data; + uint32 depth = (uint32)ldexpf(*input, 32); + fwrite(&depth, 1, 4, fp); + } + } else { + // swap red and blue + uint8* better_data = data; + for (int w = m_size.x; w > 0; w--, better_data += 4) { + uint8 red = better_data[2]; + better_data[2] = better_data[0]; + better_data[0] = red; + fwrite(better_data, 1, 4, fp); + } + } + // fwrite(data, 1, m_size.x << 2, fp); // TODO: swap red-blue? } fclose(fp); diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 81614385cb..b2a3b52c37 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -45,4 +45,5 @@ class GSTextureOGL : public GSTexture void Attach(GLenum attachment); bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); } + bool IsDss() { return (m_type == GSTexture::DepthStencil); } }; diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index b12bf4ec96..d2c9f3fb0f 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -39,6 +39,7 @@ layout(location = 0) in vec4 SV_Position; layout(location = 1) in vec2 TEXCOORD0; layout(location = 0) out vec4 SV_Target0; +layout(location = 1) out uint SV_Target1; layout(binding = 0) uniform sampler2D TextureSampler; @@ -65,6 +66,17 @@ void ps_main0() SV_Target0 = sample_c(); } +void ps_main1() +{ + vec4 c = sample_c(); + + c.a *= 256.0f / 127.0f; // hm, 0.5 won't give us 1.0 if we just multiply with 2 + + highp uvec4 i = uvec4(c * vec4(0x001f, 0x03e0, 0x7c00, 0x8000)); + + SV_Target1 = (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); +} + void ps_main7() { vec4 c = sample_c(); @@ -93,9 +105,6 @@ void ps_main6() // diagonal } // Avoid to log useless error compilation failure -void ps_main1() -{ -} void ps_main2() { } @@ -106,20 +115,6 @@ void ps_main4() { } -//void ps_main1() -//{ -// vec4 c = sample_c(); -// -// c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 -// -// uvec4 i = uvec4(c * vec4(0x001f, 0x03e0, 0x7c00, 0x8000)); -// -//#ifdef DEBUG_FRAG -// SV_Target0 = vec4(0.5,0.5,0.5,1.0); -//#else -// SV_Target0 = (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); -//#endif -//} // Texture2D Texture; // SamplerState TextureSampler; diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 1a47366e48..532ea7dbe1 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -86,12 +86,13 @@ void vs_main() // example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133 vec4 p = vec4(i_p, z, 0) - vec4(0.05f, 0.05f, 0, 0); + vec4 final_p = p * VertexScale - VertexOffset; - OUT.p = p * VertexScale - VertexOffset; + OUT.p = final_p; + gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position #if VS_RTCOPY - OUT.tp = (p * VertexScale - VertexOffset) * vec4(0.5, -0.5, 0, 0) + 0.5; + OUT.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5; #endif - gl_Position = p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position if(VS_TME != 0) { @@ -237,8 +238,13 @@ void gs_main() layout(location = 0) in vertex PSin; // Same buffer but 2 colors for dual source blending -layout(location = 0, index = 0) out vec4 SV_Target0; -layout(location = 0, index = 1) out vec4 SV_Target1; +//FIXME +#if 1 + layout(location = 0, index = 0) out vec4 SV_Target0; + layout(location = 0, index = 1) out vec4 SV_Target1; +#else + layout(location = 0) out vec4 SV_Target; +#endif layout(binding = 0) uniform sampler2D TextureSampler; layout(binding = 1) uniform sampler2D PaletteSampler; @@ -583,8 +589,6 @@ vec4 ps_color() if(PS_CLR1 != 0) // needed for Cd * (As/Ad/F + 1) blending modes { - // FIXME: I'm not sure about the value of others field - //c.rgb = 1.0f; c.rgb = vec3(1.0f, 1.0f, 1.0f); } @@ -593,6 +597,8 @@ vec4 ps_color() void ps_main() { + //FIXME +#if 1 vec4 c = ps_color(); // FIXME: I'm not sure about the value of others field @@ -611,5 +617,11 @@ void ps_main() } SV_Target0 = c; + + //SV_Target0 = vec4(1.0f,0.0f,0.0f, 1.0f); + //SV_Target1 = vec4(1.0f,0.0f,0.0f, 1.0f); +#else + SV_Target = vec4(1.0f,0.0f,0.0f, 1.0f); +#endif } #endif From 000220f93ff72a9154166faedf8998ed2d68468a Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 29 Dec 2011 14:39:53 +0000 Subject: [PATCH 22/56] gsdx-ogl: LINUX-ONLY * It works with the HW renderer !!! * Not sure this fix will work with dual blending but we will see later * screen is vertically flipped again... git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5031 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/res/tfx.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 532ea7dbe1..fbf84f659d 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -603,7 +603,7 @@ void ps_main() // FIXME: I'm not sure about the value of others field // output.c1 = c.a * 2; // used for alpha blending - SV_Target1 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2); + SV_Target0 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2); if(PS_AOUT != 0) // 16 bit output { @@ -616,10 +616,10 @@ void ps_main() if(c.a < 0.5) c.a += 0.5; } - SV_Target0 = c; + SV_Target1 = c; //SV_Target0 = vec4(1.0f,0.0f,0.0f, 1.0f); - //SV_Target1 = vec4(1.0f,0.0f,0.0f, 1.0f); + //SV_Target1 = vec4(0.0f,1.0f,0.0f, 1.0f); #else SV_Target = vec4(1.0f,0.0f,0.0f, 1.0f); #endif From ea33beb36023306c8ce71ca991e0f716151e2f8f Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 30 Dec 2011 13:55:33 +0000 Subject: [PATCH 23/56] gsdx-ogl: LINUX-ONLY * Fix the Geomtry shader to output 2 triangles for quad primitive (ie 2R rendering) - There is an AMD driver bug on geomtry shader input interface (well could be the spec too). Tell me if it still working on nvidia * Add a workaroung to a previous AMD bug. It is impossible to unattach a shader so destroy the full shader pipeline... * Be more strict on FBO management. Would optimize it later * use a texture insted of a render buffer for depth-stencil management. * add more dumping capabilities (in particular depth buffer) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5033 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 70 +++++++++++++--- plugins/GSdx/GSDeviceOGL.h | 14 +++- plugins/GSdx/GSTextureOGL.cpp | 146 +++++++--------------------------- plugins/GSdx/res/tfx.glsl | 85 +++++++++++--------- 4 files changed, 147 insertions(+), 168 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 74a3ecd720..19c9d76e44 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -53,8 +53,10 @@ // glUniformBlockBinding(program, block_index, block_binding_point); //#define LOUD_DEBUGGING -//#define DUMP_START (380) -#define DUMP_LENGTH (20) +#define SHADER_DEBUG +//#define DUMP_START (500) +//#define DUMP_LENGTH (40) +//#define DUMP_ONLY_FRAME (112) #ifdef DUMP_START static uint32 g_draw_count = 0; @@ -508,16 +510,27 @@ void GSDeviceOGL::Flip() void GSDeviceOGL::DrawPrimitive() { - glDrawArrays(m_state.topology, m_state.vb_state->start, m_state.vb_state->count); #ifdef DUMP_START - if (g_draw_count > DUMP_START && g_draw_count < (DUMP_START+DUMP_LENGTH)) { + bool dump_me = false; + if ( (g_draw_count > DUMP_START && g_draw_count < (DUMP_START+DUMP_LENGTH)) ) + dump_me = true; +#ifdef DUMP_ONLY_FRAME + if (DUMP_ONLY_FRAME != 0 && DUMP_ONLY_FRAME == g_frame_count) + dump_me = true; + else if (DUMP_ONLY_FRAME != 0) + dump_me = false; +#endif +#endif + + // DUMP INPUT +#ifdef DUMP_START + if ( dump_me ) { for (auto i = 0 ; i < 3 ; i++) { if (m_state.ps_srv[i] != NULL) { - m_state.ps_srv[i]->Save(format("/tmp/in_%d__%d.bmp", g_draw_count, i),false); + m_state.ps_srv[i]->Save(format("/tmp/in_%d__%d.bmp", g_draw_count, i)); } } - if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_%d.bmp", g_draw_count),false); - if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/out_%d_ds.bmp", g_draw_count),false); + if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); string topo; switch (m_state.topology) { @@ -530,18 +543,41 @@ void GSDeviceOGL::DrawPrimitive() fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, m_state.vb_state->count, topo.c_str() ); fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); fprintf(stderr, "Blend: %d, Depth: %d, Stencil: %d \n",m_state.bs->m_enable, m_state.dss->m_depth_enable, m_state.dss->m_stencil_enable); + } +#endif + + glDrawArrays(m_state.topology, m_state.vb_state->start, m_state.vb_state->count); + + // DUMP OUTPUT +#ifdef DUMP_START + if ( dump_me ) { + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_%d.bmp", g_draw_count)); + if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); - //fprintf(stderr, "type: %d, format: 0x%x\n", m_state.rtv->GetType(), m_state.rtv->GetFormat()); fprintf(stderr, "\n"); } g_draw_count++; #endif + + + // FIXME AMD driver bug workaround + // You cannot unattach shader. So destroy everythings and recreate the shader pipeline... + // Slow and painful... + glBindProgramPipeline(0); + glDeleteProgramPipelines(1, &m_pipeline); + m_state.gs = 0; + m_state.ps = 0; + m_state.vs = 0; + + glGenProgramPipelines(1, &m_pipeline); + glBindProgramPipeline(m_pipeline); } void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { + GLuint fbo_old = m_state.fbo; if (static_cast(t)->IsBackbuffer()) { // FIXME I really not sure OMSetFBO(0); @@ -557,6 +593,7 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) static_cast(t)->Attach(GL_COLOR_ATTACHMENT0); glClearBufferfv(GL_COLOR, 0, c.v); } + OMSetFBO(fbo_old); } void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) @@ -567,16 +604,19 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c) void GSDeviceOGL::ClearDepth(GSTexture* t, float c) { + GLuint fbo_old = m_state.fbo; // FIXME I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); static_cast(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); // FIXME can you clean depth and stencil separately glClearBufferfv(GL_DEPTH, 0, &c); + OMSetFBO(fbo_old); } void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) { + GLuint fbo_old = m_state.fbo; // FIXME I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); @@ -584,6 +624,7 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) GLint color = c; // FIXME can you clean depth and stencil separately glClearBufferiv(GL_STENCIL, 0, &color); + OMSetFBO(fbo_old); } GSTexture* GSDeviceOGL::CreateRenderTarget(int w, int h, bool msaa, int format) @@ -665,6 +706,11 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) // GL_NV_copy_image seem like the good extension but not supported on AMD... // Maybe opengl 4.3 ! // FIXME check those function work as expected + + // FIXME FBO + GLuint fbo_old = m_state.fbo; + OMSetFBO(m_fbo); + // Set the input of glCopyTexSubImage2D static_cast(st)->Attach(GL_COLOR_ATTACHMENT1); @@ -674,6 +720,8 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) static_cast(dt)->EnableUnit(0); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, dt->GetWidth(), dt->GetHeight()); + OMSetFBO(fbo_old); + #if 0 // FIXME attach the texture to the FBO GSTextureOGL* st_ogl = (GSTextureOGL*) st; @@ -879,6 +927,9 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver // +#ifdef DUMP_START + fprintf(stderr, "draw date!!!\n"); +#endif DrawPrimitive(); // @@ -982,7 +1033,6 @@ void GSDeviceOGL::GSSetShader(GLuint gs) if(m_state.gs != gs) { m_state.gs = gs; - // FIXME AMD driver bug !!!!!!!! glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs); } } @@ -1244,6 +1294,7 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st free(header_str); free(sources_array); +#ifdef SHADER_DEBUG // Print a nice debug log GLint log_length = 0; glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length); @@ -1254,6 +1305,7 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), *program); fprintf(stderr, "\n%s", macro_sel.c_str()); fprintf(stderr, "%s\n", log); +#endif free(log); } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index cc3da91b60..98ce44d7f2 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -180,10 +180,16 @@ struct GSVertexBufferState { for (int i = 0; i < layout_nbr; i++) { // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer glEnableVertexAttribArray(layout[i].index); - if (layout[i].type == GL_UNSIGNED_INT || layout[i].type == GL_UNSIGNED_SHORT) - glVertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset); - else - glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); + switch (layout[i].type) { + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + // Rule: when shader use integral (not normalized) you must use glVertexAttribIPointer (note the extra I) + glVertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset); + break; + default: + glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset); + break; + } } } diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 2cf2510196..094f5a9021 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -95,14 +95,10 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // corollary we can maybe use it for multisample stuff case GSTexture::Texture: case GSTexture::RenderTarget: + case GSTexture::DepthStencil: glGenTextures(1, &m_texture_id); m_texture_target = GL_TEXTURE_2D; break; - case GSTexture::DepthStencil: - glGenRenderbuffers(1, &m_texture_id); - m_texture_target = GL_RENDERBUFFER; - break; - break; case GSTexture::Backbuffer: m_texture_target = 0; m_texture_id = 0; @@ -123,8 +119,8 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // Allocate the buffer switch (m_type) { case GSTexture::DepthStencil: - glBindRenderbuffer(m_texture_target, m_texture_id); - glRenderbufferStorageMultisample(m_texture_target, msaa_level, m_format, m_size.y, m_size.x); + EnableUnit(1); + glTexImage2D(m_texture_target, 0, m_format, w, h, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); break; case GSTexture::RenderTarget: case GSTexture::Texture: @@ -155,28 +151,12 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) GSTextureOGL::~GSTextureOGL() { glDeleteBuffers(1, &m_extra_buffer_id); - switch (m_type) { - case GSTexture::Texture: - case GSTexture::RenderTarget: - glDeleteTextures(1, &m_texture_id); - break; - case GSTexture::DepthStencil: - glDeleteRenderbuffers(1, &m_texture_id); - break; - case GSTexture::Offscreen: - assert(0); - break; - default: - break; - } + glDeleteTextures(1, &m_texture_id); } void GSTextureOGL::Attach(GLenum attachment) { - if (m_type == GSTexture::DepthStencil) - glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id); - else - glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); } bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) @@ -245,28 +225,21 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) void GSTextureOGL::EnableUnit(uint unit) { - switch (m_type) { - case GSTexture::DepthStencil: - case GSTexture::Offscreen: - assert(0); - break; - case GSTexture::RenderTarget: - case GSTexture::Texture: - // FIXME - // Howto allocate the texture unit !!! - // In worst case the HW renderer seems to use 3 texture unit - // For the moment SW renderer only use 1 so don't bother - if (g_state_texture_unit != unit) { - g_state_texture_unit = unit; - glActiveTexture(GL_TEXTURE0 + unit); - // When you change the texture unit, texture must be rebinded - g_state_texture_id = m_texture_id; - glBindTexture(m_texture_target, m_texture_id); - } else if (g_state_texture_id != m_texture_id) { - g_state_texture_id = m_texture_id; - glBindTexture(m_texture_target, m_texture_id); - } - break; + if (!IsBackbuffer()) { + // FIXME + // Howto allocate the texture unit !!! + // In worst case the HW renderer seems to use 3 texture unit + // For the moment SW renderer only use 1 so don't bother + if (g_state_texture_unit != unit) { + g_state_texture_unit = unit; + glActiveTexture(GL_TEXTURE0 + unit); + // When you change the texture unit, texture must be rebinded + g_state_texture_id = m_texture_id; + glBindTexture(m_texture_target, m_texture_id); + } else if (g_state_texture_id != m_texture_id) { + g_state_texture_id = m_texture_id; + glBindTexture(m_texture_target, m_texture_id); + } } } @@ -303,13 +276,6 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) return false; #if 0 - if(r != NULL) - { - // ASSERT(0); // not implemented - - return false; - } - if(m_texture && m_desc.Usage == D3D11_USAGE_STAGING) { D3D11_MAPPED_SUBRESOURCE map; @@ -370,24 +336,20 @@ struct BITMAPINFOHEADER bool GSTextureOGL::Save(const string& fn, bool dds) { - // Code not yet working - if (IsDss()) return false; - // Collect the texture data uint32 pitch = 4 * m_size.x; if (IsDss()) pitch *= 2; char* image = (char*)malloc(pitch * m_size.y); if (IsBackbuffer()) { - // TODO backbuffer glReadBuffer(GL_BACK); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); } else if(IsDss()) { - Attach(GL_DEPTH_STENCIL_ATTACHMENT); - glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image); + EnableUnit(1); + glGetTexImage(m_texture_target, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image); } else { EnableUnit(0); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); + glGetTexImage(m_texture_target, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); } // Build a BMP file @@ -430,8 +392,11 @@ bool GSTextureOGL::Save(const string& fn, bool dds) uint8* better_data = data; for (int w = m_size.x; w > 0; w--, better_data += 8) { float* input = (float*)better_data; + // FIXME how to dump 32 bits value into 8bits component color uint32 depth = (uint32)ldexpf(*input, 32); - fwrite(&depth, 1, 4, fp); + uint8 small_depth = depth >> 24; + uint8 better_data[4] = {small_depth, small_depth, small_depth, 0 }; + fwrite(&better_data, 1, 4, fp); } } else { // swap red and blue @@ -443,7 +408,6 @@ bool GSTextureOGL::Save(const string& fn, bool dds) fwrite(better_data, 1, 4, fp); } } - // fwrite(data, 1, m_size.x << 2, fp); // TODO: swap red-blue? } fclose(fp); @@ -453,61 +417,5 @@ bool GSTextureOGL::Save(const string& fn, bool dds) } return false; -#if 0 - CComPtr res; - - if(m_desc.BindFlags & D3D11_BIND_DEPTH_STENCIL) - { - HRESULT hr; - - D3D11_TEXTURE2D_DESC desc; - - memset(&desc, 0, sizeof(desc)); - - m_texture->GetDesc(&desc); - - desc.Usage = D3D11_USAGE_STAGING; - desc.BindFlags = 0; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - - CComPtr src, dst; - - hr = m_dev->CreateTexture2D(&desc, NULL, &src); - - m_ctx->CopyResource(src, m_texture); - - desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - - hr = m_dev->CreateTexture2D(&desc, NULL, &dst); - - D3D11_MAPPED_SUBRESOURCE sm, dm; - - hr = m_ctx->Map(src, 0, D3D11_MAP_READ, 0, &sm); - hr = m_ctx->Map(dst, 0, D3D11_MAP_WRITE, 0, &dm); - - uint8* s = (uint8*)sm.pData; - uint8* d = (uint8*)dm.pData; - - for(uint32 y = 0; y < desc.Height; y++, s += sm.RowPitch, d += dm.RowPitch) - { - for(uint32 x = 0; x < desc.Width; x++) - { - ((uint32*)d)[x] = (uint32)(ldexpf(((float*)s)[x*2], 32)); - } - } - - m_ctx->Unmap(src, 0); - m_ctx->Unmap(dst, 0); - - res = dst; - } - else - { - res = m_texture; - } - - return SUCCEEDED(D3DX11SaveTextureToFile(m_ctx, res, dds ? D3DX11_IFF_DDS : D3DX11_IFF_BMP, fn.c_str())); -#endif } diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index fbf84f659d..8e8f63304a 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -87,6 +87,9 @@ void vs_main() vec4 p = vec4(i_p, z, 0) - vec4(0.05f, 0.05f, 0, 0); vec4 final_p = p * VertexScale - VertexOffset; + // FIXME + // FLIP vertically + final_p.y *= -1.0f; OUT.p = final_p; gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position @@ -132,7 +135,10 @@ out gl_PerVertex { float gl_ClipDistance[]; }; -layout(location = 0) in vertex GSin[]; +// FIXME +// AMD Driver bug again !!!! +//layout(location = 0) in vertex GSin[]; +in vertex GSin[]; layout(location = 0) out vertex GSout; @@ -188,46 +194,59 @@ void gs_main() #elif GS_PRIM == 3 layout(lines) in; -layout(triangle_strip, max_vertices = 4) out; +layout(triangle_strip, max_vertices = 6) out; void gs_main() { // left top => GSin[0]; // right bottom => GSin[1]; + vertex rb = GSin[1]; + vertex lt = GSin[0]; - - // left top - GSout = GSin[0]; - - GSout.p.z = GSin[1].p.z; - GSout.t.zw = GSin[1].t.zw; - gl_Position = GSout.p; // FIXME is it useful + lt.p.z = rb.p.z; + lt.t.zw = rb.t.zw; #if GS_IIP == 0 - GSout.c = GSin[1].c; + lt.c = rb.c; #endif + + vertex lb = rb; + lb.p.x = lt.p.x; + lb.t.x = lt.t.x; + + vertex rt = rb; + rt.p.y = lt.p.y; + rt.t.y = lt.t.y; + + // Triangle 1 + gl_Position = lt.p; + GSout = lt; EmitVertex(); - // left bottom - GSout = GSin[1]; - gl_Position = gl_in[1].gl_Position; // FIXME is it useful - gl_Position.x = GSin[0].p.x; - GSout.p.x = GSin[0].p.x; - GSout.t.x = GSin[0].t.x; + gl_Position = lb.p; + GSout = lb; EmitVertex(); - // rigth top - GSout = GSin[1]; - gl_Position = gl_in[1].gl_Position; // FIXME is it useful - gl_Position.y = GSin[0].p.y; - GSout.p.y = GSin[0].p.y; - GSout.t.y = GSin[0].t.y; + gl_Position = rt.p; + GSout = rt; EmitVertex(); - // rigth bottom - GSout = GSin[1]; - gl_Position = GSin[1].p; // FIXME is it useful + EndPrimitive(); + + // Triangle 2 + gl_Position = lb.p; + GSout = lb; EmitVertex(); + gl_Position = rt.p; + GSout = rt; + EmitVertex(); + + gl_Position = rb.p; + GSout = rb; + EmitVertex(); + + EndPrimitive(); + } #endif @@ -238,13 +257,8 @@ void gs_main() layout(location = 0) in vertex PSin; // Same buffer but 2 colors for dual source blending -//FIXME -#if 1 - layout(location = 0, index = 0) out vec4 SV_Target0; - layout(location = 0, index = 1) out vec4 SV_Target1; -#else - layout(location = 0) out vec4 SV_Target; -#endif +layout(location = 0, index = 0) out vec4 SV_Target0; +layout(location = 0, index = 1) out vec4 SV_Target1; layout(binding = 0) uniform sampler2D TextureSampler; layout(binding = 1) uniform sampler2D PaletteSampler; @@ -264,7 +278,10 @@ layout(std140, binding = 5) uniform cb1 vec4 sample_c(vec2 uv) { + // FIXME I'm not sure it is a good solution to flip texture return texture(TextureSampler, uv); + //FIXME another way to FLIP vertically + //return texture(TextureSampler, vec2(uv.x, 1.0f-uv.y) ); } vec4 sample_p(float u) @@ -598,7 +615,6 @@ vec4 ps_color() void ps_main() { //FIXME -#if 1 vec4 c = ps_color(); // FIXME: I'm not sure about the value of others field @@ -620,8 +636,5 @@ void ps_main() //SV_Target0 = vec4(1.0f,0.0f,0.0f, 1.0f); //SV_Target1 = vec4(0.0f,1.0f,0.0f, 1.0f); -#else - SV_Target = vec4(1.0f,0.0f,0.0f, 1.0f); -#endif } #endif From 9ca65c9cc681b5e358dfc2764805d3b9953836cc Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 30 Dec 2011 22:25:17 +0000 Subject: [PATCH 24/56] gsdx-ogl: LINUX-ONLY * invert the index of fragment output. Seem to work better on Nvidia (strangely no impact for AMD) * opengl support pitch too, so remove useless copy to an fbo git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5034 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 3 +- plugins/GSdx/GSDeviceOGL.cpp | 15 ++++----- plugins/GSdx/GSDeviceOGL.h | 6 ++++ plugins/GSdx/GSTextureOGL.cpp | 58 +++++++++-------------------------- plugins/GSdx/GSTextureOGL.h | 1 - plugins/GSdx/res/tfx.glsl | 4 +-- 6 files changed, 33 insertions(+), 54 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index c524ccf8c5..98ac7ec165 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -18,6 +18,7 @@ set(CommonFlags -Wunused-variable -std=c++0x -fno-strict-aliasing + -DOGL_DEBUG ) set(OptimizationFlags @@ -28,7 +29,7 @@ set(OptimizationFlags # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) # add defines - add_definitions(${CommonFlags} -g -Wall) + add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 19c9d76e44..bb766c7a5f 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -54,8 +54,8 @@ //#define LOUD_DEBUGGING #define SHADER_DEBUG -//#define DUMP_START (500) -//#define DUMP_LENGTH (40) +//#define DUMP_START (13000) +//#define DUMP_LENGTH (200) //#define DUMP_ONLY_FRAME (112) #ifdef DUMP_START @@ -219,9 +219,9 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glGenFramebuffers(1, &m_fbo); // Setup FBO fragment output - OMSetFBO(m_fbo); - glDrawBuffer(GL_COLOR_ATTACHMENT0); - OMSetFBO(0); + // OMSetFBO(m_fbo); + // glDrawBuffer(GL_COLOR_ATTACHMENT0); + // OMSetFBO(0); // **************************************************************** // Vertex buffer state @@ -706,12 +706,11 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) // GL_NV_copy_image seem like the good extension but not supported on AMD... // Maybe opengl 4.3 ! // FIXME check those function work as expected - + // FIXME FBO GLuint fbo_old = m_state.fbo; OMSetFBO(m_fbo); - // Set the input of glCopyTexSubImage2D static_cast(st)->Attach(GL_COLOR_ATTACHMENT1); glReadBuffer(GL_COLOR_ATTACHMENT1); @@ -1012,6 +1011,8 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count) } vb->upload(vertices, map_flags); + // FIXME: disable it when code is working + CheckDebugLog(); } void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 98ce44d7f2..016353a8b9 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -171,6 +171,12 @@ struct GSVertexBufferState { void upload(const void* src, uint32 flags) { uint8* dst = (uint8*) glMapBufferRange(GL_ARRAY_BUFFER, stride*start, stride*count, flags); +#ifdef OGL_DEBUG + if (dst == NULL) { + fprintf(stderr, "CRITICAL ERROR map failed for vb !!!\n"); + return; + } +#endif memcpy(dst, src, stride*count); glUnmapBuffer(GL_ARRAY_BUFFER); } diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 094f5a9021..39c42a25ec 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -26,8 +26,7 @@ static uint g_state_texture_unit = 0; static uint g_state_texture_id = 0; GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) - : m_texture_unit(0), - m_extra_buffer_id(0), + : m_extra_buffer_id(0), m_pbo_size(0) { // ************************************************************* @@ -120,7 +119,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) switch (m_type) { case GSTexture::DepthStencil: EnableUnit(1); - glTexImage2D(m_texture_target, 0, m_format, w, h, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); + glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); break; case GSTexture::RenderTarget: case GSTexture::Texture: @@ -130,7 +129,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // For the moment SW renderer only use 1 so don't bother EnableUnit(0); if (m_format == GL_RGBA8) { - glTexImage2D(m_texture_target, 0, m_format, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); } else assert(0); // TODO Later @@ -161,54 +160,27 @@ void GSTextureOGL::Attach(GLenum attachment) bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) { - // static int update_count = 0; - // update_count++; - // To update only a part of the texture you can use: - // glTexSubImage2D — specify a two-dimensional texture subimage if (m_type == GSTexture::DepthStencil || m_type == GSTexture::Offscreen) assert(0); - // glTexSubImage2D specifies a two-dimensional subtexture for the current texture unit, specified with glActiveTexture. - // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target - //(see glBindBuffer) while a texture image is - // specified, data is treated as a byte offset into the buffer object's data store // FIXME warning order of the y axis // FIXME I'm not confident with GL_UNSIGNED_BYTE type - // FIXME add a state check EnableUnit(0); - if (m_format != GL_RGBA8) assert(0); - - // FIXME. That suck but I don't know how to do better for now. I think we need to create a texture buffer and directly upload the copy - // The case appears on SW mode. Src pitch is 2x dst pitch. - int rowbytes = r.width() << 2; - if (pitch != rowbytes) { - uint32 map_flags = GL_MAP_WRITE_BIT; - - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_extra_buffer_id); - if (!m_pbo_size) { - m_pbo_size = m_size.x * m_size.y * 4; - glBufferData(GL_PIXEL_UNPACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); - } else { - GL_MAP_INVALIDATE_BUFFER_BIT; - } - - uint8* src = (uint8*) data; - uint8* dst = (uint8*) glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_pbo_size, map_flags); - for(int h = r.height(); h > 0; h--, src += pitch, dst += rowbytes) - { - memcpy(dst, src, rowbytes); - } - glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); - - glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, 0 /* offset in UNPACK BUFFER */); - - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - - } else { - glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); + if (m_format != GL_RGBA8) { + fprintf(stderr, "wrong pixel format\n"); + assert(0); } + // pitch could be different of width*element_size + glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>2); + // FIXME : it crash on colin mcrae rally 3 (others game too) when the size is 16 + //if (m_size.x != 16) + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior + + return true; #if 0 if(m_dev && m_texture) { diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index b2a3b52c37..9138ff4ec4 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -28,7 +28,6 @@ class GSTextureOGL : public GSTexture private: GLenum m_texture_target; // texture target: 2D, rectangle etc... GLuint m_texture_id; // the texture id - uint m_texture_unit; // the texture unit offset uint m_extra_buffer_id; int m_pbo_size; diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 8e8f63304a..4ac5f22848 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -257,8 +257,8 @@ void gs_main() layout(location = 0) in vertex PSin; // Same buffer but 2 colors for dual source blending -layout(location = 0, index = 0) out vec4 SV_Target0; -layout(location = 0, index = 1) out vec4 SV_Target1; +layout(location = 0, index = 1) out vec4 SV_Target0; +layout(location = 0, index = 0) out vec4 SV_Target1; layout(binding = 0) uniform sampler2D TextureSampler; layout(binding = 1) uniform sampler2D PaletteSampler; From 2f4e2d8b6b3e11fe03b2257d660a948800dc7537 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 31 Dec 2011 14:38:58 +0000 Subject: [PATCH 25/56] GSdx-ogl: happy new years commit :) * move all vertex buffer stuff into the class * Bypass FIFO2 because of multithread issue with OGL(temporary workaround until we found a nicer solutions) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5035 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GS.cpp | 17 +++++ plugins/GSdx/GSDeviceOGL.cpp | 39 ++--------- plugins/GSdx/GSDeviceOGL.h | 113 +++++++++++++++++++++----------- plugins/GSdx/GSTextureFXOGL.cpp | 4 +- plugins/GSdx/GSTextureOGL.cpp | 14 +++- 5 files changed, 111 insertions(+), 76 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 6daa508c07..7badb94b87 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -396,11 +396,28 @@ EXPORT_C GSwriteCSR(uint32 csr) EXPORT_C GSreadFIFO(uint8* mem) { +#ifdef _LINUX + // FIXME: double check which thread call this function + // See fifo2 issue below + if (theApp.GetConfig("renderer", 0) == 12) { + fprintf(stderr, "Disable FIFO1 on opengl\n"); + } +#endif s_gs->ReadFIFO(mem, 1); } EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) { +#ifdef _LINUX + // FIXME called from EE core thread not MTGS which cause + // invalidate data for opengl + if (theApp.GetConfig("renderer", 0) == 12) { +#ifdef OGL_DEBUG + fprintf(stderr, "Disable FIFO2 on opengl\n"); +#endif + return; + } +#endif s_gs->ReadFIFO(mem, size); } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index bb766c7a5f..a9d794bc56 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -226,12 +226,12 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** // Vertex buffer state // **************************************************************** - GSInputLayout il_convert[2] = + GSInputLayoutOGL il_convert[2] = { {0, 4, GL_FLOAT, GL_FALSE, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, p) }, {1, 2, GL_FLOAT, GL_FALSE, sizeof(GSVertexPT1), (const GLvoid*)offsetof(struct GSVertexPT1, t) }, }; - m_vb_sr = new GSVertexBufferState(sizeof(GSVertexPT1), il_convert, countof(il_convert)); + m_vb_sr = new GSVertexBufferStateOGL(sizeof(GSVertexPT1), il_convert, countof(il_convert)); // **************************************************************** // convert @@ -546,7 +546,7 @@ void GSDeviceOGL::DrawPrimitive() } #endif - glDrawArrays(m_state.topology, m_state.vb_state->start, m_state.vb_state->count); + m_state.vb_state->draw_arrays(m_state.topology); // DUMP OUTPUT #ifdef DUMP_START @@ -964,8 +964,7 @@ GSTexture* GSDeviceOGL::Resolve(GSTexture* t) void GSDeviceOGL::EndScene() { - m_state.vb_state->start += m_state.vb_state->count; - m_state.vb_state->count = 0; + m_state.vb_state->draw_done(); } void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) @@ -976,7 +975,7 @@ void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) } } -void GSDeviceOGL::IASetVertexState(GSVertexBufferState* vb_state) +void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb_state) { if (m_state.vb_state != vb_state) { m_state.vb_state = vb_state; @@ -986,33 +985,7 @@ void GSDeviceOGL::IASetVertexState(GSVertexBufferState* vb_state) void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count) { - // Note: For an explanation of the map flag - // see http://www.opengl.org/wiki/Buffer_Object_Streaming - uint32 map_flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; - - GSVertexBufferState* vb = m_state.vb_state; - vb->count = count; - - // Current GPU buffer is really too small need to realocate a new one - if (count > vb->limit) { - vb->allocate(std::max(count * 3 / 2, 60000)); - - } else if (count > (vb->limit - vb->start) ) { - // Not enough left free room. Just go back at the beginning - vb->start = 0; - - // Tell the driver that it can orphan previous buffer and restart from a scratch buffer. - // Technically the buffer will not be accessible by the application anymore but the - // GL will effectively remove it when draws call are finised. - map_flags |= GL_MAP_INVALIDATE_BUFFER_BIT; - } else { - // Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map - map_flags |= GL_MAP_INVALIDATE_RANGE_BIT; - } - - vb->upload(vertices, map_flags); - // FIXME: disable it when code is working - CheckDebugLog(); + m_state.vb_state->upload(vertices, count); } void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 016353a8b9..9100d1c5d5 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -128,7 +128,7 @@ public: } }; -struct GSInputLayout { +struct GSInputLayoutOGL { GLuint index; GLint size; GLenum type; @@ -137,51 +137,73 @@ struct GSInputLayout { const GLvoid* offset; }; -struct GSVertexBufferState { - size_t stride; - size_t start; - size_t count; - size_t limit; - GLuint vb; - GLuint va; - - GSVertexBufferState(size_t stride, GSInputLayout* layout, uint32 layout_nbr) : stride(stride) - , count(0) - { - glGenBuffers(1, &vb); - glGenVertexArrays(1, &va); - bind(); - allocate(60000); // Opengl works best with 1-4MB buffer. 60k element seems a good value. - set_internal_format(layout, layout_nbr); - } +class GSVertexBufferStateOGL { + size_t m_stride; + size_t m_start; + size_t m_count; + size_t m_limit; + GLuint m_vb; + GLuint m_va; + const GLenum m_target; void allocate(size_t new_limit) { - start = 0; - limit = new_limit; - glBufferData(GL_ARRAY_BUFFER, limit * stride, NULL, GL_STREAM_DRAW); + m_start = 0; + m_limit = new_limit; + glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW); + } + +public: + GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr) + : m_stride(stride) + , m_count(0) + , m_target(GL_ARRAY_BUFFER) + { + glGenBuffers(1, &m_vb); + glGenVertexArrays(1, &m_va); + bind(); + allocate(60000); // Opengl works best with 1-4MB buffer. 60k element seems a good value. Note stride is 32 + set_internal_format(layout, layout_nbr); } void bind() { - glBindVertexArray(va); - glBindBuffer(GL_ARRAY_BUFFER, vb); + glBindVertexArray(m_va); + glBindBuffer(m_target, m_vb); } - void upload(const void* src, uint32 flags) + void upload(const void* src, uint32 count) { - uint8* dst = (uint8*) glMapBufferRange(GL_ARRAY_BUFFER, stride*start, stride*count, flags); -#ifdef OGL_DEBUG - if (dst == NULL) { - fprintf(stderr, "CRITICAL ERROR map failed for vb !!!\n"); - return; + m_count = count; + + // Note: For an explanation of the map flag + // see http://www.opengl.org/wiki/Buffer_Object_Streaming + uint32 map_flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; + + // Current GPU buffer is really too small need to allocate a new one + if (m_count > m_limit) { + allocate(std::max(count * 3 / 2, 60000)); + + } else if (m_count > (m_limit - m_start) ) { + // Not enough left free room. Just go back at the beginning + m_start = 0; + + // Tell the driver that it can orphan previous buffer and restart from a scratch buffer. + // Technically the buffer will not be accessible by the application anymore but the + // GL will effectively remove it when draws call are finised. + map_flags |= GL_MAP_INVALIDATE_BUFFER_BIT; + } else { + // Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map + map_flags |= GL_MAP_INVALIDATE_RANGE_BIT; } -#endif - memcpy(dst, src, stride*count); - glUnmapBuffer(GL_ARRAY_BUFFER); + + // Upload the data to the buffer + uint8* dst = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); + memcpy(dst, src, m_stride*m_count); + glUnmapBuffer(m_target); } - void set_internal_format(GSInputLayout* layout, uint32 layout_nbr) + void set_internal_format(GSInputLayoutOGL* layout, uint32 layout_nbr) { for (int i = 0; i < layout_nbr; i++) { // Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer @@ -199,10 +221,21 @@ struct GSVertexBufferState { } } - ~GSVertexBufferState() + void draw_arrays(GLenum topology) { - glDeleteBuffers(1, &vb); - glDeleteVertexArrays(1, &va); + glDrawArrays(topology, m_start, m_count); + } + + void draw_done() + { + m_start += m_count; + m_count = 0; + } + + ~GSVertexBufferStateOGL() + { + glDeleteBuffers(1, &m_vb); + glDeleteVertexArrays(1, &m_va); } }; @@ -451,8 +484,8 @@ class GSDeviceOGL : public GSDevice GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container - GSVertexBufferState* m_vb; // vb_state for HW renderer - GSVertexBufferState* m_vb_sr; // vb_state for StretchRect + GSVertexBufferStateOGL* m_vb; // vb_state for HW renderer + GSVertexBufferStateOGL* m_vb_sr; // vb_state for StretchRect struct { GLuint ps[2]; // program object @@ -488,7 +521,7 @@ class GSDeviceOGL : public GSDevice struct { - GSVertexBufferState* vb_state; + GSVertexBufferStateOGL* vb_state; GLenum topology; // (ie GL_TRIANGLES...) GLuint vs; // program GSUniformBufferOGL* cb; // uniform current buffer @@ -604,7 +637,7 @@ class GSDeviceOGL : public GSDevice void IASetPrimitiveTopology(GLenum topology); void IASetVertexBuffer(const void* vertices, size_t count); - void IASetVertexState(GSVertexBufferState* vb_state); + void IASetVertexState(GSVertexBufferStateOGL* vb_state); void SetUniformBuffer(GSUniformBufferOGL* cb); diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 9560cb5b96..f3f37466d6 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -61,7 +61,7 @@ void GSDeviceOGL::CreateTextureFX() //float4 c : COLOR0; //float4 f : COLOR1; - GSInputLayout vert_format[6] = + GSInputLayoutOGL vert_format[6] = { // FIXME {0 , 2 , GL_FLOAT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(0) } , @@ -72,7 +72,7 @@ void GSDeviceOGL::CreateTextureFX() // note: there is a 32 bits pad {5 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertexHW11) , (const GLvoid*)(28) } , }; - m_vb = new GSVertexBufferState(sizeof(GSVertexHW11), vert_format, countof(vert_format)); + m_vb = new GSVertexBufferStateOGL(sizeof(GSVertexHW11), vert_format, countof(vert_format)); } void GSDeviceOGL::SetupIA(const void* vertices, int count, GLenum prim) diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 39c42a25ec..b4d1f38402 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -175,8 +175,20 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // pitch could be different of width*element_size glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>2); // FIXME : it crash on colin mcrae rally 3 (others game too) when the size is 16 - //if (m_size.x != 16) + //fprintf(stderr, "Texture %dx%d with a pitch of %d\n", m_size.x, m_size.y, pitch >>2); + //fprintf(stderr, "Box (%d,%d)x(%d,%d)\n", r.x, r.y, r.width(), r.height()); + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); +#if 0 + //if (m_size.x != 16) + if (r.width() > 16 && r.height() > 16) + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); + else { + fprintf(stderr, "skip texture upload\n"); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior + return false; + } +#endif glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior From c1d7b81a558e9eb3d3dacaedc556c5c75e9e3ec8 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Mon, 2 Jan 2012 20:08:11 +0000 Subject: [PATCH 26/56] gsdx-ogl: * Use a geometry shader pass-through to replace previous AMD workaround * various cosmetic change git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5038 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 1 + plugins/GSdx/GSDeviceOGL.cpp | 34 ++++---- plugins/GSdx/GSDeviceOGL.h | 13 +++ plugins/GSdx/GSTextureFXOGL.cpp | 7 +- plugins/GSdx/GSTextureOGL.cpp | 135 ++++++++++++++++---------------- plugins/GSdx/GSTextureOGL.h | 1 + plugins/GSdx/res/convert.glsl | 57 +++++++++++--- plugins/GSdx/res/interlace.glsl | 25 +++--- plugins/GSdx/res/merge.glsl | 13 ++- plugins/GSdx/res/tfx.glsl | 25 +++--- 10 files changed, 188 insertions(+), 123 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 98ac7ec165..b9690455c0 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -19,6 +19,7 @@ set(CommonFlags -std=c++0x -fno-strict-aliasing -DOGL_DEBUG + -DAMD_DRIVER_WORKAROUND ) set(OptimizationFlags diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index a9d794bc56..f4d2b731e7 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -54,8 +54,8 @@ //#define LOUD_DEBUGGING #define SHADER_DEBUG -//#define DUMP_START (13000) -//#define DUMP_LENGTH (200) +//#define DUMP_START (70) +//#define DUMP_LENGTH (130) //#define DUMP_ONLY_FRAME (112) #ifdef DUMP_START @@ -237,6 +237,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // convert // **************************************************************** CompileShaderFromSource("convert.glsl", "vs_main", GL_VERTEX_SHADER, &m_convert.vs); + CompileShaderFromSource("convert.glsl", "gs_main", GL_GEOMETRY_SHADER, &m_convert.gs); for(int i = 0; i < countof(m_convert.ps); i++) CompileShaderFromSource("convert.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_convert.ps[i]); @@ -540,9 +541,11 @@ void GSDeviceOGL::DrawPrimitive() case GL_POINTS: topo = "point"; break; default: topo = "!!!!"; } - fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, m_state.vb_state->count, topo.c_str() ); + fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, /*m_state.vb_state->count*/ 0, topo.c_str() ); fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); fprintf(stderr, "Blend: %d, Depth: %d, Stencil: %d \n",m_state.bs->m_enable, m_state.dss->m_depth_enable, m_state.dss->m_stencil_enable); + m_state.bs->debug(); + m_state.dss->debug_depth(); } #endif @@ -560,19 +563,6 @@ void GSDeviceOGL::DrawPrimitive() g_draw_count++; #endif - - - // FIXME AMD driver bug workaround - // You cannot unattach shader. So destroy everythings and recreate the shader pipeline... - // Slow and painful... - glBindProgramPipeline(0); - glDeleteProgramPipelines(1, &m_pipeline); - m_state.gs = 0; - m_state.ps = 0; - m_state.vs = 0; - - glGenProgramPipelines(1, &m_pipeline); - glBindProgramPipeline(m_pipeline); } void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) @@ -822,7 +812,11 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, // gs // ************************************ +#ifdef AMD_DRIVER_WORKAROUND + GSSetShader(m_convert.gs); +#else GSSetShader(0); +#endif // ************************************ // ps @@ -914,7 +908,12 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver // gs +#ifdef AMD_DRIVER_WORKAROUND + GSSetShader(m_convert.gs); +#else GSSetShader(0); +#endif + // ps @@ -1044,7 +1043,6 @@ void GSDeviceOGL::PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2) void GSDeviceOGL::PSSetShader(GLuint ps) { - if(m_state.ps != ps) { m_state.ps = ps; @@ -1279,8 +1277,8 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), *program); fprintf(stderr, "\n%s", macro_sel.c_str()); fprintf(stderr, "%s\n", log); -#endif free(log); +#endif } void GSDeviceOGL::CheckDebugLog() diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 9100d1c5d5..dcc3de9a85 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -54,6 +54,13 @@ struct GSBlendStateOGL { , m_a_msk(GL_TRUE) {} + void debug() + { + if (!m_enable) return; + fprintf(stderr,"Blend RGB: %x src:%x dst:%x\n", m_equation_RGB, m_func_sRGB, m_func_dRGB); + fprintf(stderr,"Blend ALPHA: %x src:%x dst:%x\n", m_equation_ALPHA, m_func_sALPHA, m_func_dALPHA); + fprintf(stderr,"Mask. R:%d B:%d G:%d A:%d\n", m_r_msk, m_b_msk, m_g_msk, m_a_msk); + } }; struct GSDepthStencilOGL { @@ -81,6 +88,11 @@ struct GSDepthStencilOGL { , m_stencil_spass_dpass_op(GL_KEEP) {} + void debug_depth() + { + if (!m_depth_enable) return; + fprintf(stderr, "Depth %x, %x\n", m_depth_func, m_depth_mask); + } }; class GSUniformBufferOGL { @@ -503,6 +515,7 @@ class GSDeviceOGL : public GSDevice GLuint ps[8]; // program object GLuint ln; // sampler object GLuint pt; // sampler object + GLuint gs; GSDepthStencilOGL* dss; GSBlendStateOGL* bs; } m_convert; diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index f3f37466d6..642cef238a 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -120,7 +120,12 @@ void GSDeviceOGL::SetupGS(GSSelector sel) // Static // ************************************************************* GLuint gs = 0; - if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) { +#ifdef AMD_DRIVER_WORKAROUND + if (true) +#else + if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) +#endif + { auto i = m_gs.find(sel); if(i == m_gs.end()) { diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index b4d1f38402..269da857b6 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -22,8 +22,8 @@ #pragma once #include "GSTextureOGL.h" -static uint g_state_texture_unit = 0; -static uint g_state_texture_id = 0; +static int g_state_texture_unit = -1; +static int g_state_texture_id = -1; GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) : m_extra_buffer_id(0), @@ -317,6 +317,68 @@ struct BITMAPINFOHEADER #pragma pack(pop) #endif +void GSTextureOGL::Save(const string& fn, const void* image, uint32 pitch) +{ + // Build a BMP file + FILE* fp = fopen(fn.c_str(), "wb"); + + BITMAPINFOHEADER bih; + + memset(&bih, 0, sizeof(bih)); + + bih.biSize = sizeof(bih); + bih.biWidth = m_size.x; + bih.biHeight = m_size.y; + bih.biPlanes = 1; + bih.biBitCount = 32; + bih.biCompression = BI_RGB; + bih.biSizeImage = m_size.x * m_size.y << 2; + + BITMAPFILEHEADER bfh; + + memset(&bfh, 0, sizeof(bfh)); + + uint8* bfType = (uint8*)&bfh.bfType; + + // bfh.bfType = 'MB'; + bfType[0] = 0x42; + bfType[1] = 0x4d; + bfh.bfOffBits = sizeof(bfh) + sizeof(bih); + bfh.bfSize = bfh.bfOffBits + bih.biSizeImage; + bfh.bfReserved1 = bfh.bfReserved2 = 0; + + fwrite(&bfh, 1, sizeof(bfh), fp); + fwrite(&bih, 1, sizeof(bih), fp); + + uint8* data = (uint8*)image + (m_size.y - 1) * pitch; + + for(int h = m_size.y; h > 0; h--, data -= pitch) + { + if (IsDss()) { + // Only get the depth and convert it to an integer + uint8* better_data = data; + for (int w = m_size.x; w > 0; w--, better_data += 8) { + float* input = (float*)better_data; + // FIXME how to dump 32 bits value into 8bits component color + uint32 depth = (uint32)ldexpf(*input, 32); + uint8 small_depth = depth >> 24; + uint8 better_data[4] = {small_depth, small_depth, small_depth, 0 }; + fwrite(&better_data, 1, 4, fp); + } + } else { + // swap red and blue + uint8* better_data = data; + for (int w = m_size.x; w > 0; w--, better_data += 4) { + uint8 red = better_data[2]; + better_data[2] = better_data[0]; + better_data[0] = red; + fwrite(better_data, 1, 4, fp); + } + } + } + + fclose(fp); +} bool GSTextureOGL::Save(const string& fn, bool dds) { @@ -325,6 +387,8 @@ bool GSTextureOGL::Save(const string& fn, bool dds) if (IsDss()) pitch *= 2; char* image = (char*)malloc(pitch * m_size.y); + // FIXME instead of swapping manually B and R maybe you can request the driver to do it + // for us if (IsBackbuffer()) { glReadBuffer(GL_BACK); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); @@ -336,70 +400,9 @@ bool GSTextureOGL::Save(const string& fn, bool dds) glGetTexImage(m_texture_target, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); } - // Build a BMP file - if(FILE* fp = fopen(fn.c_str(), "wb")) - { - BITMAPINFOHEADER bih; + Save(fn, image, pitch); + free(image); - memset(&bih, 0, sizeof(bih)); - - bih.biSize = sizeof(bih); - bih.biWidth = m_size.x; - bih.biHeight = m_size.y; - bih.biPlanes = 1; - bih.biBitCount = 32; - bih.biCompression = BI_RGB; - bih.biSizeImage = m_size.x * m_size.y << 2; - - BITMAPFILEHEADER bfh; - - memset(&bfh, 0, sizeof(bfh)); - - uint8* bfType = (uint8*)&bfh.bfType; - - // bfh.bfType = 'MB'; - bfType[0] = 0x42; - bfType[1] = 0x4d; - bfh.bfOffBits = sizeof(bfh) + sizeof(bih); - bfh.bfSize = bfh.bfOffBits + bih.biSizeImage; - bfh.bfReserved1 = bfh.bfReserved2 = 0; - - fwrite(&bfh, 1, sizeof(bfh), fp); - fwrite(&bih, 1, sizeof(bih), fp); - - uint8* data = (uint8*)image + (m_size.y - 1) * pitch; - - for(int h = m_size.y; h > 0; h--, data -= pitch) - { - if (IsDss()) { - // Only get the depth and convert it to an integer - uint8* better_data = data; - for (int w = m_size.x; w > 0; w--, better_data += 8) { - float* input = (float*)better_data; - // FIXME how to dump 32 bits value into 8bits component color - uint32 depth = (uint32)ldexpf(*input, 32); - uint8 small_depth = depth >> 24; - uint8 better_data[4] = {small_depth, small_depth, small_depth, 0 }; - fwrite(&better_data, 1, 4, fp); - } - } else { - // swap red and blue - uint8* better_data = data; - for (int w = m_size.x; w > 0; w--, better_data += 4) { - uint8 red = better_data[2]; - better_data[2] = better_data[0]; - better_data[0] = red; - fwrite(better_data, 1, 4, fp); - } - } - } - - fclose(fp); - - free(image); - return true; - } - - return false; + return true; } diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 9138ff4ec4..92c9010928 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -39,6 +39,7 @@ class GSTextureOGL : public GSTexture bool Map(GSMap& m, const GSVector4i* r = NULL); void Unmap(); bool Save(const string& fn, bool dds = false); + void Save(const string& fn, const void* image, uint32 pitch); void EnableUnit(uint unit); void Attach(GLenum attachment); diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index d2c9f3fb0f..2887215d72 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -1,5 +1,12 @@ //#version 420 // Keep it for editor detection +struct vertex_basic +{ + vec4 p; + vec2 t; +}; + + #ifdef VERTEX_SHADER out gl_PerVertex { @@ -19,24 +26,54 @@ layout(location = 1) in vec2 TEXCOORD0; // smooth, the default, means to do perspective-correct interpolation. // // The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area. -// FIXME gl_Position -layout(location = 0) out vec4 POSITION_OUT; -layout(location = 1) out vec2 TEXCOORD0_OUT; +layout(location = 0) out vertex_basic VSout; void vs_main() { - POSITION_OUT = POSITION; - TEXCOORD0_OUT = TEXCOORD0; + VSout.p = POSITION; + VSout.t = TEXCOORD0; gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position } #endif +#ifdef GEOMETRY_SHADER +in gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +} gl_in[]; + +out gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + +// FIXME +// AMD Driver bug again !!!! +//layout(location = 0) in vertex GSin[]; +in vertex_basic GSin[]; + +layout(location = 0) out vertex_basic GSout; +layout(triangles) in; +layout(triangle_strip, max_vertices = 3) out; + +void gs_main() +{ + for(int i = 0; i < gl_in.length(); i++) { + gl_Position = gl_in[i].gl_Position; + GSout = GSin[i]; + EmitVertex(); + } + EndPrimitive(); +} +#endif + #ifdef FRAGMENT_SHADER // NOTE: pixel can be clip with "discard" -layout(location = 0) in vec4 SV_Position; -layout(location = 1) in vec2 TEXCOORD0; +layout(location = 0) in vertex_basic PSin; layout(location = 0) out vec4 SV_Target0; layout(location = 1) out uint SV_Target1; @@ -45,7 +82,7 @@ layout(binding = 0) uniform sampler2D TextureSampler; vec4 sample_c() { - return texture(TextureSampler, vec2(TEXCOORD0.x,TEXCOORD0.y) ); + return texture(TextureSampler, PSin.t ); } vec4 ps_crt(uint i) @@ -88,7 +125,7 @@ void ps_main7() void ps_main5() // triangular { - highp uvec4 p = uvec4(SV_Position); + highp uvec4 p = uvec4(PSin.p); vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) % 3u); @@ -97,7 +134,7 @@ void ps_main5() // triangular void ps_main6() // diagonal { - uvec4 p = uvec4(SV_Position); + uvec4 p = uvec4(PSin.p); vec4 c = ps_crt((p.x + (p.y % 3)) % 3); diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index 2792ea60a6..97e567fa1b 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -1,8 +1,13 @@ //#version 420 // Keep it for editor detection +struct vertex_basic +{ + vec4 p; + vec2 t; +}; + #ifdef FRAGMENT_SHADER -layout(location = 0) in vec4 SV_Position; -layout(location = 1) in vec2 TEXCOORD0; +layout(location = 0) in vertex_basic PSin; layout(location = 0) out vec4 SV_Target0; @@ -19,8 +24,8 @@ void ps_main0() { // I'm not sure it impact us but be safe to lookup texture before conditional if // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control - vec4 c = texture(TextureSampler, TEXCOORD0); - if (fract(TEXCOORD0.y * hH) - 0.5 < 0.0) + vec4 c = texture(TextureSampler, PSin.t); + if (fract(PSin.t.y * hH) - 0.5 < 0.0) discard; SV_Target0 = c; @@ -30,8 +35,8 @@ void ps_main1() { // I'm not sure it impact us but be safe to lookup texture before conditional if // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control - vec4 c = texture(TextureSampler, TEXCOORD0); - if (0.5 - fract(TEXCOORD0.y * hH) < 0.0) + vec4 c = texture(TextureSampler, PSin.t); + if (0.5 - fract(PSin.t.y * hH) < 0.0) discard; SV_Target0 = c; @@ -39,16 +44,16 @@ void ps_main1() void ps_main2() { - vec4 c0 = texture(TextureSampler, TEXCOORD0 - ZrH); - vec4 c1 = texture(TextureSampler, TEXCOORD0); - vec4 c2 = texture(TextureSampler, TEXCOORD0 + ZrH); + vec4 c0 = texture(TextureSampler, PSin.t - ZrH); + vec4 c1 = texture(TextureSampler, PSin.t); + vec4 c2 = texture(TextureSampler, PSin.t + ZrH); SV_Target0 = (c0 + c1 * 2 + c2) / 4; } void ps_main3() { - SV_Target0 = texture(TextureSampler, TEXCOORD0); + SV_Target0 = texture(TextureSampler, PSin.t); } #endif diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index 2e438d4055..e9a93bdc88 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -1,8 +1,13 @@ //#version 420 // Keep it for editor detection +struct vertex_basic +{ + vec4 p; + vec2 t; +}; + #ifdef FRAGMENT_SHADER -layout(location = 0) in vec4 SV_Position; -layout(location = 1) in vec2 TEXCOORD0; +layout(location = 0) in vertex_basic PSin; layout(location = 0) out vec4 SV_Target0; @@ -15,14 +20,14 @@ layout(binding = 0) uniform sampler2D TextureSampler; void ps_main0() { - vec4 c = texture(TextureSampler, TEXCOORD0); + vec4 c = texture(TextureSampler, PSin.t); c.a = min(c.a * 2, 1.0); SV_Target0 = c; } void ps_main1() { - vec4 c = texture(TextureSampler, TEXCOORD0); + vec4 c = texture(TextureSampler, PSin.t); c.a = BGColor.a; SV_Target0 = c; } diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 4ac5f22848..0737c5e56e 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -55,7 +55,7 @@ layout(location = 3) in uvec2 i_p; layout(location = 4) in uint i_z; layout(location = 5) in vec4 i_f; -layout(location = 0) out vertex OUT; +layout(location = 0) out vertex VSout; out gl_PerVertex { vec4 gl_Position; @@ -91,33 +91,33 @@ void vs_main() // FLIP vertically final_p.y *= -1.0f; - OUT.p = final_p; + VSout.p = final_p; gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position #if VS_RTCOPY - OUT.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5; + VSout.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5; #endif if(VS_TME != 0) { if(VS_FST != 0) { - OUT.t.xy = i_t * TextureScale; - OUT.t.w = 1.0f; + VSout.t.xy = i_t * TextureScale; + VSout.t.w = 1.0f; } else { - OUT.t.xy = i_t; - OUT.t.w = i_q; + VSout.t.xy = i_t; + VSout.t.w = i_q; } } else { - OUT.t.xy = vec2(0.0f, 0.0f); - OUT.t.w = 1.0f; + VSout.t.xy = vec2(0.0f, 0.0f); + VSout.t.w = 1.0f; } - OUT.c = i_c; - OUT.t.z = i_f.a; + VSout.c = i_c; + VSout.t.z = i_f.a; } #endif @@ -633,8 +633,5 @@ void ps_main() } SV_Target1 = c; - - //SV_Target0 = vec4(1.0f,0.0f,0.0f, 1.0f); - //SV_Target1 = vec4(0.0f,1.0f,0.0f, 1.0f); } #endif From 90c52c27f66e65d13aeb42cb8c81c5b6cb306a41 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Tue, 3 Jan 2012 13:11:40 +0000 Subject: [PATCH 27/56] gsdx-ogl: * replace hexa debug value with nice string for standard human * move things around git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5039 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 63 ++++----------- plugins/GSdx/GSDeviceOGL.h | 138 ++++++++++++++++++++++++++++++-- plugins/GSdx/GSTextureFXOGL.cpp | 39 +++------ 3 files changed, 161 insertions(+), 79 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index f4d2b731e7..b3537619c8 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -54,8 +54,8 @@ //#define LOUD_DEBUGGING #define SHADER_DEBUG -//#define DUMP_START (70) -//#define DUMP_LENGTH (130) +#define DUMP_START (70) +#define DUMP_LENGTH (130) //#define DUMP_ONLY_FRAME (112) #ifdef DUMP_START @@ -302,13 +302,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd) CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge.ps[i]); m_merge.bs = new GSBlendStateOGL(); - m_merge.bs->m_enable = true; - m_merge.bs->m_equation_RGB = GL_FUNC_ADD; - m_merge.bs->m_equation_ALPHA = GL_FUNC_ADD; - m_merge.bs->m_func_sRGB = GL_SRC_ALPHA; - m_merge.bs->m_func_dRGB = GL_ONE_MINUS_SRC_ALPHA; - m_merge.bs->m_func_sALPHA = GL_ONE; - m_merge.bs->m_func_dALPHA = GL_ZERO; + m_merge.bs->EnableBlend(); + m_merge.bs->SetRGB(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // **************************************************************** // interlace @@ -352,9 +347,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** m_date.dss = new GSDepthStencilOGL(); - m_date.dss->m_stencil_enable = true; - m_date.dss->m_stencil_func = GL_ALWAYS; - m_date.dss->m_stencil_spass_dpass_op = GL_REPLACE; + m_date.dss->EnableStencil(); + m_date.dss->SetStencil(GL_ALWAYS, GL_REPLACE); //memset(&dsd, 0, sizeof(dsd)); //dsd.DepthEnable = false; @@ -541,11 +535,10 @@ void GSDeviceOGL::DrawPrimitive() case GL_POINTS: topo = "point"; break; default: topo = "!!!!"; } - fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, /*m_state.vb_state->count*/ 0, topo.c_str() ); + fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, m_state.vb_state->get_count(), topo.c_str() ); fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); - fprintf(stderr, "Blend: %d, Depth: %d, Stencil: %d \n",m_state.bs->m_enable, m_state.dss->m_depth_enable, m_state.dss->m_stencil_enable); m_state.bs->debug(); - m_state.dss->debug_depth(); + m_state.dss->debug(); } #endif @@ -1095,50 +1088,28 @@ void GSDeviceOGL::OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref) { uint ref = sref; - if(m_state.dss != dss || m_state.sref != sref) - { + if(m_state.dss != dss) { m_state.dss = dss; m_state.sref = sref; - if (dss->m_depth_enable) { - glEnable(GL_DEPTH_TEST); - glDepthFunc(dss->m_depth_func); - glDepthMask(dss->m_depth_mask); - } else - glDisable(GL_DEPTH_TEST); + dss->SetupDepth(); + dss->SetupStencil(sref); - if (dss->m_stencil_enable) { - glEnable(GL_STENCIL_TEST); - glStencilFunc(dss->m_stencil_func, ref, dss->m_stencil_mask); - glStencilOp(dss->m_stencil_sfail_op, dss->m_stencil_spass_dfail_op, dss->m_stencil_spass_dpass_op); - } else - glDisable(GL_STENCIL_TEST); + } else if (m_state.sref != sref) { + m_state.sref = sref; + + dss->SetupStencil(sref); } } void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf) { - // DX:Blend factor D3D11_BLEND_BLEND_FACTOR | D3D11_BLEND_INV_BLEND_FACTOR - // OPENGL: GL_CONSTANT_COLOR | GL_ONE_MINUS_CONSTANT_COLOR - // Note factor must be set before by glBlendColor - if(m_state.bs != bs || m_state.bf != bf) + if( m_state.bs != bs || (m_state.bf != bf && bs->HasConstantFactor()) ) { m_state.bs = bs; m_state.bf = bf; - glColorMask(bs->m_r_msk, bs->m_g_msk, bs->m_b_msk, bs->m_a_msk); - - if (bs->m_enable) { - glEnable(GL_BLEND); - // FIXME: double check when blend stuff is complete - if (bs->m_func_sRGB == GL_CONSTANT_COLOR || bs->m_func_sRGB == GL_ONE_MINUS_CONSTANT_COLOR - || bs->m_func_dRGB == GL_CONSTANT_COLOR || bs->m_func_dRGB == GL_ONE_MINUS_CONSTANT_COLOR) - glBlendColor(bf, bf, bf, 0); - - glBlendEquationSeparate(bs->m_equation_RGB, bs->m_equation_ALPHA); - glBlendFuncSeparate(bs->m_func_sRGB, bs->m_func_dRGB, bs->m_func_sALPHA, bs->m_func_dALPHA); - } else - glDisable(GL_BLEND); + bs->SetupBlend(bf); } } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index dcc3de9a85..cab27d0ce9 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -26,7 +26,7 @@ #include "GSTextureOGL.h" #include "GSdx.h" -struct GSBlendStateOGL { +class GSBlendStateOGL { // Note: You can also select the index of the draw buffer for which to set the blend setting // We will keep basic the first try bool m_enable; @@ -40,6 +40,9 @@ struct GSBlendStateOGL { bool m_b_msk; bool m_g_msk; bool m_a_msk; + bool constant_factor; + +public: GSBlendStateOGL() : m_enable(false) , m_equation_RGB(0) @@ -52,18 +55,89 @@ struct GSBlendStateOGL { , m_b_msk(GL_TRUE) , m_g_msk(GL_TRUE) , m_a_msk(GL_TRUE) + , constant_factor(true) {} + void SetRGB(GLenum op, GLenum src, GLenum dst) + { + m_equation_RGB = op; + m_func_sRGB = src; + m_func_dRGB = dst; + if (IsConstant(src) || IsConstant(dst)) constant_factor = true; + } + + void SetALPHA(GLenum op, GLenum src, GLenum dst) + { + m_equation_ALPHA = op; + m_func_sALPHA = src; + m_func_dALPHA = dst; + } + + void SetMask(bool r, bool g, bool b, bool a) { m_r_msk = r; m_g_msk = g; m_b_msk = b; m_a_msk = a; } + + void RevertOp() + { + if(m_equation_RGB == GL_FUNC_ADD) + m_equation_RGB = GL_FUNC_REVERSE_SUBTRACT; + else if(m_equation_RGB == GL_FUNC_REVERSE_SUBTRACT) + m_equation_RGB = GL_FUNC_ADD; + } + + void EnableBlend() { m_enable = true;} + + bool IsConstant(GLenum factor) { return ((factor == GL_CONSTANT_COLOR) || (factor == GL_ONE_MINUS_CONSTANT_COLOR)); } + + bool HasConstantFactor() { return constant_factor; } + + void SetupColorMask() + { + glColorMask(m_r_msk, m_g_msk, m_b_msk, m_a_msk); + } + + void SetupBlend(float factor) + { + SetupColorMask(); + + if (m_enable) { + glEnable(GL_BLEND); + if (HasConstantFactor()) glBlendColor(factor, factor, factor, 0); + + glBlendEquationSeparate(m_equation_RGB, m_equation_ALPHA); + glBlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA); + } else { + glDisable(GL_BLEND); + } + } + + char* NameOfParam(GLenum p) + { + switch (p) { + case GL_FUNC_ADD: return "ADD"; + case GL_FUNC_SUBTRACT: return "SUB"; + case GL_FUNC_REVERSE_SUBTRACT: return "REV SUB"; + case GL_ONE: return "ONE"; + case GL_ZERO: return "ZERO"; + case GL_SRC1_ALPHA: return "SRC1 ALPHA"; + case GL_ONE_MINUS_DST_ALPHA: return "1 - DST ALPHA"; + case GL_DST_ALPHA: return "DST ALPHA"; + case GL_DST_COLOR: return "DST COLOR"; + case GL_ONE_MINUS_SRC1_ALPHA: return "1 - SRC1 ALPHA"; + case GL_CONSTANT_COLOR: return "CST"; + case GL_ONE_MINUS_CONSTANT_COLOR: return "1 - CST"; + default: return "UKN"; + } + return "UKN"; + } + void debug() { if (!m_enable) return; - fprintf(stderr,"Blend RGB: %x src:%x dst:%x\n", m_equation_RGB, m_func_sRGB, m_func_dRGB); - fprintf(stderr,"Blend ALPHA: %x src:%x dst:%x\n", m_equation_ALPHA, m_func_sALPHA, m_func_dALPHA); + fprintf(stderr,"Blend op: %s; src:%s; dst:%s\n", NameOfParam(m_equation_RGB), NameOfParam(m_func_sRGB), NameOfParam(m_func_dRGB)); fprintf(stderr,"Mask. R:%d B:%d G:%d A:%d\n", m_r_msk, m_b_msk, m_g_msk, m_a_msk); } }; -struct GSDepthStencilOGL { +class GSDepthStencilOGL { bool m_depth_enable; GLenum m_depth_func; GLboolean m_depth_mask; @@ -76,6 +150,23 @@ struct GSDepthStencilOGL { GLuint m_stencil_spass_dfail_op; GLuint m_stencil_spass_dpass_op; + char* NameOfParam(GLenum p) + { + switch(p) { + case GL_NEVER: return "NEVER"; + case GL_ALWAYS: return "ALWAYS"; + case GL_GEQUAL: return "GEQUAL"; + case GL_GREATER: return "GREATER"; + case GL_KEEP: return "KEEP"; + case GL_EQUAL: return "EQUAL"; + case GL_REPLACE: return "REPLACE"; + default: return "UKN"; + } + return "UKN"; + } + +public: + GSDepthStencilOGL() : m_depth_enable(false) , m_depth_func(0) , m_depth_mask(0) @@ -88,10 +179,45 @@ struct GSDepthStencilOGL { , m_stencil_spass_dpass_op(GL_KEEP) {} + void EnableDepth() { m_depth_enable = true; } + void EnableStencil() { m_stencil_enable = true; } + + void SetDepth(GLenum func, GLboolean mask) { m_depth_func = func; m_depth_mask = mask; } + void SetStencil(GLuint func, GLuint pass) { m_stencil_func = func; m_stencil_spass_dpass_op = pass; } + + void SetupDepth() + { + if (m_depth_enable) { + glEnable(GL_DEPTH_TEST); + glDepthFunc(m_depth_func); + glDepthMask(m_depth_mask); + } else + glDisable(GL_DEPTH_TEST); + } + + void SetupStencil(uint8 sref) + { + uint ref = sref; + if (m_stencil_enable) { + glEnable(GL_STENCIL_TEST); + glStencilFunc(m_stencil_func, ref, m_stencil_mask); + glStencilOp(m_stencil_sfail_op, m_stencil_spass_dfail_op, m_stencil_spass_dpass_op); + } else + glDisable(GL_STENCIL_TEST); + } + + void debug() { debug_depth(); debug_stencil(); } + void debug_depth() { if (!m_depth_enable) return; - fprintf(stderr, "Depth %x, %x\n", m_depth_func, m_depth_mask); + fprintf(stderr, "Depth %s. Mask %x\n", NameOfParam(m_depth_func), m_depth_mask); + } + + void debug_stencil() + { + if (!m_stencil_enable) return; + fprintf(stderr, "Stencil %s. Both pass op %s\n", NameOfParam(m_stencil_func), NameOfParam(m_stencil_spass_dpass_op)); } }; @@ -244,6 +370,8 @@ public: m_count = 0; } + uint32 get_count() { return m_count; } + ~GSVertexBufferStateOGL() { glDeleteBuffers(1, &m_vb); diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 642cef238a..0e61c2b7bc 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -265,9 +265,8 @@ void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, ui if (dssel.date) { - dss->m_stencil_enable = true; - dss->m_stencil_func = GL_EQUAL; - dss->m_stencil_spass_dpass_op = GL_KEEP; + dss->EnableStencil(); + dss->SetStencil(GL_EQUAL, GL_KEEP); } if(dssel.ztst != ZTST_ALWAYS || dssel.zwe) @@ -279,9 +278,8 @@ void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, ui GL_GEQUAL, GL_GREATER }; - dss->m_depth_enable = true; - dss->m_depth_mask = dssel.zwe ? GL_TRUE : GL_FALSE; - dss->m_depth_func = ztst[dssel.ztst]; + dss->EnableDepth(); + dss->SetDepth(ztst[dssel.ztst], dssel.zwe); } m_om_dss[dssel] = dss; @@ -302,32 +300,19 @@ void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, ui { GSBlendStateOGL* bs = new GSBlendStateOGL(); - bs->m_enable = bsel.abe; - if(bsel.abe) { int i = ((bsel.a * 3 + bsel.b) * 3 + bsel.c) * 3 + bsel.d; - bs->m_equation_RGB = m_blendMapD3D9[i].op; - bs->m_func_sRGB = m_blendMapD3D9[i].src; - bs->m_func_dRGB = m_blendMapD3D9[i].dst; - // Not very good but I don't wanna write another 81 row table - if(bsel.negative) - { - if(bs->m_equation_RGB == GL_FUNC_ADD) - bs->m_equation_RGB = GL_FUNC_REVERSE_SUBTRACT; - else if(bs->m_equation_RGB == GL_FUNC_REVERSE_SUBTRACT) - bs->m_equation_RGB = GL_FUNC_ADD; - else - ; // god knows, best just not to mess with it for now - } + bs->EnableBlend(); + bs->SetRGB(m_blendMapD3D9[i].op, m_blendMapD3D9[i].src, m_blendMapD3D9[i].dst); if(m_blendMapD3D9[i].bogus == 1) { if (bsel.a == 0) - bs->m_func_sRGB = GL_ONE; + bs->SetRGB(m_blendMapD3D9[i].op, GL_ONE, m_blendMapD3D9[i].dst); else - bs->m_func_dRGB = GL_ONE; + bs->SetRGB(m_blendMapD3D9[i].op, m_blendMapD3D9[i].src, GL_ONE); const string afixstr = format("%d >> 7", afix); const char *col[3] = {"Cs", "Cd", "0"}; @@ -337,13 +322,11 @@ void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, ui fprintf(stderr, "Impossible blend for D3D: (%s - %s) * %s + %s\n", col[bsel.a], col[bsel.b], alpha[bsel.c], col[bsel.d]); } - + // Not very good but I don't wanna write another 81 row table + if(bsel.negative) bs->RevertOp(); } - bs->m_r_msk = bsel.wr; - bs->m_g_msk = bsel.wg; - bs->m_b_msk = bsel.wb; - bs->m_a_msk = bsel.wa; + bs->SetMask(bsel.wr, bsel.wg, bsel.wb, bsel.wa); m_om_bs[bsel] = bs; j = m_om_bs.find(bsel); From cc6e48674214f1df5a4ba625d5e629e0d2c6eddf Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Tue, 3 Jan 2012 16:12:34 +0000 Subject: [PATCH 28/56] gsdx-ogl: * add a new define (DISABLE_DUAL_BLEND) to easily test blend mode git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5040 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 47 ++++++++++++++++++++---------------- plugins/GSdx/GSDeviceOGL.h | 40 +++++++++++++++++++++++++----- plugins/GSdx/res/tfx.glsl | 6 +++++ 3 files changed, 66 insertions(+), 27 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index b3537619c8..60f7e6e4f1 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -54,10 +54,13 @@ //#define LOUD_DEBUGGING #define SHADER_DEBUG -#define DUMP_START (70) -#define DUMP_LENGTH (130) +//#define DUMP_START (70) +//#define DUMP_LENGTH (130) //#define DUMP_ONLY_FRAME (112) +// It seems dual blending does not work (at least on AMD) +//#define DISABLE_DUAL_BLEND + #ifdef DUMP_START static uint32 g_draw_count = 0; static uint32 g_frame_count = 0; @@ -527,22 +530,15 @@ void GSDeviceOGL::DrawPrimitive() } if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); - string topo; - switch (m_state.topology) { - case GL_TRIANGLE_STRIP: topo = "triangle_strip"; break; - case GL_TRIANGLES: topo = "triangle"; break; - case GL_LINES: topo = "line"; break; - case GL_POINTS: topo = "point"; break; - default: topo = "!!!!"; - } - fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, m_state.vb_state->get_count(), topo.c_str() ); + fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); + m_state.vb->debug(); m_state.bs->debug(); m_state.dss->debug(); } #endif - m_state.vb_state->draw_arrays(m_state.topology); + m_state.vb->draw_arrays(); // DUMP OUTPUT #ifdef DUMP_START @@ -956,7 +952,7 @@ GSTexture* GSDeviceOGL::Resolve(GSTexture* t) void GSDeviceOGL::EndScene() { - m_state.vb_state->draw_done(); + m_state.vb->draw_done(); } void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) @@ -967,22 +963,22 @@ void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) } } -void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb_state) +void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb) { - if (m_state.vb_state != vb_state) { - m_state.vb_state = vb_state; - vb_state->bind(); + if (m_state.vb != vb) { + m_state.vb = vb; + vb->bind(); } } void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count) { - m_state.vb_state->upload(vertices, count); + m_state.vb->upload(vertices, count); } void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) { - m_state.topology = topology; + m_state.vb->SetTopology(topology); } void GSDeviceOGL::VSSetShader(GLuint vs) @@ -1190,6 +1186,9 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st std::string entry_main = format("#define %s main\n", entry.c_str()); std::string header = version + shader_type + entry_main + macro_sel; +#ifdef DISABLE_DUAL_BLEND + header += "#define DISABLE_DUAL_BLEND 1\n"; +#endif // ***************************************************** // Read the source file @@ -1343,13 +1342,19 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi #define D3DBLEND_ONE GL_ONE #define D3DBLEND_ZERO GL_ZERO -#define D3DBLEND_SRCALPHA GL_SRC1_ALPHA #define D3DBLEND_INVDESTALPHA GL_ONE_MINUS_DST_ALPHA #define D3DBLEND_DESTALPHA GL_DST_ALPHA #define D3DBLEND_DESTCOLOR GL_DST_COLOR -#define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC1_ALPHA #define D3DBLEND_BLENDFACTOR GL_CONSTANT_COLOR #define D3DBLEND_INVBLENDFACTOR GL_ONE_MINUS_CONSTANT_COLOR + +#ifdef DISABLE_DUAL_BLEND + #define D3DBLEND_SRCALPHA GL_SRC_ALPHA + #define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC_ALPHA +#else + #define D3DBLEND_SRCALPHA GL_SRC1_ALPHA + #define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC1_ALPHA +#endif const GSDeviceOGL::D3D9Blend GSDeviceOGL::m_blendMapD3D9[3*3*3*3] = { diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index cab27d0ce9..47276fc2ed 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -118,10 +118,12 @@ public: case GL_ONE: return "ONE"; case GL_ZERO: return "ZERO"; case GL_SRC1_ALPHA: return "SRC1 ALPHA"; + case GL_SRC_ALPHA: return "SRC ALPHA"; case GL_ONE_MINUS_DST_ALPHA: return "1 - DST ALPHA"; case GL_DST_ALPHA: return "DST ALPHA"; case GL_DST_COLOR: return "DST COLOR"; case GL_ONE_MINUS_SRC1_ALPHA: return "1 - SRC1 ALPHA"; + case GL_ONE_MINUS_SRC_ALPHA: return "1 - SRC ALPHA"; case GL_CONSTANT_COLOR: return "CST"; case GL_ONE_MINUS_CONSTANT_COLOR: return "1 - CST"; default: return "UKN"; @@ -283,6 +285,7 @@ class GSVertexBufferStateOGL { GLuint m_vb; GLuint m_va; const GLenum m_target; + GLenum m_topology; void allocate(size_t new_limit) { @@ -359,9 +362,9 @@ public: } } - void draw_arrays(GLenum topology) + void draw_arrays() { - glDrawArrays(topology, m_start, m_count); + glDrawArrays(m_topology, m_start, m_count); } void draw_done() @@ -370,13 +373,39 @@ public: m_count = 0; } - uint32 get_count() { return m_count; } + void SetTopology(GLenum topology) { m_topology = topology; } ~GSVertexBufferStateOGL() { glDeleteBuffers(1, &m_vb); glDeleteVertexArrays(1, &m_va); } + + void debug() + { + uint32 element; + string topo; + switch (m_topology) { + case GL_POINTS: + element = m_count; + topo = "point"; + break; + case GL_LINES: + element = m_count/2; + topo = "line"; + break; + case GL_TRIANGLES: + element = m_count/3; + topo = "triangle"; + break; + case GL_TRIANGLE_STRIP: + element = m_count - 3; + topo = "triangle strip"; + break; + } + fprintf(stderr, "%d elements of %s\n", element, topo.c_str()); + + } }; class GSDeviceOGL : public GSDevice @@ -662,8 +691,7 @@ class GSDeviceOGL : public GSDevice struct { - GSVertexBufferStateOGL* vb_state; - GLenum topology; // (ie GL_TRIANGLES...) + GSVertexBufferStateOGL* vb; GLuint vs; // program GSUniformBufferOGL* cb; // uniform current buffer GLuint gs; // program @@ -778,7 +806,7 @@ class GSDeviceOGL : public GSDevice void IASetPrimitiveTopology(GLenum topology); void IASetVertexBuffer(const void* vertices, size_t count); - void IASetVertexState(GSVertexBufferStateOGL* vb_state); + void IASetVertexState(GSVertexBufferStateOGL* vb); void SetUniformBuffer(GSUniformBufferOGL* cb); diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 0737c5e56e..aec8596c6e 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -257,8 +257,12 @@ void gs_main() layout(location = 0) in vertex PSin; // Same buffer but 2 colors for dual source blending +#ifndef DISABLE_DUAL_BLEND layout(location = 0, index = 1) out vec4 SV_Target0; layout(location = 0, index = 0) out vec4 SV_Target1; +#else +layout(location = 0) out vec4 SV_Target1; +#endif layout(binding = 0) uniform sampler2D TextureSampler; layout(binding = 1) uniform sampler2D PaletteSampler; @@ -619,7 +623,9 @@ void ps_main() // FIXME: I'm not sure about the value of others field // output.c1 = c.a * 2; // used for alpha blending +#ifndef DISABLE_DUAL_BLEND SV_Target0 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2); +#endif if(PS_AOUT != 0) // 16 bit output { From 76542f89c9254511c5bdd09a4b4300ccfb0a26b4 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Tue, 3 Jan 2012 17:17:04 +0000 Subject: [PATCH 29/56] gsdx-ogl: code seems compatible with an opengl 3.3 context. Only load some shader extensions. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5041 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 18 +++++++++++++++--- plugins/GSdx/GSWnd.cpp | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 60f7e6e4f1..0e7071692b 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -203,8 +203,20 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // Note: 4.2 crash on latest nvidia drivers! // So only check 4.1 // if ( (major < 4) || ( major == 4 && minor < 2 ) ) return false; - if ( (major < 4) || ( major == 4 && minor < 1 ) ) return false; + // if ( (major < 4) || ( major == 4 && minor < 1 ) ) return false; + if ( (major < 3) || ( major == 3 && minor < 3 ) ) { + fprintf(stderr, "OPENGL 3.3 is not supported\n"); + return false; + } + if ( !glewIsSupported("GL_ARB_separate_shader_objects")) { + fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n"); + return false; + } + if ( !glewIsSupported("GL_ARB_shading_language_420pack")) { + fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n"); + return false; + } } @@ -1164,8 +1176,8 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st // Build a header string // ***************************************************** // First select the version (must be the first line so we need to generate it - //std::string version = "#version 410\n#extension GL_ARB_shading_language_420pack: enable\n"; - std::string version = "#version 420\n"; + std::string version = "#version 330\n#extension GL_ARB_shading_language_420pack: enable\n#extension GL_ARB_separate_shader_objects : enable\n"; + //std::string version = "#version 420\n"; // Allow to puts several shader in 1 files std::string shader_type; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index cefeba6e55..a977aba0f2 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -369,9 +369,9 @@ bool GSWnd::Attach(void* handle, bool managed) // Create a context int context_attribs[] = { - GLX_CONTEXT_MAJOR_VERSION_ARB, 4, + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, // Note: 4.2 crash on latest nvidia drivers! - GLX_CONTEXT_MINOR_VERSION_ARB, 1, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, // FIXME : Request a debug context to ease opengl development // Note: don't support deprecated feature (pre openg 3.1) //GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, From 01164026204de8583d5f26f895f7c2075fd94441 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Wed, 4 Jan 2012 10:42:53 +0000 Subject: [PATCH 30/56] gsdx-ogl: Fix a few glsl errors. Comment out line 218 of GSDevice.cpp. Mess with the fifo hack a bit. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5042 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GS.cpp | 4 ++-- plugins/GSdx/GSDeviceOGL.cpp | 2 +- plugins/GSdx/GSDeviceOGL.h | 11 ++++++++++- plugins/GSdx/res/tfx.glsl | 10 +++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 7badb94b87..a052142637 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -413,9 +413,9 @@ EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) // invalidate data for opengl if (theApp.GetConfig("renderer", 0) == 12) { #ifdef OGL_DEBUG - fprintf(stderr, "Disable FIFO2 on opengl\n"); + fprintf(stderr, "Disable FIFO2(%d) on opengl\n", size); #endif - return; + //return; } #endif s_gs->ReadFIFO(mem, size); diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 0e7071692b..cf53ec34b6 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -215,7 +215,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) } if ( !glewIsSupported("GL_ARB_shading_language_420pack")) { fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n"); - return false; + //return false; } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 47276fc2ed..653218b98c 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -315,6 +315,11 @@ public: void upload(const void* src, uint32 count) { + GLint b_size = -1; + glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); + + if (b_size <= 0) return; + m_count = count; // Note: For an explanation of the map flag @@ -337,9 +342,13 @@ public: // Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map map_flags |= GL_MAP_INVALIDATE_RANGE_BIT; } - + // Upload the data to the buffer uint8* dst = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); + if (dst == NULL) { + fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n"); + return; + } memcpy(dst, src, m_stride*m_count); glUnmapBuffer(m_target); } diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index aec8596c6e..2bf22ca9ff 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -74,9 +74,9 @@ void vs_main() { uint z; if(VS_BPPZ == 1) // 24 - z = i_z & 0xffffff; + z = i_z & uint(0xffffff); else if(VS_BPPZ == 2) // 16 - z = i_z & 0xffff; + z = i_z & uint(0xffff); else z = i_z; @@ -312,7 +312,7 @@ vec4 wrapuv(vec4 uv) } else if(PS_WMS == 3) { - uv_out = vec4(((ivec4(uv * WH.xyxy) & MskFix.xyxy) | MskFix.zwzw) / WH.xyxy); + uv_out = vec4(((ivec4(uv * WH.xyxy) & ivec4(MskFix.xyxy)) | ivec4(MskFix.zwzw)) / WH.xyxy); } } else @@ -323,7 +323,7 @@ vec4 wrapuv(vec4 uv) } else if(PS_WMS == 3) { - uv_out.xz = vec2(((ivec2(uv.xz * WH.xx) & MskFix.xx) | MskFix.zz) / WH.xx); + uv_out.xz = vec2(((ivec2(uv.xz * WH.xx) & ivec2(MskFix.xx)) | ivec2(MskFix.zz)) / WH.xx); } if(PS_WMT == 2) { @@ -331,7 +331,7 @@ vec4 wrapuv(vec4 uv) } else if(PS_WMT == 3) { - uv_out.yw = vec2(((ivec2(uv.yw * WH.yy) & MskFix.yy) | MskFix.ww) / WH.yy); + uv_out.yw = vec2(((ivec2(uv.yw * WH.yy) & ivec2(MskFix.yy)) | ivec2(MskFix.ww)) / WH.yy); } } From 4c5d1e11a854ecf3bd7c38456147dbdb7379db66 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Wed, 4 Jan 2012 11:14:57 +0000 Subject: [PATCH 31/56] gsdx-ogl: Fix a few glsl errors I missed last commit. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5043 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/res/convert.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 2887215d72..4cb6e2c63c 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -111,7 +111,7 @@ void ps_main1() highp uvec4 i = uvec4(c * vec4(0x001f, 0x03e0, 0x7c00, 0x8000)); - SV_Target1 = (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); + SV_Target1 = (i.x & uint(0x001f)) | (i.y & uint(0x03e0)) | (i.z & uint(0x7c00)) | (i.w & uint(0x8000)); } void ps_main7() @@ -136,7 +136,7 @@ void ps_main6() // diagonal { uvec4 p = uvec4(PSin.p); - vec4 c = ps_crt((p.x + (p.y % 3)) % 3); + vec4 c = ps_crt((p.x + (p.y % 3u)) % 3u); SV_Target0 = c; } From 0e80e0adca0834e2c7bc5001c16189bcc5edb74d Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Wed, 4 Jan 2012 23:19:17 +0000 Subject: [PATCH 32/56] gsdx-ogl: * add some define to enable/disable SDL so we could build gsdx without SDL * debug: dump data based on frame count rather from draw count git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5044 96395faa-99c1-11dd-bbfe-3dabce05a288 --- cmake/SelectPcsx2Plugins.cmake | 6 +++--- plugins/GSdx/CMakeLists.txt | 14 ++++++++------ plugins/GSdx/GPU.cpp | 2 ++ plugins/GSdx/GS.cpp | 13 +++++++++++-- plugins/GSdx/GSDeviceOGL.cpp | 20 +++++++++++--------- plugins/GSdx/GSDeviceOGL.h | 2 +- plugins/GSdx/GSDeviceSDL.cpp | 2 ++ plugins/GSdx/GSDeviceSDL.h | 5 ++++- plugins/GSdx/GSWnd.cpp | 22 ++++++++++++++++++++++ plugins/GSdx/GSWnd.h | 8 ++++++++ 10 files changed, 72 insertions(+), 22 deletions(-) diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index b4cf72779e..b5e35e0f36 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -121,13 +121,13 @@ endif(GTK2_FOUND) # -X11 # -PCSX2 SDL #--------------------------------------- -if(OPENGL_FOUND AND X11_FOUND AND projectSDL) +if(OPENGL_FOUND AND X11_FOUND) set(GSdx TRUE) -else(OPENGL_FOUND AND X11_FOUND AND projectSDL) +else(OPENGL_FOUND AND X11_FOUND) set(GSdx FALSE) message(STATUS "Skip build of GSdx: miss some dependencies") message(STATUS "${msg_dep_gsdx}") -endif(OPENGL_FOUND AND X11_FOUND AND projectSDL) +endif(OPENGL_FOUND AND X11_FOUND) #--------------------------------------- #--------------------------------------- diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index b9690455c0..53bb692fa0 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -18,7 +18,7 @@ set(CommonFlags -Wunused-variable -std=c++0x -fno-strict-aliasing - -DOGL_DEBUG + -DOGL_DEBUG # FIXME remove me when code is ready -DAMD_DRIVER_WORKAROUND ) @@ -27,21 +27,22 @@ set(OptimizationFlags -DNDEBUG ) +if(projectSDL) + add_definitions(-DENABLE_SDL_DEV) +endif(projectSDL) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) - # add defines add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build if(CMAKE_BUILD_TYPE STREQUAL Devel) - # add defines add_definitions(${CommonFlags} ${OptimizationFlags} -g -W) endif(CMAKE_BUILD_TYPE STREQUAL Devel) # Release - Build if(CMAKE_BUILD_TYPE STREQUAL Release) - # add defines add_definitions(${CommonFlags} ${OptimizationFlags} -W) endif(CMAKE_BUILD_TYPE STREQUAL Release) @@ -188,8 +189,9 @@ add_library(${Output} SHARED # link target with X11 target_link_libraries(${Output} ${X11_LIBRARIES}) -# link target with SDL -target_link_libraries(${Output} ${SDL_LIBRARY}) +if(projectSDL) + target_link_libraries(${Output} ${SDL_LIBRARY}) +endif(projectSDL) # link target with glew target_link_libraries(${Output} ${GLEW_LIBRARY}) diff --git a/plugins/GSdx/GPU.cpp b/plugins/GSdx/GPU.cpp index c2764016eb..4df60190c9 100644 --- a/plugins/GSdx/GPU.cpp +++ b/plugins/GSdx/GPU.cpp @@ -118,7 +118,9 @@ EXPORT_C_(int32) GPUopen(void* hWnd) case 0: s_gpu = new GPURendererSW(new GSDevice9(), threads); break; case 1: s_gpu = new GPURendererSW(new GSDevice11(), threads); break; #endif + #ifdef ENABLE_SDL_DEV case 2: s_gpu = new GPURendererSW(new GSDeviceSDL(), threads); break; + #endif case 3: s_gpu = new GPURendererSW(new GSDeviceNull(), threads); break; //case 4: s_gpu = new GPURendererNull(new GSDeviceNull()); break; } diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index a052142637..c0baf6196c 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -136,6 +136,7 @@ EXPORT_C_(int) GSinit() #endif +#ifdef ENABLE_SDL_DEV if(!SDL_WasInit(SDL_INIT_VIDEO)) { if(SDL_Init(SDL_INIT_VIDEO) < 0) @@ -143,6 +144,7 @@ EXPORT_C_(int) GSinit() return -1; } } +#endif return 0; } @@ -155,7 +157,9 @@ EXPORT_C GSshutdown() s_renderer = -1; +#ifdef ENABLE_SDL_DEV SDL_Quit(); +#endif #ifdef _WINDOWS @@ -216,7 +220,11 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) case 0: dev = new GSDevice9(); break; case 1: dev = new GSDevice11(); break; #endif + #ifdef ENABLE_SDL_DEV case 2: dev = new GSDeviceSDL(); break; + #else + case 2: dev = NULL; break; + #endif case 3: dev = new GSDeviceNull(); break; case 4: dev = new GSDeviceOGL(); break; } @@ -287,7 +295,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) { s_gs->SetMultithreaded(true); -#ifdef __LINUX__ +#ifdef _LINUX // Get the Xwindow from dsp. if( !s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false) ) return -1; @@ -325,7 +333,8 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags) int retval = _GSopen(dsp, NULL, renderer); - s_gs->SetAspectRatio(0); // PCSX2 manages the aspect ratios + if (s_gs != NULL) + s_gs->SetAspectRatio(0); // PCSX2 manages the aspect ratios return retval; } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index cf53ec34b6..57aa9b8966 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -56,9 +56,10 @@ #define SHADER_DEBUG //#define DUMP_START (70) //#define DUMP_LENGTH (130) -//#define DUMP_ONLY_FRAME (112) +//#define PRINT_FRAME_NUMBER +//#define ONLY_LINES -// It seems dual blending does not work (at least on AMD) +// It seems dual blending does not work on AMD !!! //#define DISABLE_DUAL_BLEND #ifdef DUMP_START @@ -337,6 +338,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // FIXME enable it when multisample code will be here // DX: rd.MultisampleEnable = true; glDisable(GL_MULTISAMPLE); +#ifdef ONLY_LINES + glLineWidth(5.0); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); +#endif // Hum I don't know for those options but let's hope there are not activated #if 0 rd.FrontCounterClockwise = false; @@ -513,6 +518,9 @@ void GSDeviceOGL::Flip() // FIXME: disable it when code is working CheckDebugLog(); m_wnd->Flip(); +#ifdef PRINT_FRAME_NUMBER + fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); +#endif #ifdef DUMP_START g_frame_count++; #endif @@ -522,14 +530,8 @@ void GSDeviceOGL::DrawPrimitive() { #ifdef DUMP_START bool dump_me = false; - if ( (g_draw_count > DUMP_START && g_draw_count < (DUMP_START+DUMP_LENGTH)) ) + if ( (g_frame_count > DUMP_START && g_frame_count < (DUMP_START+DUMP_LENGTH)) ) dump_me = true; -#ifdef DUMP_ONLY_FRAME - if (DUMP_ONLY_FRAME != 0 && DUMP_ONLY_FRAME == g_frame_count) - dump_me = true; - else if (DUMP_ONLY_FRAME != 0) - dump_me = false; -#endif #endif // DUMP INPUT diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 653218b98c..2e727d3922 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -408,7 +408,7 @@ public: topo = "triangle"; break; case GL_TRIANGLE_STRIP: - element = m_count - 3; + element = m_count - 2; topo = "triangle strip"; break; } diff --git a/plugins/GSdx/GSDeviceSDL.cpp b/plugins/GSdx/GSDeviceSDL.cpp index be0a15ecdf..1fccc4b386 100644 --- a/plugins/GSdx/GSDeviceSDL.cpp +++ b/plugins/GSdx/GSDeviceSDL.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include "GSDeviceSDL.h" +#ifdef ENABLE_SDL_DEV GSDeviceSDL::GSDeviceSDL() : m_free_window(false) , m_window(NULL) @@ -230,3 +231,4 @@ void GSDeviceSDL::Flip() { SDL_RenderPresent(m_renderer); } +#endif diff --git a/plugins/GSdx/GSDeviceSDL.h b/plugins/GSdx/GSDeviceSDL.h index 324d41c2c8..6a61ce30f2 100644 --- a/plugins/GSdx/GSDeviceSDL.h +++ b/plugins/GSdx/GSDeviceSDL.h @@ -21,6 +21,8 @@ #pragma once +#ifdef ENABLE_SDL_DEV + #include "GSDeviceSW.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" @@ -52,4 +54,5 @@ public: bool Reset(int w, int h); void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0); void Flip(); -}; \ No newline at end of file +}; +#endif diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index a977aba0f2..d3ec81e6f1 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -318,11 +318,13 @@ GSWnd::GSWnd() GSWnd::~GSWnd() { +#ifdef ENABLE_SDL_DEV if(m_window != NULL && m_managed) { SDL_DestroyWindow(m_window); m_window = NULL; } +#endif if (m_XDisplay) { XCloseDisplay(m_XDisplay); m_XDisplay = NULL; @@ -402,11 +404,13 @@ void GSWnd::Detach() // Actually the destructor is not called when there is only a GSclose/GSshutdown // The window still need to be closed if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV if(m_window != NULL && m_managed) { SDL_DestroyWindow(m_window); m_window = NULL; } +#endif } else { glXMakeCurrent(m_XDisplay, None, NULL); if (m_context) glXDestroyContext(m_XDisplay, m_context); @@ -419,6 +423,7 @@ void GSWnd::Detach() bool GSWnd::Create(const string& title, int w, int h) { +#ifdef ENABLE_SDL_DEV if(m_window != NULL) return false; if(w <= 0 || h <= 0) { @@ -456,10 +461,14 @@ bool GSWnd::Create(const string& title, int w, int h) m_Xwindow = wminfo.info.x11.window; return (m_window != NULL); +#else + return false; +#endif } Display* GSWnd::GetDisplay() { +#ifdef ENABLE_SDL_DEV SDL_SysWMinfo wminfo; memset(&wminfo, 0, sizeof(wminfo)); @@ -470,6 +479,9 @@ Display* GSWnd::GetDisplay() SDL_GetWindowWMInfo(m_window, &wminfo); return wminfo.subsystem == SDL_SYSWM_X11 ? wminfo.info.x11.display : NULL; +#else + return NULL; +#endif } GSVector4i GSWnd::GetClientRect() @@ -490,8 +502,10 @@ GSVector4i GSWnd::GetClientRect() // In real world...: if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL); XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy); +#ifdef ENABLE_SDL_DEV if (m_renderer == 2) SDL_SetWindowSize(m_window, w, h); +#endif return GSVector4i(0, 0, (int)w, (int)h); } @@ -501,6 +515,7 @@ GSVector4i GSWnd::GetClientRect() bool GSWnd::SetWindowText(const char* title) { +#if ENABLE_SDL_DEV if (!m_managed) return true; // Do not find anyway to check the current fullscreen status @@ -519,16 +534,19 @@ bool GSWnd::SetWindowText(const char* title) SDL_SetWindowTitle(m_window, title); } +#endif return true; } void GSWnd::Flip() { if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV #if SDL_VERSION_ATLEAST(1,3,0) SDL_GL_SwapWindow(m_window); #else SDL_GL_SwapBuffers(); +#endif #endif } else { glXSwapBuffers(m_XDisplay, m_Xwindow); @@ -538,7 +556,9 @@ void GSWnd::Flip() void GSWnd::Show() { if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV SDL_ShowWindow(m_window); +#endif } else { XMapRaised(m_XDisplay, m_Xwindow); XFlush(m_XDisplay); @@ -548,7 +568,9 @@ void GSWnd::Show() void GSWnd::Hide() { if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV SDL_HideWindow(m_window); +#endif } else { XUnmapWindow(m_XDisplay, m_Xwindow); XFlush(m_XDisplay); diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index 44fcc844db..6e85a3aef5 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -88,12 +88,18 @@ public: }; */ #include +#ifdef ENABLE_SDL_DEV #include "../../3rdparty/SDL-1.3.0-5387/include/SDL.h" #include "../../3rdparty/SDL-1.3.0-5387/include/SDL_syswm.h" +#endif class GSWnd { +#ifdef ENABLE_SDL_DEV SDL_Window* m_window; +#else + void* m_window; +#endif Window m_Xwindow; Display* m_XDisplay; bool m_managed; @@ -113,7 +119,9 @@ public: void* GetHandle() {return (void*)m_Xwindow;} GSVector4i GetClientRect(); bool SetWindowText(const char* title); +#ifdef ENABLE_SDL_DEV void SetWindow(SDL_Window* current_window) { if (current_window) m_window = current_window; } +#endif void Show(); void Hide(); From 53a5089d7b6991f34b39fcca51e7c61a93b9da08 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 6 Jan 2012 07:20:37 +0000 Subject: [PATCH 33/56] gsdx-ogl: * fix some issue with cmake and new sdl define * Implement shortcut key handling on linux. + some option are not yet implemented (fxaa) + gs dump can be created with git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5050 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 10 +++-- plugins/GSdx/GSRenderer.cpp | 73 ++++++++++++++++++++++++++++++++++--- plugins/GSdx/GSRenderer.h | 4 ++ 3 files changed, 77 insertions(+), 10 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 53bb692fa0..ef836d6a98 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -28,22 +28,24 @@ set(OptimizationFlags ) if(projectSDL) - add_definitions(-DENABLE_SDL_DEV) + set(SDLFlags -DENABLE_SDL_DEV) +else(projectSDL) + set(SDLFlags "") endif(projectSDL) # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) - add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall) + add_definitions(${CommonFlags} ${SDLFlags} -DOGL_DEBUG -g -Wall) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build if(CMAKE_BUILD_TYPE STREQUAL Devel) - add_definitions(${CommonFlags} ${OptimizationFlags} -g -W) + add_definitions(${CommonFlags} ${SDLFlags} ${OptimizationFlags} -g -W) endif(CMAKE_BUILD_TYPE STREQUAL Devel) # Release - Build if(CMAKE_BUILD_TYPE STREQUAL Release) - add_definitions(${CommonFlags} ${OptimizationFlags} -W) + add_definitions(${CommonFlags} ${SDLFlags} ${OptimizationFlags} -W) endif(CMAKE_BUILD_TYPE STREQUAL Release) set(GSdxSources diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index b5d434dcf8..89f9a4e934 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -27,6 +27,8 @@ GSRenderer::GSRenderer() , m_vt(this) , m_dev(NULL) , m_shader(0) + , m_shift_key(false) + , m_control_key(false) { m_GStitleInfoBuffer[0] = 0; @@ -407,6 +409,10 @@ void GSRenderer::VSync(int field) shift = !!(::GetAsyncKeyState(VK_SHIFT) & 0x8000); + #else + + shift = m_shift_key; + #endif if(!m_dump && shift) @@ -440,6 +446,10 @@ void GSRenderer::VSync(int field) control = !!(::GetAsyncKeyState(VK_CONTROL) & 0x8000); + #else + + control = m_control_key; + #endif m_dump.VSync(field, !control, m_regs); @@ -500,9 +510,9 @@ void GSRenderer::EndCapture() void GSRenderer::KeyEvent(GSKeyEventData* e) { +#ifdef _WINDOWS if(e->type == KEYPRESS) { - #ifdef _WINDOWS int step = (::GetAsyncKeyState(VK_SHIFT) & 0x8000) ? -1 : 1; @@ -534,12 +544,63 @@ void GSRenderer::KeyEvent(GSKeyEventData* e) return; } - #else - - // TODO: linux - - #endif } +#else + if(e->type == KEYPRESS) + { + int step = m_shift_key ? -1 : 1; + + switch(e->key) + { + case XK_F5: + m_interlace = (m_interlace + 7 + step) % 7; + fprintf(stderr, "GSdx: Set deinterlace mode to %d (%s).\n", (int)m_interlace, theApp.m_gs_interlace.at(m_interlace).name.c_str()); + return; + case XK_F6: + if( m_wnd.IsManaged() ) + m_aspectratio = (m_aspectratio + 3 + step) % 3; + return; + case XK_F7: + m_shader = (m_shader + 3 + step) % 3; + fprintf(stderr,"GSdx: Set shader %d.\n", (int)m_shader); + return; + case XK_Delete: + m_aa1 = !m_aa1; + fprintf(stderr,"GSdx: (Software) aa1 is now %s.\n", m_aa1 ? "enabled" : "disabled"); + return; + case XK_Insert: + m_mipmap = !m_mipmap; + fprintf(stderr,"GSdx: (Software) mipmapping is now %s.\n", m_mipmap ? "enabled" : "disabled"); + return; + case XK_Prior: + m_fxaa = !m_fxaa; + fprintf(stderr,"GSdx: fxaa is now %s.\n", m_fxaa ? "enabled" : "disabled"); + return; + case XK_Shift_L: + case XK_Shift_R: + m_shift_key = true; + return; + case XK_Control_L: + case XK_Control_R: + m_control_key = true; + return; + } + + } else if(e->type == KEYRELEASE) + { + switch(e->key) + { + case XK_Shift_L: + case XK_Shift_R: + m_shift_key = false; + return; + case XK_Control_L: + case XK_Control_R: + m_control_key = false; + return; + } + } +#endif } void GSRenderer::GetTextureMinMax(GSVector4i& r, const GIFRegTEX0& TEX0, const GIFRegCLAMP& CLAMP, bool linear) diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index 80d088f79a..8cc81a0ae0 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -37,6 +37,10 @@ class GSRenderer : public GSState bool Merge(int field); + // Only used on linux + bool m_shift_key; + bool m_control_key; + protected: int m_interlace; int m_aspectratio; From 21724ddbf884632214cb6267393bea71e1cd552b Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 6 Jan 2012 21:43:39 +0000 Subject: [PATCH 34/56] gsdx-ogl: add a loader to replay gs file. Quite shaky but probably enough for debug :) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5052 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 31 ++++-- plugins/GSdx/GS.cpp | 187 ++++++++++++++++++++++++++++++++++ plugins/GSdx/GSDeviceOGL.cpp | 2 +- plugins/GSdx/GSWnd.cpp | 167 ++++++++++++++++++++---------- plugins/GSdx/GSWnd.h | 10 +- plugins/GSdx/linux_replay.cpp | 41 ++++++++ 6 files changed, 370 insertions(+), 68 deletions(-) create mode 100644 plugins/GSdx/linux_replay.cpp diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index ef836d6a98..ebb5585f4b 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -8,6 +8,8 @@ endif(NOT TOP_CMAKE_WAS_SOURCED) # plugin name set(Output GSdx-0.1.16) +set(Replay pcsx2_GSReplayLoader) +set(Static GSdx-static) set(CommonFlags -D_LINUX @@ -179,38 +181,47 @@ set(GSdxHeaders xbyak/xbyak_util.h ) -# add additional include directories include_directories(.) -# add library -add_library(${Output} SHARED - ${GSdxSources} - ${GSdxHeaders} - ) +add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders}) + +add_library(${Static} STATIC ${GSdxSources} ${GSdxHeaders}) + +add_executable(${Replay} linux_replay.cpp) -# link target with X11 target_link_libraries(${Output} ${X11_LIBRARIES}) +target_link_libraries(${Output} ${GLEW_LIBRARY}) +target_link_libraries(${Output} ${OPENGL_LIBRARIES}) if(projectSDL) target_link_libraries(${Output} ${SDL_LIBRARY}) endif(projectSDL) -# link target with glew -target_link_libraries(${Output} ${GLEW_LIBRARY}) +target_link_libraries(${Replay} ${OPENGL_LIBRARIES}) +target_link_libraries(${Replay} ${X11_LIBRARIES}) +target_link_libraries(${Replay} ${GLEW_LIBRARY}) +target_link_libraries(${Replay} ${GTK2_LIBRARIES}) +target_link_libraries(${Replay} ${Static}) + -# User flags options if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}") endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") if(PACKAGE_MODE) + install(TARGETS ${Replay} DESTINATION bin) + install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${PLUGIN_DIR}) else(PACKAGE_MODE) + install(TARGETS ${Replay} DESTINATION ${CMAKE_SOURCE_DIR}/bin) + install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index c0baf6196c..7133ae4280 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1084,3 +1084,190 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow } #endif + +#ifdef _LINUX + +// Note +EXPORT_C GSReplay(char* lpszCmdLine, int renderer) +{ + + +// lpszCmdLine: +// First parameter is the renderer. +// Second parameter is the gs file to load and run. + +//EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) +#if 0 + int renderer = -1; + + { + char* start = lpszCmdLine; + char* end = NULL; + long n = strtol(lpszCmdLine, &end, 10); + if(end > start) {renderer = n; lpszCmdLine = end;} + } + + while(*lpszCmdLine == ' ') lpszCmdLine++; + + ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); +#endif + + if(FILE* fp = fopen(lpszCmdLine, "rb")) + { + //Console console("GSdx", true); + + GSinit(); + + uint8 regs[0x2000]; + GSsetBaseMem(regs); + + s_vsync = !!theApp.GetConfig("vsync", 0); + + void* hWnd = NULL; + + _GSopen((void**)&hWnd, "", renderer); + + uint32 crc; + fread(&crc, 4, 1, fp); + GSsetGameCRC(crc, 0); + + GSFreezeData fd; + fread(&fd.size, 4, 1, fp); + fd.data = new uint8[fd.size]; + fread(fd.data, fd.size, 1, fp); + GSfreeze(FREEZE_LOAD, &fd); + delete [] fd.data; + + fread(regs, 0x2000, 1, fp); + + long start = ftell(fp); + + GSvsync(1); + + struct Packet {uint8 type, param; uint32 size, addr; vector buff;}; + + list packets; + vector buff; + int type; + + while((type = fgetc(fp)) != EOF) + { + Packet* p = new Packet(); + + p->type = (uint8)type; + + switch(type) + { + case 0: + + p->param = (uint8)fgetc(fp); + + fread(&p->size, 4, 1, fp); + + switch(p->param) + { + case 0: + p->buff.resize(0x4000); + p->addr = 0x4000 - p->size; + fread(&p->buff[p->addr], p->size, 1, fp); + break; + case 1: + case 2: + case 3: + p->buff.resize(p->size); + fread(&p->buff[0], p->size, 1, fp); + break; + } + + break; + + case 1: + + p->param = (uint8)fgetc(fp); + + break; + + case 2: + + fread(&p->size, 4, 1, fp); + + break; + + case 3: + + p->buff.resize(0x2000); + + fread(&p->buff[0], 0x2000, 1, fp); + + break; + } + + packets.push_back(p); + } + + sleep(30); + // FIXME too slow :p + // sleep(100); + + //while(IsWindowVisible(hWnd)) + //FIXME map? + while(true) + { + for(auto i = packets.begin(); i != packets.end(); i++) + { + Packet* p = *i; + + switch(p->type) + { + case 0: + + switch(p->param) + { + case 0: GSgifTransfer1(&p->buff[0], p->addr); break; + case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; + case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; + case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; + } + + break; + + case 1: + + GSvsync(p->param); + + break; + + case 2: + + if(buff.size() < p->size) buff.resize(p->size); + + GSreadFIFO2(&buff[0], p->size / 16); + + break; + + case 3: + + memcpy(regs, &p->buff[0], 0x2000); + + break; + } + } + } + + for(auto i = packets.begin(); i != packets.end(); i++) + { + delete *i; + } + + packets.clear(); + + sleep(100); + + GSclose(); + GSshutdown(); + + fclose(fp); + } +} +#endif + diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 57aa9b8966..742b9b078c 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -195,7 +195,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) s = glGetString(GL_VERSION); if (s == NULL) return false; - GLuint dot; + GLuint dot = 0; while (s[dot] != '\0' && s[dot] != '.') dot++; if (dot == 0) return false; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index d3ec81e6f1..75147c4eb6 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -331,6 +331,74 @@ GSWnd::~GSWnd() } } +bool GSWnd::CreateContext(int major, int minor) +{ + if ( !m_XDisplay || !m_Xwindow ) + { + fprintf( stderr, "Wrong X11 display/window\n" ); + exit(1); + } + + // Get visual information + static int attrListDbl[] = + { + GLX_X_RENDERABLE , True, + GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT, + GLX_RENDER_TYPE , GLX_RGBA_BIT, + GLX_RED_SIZE , 8, + GLX_GREEN_SIZE , 8, + GLX_BLUE_SIZE , 8, + GLX_DEPTH_SIZE , 24, + GLX_DOUBLEBUFFER , True, + None + }; + + PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig"); + int fbcount = 0; + GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount); + if (!fbc || fbcount < 1) return false; + + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB"); + if (!glXCreateContextAttribsARB) return false; + + // Create a context + int context_attribs[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, major, + GLX_CONTEXT_MINOR_VERSION_ARB, minor, + // FIXME : Request a debug context to ease opengl development + // Note: don't support deprecated feature (pre openg 3.1) + //GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + None + }; + + m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); + if (!m_context) return false; + + XSync( m_XDisplay, false); +} + +void GSWnd::AttachContext() +{ + glXMakeCurrent(m_XDisplay, m_Xwindow, m_context); +} + +void GSWnd::DetachContext() +{ + glXMakeCurrent(m_XDisplay, None, NULL); +} + +void GSWnd::CheckContext() +{ + int glxMajorVersion, glxMinorVersion; + glXQueryVersion(m_XDisplay, &glxMajorVersion, &glxMinorVersion); + if (glXIsDirect(m_XDisplay, m_context)) + fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion); + else + fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It will be slow\n", glxMajorVersion, glxMinorVersion); +} + bool GSWnd::Attach(void* handle, bool managed) { m_Xwindow = *(Window*)handle; @@ -340,60 +408,12 @@ bool GSWnd::Attach(void* handle, bool managed) if (m_renderer != 2) { m_XDisplay = XOpenDisplay(NULL); - if ( !m_XDisplay ) - { - fprintf( stderr, "Failed to open X display\n" ); - exit(1); - } - - // Get visual information - static int attrListDbl[] = - { - GLX_X_RENDERABLE , True, - GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT, - GLX_RENDER_TYPE , GLX_RGBA_BIT, - GLX_RED_SIZE , 8, - GLX_GREEN_SIZE , 8, - GLX_BLUE_SIZE , 8, - GLX_DEPTH_SIZE , 24, - GLX_DOUBLEBUFFER , True, - None - }; - - PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig"); - int fbcount = 0; - GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount); - if (!fbc || fbcount < 1) return false; + // Note: 4.2 crash on latest nvidia drivers! + if (!CreateContext(3, 3)) return false; - PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB"); - if (!glXCreateContextAttribsARB) return false; - - // Create a context - int context_attribs[] = - { - GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - // Note: 4.2 crash on latest nvidia drivers! - GLX_CONTEXT_MINOR_VERSION_ARB, 3, - // FIXME : Request a debug context to ease opengl development - // Note: don't support deprecated feature (pre openg 3.1) - //GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, - None - }; - m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); - XSync( m_XDisplay, false); - - if (!m_context) return false; - glXMakeCurrent(m_XDisplay, m_Xwindow, m_context); - - // Check the status - int glxMajorVersion, glxMinorVersion; - glXQueryVersion(m_XDisplay, &glxMajorVersion, &glxMinorVersion); - if (glXIsDirect(m_XDisplay, m_context)) - fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion); - else - fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It will be slow\n", glxMajorVersion, glxMinorVersion); + AttachContext(); + CheckContext(); } return true; @@ -412,7 +432,7 @@ void GSWnd::Detach() } #endif } else { - glXMakeCurrent(m_XDisplay, None, NULL); + DetachContext(); if (m_context) glXDestroyContext(m_XDisplay, m_context); } if (m_XDisplay) { @@ -462,7 +482,43 @@ bool GSWnd::Create(const string& title, int w, int h) return (m_window != NULL); #else - return false; + + // note this part must be only executed when replaying .gs debug file + m_managed = true; + + m_XDisplay = XOpenDisplay(NULL); + + int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_DEPTH_SIZE, 24, + None + }; + XVisualInfo* vi = glXChooseVisual(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl); + + /* create a color map */ + XSetWindowAttributes attr; + attr.colormap = XCreateColormap(m_XDisplay, RootWindow(m_XDisplay, vi->screen), + vi->visual, AllocNone); + attr.border_pixel = 0; + attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | + StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | + EnterWindowMask | LeaveWindowMask | FocusChangeMask ; + + // Create a window at the last position/size + m_Xwindow = XCreateWindow(m_XDisplay, RootWindow(m_XDisplay, vi->screen), + 0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask, &attr); + + XMapWindow (m_XDisplay, m_Xwindow); + XFree(vi); + + if (!CreateContext(3, 3)) return false; + + AttachContext(); + + return (m_Xwindow != 0); #endif } @@ -480,7 +536,8 @@ Display* GSWnd::GetDisplay() return wminfo.subsystem == SDL_SYSWM_X11 ? wminfo.info.x11.display : NULL; #else - return NULL; + // note this part must be only executed when replaying .gs debug file + return m_XDisplay; #endif } diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index 6e85a3aef5..6e2967fad0 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -100,8 +100,9 @@ class GSWnd #else void* m_window; #endif - Window m_Xwindow; - Display* m_XDisplay; + Window m_Xwindow; + Display* m_XDisplay; + bool m_managed; int m_renderer; GLXContext m_context; @@ -123,6 +124,11 @@ public: void SetWindow(SDL_Window* current_window) { if (current_window) m_window = current_window; } #endif + bool CreateContext(int major, int minor); + void AttachContext(); + void DetachContext(); + void CheckContext(); + void Show(); void Hide(); void HideFrame(); diff --git a/plugins/GSdx/linux_replay.cpp b/plugins/GSdx/linux_replay.cpp new file mode 100644 index 0000000000..f2d25ab8c9 --- /dev/null +++ b/plugins/GSdx/linux_replay.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 20011-2012 Hainaut gregory + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "stdafx.h" + +EXPORT_C GSsetSettingsDir(const char* dir); +EXPORT_C GSReplay(char* lpszCmdLine, int renderer); + + +void help() +{ + fprintf(stderr, "Loader gs file\n"); + fprintf(stderr, "ARG1 Ini directory\n"); + fprintf(stderr, "ARG2 .gs file\n"); + exit(1); +} + +int main ( int argc, char *argv[] ) +{ + if ( argc != 3 ) help(); + + GSsetSettingsDir(argv[1]); + GSReplay(argv[2], 12); +} From 657da538de9824b51c1e59490e5895ca289763de Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 6 Jan 2012 22:51:05 +0000 Subject: [PATCH 35/56] gsdx-ogl: was too shaky after all! git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5053 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 4 +++- plugins/GSdx/GS.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index ebb5585f4b..70e3262bcf 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -192,7 +192,6 @@ add_executable(${Replay} linux_replay.cpp) target_link_libraries(${Output} ${X11_LIBRARIES}) target_link_libraries(${Output} ${GLEW_LIBRARY}) target_link_libraries(${Output} ${OPENGL_LIBRARIES}) - if(projectSDL) target_link_libraries(${Output} ${SDL_LIBRARY}) endif(projectSDL) @@ -202,6 +201,9 @@ target_link_libraries(${Replay} ${X11_LIBRARIES}) target_link_libraries(${Replay} ${GLEW_LIBRARY}) target_link_libraries(${Replay} ${GTK2_LIBRARIES}) target_link_libraries(${Replay} ${Static}) +if(projectSDL) + target_link_libraries(${Replay} ${SDL_LIBRARY}) +endif(projectSDL) if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 7133ae4280..bb5a8c5b4b 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1205,7 +1205,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) packets.push_back(p); } - sleep(30); + sleep(10); // FIXME too slow :p // sleep(100); From 545df08ecc28bd79b91f83767bd2aaed95450686 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 7 Jan 2012 12:28:29 +0000 Subject: [PATCH 36/56] gsdx-ogl: Add a Native Resolution checkmark to the dialog box. Set a default for ModHeight & ModeWidth when saving the ini file. Link the gdsx static library against a few things. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5054 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 7 +++++++ plugins/GSdx/GSLinuxDialog.cpp | 29 ++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 70e3262bcf..f8484c1982 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -205,6 +205,13 @@ if(projectSDL) target_link_libraries(${Replay} ${SDL_LIBRARY}) endif(projectSDL) +target_link_libraries(${Static} ${OPENGL_LIBRARIES}) +target_link_libraries(${Static} ${X11_LIBRARIES}) +target_link_libraries(${Static} ${GLEW_LIBRARY}) +target_link_libraries(${Static} ${GTK2_LIBRARIES}) +if(projectSDL) + target_link_libraries(${Static} ${SDL_LIBRARY}) +endif(projectSDL) if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}") diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index ed51704800..bcd82628ad 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -47,7 +47,7 @@ bool RunLinuxDialog() GtkWidget *render_label, *render_combo_box; GtkWidget *interlace_label, *interlace_combo_box; GtkWidget *swthreads_label, *swthreads_text; - GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *win_check, *msaa_check; + GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *win_check, *msaa_check, *native_res_check; int return_value; /* Create the widgets */ @@ -134,7 +134,8 @@ bool RunLinuxDialog() aa_check = gtk_check_button_new_with_label("Edge anti-aliasing"); win_check = gtk_check_button_new_with_label("Disable Effects Processing"); msaa_check = gtk_check_button_new_with_label("Enable MultiSample AA (not yet implemented)"); - + native_res_check = gtk_check_button_new_with_label("Native Resolution"); + gtk_container_add(GTK_CONTAINER(main_box), filter_check); gtk_container_add(GTK_CONTAINER(main_box), logz_check); gtk_container_add(GTK_CONTAINER(main_box), paltex_check); @@ -142,6 +143,7 @@ bool RunLinuxDialog() gtk_container_add(GTK_CONTAINER(main_box), aa_check); gtk_container_add(GTK_CONTAINER(main_box), win_check); gtk_container_add(GTK_CONTAINER(main_box), msaa_check); + gtk_container_add(GTK_CONTAINER(main_box), native_res_check); // Filter should be 3 states, not 2. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filter_check), theApp.GetConfig("filter", 1)); @@ -151,6 +153,7 @@ bool RunLinuxDialog() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win_check), theApp.GetConfig("windowed", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msaa_check), theApp.GetConfig("msaa", 0)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0)); gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); gtk_widget_show_all (dialog); @@ -159,6 +162,13 @@ bool RunLinuxDialog() if (return_value == GTK_RESPONSE_ACCEPT) { + int mode_height = 0, mode_width = 0; + + mode_width = theApp.GetConfig("ModeWidth", 640); + mode_height = theApp.GetConfig("ModeHeight", 480); + theApp.SetConfig("ModeHeight", mode_height); + theApp.SetConfig("ModeWidth", mode_width); + // Get all the settings from the dialog box. if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) { // FIXME test current opengl version supported through glxinfo (OpenGL version string:) @@ -180,13 +190,14 @@ bool RunLinuxDialog() theApp.SetConfig("extrathreads", atoi((char*)gtk_entry_get_text(GTK_ENTRY(swthreads_text))) ); - theApp.SetConfig("filter", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_check))); - theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check))); - theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check))); - theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); - theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); - theApp.SetConfig("windowed", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win_check))); - theApp.SetConfig("msaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msaa_check))); + theApp.SetConfig("filter", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_check))); + theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check))); + theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check))); + theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); + theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); + theApp.SetConfig("windowed", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win_check))); + theApp.SetConfig("msaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msaa_check))); + theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check))); gtk_widget_destroy (dialog); From 9de050a51ff569bc56e485279020797eb1446604 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 7 Jan 2012 22:20:50 +0000 Subject: [PATCH 37/56] gsdx-ogl: Revise build.sh script, redoing the command line options. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5055 96395faa-99c1-11dd-bbfe-3dabce05a288 --- build.sh | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/build.sh b/build.sh index a8aa0fd25e..9027f7bc16 100755 --- a/build.sh +++ b/build.sh @@ -4,23 +4,38 @@ flags="" args="$@" clean_build=false -for f in $args; do - if [ "$f" = "gsdx" ] ; then - flags="$flags -DFORCE_INTERNAL_SDL=TRUE" - fi - if [ "$f" = "dev" ] ; then - flags="$flags -DCMAKE_BUILD_TYPE=Devel" - fi - if [ "$f" = "debug" ] ; then - flags="$flags -DCMAKE_BUILD_TYPE=Debug" - fi - if [ "$f" = "release" ] ; then - flags="$flags -DCMAKE_BUILD_TYPE=Release" - fi - if [ "$f" = "clean" ] ; then - clean_build=true - fi -done +for f in $* +do + case $f in + --sdl13) + flags="$flags -DFORCE_INTERNAL_SDL=TRUE" + ;; + --dev) + flags="$flags -DCMAKE_BUILD_TYPE=Devel" + ;; + --devel) + flags="$flags -DCMAKE_BUILD_TYPE=Devel" + ;; + --debug) + flags="$flags -DCMAKE_BUILD_TYPE=Debug" + ;; + --release) + flags="$flags -DCMAKE_BUILD_TYPE=Release" + ;; + --clean) + clean_build=true + ;; + *) + # unknown option + echo "Valid options are:" + echo "--dev / --devel - Build pcsx2 as a Development build." + echo "--debug - Build pcsx2 as a Debug build." + echo "--release - Build pcsx2 as a Release build." + echo "--clean - Do a clean build." + echo "--sdl13 - Use the internal copy of sdl (needed for gsdx to use sdl)." + exit 1;; + esac +done rm install_log.txt From 27de4b086dab12ee30e7113f7dcfbdb012870855 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 8 Jan 2012 01:18:23 +0000 Subject: [PATCH 38/56] gsdx-ogl: Remodel the linux dialog box to make it look better. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5056 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSLinuxDialog.cpp | 173 +++++++++++++++++++++------------ 1 file changed, 112 insertions(+), 61 deletions(-) diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index bcd82628ad..b25b230f9e 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -40,32 +40,11 @@ static void SysMessage(const char *fmt, ...) gtk_widget_destroy (dialog); } -bool RunLinuxDialog() +GtkWidget* CreateRenderComboBox() { - GtkWidget *dialog; - GtkWidget *main_frame, *main_box; - GtkWidget *render_label, *render_combo_box; - GtkWidget *interlace_label, *interlace_combo_box; - GtkWidget *swthreads_label, *swthreads_text; - GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *win_check, *msaa_check, *native_res_check; - int return_value; - - /* Create the widgets */ - dialog = gtk_dialog_new_with_buttons ( - "GSdx Config", - NULL, /* parent window*/ - (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, - NULL); - - main_box = gtk_vbox_new(false, 5); - main_frame = gtk_frame_new ("GSdx Config"); - gtk_container_add (GTK_CONTAINER(main_frame), main_box); - - render_label = gtk_label_new ("Renderer:"); + GtkWidget *render_combo_box; + int renderer_box_position = 0; + render_combo_box = gtk_combo_box_new_text (); for(size_t i = 6; i < theApp.m_gs_renderers.size(); i++) @@ -84,7 +63,6 @@ bool RunLinuxDialog() gtk_combo_box_append_text(GTK_COMBO_BOX(render_combo_box), label.c_str()); } - int renderer_box_position = 0; switch (theApp.GetConfig("renderer", 0)) { // Note the value are based on m_gs_renderers vector on GSdx.cpp case 7 : renderer_box_position = 0; break; @@ -94,12 +72,13 @@ bool RunLinuxDialog() case 12: renderer_box_position = 4; break; case 13: renderer_box_position = 5; break; } - gtk_combo_box_set_active(GTK_COMBO_BOX(render_combo_box), renderer_box_position ); - gtk_container_add(GTK_CONTAINER(main_box), render_label); - gtk_container_add(GTK_CONTAINER(main_box), render_combo_box); + gtk_combo_box_set_active(GTK_COMBO_BOX(render_combo_box), renderer_box_position); + return render_combo_box; +} - - interlace_label = gtk_label_new ("Interlace:"); +GtkWidget* CreateInterlaceComboBox() +{ + GtkWidget *interlace_combo_box; interlace_combo_box = gtk_combo_box_new_text (); for(size_t i = 0; i < theApp.m_gs_interlace.size(); i++) @@ -114,50 +93,121 @@ bool RunLinuxDialog() } gtk_combo_box_set_active(GTK_COMBO_BOX(interlace_combo_box), theApp.GetConfig("interlace", 0)); - gtk_container_add(GTK_CONTAINER(main_box), interlace_label); - gtk_container_add(GTK_CONTAINER(main_box), interlace_combo_box); + return interlace_combo_box; +} - swthreads_label = gtk_label_new("Extra sw renderer threads:"); - swthreads_text = gtk_entry_new(); - char buf[5]; - sprintf(buf, "%d", theApp.GetConfig("extrathreads", 0)); +bool RunLinuxDialog() +{ + GtkWidget *dialog; + + GtkWidget *main_box, *res_box, *hw_box, *sw_box; + GtkWidget *res_frame, *hw_frame, *sw_frame; + GtkWidget *render_label, *render_combo_box; + GtkWidget *interlace_label, *interlace_combo_box; + GtkWidget *threads_label, *threads_spin; + GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check, *native_label, *native_box; + GtkWidget *hw_table, *renderer_box, *interlace_box, *threads_box; + int return_value; - gtk_entry_set_text(GTK_ENTRY(swthreads_text), buf); - gtk_container_add(GTK_CONTAINER(main_box), swthreads_label); - gtk_container_add(GTK_CONTAINER(main_box), swthreads_text); + /* Create the widgets */ + dialog = gtk_dialog_new_with_buttons ( + "GSdx Config", + NULL, /* parent window*/ + (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + NULL); + // The main area for the whole dialog box. + main_box = gtk_vbox_new(false, 5); + + // The Internal resolution frame and container. + res_box = gtk_vbox_new(false, 5); + res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)"); + gtk_container_add(GTK_CONTAINER(res_frame), res_box); + + // The hardware mode frame, container, and table. + hw_box = gtk_vbox_new(false, 5); + hw_frame = gtk_frame_new ("Hardware Mode Settings"); + gtk_container_add(GTK_CONTAINER(hw_frame), hw_box); + hw_table = gtk_table_new(2,2, false); + gtk_container_add(GTK_CONTAINER(hw_box), hw_table); + + // The software mode frame and container. (It doesn't have enough in it for a table.) + sw_box = gtk_vbox_new(false, 5); + sw_frame = gtk_frame_new ("Software Mode Settings"); + gtk_container_add(GTK_CONTAINER(sw_frame), sw_box); + + // Create the renderer combo box and label, and stash them in a box. + render_label = gtk_label_new ("Renderer:"); + render_combo_box = CreateRenderComboBox(); + renderer_box = gtk_hbox_new(false, 5); + // Use gtk_box_pack_start instead of gtk_container_add so it lines up nicely. + gtk_box_pack_start(GTK_BOX(renderer_box), render_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(renderer_box), render_combo_box, false, false, 5); + + // Create the interlace combo box and label, and stash them in a box. + interlace_label = gtk_label_new ("Interlacing (F5):"); + interlace_combo_box = CreateInterlaceComboBox(); + interlace_box = gtk_hbox_new(false, 5); + gtk_box_pack_start(GTK_BOX(interlace_box), interlace_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(interlace_box), interlace_combo_box, false, false, 5); + // Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.) + threads_label = gtk_label_new("Extra rendering threads:"); + threads_spin = gtk_spin_button_new_with_range(0,100,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(threads_spin), theApp.GetConfig("extrathreads", 0)); + threads_box = gtk_hbox_new(false, 0); + gtk_box_pack_start(GTK_BOX(threads_box), threads_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(threads_box), threads_spin, false, false, 5); + + // A bit of funkiness for the resolution box. + native_label = gtk_label_new("Original PS2 Resolution: "); + native_res_check = gtk_check_button_new_with_label("Native"); + native_box = gtk_hbox_new(false, 5); + gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5); + + // Create our checkboxes. filter_check = gtk_check_button_new_with_label("Texture Filtering"); logz_check = gtk_check_button_new_with_label("Logarithmic Z"); paltex_check = gtk_check_button_new_with_label("Allow 8 bit textures"); fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)"); aa_check = gtk_check_button_new_with_label("Edge anti-aliasing"); - win_check = gtk_check_button_new_with_label("Disable Effects Processing"); - msaa_check = gtk_check_button_new_with_label("Enable MultiSample AA (not yet implemented)"); - native_res_check = gtk_check_button_new_with_label("Native Resolution"); - gtk_container_add(GTK_CONTAINER(main_box), filter_check); - gtk_container_add(GTK_CONTAINER(main_box), logz_check); - gtk_container_add(GTK_CONTAINER(main_box), paltex_check); - gtk_container_add(GTK_CONTAINER(main_box), fba_check); - gtk_container_add(GTK_CONTAINER(main_box), aa_check); - gtk_container_add(GTK_CONTAINER(main_box), win_check); - gtk_container_add(GTK_CONTAINER(main_box), msaa_check); - gtk_container_add(GTK_CONTAINER(main_box), native_res_check); - - // Filter should be 3 states, not 2. + // Set the checkboxes. + // Filter should have 3 states, not 2. gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filter_check), theApp.GetConfig("filter", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(logz_check), theApp.GetConfig("logz", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win_check), theApp.GetConfig("windowed", 1)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msaa_check), theApp.GetConfig("msaa", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0)); + + // Populate all those boxes we created earlier with widgets. + gtk_container_add(GTK_CONTAINER(res_box), native_box); + + gtk_container_add(GTK_CONTAINER(sw_box), threads_box); + gtk_container_add(GTK_CONTAINER(sw_box), aa_check); + + // Tables are strange. The numbers are for their position: left, right, top, bottom. + gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_check, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(hw_table), logz_check, 1, 2, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2); + + // Put everything in the big box. + gtk_container_add(GTK_CONTAINER(main_box), renderer_box); + gtk_container_add(GTK_CONTAINER(main_box), interlace_box); + gtk_container_add(GTK_CONTAINER(main_box), res_frame); + gtk_container_add(GTK_CONTAINER(main_box), hw_frame); + gtk_container_add(GTK_CONTAINER(main_box), sw_frame); - gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); + // Put the box in the dialog and show it to the world. + gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box); gtk_widget_show_all (dialog); - return_value = gtk_dialog_run (GTK_DIALOG (dialog)); if (return_value == GTK_RESPONSE_ACCEPT) @@ -187,17 +237,18 @@ bool RunLinuxDialog() if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1) theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) ); - - theApp.SetConfig("extrathreads", atoi((char*)gtk_entry_get_text(GTK_ENTRY(swthreads_text))) ); + theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin))); theApp.SetConfig("filter", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_check))); theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check))); theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check))); theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); - theApp.SetConfig("windowed", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win_check))); - theApp.SetConfig("msaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msaa_check))); theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check))); + + //These aren't actually shown in the windows version, so I'll take them out of the dialog for the moment. + theApp.SetConfig("windowed", 1); + theApp.SetConfig("msaa", 0); gtk_widget_destroy (dialog); From abd99c00f088408080e299afdb876d60a0d41b80 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 8 Jan 2012 02:32:56 +0000 Subject: [PATCH 39/56] gsdx-ogl: Add msaa controls. (Probably doesn't actually do anything at the moment.) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5057 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSLinuxDialog.cpp | 48 +++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index b25b230f9e..344232b088 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -96,6 +96,23 @@ GtkWidget* CreateInterlaceComboBox() return interlace_combo_box; } +GtkWidget* CreateMsaaComboBox() +{ + GtkWidget *msaa_combo_box; + msaa_combo_box = gtk_combo_box_new_text (); + + // For now, let's just put in the same vaues that show up in the windows combo box. + gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "Custom"); + gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "2x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "3x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "4x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "5x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "6x"); + + gtk_combo_box_set_active(GTK_COMBO_BOX(msaa_combo_box), theApp.GetConfig("msaa", 0)); + return msaa_combo_box; +} + bool RunLinuxDialog() { GtkWidget *dialog; @@ -105,7 +122,8 @@ bool RunLinuxDialog() GtkWidget *render_label, *render_combo_box; GtkWidget *interlace_label, *interlace_combo_box; GtkWidget *threads_label, *threads_spin; - GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check, *native_label, *native_box; + GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; + GtkWidget *native_label, *native_box, *msaa_label, *msaa_combo_box, *msaa_box, *rexy_label, *resx_spin, *resy_spin, *resxy_box; GtkWidget *hw_table, *renderer_box, *interlace_box, *threads_box; int return_value; @@ -170,6 +188,23 @@ bool RunLinuxDialog() gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5); gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5); + msaa_label = gtk_label_new("Or Use Scaling (broken):"); + msaa_combo_box = CreateMsaaComboBox(); + msaa_box = gtk_hbox_new(false, 5); + gtk_box_pack_start(GTK_BOX(msaa_box), msaa_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(msaa_box), msaa_combo_box, false, false, 5); + + rexy_label = gtk_label_new("Custom Resolution:"); + resx_spin = gtk_spin_button_new_with_range(256,8192,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(resx_spin), theApp.GetConfig("resx", 1024)); + resy_spin = gtk_spin_button_new_with_range(256,8192,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(resy_spin), theApp.GetConfig("resy", 1024)); + resxy_box = gtk_hbox_new(false, 5); + gtk_box_pack_start(GTK_BOX(resxy_box), rexy_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5); + gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5); + + // Create our checkboxes. filter_check = gtk_check_button_new_with_label("Texture Filtering"); logz_check = gtk_check_button_new_with_label("Logarithmic Z"); @@ -188,6 +223,8 @@ bool RunLinuxDialog() // Populate all those boxes we created earlier with widgets. gtk_container_add(GTK_CONTAINER(res_box), native_box); + gtk_container_add(GTK_CONTAINER(res_box), msaa_box); + gtk_container_add(GTK_CONTAINER(res_box), resxy_box); gtk_container_add(GTK_CONTAINER(sw_box), threads_box); gtk_container_add(GTK_CONTAINER(sw_box), aa_check); @@ -235,7 +272,7 @@ bool RunLinuxDialog() } if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1) - theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) ); + theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box))); theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin))); @@ -246,9 +283,12 @@ bool RunLinuxDialog() theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check))); - //These aren't actually shown in the windows version, so I'll take them out of the dialog for the moment. + theApp.SetConfig("msaa", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(msaa_combo_box))); + theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin))); + theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin))); + + // Let's just be windowed for the moment. theApp.SetConfig("windowed", 1); - theApp.SetConfig("msaa", 0); gtk_widget_destroy (dialog); From 009f6e2dcbf5f9b6b9136c8738302682e990088d Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 8 Jan 2012 03:52:58 +0000 Subject: [PATCH 40/56] gsdx-ogl: Things now disable and reenable when appropriate. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5058 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSLinuxDialog.cpp | 75 +++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 344232b088..8f0cda87ef 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -113,18 +113,70 @@ GtkWidget* CreateMsaaComboBox() return msaa_combo_box; } +GtkWidget *render_combo_box; +GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; +GtkWidget *msaa_combo_box, *resx_spin, *resy_spin; + +void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) +{ + int render_type; + bool hardware_render = false, software_render = false, sdl_render = false, null_render = false; + + render_type = gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)); + hardware_render = (render_type == 1 || render_type == 4 || render_type == 7 || render_type == 13); + + if (hardware_render) + { + gtk_widget_set_sensitive(filter_check, true); + gtk_widget_set_sensitive(logz_check, true); + gtk_widget_set_sensitive(paltex_check, true); + gtk_widget_set_sensitive(fba_check, true); + gtk_widget_set_sensitive(native_res_check, true); + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check))) + { + gtk_widget_set_sensitive(msaa_combo_box, false); + gtk_widget_set_sensitive(resx_spin, false); + gtk_widget_set_sensitive(resy_spin, false); + } + else + { + gtk_widget_set_sensitive(msaa_combo_box, true); + + if (gtk_combo_box_get_active(GTK_COMBO_BOX(msaa_combo_box)) == 0) + { + gtk_widget_set_sensitive(resx_spin, true); + gtk_widget_set_sensitive(resy_spin, true); + } + else + { + gtk_widget_set_sensitive(resx_spin, false); + gtk_widget_set_sensitive(resy_spin, false); + } + } + } + else + { + gtk_widget_set_sensitive(filter_check, false); + gtk_widget_set_sensitive(logz_check, false); + gtk_widget_set_sensitive(paltex_check, false); + gtk_widget_set_sensitive(fba_check, false); + + gtk_widget_set_sensitive(native_res_check, false); + gtk_widget_set_sensitive(msaa_combo_box, false); + gtk_widget_set_sensitive(resx_spin, false); + gtk_widget_set_sensitive(resy_spin, false); + } +} + bool RunLinuxDialog() { GtkWidget *dialog; - GtkWidget *main_box, *res_box, *hw_box, *sw_box; - GtkWidget *res_frame, *hw_frame, *sw_frame; - GtkWidget *render_label, *render_combo_box; - GtkWidget *interlace_label, *interlace_combo_box; - GtkWidget *threads_label, *threads_spin; - GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; - GtkWidget *native_label, *native_box, *msaa_label, *msaa_combo_box, *msaa_box, *rexy_label, *resx_spin, *resy_spin, *resxy_box; - GtkWidget *hw_table, *renderer_box, *interlace_box, *threads_box; + GtkWidget *native_box, *msaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box; + GtkWidget *hw_table, *res_frame, *hw_frame, *sw_frame; + GtkWidget *interlace_combo_box, *threads_spin; + GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label; int return_value; /* Create the widgets */ @@ -204,13 +256,12 @@ bool RunLinuxDialog() gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5); - // Create our checkboxes. filter_check = gtk_check_button_new_with_label("Texture Filtering"); logz_check = gtk_check_button_new_with_label("Logarithmic Z"); paltex_check = gtk_check_button_new_with_label("Allow 8 bit textures"); fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)"); - aa_check = gtk_check_button_new_with_label("Edge anti-aliasing"); + aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)"); // Set the checkboxes. // Filter should have 3 states, not 2. @@ -242,9 +293,13 @@ bool RunLinuxDialog() gtk_container_add(GTK_CONTAINER(main_box), hw_frame); gtk_container_add(GTK_CONTAINER(main_box), sw_frame); + g_signal_connect(render_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL); + g_signal_connect(msaa_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL); + g_signal_connect(native_res_check, "toggled", G_CALLBACK(toggle_widget_states), NULL); // Put the box in the dialog and show it to the world. gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box); gtk_widget_show_all (dialog); + toggle_widget_states(NULL, NULL); return_value = gtk_dialog_run (GTK_DIALOG (dialog)); if (return_value == GTK_RESPONSE_ACCEPT) From 8bb44cfcac0f4c86747719688024cf963a14bb89 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 8 Jan 2012 04:59:29 +0000 Subject: [PATCH 41/56] gsdx-ogl: All the Windows versions get a fancy logo on top, so... git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5059 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 1 + plugins/GSdx/GSLinuxDialog.cpp | 12 +- plugins/GSdx/GSLinuxLogo.h | 2649 ++++++++++++++++++++++++++++++++ plugins/GSdx/res/logo-ogl.bmp | Bin 0 -> 74462 bytes 4 files changed, 2661 insertions(+), 1 deletion(-) create mode 100644 plugins/GSdx/GSLinuxLogo.h create mode 100644 plugins/GSdx/res/logo-ogl.bmp diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index f8484c1982..37658aef3d 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -146,6 +146,7 @@ set(GSdxHeaders GSDrawingEnvironment.h GSDump.h GSFunctionMap.h + GSLinuxLogo.h GSLocalMemory.h GSPerfMon.h GSRasterizer.h diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 8f0cda87ef..1837fffb19 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include #include "GSdx.h" +#include "GSLinuxLogo.h" static void SysMessage(const char *fmt, ...) { @@ -178,7 +179,10 @@ bool RunLinuxDialog() GtkWidget *interlace_combo_box, *threads_spin; GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label; int return_value; - + + GdkPixbuf* logo_pixmap; + GtkWidget *logo_image; + /* Create the widgets */ dialog = gtk_dialog_new_with_buttons ( "GSdx Config", @@ -210,6 +214,12 @@ bool RunLinuxDialog() sw_frame = gtk_frame_new ("Software Mode Settings"); gtk_container_add(GTK_CONTAINER(sw_frame), sw_box); + // Grab a logo, to make things look nice. + logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL); + logo_image = gtk_image_new_from_pixbuf(logo_pixmap); + //gtk_container_add(GTK_CONTAINER(main_box), logo_image); + gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0); + // Create the renderer combo box and label, and stash them in a box. render_label = gtk_label_new ("Renderer:"); render_combo_box = CreateRenderComboBox(); diff --git a/plugins/GSdx/GSLinuxLogo.h b/plugins/GSdx/GSLinuxLogo.h new file mode 100644 index 0000000000..1f976d4320 --- /dev/null +++ b/plugins/GSdx/GSLinuxLogo.h @@ -0,0 +1,2649 @@ +/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */ + +#include + +static const GdkPixdata gsdx_ogl_logo = { + 0x47646b50, /* Pixbuf magic: 'GdkP' */ + 24 + 71939, /* header length + pixel_data length */ + 0x2010002, /* pixdata_type */ + 1048, /* rowstride */ + 262, /* width */ + 71, /* height */ + /* pixel_data: */ + (unsigned char*)"\177\306M\223\377\322H\237\377\310E\227\377\303=\222\377\2513\200\377" + "\2521o\377\241)j\377\257&f\377\256*g\377\242(u\377\245\37g\377\244%l" + "\377\254/e\377\244\37`\377\2261c\377\217+e\377\2468i\377\2516q\377\225" + "@v\377\2216{\377\232,z\377\2328z\377\216.t\377\2200v\377\216/s\377\205" + "7v\377|-s\377|;a\377v,i\377\204*o\377~5v\377r-x\377\2031\204\377}6\177" + "\377z:}\377|\203\377cB\201\377r0t\377o6r\377" + "`D\205\377gA\205\377[\77\205\377^E}\377PFw\377U<\203\377W/\205\377L&" + "}\377\77$o\377\77/z\377H0t\377R(w\377R)v\377F0y\377L+k\377F0~\377D.\215" + "\377@+\204\377@7\210\37789\201\3776D{\377\216\377*C\227\377\35<\231\377#2\210\377'$z\377$" + "5~\37734\200\377>4\225\377A1\221\377@+\230\377<3\231\377:8\244\377A6" + "\243\37785\224\377G1\227\377>%\244\377=(\236\3776,\232\3771\36\243\377" + "2\30\224\3778\11\226\377\77\17\241\377@\35\222\3770\22\233\377/\23\234" + "\377-\32\242\3776\31\247\3771\16\246\3771\15\227\377/\22\234\377>\22" + "\232\3776\1\214\377A\0\214\377;\20\220\377C\14}\3779\5\210\3775\17}\377" + ":\10\204\377N\5\225\377D\0\204\377R\0\210\377^\2\215\377T\0\217\377S" + "\4\235\377Y\12\234\377T\14\216\377T\26\215\377R\23\226\377L\23\213\377" + "S\13\225\377Y\33\230\377S\3\214\377G\23\210\377J\33\204\377O\32\202\377" + "P\0v\377V\0p\377D\0m\377V\0q\377G\6}\377V\0j\377X\6w\377Y\20i\377K\1" + "r\377R\0{\377T\6l\377O\0m\377V\3x\377Z\14x\377S\11\211\377F\13\216\377" + "J\3\214\377Q\31\217\377R\40\231\377V*\241\377i\35\243\377Z/\242\377[" + "&\243\377Q)\254\377[&\252\377W1\252\377e+\240\377_4\244\377`0\250\377" + "]$\257\377g-\261\377e)\267\377c/\300\377j$\260\377k:\262\377sE\306\377" + "jK\273\377u\77\301\377pL\273\377zF\303\377mE\310\377r=\305\377x5\311" + "\377\177B\302\377\207/\313\377\2067\301\377x4\317\377\202>\322\377\201" + "+\311\377\1776\333\377\1778\324\377};\317\377\2029\317\377\2217\317\377" + "\2041\314\377\204>\306\377\203=\323\377\2160\324\377\231=\321\377\234" + "B\302\377\234>\327\377\246C\316\377\237%\337\377\2270\341\377\230\77" + "\352\377\245\77\355\377s\250L\345\377\262R\335\377\257S\353\377\255K" + "\344\377\253<\332\377\2110\265\377g\12\244\377:\0\200\377\2760\216\377" + "\311B\202\377\263C{\377\231\37k\377\177\2O\377q\0""8\377k\0""3\377e\0" + "6\377\\\0%\377[\0""2\377`\0\34\377]\0\36\377V\0#\377\\\0%\377X\0%\377" + "O\0#\377U\0!\377K\0%\377T\0""3\377Q\0+\377O\0*\377Q\0""1\377@\0\40\377" + "F\0\40\3775\0*\377.\0.\3771\0\37\377A\0\32\377:\0\"\3774\0""9\3772\0" + "@\377-\0@\3770\0E\377F\0B\377.\6-\3771\5.\377A\0.\377A\0B\377=\17C\377" + "<\4A\377=\13=\377I\22;\377F\11\77\377M\0""7\377E\11K\377C\15A\377P\13" + "3\377J\23""9\377E\24""2\377I\11""8\377M\4+\377>\2.\377J\0-\377M\0>\377" + "B\0<\377<\0D\3773\3A\377A\10I\377C\7""5\377<\7-\377N\11""2\377H\0""4" + "\377G\0&\377F\0""7\377D\0\77\377I\0""8\377<\0'\377M\0""4\377C\0:\377" + "6\0I\377A\0:\377N\0M\377A\0L\3779\0E\377F\0I\3777\0O\377/\0I\377;\0[" + "\377:\0Z\3776\0L\377.\0O\377.\2G\3771\0N\377'\2R\377-\0N\377\37\0I\377" + "\27\0E\377%\10:\377\33\10""9\377#\0<\377&\3H\377!\11A\377\"\0""1\377" + "\36\0#\377\31\6""2\377\12\5""4\377\34\4@\377\34\2C\377\21\3G\377\20\0" + "B\377\25\0;\377\16\0""2\377\20\0""2\377\13\0:\377\1\0""0\377\0\0""4\377" + "\0\0""9\377\202\0\0<\377'\0\0""1\377\1\0""7\377\0\0C\377\0\0E\377\0\0" + "8\377\2\0\77\377\0\0""8\377\0\0=\377\0\0""9\377\0\11F\377\0\0T\377\0" + "\10S\377\0\12L\377\0\16R\377\0\15""4\377\0\16""9\377\0\20K\377\0\26C" + "\377\0\30O\377\0\37A\377\0\40<\377\0\20D\377\0\13A\377\0\13E\377\0\2" + "\77\377\0\0\77\377\0\1@\377\0\0""5\377\0\0""8\377\0\0""0\377\0\0""3\377" + "\0\0C\377\0\0H\377\0\0J\377\0\0H\377\0\0O\377\0\0A\377\0\0M\377\6\0S" + "\377\202\0\0S\377\2\2\0K\377\0\0S\377\202\0\0Z\377}\0\0L\377\0\0N\377" + "\0\0I\377\0\0Z\377\0\0U\377\0\0_\377\0\0P\377\0\0I\377\0\0R\377\0\0O" + "\377\0\0P\377\0\0U\377\0\0A\377\0\0N\377\0\0K\377\0\0J\377\7\0@\377\4" + "\0P\377\7\0T\377\30\0T\377\17\0M\377\16\0S\377\0\0S\377\5\0N\377\3\0" + "\77\377\1\0I\377\0\0H\377\5\0E\377\0\0E\377\12\0N\377\0\0F\377\15\0\77" + "\377\13\0*\377\23\0,\377\4\0\36\377\0\0-\377\13\0""1\377\33\0-\377\12" + "\0%\377\12\0*\377\22\0""0\377\15\0'\377\32\0/\377\15\0%\377\20\0'\377" + "\7\0""5\377\11\0""1\377\22\0:\377\10\0B\377\0\0D\377\2\0P\377\0\0N\377" + "\3\0R\377\36\0f\377\"\0a\377\35\0]\377\13\0h\377\26\0f\377\27\0d\377" + "\40\0c\377\27\0V\377\13\0`\377\25\0X\377\"\0i\377'\0y\377\36\0w\377$" + "\0x\377#\0\200\377+\0z\3771\2\203\377%\0x\3772\0\202\3776\0\204\3777" + "\12\201\377*\21\211\3778\0\224\377:\5{\377;\0{\3777\0\211\3779\4\206" + "\377I\4\215\377K\0\214\377H\0\221\377D\4\223\377J\0\217\377@\1\226\377" + "2\0}\3772\0|\377I\0\210\377=\0\214\377H\1\223\377W\0\204\377T\0\221\377" + "O\0\205\377N\0\220\377Y\0\234\377T\0\214\377T\0\215\377U\0\224\377Z\0" + "\236\377s\24\251\377~!\266\377\2154\266\377\2347\277\377\205*\306\377" + "Y\15\236\3776\0y\3777\0`\377\233$v\377\255)p\377\227\23]\377g\0<\377" + ",\0\0\3777\0\0\3771\0\0\377-\0\11\3775\0\0\3778\0\0\377)\0\0\377*\0\0" + "\377\"\0\0\377&\0\0\377/\0\0\377%\0\0\377\35\0\0\377\202\31\0\0\377\7" + "\34\0\0\377\21\0\0\377\10\0\0\377\26\0\0\377\14\0\0\377\26\0\0\377\10" + "\0\0\377\202\7\0\0\377\77\2\0\0\377\13\0\0\377\4\0\21\377\0\0\17\377" + "\2\0\7\377\5\0\2\377\0\0\0\377\10\0\0\377\0\0\10\377\0\0\17\377\0\0\27" + "\377\16\0\15\377\11\0\7\377\17\0\11\377\12\0\17\377\20\0\17\377\27\0" + "\24\377\24\0\17\377\3\0\6\377\7\0\17\377\34\0\15\377\27\0\15\377\21\0" + "\0\377\37\0\1\377\17\0\0\377!\0\11\377\22\0\4\377\17\0\25\377\27\0\1" + "\377\31\0\3\377\32\0\6\377\35\0\0\377\22\0\0\377\25\0\26\377\21\0\13" + "\377\13\0\27\377\5\0\27\377\15\0\3\377\23\0\11\377\10\0\11\377\15\0\11" + "\377\15\0\27\377\10\0\17\377\1\0$\377\22\0'\377\14\0\35\377\7\0#\377" + "\13\0\40\377\0\0\"\377\13\0\26\377\0\0\37\377\0\0\23\377\1\0\21\377\0" + "\0\17\377\0\0\"\377\0\0\35\377\0\0\21\377\0\0\16\377\0\0\23\377\0\0\4" + "\377\0\0\10\377\0\0\5\377\0\0\12\377\204\0\0\0\377\2\0\0\21\377\0\0\14" + "\377\202\0\0\0\377\2\0\0\6\377\0\0\2\377\203\0\0\0\377\3\0\0\5\377\0" + "\0\17\377\0\0\26\377\203\0\0\0\377\17\0\0\3\377\0\0\13\377\0\0\15\377" + "\0\0\5\377\0\0\14\377\0\0\11\377\0\0\20\377\0\0\25\377\0\0\27\377\0\0" + "\16\377\0\0\12\377\0\0\22\377\0\0\12\377\0\0\10\377\0\0\7\377\206\0\0" + "\0\377\2\0\0\2\377\0\0\11\377\202\0\0\0\377\2\0\0\16\377\0\0\2\377\203" + "\0\0\0\377\36\0\0\11\377\0\0\5\377\0\0\12\377\0\0\16\377\0\0\24\377\0" + "\0\27\377\0\0\31\377\0\0\23\377\0\0\32\377\0\0\20\377\0\0\24\377\0\0" + "\31\377\0\0\16\377\0\0\23\377\0\0\13\377\0\0\22\377\0\0\27\377\0\0'\377" + "\0\0\24\377\0\0\33\377\0\0\31\377\0\0\21\377\0\0\24\377\0\0\36\377\0" + "\0\27\377\0\0\36\377\0\0\32\377\0\0\10\377\0\0\21\377\0\0\20\377\202" + "\0\0\17\377\12\0\0\15\377\0\0\30\377\0\0\36\377\0\0\22\377\0\0\17\377" + "\0\0\20\377\0\0\"\377\0\0\26\377\0\0\10\377\0\0\16\377\202\0\0\21\377" + "\3\0\0\2\377\0\0\17\377\0\0\3\377\214\0\0\0\377\11\0\0\4\377\0\0\20\377" + "\0\0\12\377\0\0\21\377\0\0\32\377\0\0\27\377\0\0'\377\0\0\40\377\0\0" + "\34\377\202\0\0)\377\177\0\0'\377\0\0""4\377\0\0+\377\0\0-\377\0\0/\377" + "\0\0(\377\0\0""1\377\0\0""6\377\0\0G\377\0\0I\377\0\0>\377\0\0N\377\0" + "\0U\377\0\0M\377\0\0O\377\0\0Q\377\0\0O\377\7\0T\377\4\0M\377\4\0V\377" + "\13\0V\377\17\0N\377\17\0M\377\21\0Q\377\30\0^\377\31\0_\377\1\0P\377" + "\10\0Q\377\15\0N\377\0\0G\377\14\0M\377\17\0U\377\2\0X\377\0\0V\377\15" + "\0Z\377\31\0X\377\37\0a\377\20\0T\377\25\0]\377\14\0^\377\17\0_\377\30" + "\0Z\377+\0f\377!\0e\377\34\0c\377\40\0c\377>\0\201\377M\7\233\377P\4" + "\227\377:\0x\377)\0f\377/\0o\377\214\3W\377y\0N\377`\0\35\3775\0\0\377" + "4\0\0\377,\0\0\377+\0\0\3776\0\0\3771\0\0\377)\0\0\3776\0\0\377#\0\0" + "\3776\0\0\377)\0\0\377*\0\0\377%\0\0\377+\0\0\377\30\0\0\377!\0\0\377" + "-\0\0\377\24\0\0\377\13\0\4\377\22\0\0\377\23\0\11\377\23\0\0\377\16" + "\0\0\377\0\0\0\377\0\0\2\377\0\0\0\377\1\0\1\377\2\0\7\377\15\0\26\377" + "\2\0\14\377\0\0\0\377\0\0\5\377\0\0\17\377\0\0\6\377\11\0\13\377\7\0" + "\23\377\25\0\30\377\17\0\4\377\6\0\10\377\23\0\32\377\17\0\36\377\17" + "\0\20\377\15\0\22\377\22\0\31\377\15\0\34\377\17\0\23\377\32\0\24\377" + "\27\0\21\377\15\0\5\377\21\0\11\377\30\0\11\377\22\0\6\377\21\0\21\377" + "\17\0\15\377\27\0\20\377\22\0\16\377\30\0\16\377\10\0\11\377\6\0\27\377" + "\0\0\24\377\0\0\37\377\0\0\10\377\25\0\31\377\17\0\21\377\23\0\26\377" + "\21\0\26\377\12\0\30\377\0\0\35\377\3\0$\377\0\0*\377\0\0#\377\0\0*\377" + "\4\0\0,\377\5\0\36\377\0\0\34\377\0\0)\377\202\0\0\25\377\10\0\0!\377" + "\0\0'\377\0\0\32\377\0\0\25\377\0\0\17\377\0\0\26\377\0\0\5\377\0\0\22" + "\377\202\0\0\14\377\204\0\0\0\377\5\0\0\1\377\0\0\2\377\0\0\7\377\0\0" + "\13\377\0\0\14\377\203\0\0\0\377\202\0\0\3\377\204\0\0\0\377\15\0\0\5" + "\377\0\0\2\377\0\0\6\377\0\0\23\377\0\0\13\377\0\0\12\377\0\0\6\377\0" + "\0\0\377\0\0\13\377\0\0\11\377\0\0\5\377\0\0\7\377\0\0\10\377\213\0\0" + "\0\377\3\0\0\2\377\0\0\0\377\0\0\5\377\203\0\0\0\377\1\0\0\1\377\202" + "\0\0\3\377\24\0\0\10\377\0\0\0\377\0\0\21\377\0\0\17\377\0\0\33\377\0" + "\0\37\377\0\0\22\377\0\0\10\377\0\0\16\377\0\0\33\377\0\0\34\377\0\0" + "\32\377\0\0\36\377\0\0\31\377\0\0\26\377\0\0\25\377\0\0\21\377\0\0\12" + "\377\0\0\24\377\0\0\36\377\202\0\0\34\377\7\0\0\31\377\0\0\20\377\0\0" + "\6\377\0\0\15\377\0\0\30\377\0\0\21\377\0\0\20\377\202\0\0\23\377\11" + "\0\0\25\377\0\0\13\377\0\0\10\377\0\0\4\377\0\0\16\377\0\0\12\377\0\0" + "\15\377\0\0\0\377\0\0\5\377\203\0\0\0\377\5\0\0\2\377\0\0\0\377\0\0\1" + "\377\0\0\0\377\0\0\5\377\211\0\0\0\377\177\0\0\14\377\0\0\11\377\0\0" + "\20\377\0\0\17\377\0\0\33\377\0\0\22\377\0\0\25\377\0\0\"\377\0\0*\377" + "\0\0\36\377\0\0(\377\0\0#\377\0\0/\377\0\0""2\377\0\0+\377\0\0(\377\0" + "\0.\377\0\0\77\377\0\0F\377\0\0P\377\0\0E\377\0\0F\377\0\0L\377\0\0J" + "\377\0\0N\377\0\0T\377\0\0I\377\0\0J\377\0\0L\377\0\0N\377\0\0G\377\10" + "\0P\377\0\0Z\377\0\0R\377\4\0T\377\0\0Y\377\5\0Q\377\7\0U\377\13\0T\377" + "\0\0W\377\0\0[\377\0\0R\377\3\0G\377\6\0K\377\5\0X\377\0\0E\377\25\0" + "Z\377\10\0S\377\4\0b\377\23\0R\377\13\0V\377\32\0Z\377%\0[\377\27\0V" + "\377\37\0h\377!\0X\377*\0V\377(\0e\3779\0m\3771\0m\3775\0v\377+\0q\377" + "3\0o\377s\0""6\377k\0\25\377;\0\2\3777\0\0\377A\7\1\377M\24\0\377;\22" + "\1\377-\31\0\3775\15\0\3770\25\0\377F\13\0\377L\20\0\377@\32\0\377E\23" + "\0\377C\20\5\377@\21\13\377:\31\10\377/\25\10\3778\37\11\377,\36\14\377" + "\32\25\6\377\25\22\7\377\32\21\25\377\25\24\34\377\10\35\7\377\11+\1" + "\377\4!\12\377\4\37\6\377\10(\13\377\0*\25\377\17+\25\377\6'\20\377\16" + "'\27\377\12)\35\377\6.\20\377\3)\27\377\16''\377\14.)\377\15""7\26\377" + "\20""8\11\377#7\26\377!S\36\377$Z\"\377\34X\37\377\32X2\377\37W#\377" + "\30d.\377\26e3\377\20h\33\377\21T\36\377\33[\32\377\23S\31\377\"X/\377" + "\26I\35\377\12@\37\377\11""6\27\377\31-#\377\14$\26\377\25/!\377\27""7" + "\"\377\16.!\377\6,\16\377\25&\37\377\25'*\377@\37%\34\377\15/\26\377" + "\25""2\24\377\33&%\377\17+3\377\2\37-\377\2""09\377\5(1\377\0""4=\377" + "\0""6>\377\0B0\377\0I3\377\0K-\377\1""8'\377\0\77)\377\11I1\377\3<&\377" + "\0""61\377\0E2\377\0:\32\377\0O&\377\4P$\377\0I\32\377\0M\30\377\0G%" + "\377\0D\13\377\0""8\20\377\0.\33\377\0""0\12\377\0,\6\377\0=\20\377\0" + "-\22\377\0""0\5\377\0/\16\377\0)\13\377\0!\10\377\0(\10\377\0""1\11\377" + "\0""1\34\377\0-\15\377\0\33\0\377\0.\1\377\0%\0\377\0#\0\377\0'\14\377" + "\0\32\6\377\0\36\0\377\0\31\15\377\0+\12\377\0&\0\377\0*\0\377\0(\0\377" + "\0!\11\377\0'\11\377\0""6\13\377\0/\0\377\0""7\0\377\0=\0\377\0;\0\377" + "\0/\0\377\0>\0\377\0N\0\377\0T\0\377\0L\0\377\202\0B\0\377,\0<\0\377" + "\0+\0\377\0""1\0\377\0:\0\377\0/\0\377\0""1\0\377\0(\0\377\0)\0\377\0" + "\27\10\377\0\37\0\377\0&\0\377\0\40\5\377\0\26\11\377\0\36\12\377\0\37" + "\26\377\0\20\26\377\0\23\14\377\0\31\37\377\0\0\26\377\0\7\10\377\0\0" + "\10\377\0\1\27\377\0\5\12\377\0\23\26\377\0\0\13\377\0\0\32\377\0\0\23" + "\377\0\0\0\377\0\0\10\377\0\0\21\377\0\0(\377\0\0\34\377\0\0\30\377\0" + "\0\21\377\0\0\25\377\0\0\36\377\0\23\35\377\0\30\31\377\0\"\37\377\0" + "\32\31\377\0\0\23\377\0\0\21\377\0\0\26\377\0\0\16\377\203\0\0\0\377" + "\3\0\0\2\377\0\0\4\377\0\0\1\377\205\0\0\0\377\2\0\0\7\377\0\0\1\377" + "\203\0\0\0\377\35\0\7\3\377\0\26\0\377\0+\3\377\0""4\17\377\0L\11\377" + "\0M\23\377\0G(\377\4^'\377\5]&\377\5[+\377\0^$\377\4R\33\377\0E\36\377" + "\0M(\377\0L+\377\0N3\377\6G/\377\0>0\377\0):\377\0%7\377\0\30""4\377" + "\0\21""4\377\0\32/\377\0\26""5\377\0\27<\377\0\20@\377\0\14\77\377\0" + "\0\77\377\0\14H\377\202\0\2L\377\177\0\3[\377\0\0J\377\0\15R\377\0\20" + "L\377\0\30T\377\0$M\377\0#R\377\2;P\377\11YY\377\0mj\377\16lv\377+xu" + "\377\37kq\377\25Mi\377\0;e\377\6%W\377\0\37_\377\3&e\377\0""9a\377\4" + "0`\377\5&V\377\0/R\377\4EZ\377\7;U\377\17""4Y\377\0""5`\377\3A[\377\10" + ":a\377\23-W\377\34$^\377\36+`\377&#d\377&\35\\\377\35!b\377-&g\377.5" + "t\3775=u\377.\0g\377+\0u\377/\0q\3773\0r\377k\0""7\377B\0\17\377,\0\0" + "\3774\0\0\377>\21\0\3771\15\0\3774\30\5\377+\31\7\377>\21\5\377<\37\7" + "\377I\26\12\377H\26\1\377=\21\15\377R\27\22\377C,\20\377>&\13\3777\32" + "\22\3770\32\6\377'\30\20\377/\34\21\377\35\34\15\377\32\35\31\377\33" + "\24\11\377\36\31\26\377\16\30\1\377\20\33\1\377\0\36\14\377\2\33\0\377" + "\10!\6\377\3(\16\377\0""4\36\377\10(\21\377\15""1\33\377\7""7\23\377" + "\13.\"\377\24*/\377\17)&\377#3'\377\27;\15\377\32\77\20\377&I\21\377" + "#F\24\377\30P'\377\32^0\377\25c+\377\27S)\377!].\377\40b(\377\24h$\377" + "\27i-\377%[&\377\37Y-\377\20L'\377\21P1\377\13=.\377\22A*\377\3""8#\377" + "\15>,\377\6""3!\377\13;+\377\32\40""3\377\21""3'\377\26\"-\377\32#&\377" + "\24.+\377\24,3\377\13+*\377\1\35\34\377\12#$\377\4\",\377\26-.\377\5" + "E6\377\2F-\377\0""6.\377\0;+\377\14F5\377\12K<\377\15@.\377\1F(\377\0" + "=/\377\0Q-\377\1F,\377\0A#\377\0C0\377\0E1\377\0D\35\377\33\1<\37\377" + "\0;\40\377\0@\37\377\0""2\22\377\0:\26\377\0-\20\377\0+\30\377\0)\10" + "\377\0""3\22\377\0*\10\377\0""1\14\377\0""4\2\377\0*\10\377\0""1\0\377" + "\0-\12\377\0""0\0\377\0\"\0\377\0""4\2\377\0.\16\377\0(\11\377\0*\3\377" + "\0(\6\377\0+\7\377\0)\12\377\0\34\15\377\0#\4\377\0+\0\377\202\0""1\0" + "\377\25\0""3\0\377\0.\0\377\0""1\0\377\0""2\0\377\0>\2\377\0E\0\377\0" + "3\0\377\0@\0\377\0J\0\377\0H\0\377\0O\0\377\0L\0\377\0M\0\377\0H\0\377" + "\0F\0\377\0B\0\377\0G\0\377\0K\0\377\0<\4\377\0""2\0\377\0*\0\377\202" + "\0+\0\377\21\0""4\0\377\0""5\0\377\0(\0\377\0\32\0\377\0\40\12\377\0" + ",\13\377\0(\5\377\0)\21\377\0\40\15\377\0'\22\377\0\35\21\377\0\31\4" + "\377\0\6\14\377\0\22\14\377\0\27\5\377\0\27\14\377\0\17\5\377\202\0\0" + "\0\377\21\0\0\3\377\0\0\33\377\0\0\32\377\0\0\30\377\0\0\16\377\0\0\12" + "\377\0\0\3\377\0\0\12\377\0\0\35\377\0\11\15\377\0!\13\377\0\32\14\377" + "\0\14\15\377\0\0\10\377\0\0\26\377\0\0\0\377\0\0\4\377\203\0\0\0\377" + "\1\0\0\3\377\210\0\0\0\377\177\0\0\10\377\0\0\0\377\0\7\0\377\0\0\0\377" + "\0\5\0\377\0\24\11\377\0%\10\377\0=\20\377\0\77\11\377\0B\22\377\10N" + "\24\377\0U$\377\0h7\377\0c\36\377\0f\33\377\0U1\377\0Q0\377\0Q2\377\0" + "V/\377\0Q.\377\0K;\377\2Q\77\377\0JB\377\0A9\377\0%6\377\0\35""7\377" + "\0\32.\377\0\35""2\377\0\20""4\377\0\10""4\377\0\1E\377\0\6>\377\0\0" + ";\377\0\7L\377\0\4Q\377\0\1I\377\0\6M\377\0\4]\377\0\23[\377\0\32`\377" + "\0\30e\377\0\"X\377\0+Y\377\0IZ\377\2vk\377\24{q\377\30s\177\377\14r" + "u\377\11_n\377\4Il\377\0,j\377\0""3i\377\0""6\\\377\0""3e\377\0-Z\377" + "\0""7c\377\0NX\377\0\\K\377\6Lc\377\20@`\377\4Kd\377\21M]\377\10Ue\377" + "\14Kf\377\33=Y\377\30""7X\377\30.`\377\35'f\377\21\36m\377\30'o\377\35" + ",\202\377,=|\377)\0n\377'\0}\377-\0z\377-\5x\377k\0)\377O\0\15\377A\0" + "\0\3778\0\5\3772\10\21\3778\16\6\377;\31\13\3777\32\30\377\77\33\26\377" + "C(\20\377=#\40\3778\31\24\3771!\5\377<*\31\3772+\17\377=/\17\3774\37" + "\12\3770)\11\377'\32\7\377\40\27\21\377\24\35\23\377\34!\16\377\34*\26" + "\377\10)&\377\23-\14\377\10\"\5\377\22\"\4\377\14-\1\377\32+\30\377\22" + "<\27\377\20%\40\377\5(\33\377\20-\30\377\16.\17\377\14""6\25\377\16""4" + "\33\377\16=\15\377\20/\27\377\21=\23\377\34\77\25\377\34>!\377!H%\377" + "\32K&\377\16N\36\377\14[\30\377\16Y*\377\16k\30\377\14d\30\377\15j)\377" + "\11i!\377\20b*\377V\25a0\377\21R;\377\23T3\377\12L-\377\6O+\377\15E1" + "\377\26>>\377\10;\77\377\20""2.\377\2""4,\377\11/(\377\0""8,\377\0""5" + "9\377\0'9\377\0\35""1\377\0'\"\377\2(1\377\7)+\377\0""6'\377\12""1!\377" + "\12""76\377\0""7-\377\0""74\377\2H5\377\0G.\377\16D,\377\2G)\377\6=." + "\377\13K2\377\20>'\377\1=$\377\0D-\377\0T(\377\0J.\377\0""7\"\377\0=" + "!\377\0""4\27\377\0""7\36\377\0""2\35\377\0""7!\377\0""6\23\377\0+\2" + "\377\0""7\22\377\0'\14\377\0\37\21\377\0-\6\377\0%\0\377\0""6\0\377\0" + ")\1\377\0""1\6\377\0""0\15\377\0""1\16\377\0;\30\377\0""7\24\377\0D\6" + "\377\0\77\4\377\0""8\0\377\0;\0\377\0-\0\377\0\35\0\377\0#\0\377\0!\0" + "\377\0""2\0\377\0""3\0\377\0!\0\377\0/\0\377\0,\0\377\0=\0\377\0@\0\377" + "\0=\0\377\0L\0\377\0D\0\377\0E\0\377\0S\0\377\0""5\0\377\0""7\0\377\0" + "C\0\377\0@\0\377\0D\0\377\0V\0\377\0B\0\377\0<\0\377\0""5\0\377\0""2" + "\0\377\0""1\0\377\0&\0\377\202\0,\0\377\24\0\40\0\377\0*\3\377\0(\0\377" + "\0,\0\377\0&\5\377\0%\1\377\0""1\0\377\0\34\7\377\0!\0\377\0\33\0\377" + "\0&\0\377\0\25\0\377\0\32\0\377\0\32\5\377\0\32\0\377\0\27\0\377\0\26" + "\0\377\0\0\15\377\0\13\22\377\0\0\6\377\205\0\0\0\377\6\0\0\10\377\0" + "\0\2\377\0\4\2\377\0\20\2\377\0\16\16\377\0\10\23\377\202\0\0\0\377\1" + "\0\0\4\377\204\0\0\0\377\2\0\0\1\377\0\0\3\377\205\0\0\0\377\3\0\0\7" + "\377\0\0\17\377\0\0\3\377\203\0\0\0\377\177\0\14\0\377\0\36\13\377\0" + "'\14\377\0-\27\377\0""6\24\377\0B\33\377\0S\37\377\0[\"\377\0\\#\377" + "\0o(\377\0p,\377\0h8\377\0n2\377\0X9\377\0b4\377\6n8\377\14cF\377\0g" + "K\377\0b<\377\0UI\377\0;=\377\0(1\377\0%+\377\0\30""0\377\0\32:\377\0" + "\13E\377\0\26<\377\0\7/\377\0\7@\377\0\20O\377\0\14G\377\0\24M\377\0" + "\15W\377\0\20^\377\0\36`\377\0\27e\377\0%`\377\0)[\377\0Ij\377\0la\377" + "\12\177j\377\31\221v\377\26\214{\377\2zy\377\14_p\377\3N^\377\0\77a\377" + "\6/k\377\0""3l\377\0""2Y\377\0""4c\377\0B]\377\0KX\377\0Ye\377\0Vd\377" + "\2N]\377\0Xa\377\0^i\377\5Q^\377\23FW\377$Ab\377\21;a\377!7[\377\32""8" + "i\377\36&n\377\24""5o\377)5v\377#:\203\377\40\25u\377,\13f\3771\15l\377" + ":\4\177\377s\0'\377N\0\15\3770\0\11\3779\0\5\377.\22\17\377,\24\25\377" + "2\36\25\377+\37#\37723\26\377<4\37\377>\"\22\3770*\20\377*\34\22\377" + "\36!\20\377(\40\31\377\37\35\10\377\35\15\0\377\35\23\11\377\17\30\30" + "\377\5\22\26\377\24\34\27\377\26!\27\377\10""8\33\377\12""3(\377\22""3" + "\21\377\13""5\14\377\26""8\27\377\16,\32\377\7""4!\377\0,\31\377\0'\36" + "\377\0$\24\377\0\40\13\377\2(\36\377\0""6\23\377\15D\23\377\13""4#\377" + "\17""2\36\377\27""8\34\377\27""8\"\377\24=\35\377\34B\35\377\35\\-\377" + "\24f$\377\3b%\377\15d\40\377\10l-\377\14o\26\377\0^\40\377\1]%\377\16" + "^2\377\5Y1\377\5^3\377\0]7\377\0O1\377=\0I-\377\0D6\377\3C-\377\25""7" + "1\377\27""5;\377\5/=\377\10""8.\377\11""21\377\2-/\377\2\";\377\12(," + "\377\0-)\377\0\"0\377\4.,\377\10,!\377\13""8\34\377\0""8$\377\0>*\377" + "\0""85\377\0D0\377\0E0\377\5G4\377\3=(\377\4E'\377\2W(\377\11Q-\377\16" + "E(\377\2H%\377\1J*\377\0\77%\377\1;#\377\0E!\377\0@\37\377\0""1&\377" + "\0""3\23\377\0""8\17\377\0'\10\377\0*\11\377\0\30!\377\0'\20\377\0""5" + "\23\377\0/\7\377\0""1\0\377\0""5\2\377\0""8\20\377\0-\14\377\0A\15\377" + "\0=\16\377\0""4\12\377\0""1\12\377\0J\0\377\0;\0\377\0""3\0\377\0""2" + "\0\377\0-\0\377\0""0\0\377\0""2\0\377\0\"\0\377\0+\0\377\0'\0\377\0/" + "\0\377\202\0,\0\377\35\0""2\0\377\0""0\0\377\0""4\0\377\0F\0\377\0""8" + "\0\377\0@\0\377\0=\0\377\0""7\0\377\0""2\0\377\0D\0\377\0:\0\377\0B\0" + "\377\0""0\0\377\0D\0\377\0P\0\377\0L\0\377\0:\0\377\0""6\0\377\0.\0\377" + "\0-\0\377\0.\0\377\0*\0\377\0-\0\377\0""0\0\377\0:\0\377\0""3\0\377\0" + "/\0\377\0""8\0\377\0)\0\377\203\0*\0\377\11\0\30\2\377\0\17\0\377\0#" + "\0\377\0\"\0\377\0\33\0\377\0\16\0\377\0\21\11\377\0\14\5\377\0\0\1\377" + "\205\0\0\0\377\7\0\0\1\377\0\0\3\377\0\5\0\377\0\10\16\377\0\0\2\377" + "\0\0\4\377\0\0\1\377\216\0\0\0\377$\0\0\10\377\0\0\0\377\0\0\11\377\0" + "\0\20\377\0\0\0\377\0\14\2\377\0\26\16\377\0\40\16\377\0""4\16\377\0" + "1\11\377\0+\23\377\0>\31\377\0`\34\377\0f(\377\0n8\377\0r<\377\15l6\377" + "\3s\77\377\11u>\377\0}=\377\0yG\377\0{;\377\0~\77\377\0t;\377\0p7\377" + "\0oC\377\0Q5\377\0""9.\377\0#.\377\0\26""8\377\0\25+\377\0\24""6\377" + "\0\15;\377\0\11G\377\0\35D\377\0\34Q\377\202\0*R\377\177\0""2]\377\0" + ",^\377\0""2b\377\0.W\377\0=g\377\0Kh\377\0ae\377\3\211t\377\15\214p\377" + "\27zp\377\5mm\377\0cp\377\0X\\\377\0Un\377\0Co\377\0L]\377\0q\377\36Lu\377*'\203\377$!z\377&\23l\377&\26q\377e\0""8\377H\0\25" + "\377*\0\0\377&\0\16\377,\15\40\3770\34\17\377$\33\25\377(\26\34\377)" + "\21\33\377\"'\22\377\36)\31\377\37+\25\377\23\33\7\377\17\31\26\377\34" + "\36\13\377\36&\12\377\16\40\34\377\24#.\377\11\33\26\377\0\40\40\377" + "\17\35&\377\21\40\35\377\0,\25\377\0!\"\377\11\"\35\377\3%'\377\16!&" + "\377\5\"\36\377\3.\37\377\0)\30\377\0!\23\377\0&\34\377\0""1\31\377\0" + "/\35\377\7""6\33\377\2""6\30\377\0""8\33\377\5>\27\377\0\77!\377\0>\40" + "\377\23R\40\377\27E\37\377\0Z\33\377\0\\\31\377\3b/\377\0h\36\377\0g" + ")\377\0\\0\377\1n6\377\3Z)\377\11Z6\377\0R4\377\0U-\377\0^;\377\0\\-" + "\377\0O\"\377\5L0\377\5B*\377\1=5\377\2/3\377\0,-\377\0-*\377\5,2\377" + "\30)7\377\24'0\377\0""0&\377\0--\377\0$%\377\3$)\377\0,.\377\0""1%\377" + "\0.#\377\0""3,\377\0B\36\377\0<(\377\0:\"\377\0I!\377\0Q*\377\0W$\377" + "\13K\32\377\0;\31\377\0H\25\377\0I\23\377\0D\13\377\1E\27\377\0F\36\377" + "\0J\36\377\0>\30\377\35\0D\13\377\0/\20\377\0""0\10\377\0'\13\377\0." + "\26\377\0""0\20\377\0""9\31\377\0&\16\377\0#\20\377\0+\22\377\0\"\6\377" + "\0-\20\377\0""8\3\377\0""0\0\377\0""1\23\377\0A\2\377\0F\0\377\0""1\0" + "\377\0\77\0\377\0@\0\377\0I\0\377\0:\0\377\0<\0\377\0I\0\377\0E\0\377" + "\0B\0\377\0""5\0\377\0)\0\377\0$\0\377\202\0\35\0\377'\0-\0\377\0>\0" + "\377\0""9\0\377\0""4\0\377\0-\0\377\0'\0\377\0C\0\377\0E\0\377\0\77\0" + "\377\0F\0\377\0=\0\377\0D\0\377\0C\0\377\0""6\0\377\0=\0\377\0Q\0\377" + "\0R\0\377\0@\0\377\0F\0\377\0;\0\377\0:\0\377\0""7\0\377\0+\0\377\0;" + "\0\377\0M\0\377\0;\0\377\0\77\0\377\0<\0\377\0/\0\377\0%\0\377\0\25\0" + "\377\0\30\0\377\0\"\0\377\0,\0\377\0\31\0\377\0$\0\377\0\34\0\377\0\20" + "\0\377\0\26\0\377\213\0\0\0\377\1\0\4\0\377\204\0\0\0\377\4\0\0\13\377" + "\0\0\2\377\0\0\14\377\0\0\3\377\211\0\0\0\377\177\0\0\13\377\0\6\0\377" + "\0\16\0\377\0\31\0\377\0""1\7\377\0'\13\377\0""5\15\377\0""2\21\377\0" + ";\17\377\0=\14\377\0N\40\377\0K\40\377\0`1\377\0i2\377\0n6\377\0q;\377" + "\0p:\377\0\202:\377\0wB\377\0{7\377\0\2056\377\0\205F\377\0\200E\377" + "\0yI\377\0`2\377\0O6\377\0""17\377\0\21""8\377\0\31""3\377\0\17<\377" + "\0\17A\377\0\21E\377\0#K\377\0*M\377\0-Y\377\0""6P\377\0""9O\377\0""6" + "Z\377\0""8H\377\0DM\377\0NY\377\0Dg\377\0j_\377\0\215`\377\0\212i\377" + "\0\226u\377\0xm\377\0gj\377\0^b\377\0T_\377\0Vg\377\0Mf\377\0B`\377\0" + "\77c\377\0Ci\377\0G]\377\0L`\377\0Xc\377\0]a\377\4\\h\377\2Vi\377\2Y" + "h\377\20Xx\377\20Mw\377\17Nt\377\5\77v\377\0>\203\377\0E\202\377\0=~" + "\377\5:\202\377\23""6\200\3771O\242\377\32""2\222\377\3\36u\377\26\23" + "|\377g\0\77\377H\0&\377*\0\30\377-\0\25\377.\14\34\377,\11\"\377#\13" + "\40\377&\11%\377(\32\26\377\35\21\17\377\26\32\26\377\32\27\25\377\16" + "\34\13\377\10\25\17\377\27\34\24\377\21\30\31\377\5\36\33\377\20\26\31" + "\377\11\27\36\377\15\14$\377\6\17\31\377\13\25\32\377\1\36\26\377\6\27" + "$\377\11\34\40\377\11\36\32\377\1%(\377\10\34%\377\0$\24\377\0'\25\377" + "\0""0\34\377\0""2$\377\0%'\377\0.\"\377\0""4+\377\0/\"\377\0C)\377\0" + ":+\377\4<.\377\0:'\377\2B7\377\0J0\377\0R+\377\0[/\377\0l-\377\0i*\377" + "\14b8\377\7h\77\377\1b=\377\0\\8\377\0\\+\377\0^7\377>\4a0\377\10b3\377" + "\0T+\377\0M/\377\0J.\377\0E4\377\0=2\377\1""71\377\7;*\377\20@)\377\5" + "94\377\4/6\377\0/2\377\7""4!\377\4%\40\377\11/(\377\3.+\377\0-&\377\0" + "1*\377\3/\37\377\0-(\377\0+&\377\0\77\"\377\0V\35\377\3_\35\377\0\\#" + "\377\2W\40\377\3D\15\377\0H\13\377\0N%\377\0@+\377\0B\22\377\0S\27\377" + "\0N\35\377\0A#\377\0J\17\377\0>\10\377\0""9\0\377\0A\10\377\0>\12\377" + "\0""2\13\377\0+\15\377\0""7\34\377\0\"\27\377\0#\20\377\0!\14\377\0\"" + "\16\377\0(\12\377\0.\0\377\0<\17\377\0J\7\377\0@\22\377\0A\10\377\0I" + "\0\377\0<\0\377\0""7\0\377\0<\0\377\0F\0\377\0O\0\377\0G\0\377\0R\0\377" + "\0T\0\377\202\0A\0\377\1\0""6\0\377\202\0=\0\377\4\0+\0\377\0""6\0\377" + "\0(\0\377\0""5\0\377\202\0A\0\377\2\0D\0\377\0F\0\377\202\0C\0\377\26" + "\0""7\0\377\0=\0\377\0@\0\377\0E\0\377\0G\0\377\0M\0\377\0S\0\377\0E" + "\0\377\0A\0\377\0""3\0\377\0""2\0\377\0C\0\377\0B\0\377\0I\0\377\0O\0" + "\377\0I\0\377\0C\0\377\0>\0\377\0.\0\377\0%\0\377\0\36\0\377\0#\0\377" + "\202\0$\0\377\6\0\35\0\377\0\30\0\377\0\21\0\377\0\22\0\377\0\14\0\377" + "\0\1\0\377\210\0\0\0\377\202\0\13\0\377\212\0\0\0\377\3\0\0\15\377\0" + "\0\0\377\0\0\10\377\205\0\0\0\377\177\0\16\0\377\0\30\0\377\0\22\0\377" + "\0\40\14\377\0%\2\377\0\77\26\377\0@\16\377\0""8\27\377\0;\4\377\0D\10" + "\377\0B\37\377\0""9\37\377\0S(\377\0Y/\377\0l8\377\0p\77\377\0\1778\377" + "\0\202D\377\0|5\377\0x:\377\0\200F\377\0\213H\377\0\220K\377\0\211@\377" + "\0\201@\377\0a\77\377\0CB\377\0""2\77\377\0\32E\377\0\32>\377\0\31H\377" + "\0\"J\377\0\30P\377\0%Q\377\0*P\377\0$Q\377\0""2U\377\0/W\377\0FS\377" + "\0Ab\377\0Dg\377\0T[\377\0pd\377\0\222a\377\0\232\201\377\0\240\177\377" + "\0\215y\377\0pr\377\0gm\377\0U\\\377\0Ce\377\0\77i\377\0@o\377\0Hp\377" + "\0\0\377\0;\0\377\0B\0\377\0H\13\377\0E\17\377\0""5\16\377\0,\23\377" + "\0*\26\377\0&\15\377\0""7\0\377\0""8\3\377\0=\15\377\0@\26\377\0;\30" + "\377\0E\17\377\0F\10\377\0R\0\377\0J\0\377\0B\0\377\0G\0\377\0D\0\377" + "\0;\0\377\0N\0\377\0f\0\377\0d\0\377\0g\0\377\0O\0\377\0V\0\377\0J\0" + "\377\0""3\0\377\0;\0\377\0""2\0\377\0""7\0\377\0""0\0\377\0""4\0\377" + "\0>\0\377\0C\0\377\0:\0\377\0P\0\377\0\77\0\377\0""9\0\377\0<\0\377\0" + "@\0\377\0G\0\377\0N\0\377\0K\0\377\0O\0\377\0E\0\377\0:\0\377\0""8\0" + "\377\0""6\0\377\0""9\0\377\0""6\0\377\0:\0\377\0D\0\377\0E\0\377\0I\0" + "\377\0A\0\377\0""3\0\377\0;\0\377\202\0""1\0\377\13\0'\0\377\0)\0\377" + "\0""0\0\377\0\"\0\377\0\31\0\377\0\22\0\377\0\24\0\377\0\20\0\377\0\17" + "\0\377\0\21\0\377\0\5\0\377\203\0\3\0\377\6\0\11\0\377\0\16\0\377\0\5" + "\0\377\0\11\0\377\0\0\0\377\0\2\0\377\203\0\0\0\377\3\0\2\0\377\0\0\0" + "\377\0\0\2\377\203\0\0\0\377\1\0\0\7\377\203\0\0\0\377\2\0\0\1\377\0" + "\1\2\377\202\1\1\3\377\177\2\21\4\377\2\20\4\377\2/\4\377\1*\2\377\1" + "4\1\377\0""5\0\377\0""3\13\377\0-\0\377\0;\13\377\0""4\12\377\0""5\13" + "\377\0>\20\377\0Q\27\377\0d\34\377\0f\33\377\0y2\377\0\201*\377\0\206" + "*\377\0\206+\377\0\2149\377\0\220<\377\0\231;\377\0\223B\377\0\2154\377" + "\0|<\377\0`<\377\0T\77\377\0>/\377\0""49\377\0\36""1\377\0!>\377\0\21" + "B\377\0\31L\377\0\35F\377\0#;\377\0(=\377\0/P\377\0@O\377\0RU\377\0T" + "T\377\0QX\377\0[S\377\0mV\377\0\200m\377\0\224{\377\0\227\201\377\0\216" + "y\377\0n[\377\0U^\377\0S]\377\0MY\377\0Dh\377\0Ft\377\0Ck\377\0F_\377" + "\0Er\377\0Cr\377\0Js\377\0Oo\377\0Nh\377\0`e\377\0Ua\377\0Oe\377\0Po" + "\377\0Pq\377\0V|\377\0F\177\377\0Wm\377\0L{\377\0>x\377\0:\202\377$Q" + "\255\377\11/\213\377\0\17v\377\0\37k\377`\11G\377C\0!\377\35\0\17\377" + "\37\0\2\377'\5\"\377%\12$\377!\0\25\377\34\0\30\377\30\1\22\377\31\0" + "\33\377\11\12\22\377\13\25\23\377\13\4\16\377\15\6\26\377\16\26$\377" + "\6\32+\377\0\24\35\377\0\40%\377\7\31*\377\7\33%\377\16\35*\377\7\37" + "\37\377\21\25""4\377\20+*\377\0#+\377\16\"#\377\0&*\377\0\34!\377\0""3" + "(\377\0""5&\377\0,3\377\0""56\377\0%\37\377\0*+\377\0+%\377\0)'\377\0" + "7\"\377\0""6+\377\0>-\377\0""3'\377\0:+\377\0@'\377\0`.\377\0\\4\377" + "\0_*\377\4g$\377\5t0\377\16o;\377\5h,\377\10k-\377\7n@\377\15p6\377F" + "\0c(\377\3j)\377\0U+\377\0H#\377\0R+\377\0@$\377\0>&\377\3""02\377\2" + "/(\377\11,&\377\0-\37\377\4""01\377\6""5%\377\6-/\377\4""3*\377\0!*\377" + "\0\15""0\377\1\40$\377\2!'\377\0\40$\377\4%\40\377\0.\40\377\0""6\31" + "\377\0A\30\377\0N\27\377\0M\35\377\0M\23\377\0B\35\377\0M'\377\0A\27" + "\377\0@\24\377\0B\20\377\0C\13\377\0O\3\377\0J\4\377\0K\16\377\0I\14" + "\377\0S\7\377\0A\7\377\0""9\11\377\0B\12\377\0""4\4\377\0'\15\377\0+" + "\21\377\0""5\15\377\0:\5\377\0""6\0\377\0J\10\377\0G\6\377\0G\11\377" + "\0\77\7\377\0X\0\377\0V\0\377\0G\0\377\0I\0\377\0C\0\377\0;\0\377\0G" + "\0\377\0O\0\377\0f\0\377\0^\0\377\0Z\0\377\0]\0\377\0P\0\377\0L\0\377" + "\0B\0\377\0>\0\377\0""1\0\377\0.\0\377\0""5\0\377\202\0""4\0\377-\0+" + "\0\377\0>\0\377\0""8\0\377\0""5\0\377\0B\0\377\0E\0\377\0>\0\377\0@\0" + "\377\0=\0\377\0L\0\377\0C\0\377\0F\0\377\0;\0\377\0\77\0\377\0B\0\377" + "\0""5\0\377\0<\0\377\0""9\0\377\0H\0\377\0\77\0\377\0=\0\377\0/\0\377" + "\0""6\0\377\0""1\0\377\0""8\0\377\0""6\1\377\0,\0\377\0/\0\377\0(\0\377" + "\0\33\0\377\0'\0\377\0\40\0\377\0\34\0\377\0\36\0\377\0\12\0\377\0\24" + "\0\377\0\26\0\377\0\32\0\377\0\17\0\377\0\20\0\377\0\22\0\377\0\15\0" + "\377\0\14\0\377\0\22\0\377\0\6\0\377\213\0\0\0\377\177\2\4\6\377\5\7" + "\13\377\10\17\25\377\13\26\36\377\20\36,\377\13$7\377\20,8\377\15""0" + "#\377\7/\35\377\5=\12\377\4/\27\377\3""4\14\377\2(\22\377\0-\11\377\0" + "8\4\377\0=\10\377\0H\15\377\0""6\14\377\0<\12\377\0\77\14\377\0V\10\377" + "\0T\30\377\0y\27\377\0u\32\377\0\210\31\377\0\205\25\377\0\221\25\377" + "\0\2153\377\0\2201\377\0\202)\377\0z/\377\0b4\377\0R%\377\0T)\377\0>" + "&\377\0""51\377\0*6\377\0\35-\377\0\35""0\377\0\36<\377\0!6\377\0'4\377" + "\0,9\377\0""43\377\0@D\377\0KD\377\0CU\377\0VW\377\0OQ\377\0qg\377\0" + "\201]\377\0\217v\377\0\210q\377\0\203g\377\0rV\377\0jM\377\0Ke\377\0" + "Ge\377\0>k\377\0Ek\377\0Df\377\0\0\377\0""5\0\377\0D\0\377\0G\0\377\0E\0\377" + "\0A\0\377\0:\0\377\202\0>\0\377\1\0<\0\377\202\0C\0\377\36\0<\0\377\0" + "B\0\377\0""4\0\377\0.\0\377\0<\0\377\0""0\0\377\0;\0\377\0=\0\377\0""2" + "\0\377\0""1\0\377\0,\0\377\0F\0\377\0""5\0\377\0.\0\377\0!\0\377\0\"" + "\0\377\0\30\0\377\0\25\0\377\0&\0\377\0$\0\377\0\27\0\377\0\26\0\377" + "\0\36\0\377\0$\0\377\0\22\0\377\0\12\0\377\0\27\0\377\0\7\0\377\0\3\12" + "\377\0\0\2\377\205\0\0\0\377z\6\23\34\377\20%/\377\11\30\37\377\7\26" + "\27\377\12(0\377\14A4\377\15""1B\377\13""8=\377\12""83\377\7,\33\377" + "\10""3\22\377\6>\30\377\4<\37\377\5;\37\377\5@\32\377\4@\26\377\2>\4" + "\377\0M\0\377\0A\17\377\0E\20\377\0<\16\377\0C\14\377\0@\16\377\0S\10" + "\377\0U\12\377\0^\32\377\0b\24\377\0u\26\377\0\206\25\377\0|\30\377\0" + "\206\34\377\0\211\33\377\0\203!\377\0m\40\377\0_\25\377\0F\21\377\0H" + "'\377\0D\37\377\0A,\377\0/-\377\0-*\377\0)-\377\0%'\377\0\40/\377\0&" + ",\377\0+-\377\0:\77\377\0;I\377\0\77G\377\0DB\377\0HB\377\0SR\377\0r" + "K\377\0tb\377\0\200o\377\0\201g\377\0\200b\377\0gc\377\0ii\377\0k[\377" + "\0Ul\377\0Jb\377\0F]\377\0""9e\377\0""5a\377\0""7g\377\0Cv\377\0""0v" + "\377\0Dg\377\0@j\377\0Qo\377\0\77u\377\0R\204\377\0K\204\377\0R\203\377" + "\0Xl\377\0[j\377\0Oi\377\0Gd\377\0Mw\377\0Ch\377\27V\242\377\0""6z\377" + "\0\35q\377\0\35|\377\\\16""3\3774\0\34\377\34\0\5\377\25\0\4\377\21\34" + "\24\377\25\40\20\377\23&%\377\13\31\40\377\25\13\37\377\26\25!\377\26" + "\23\33\377\23\23\31\377\20\23&\377\22\27\35\377\15\26\22\377\5\20#\377" + "\0\32\25\377\15$!\377\4\23*\377\0\27""4\377\5'1\377\10\37A\377\5\34*" + "\377\5#,\377\16""0.\377\12""2.\377\0-+\377\0.5\377\0""5+\377\0,+\377" + "\0.@\377\0)5\377\0+(\377\0*(\377\0+1\377\0+%\377\0-\37\377\202\0\0\377\0" + "B\0\377\0\77\0\377\0J\0\377\0R\0\377\0Q\0\377\0G\0\377\0O\0\377\0L\0" + "\377\0M\0\377\0=\0\377\0\77\0\377\0;\0\377\0""7\0\377\0@\0\377\0""5\0" + "\377\0+\0\377\0""8\0\377\0""2\0\377\0=\0\377\0G\0\377\0F\0\377\0;\0\377" + "\0P\0\377\0O\0\377\0G\0\377\0S\0\377\0W\0\377\0=\0\377\0@\0\377\202\0" + "<\0\377\13\0;\0\377\0<\0\377\0""7\0\377\0""9\0\377\0""5\0\377\0""6\0" + "\377\0:\0\377\0C\0\377\0I\0\377\0D\0\377\0""0\0\377\202\0(\0\377\177" + "\0\35\0\377\0\27\0\377\0#\0\377\0\27\0\377\0\"\0\377\0\37\0\377\0\24" + "\0\377\0\32\0\377\0\34\0\377\0\24\0\377\0\22\0\377\0\33\0\377\0\35\0" + "\377\0\30\0\377\0\24\0\377\0\32\0\377\0\4\0\377\0\10\0\377\0\4\0\377" + "\3\27\23\377\2%\15\377\10\"\35\377\6$\33\377\11-!\377\13@6\377\11""8" + "<\377\13C1\377\15:)\377\10""5,\377\10""4$\377\10/\40\377\6\77\24\377" + "\4H\21\377\7F\16\377\4A\11\377\3C\6\377\3@\5\377\3H\5\377\0L\30\377\0" + "G\27\377\0C\21\377\0E\26\377\0Q\0\377\0Z\26\377\0T\21\377\0S\25\377\0" + "_\26\377\0r\30\377\0m\34\377\0w\17\377\0x\35\377\0\177(\377\0^#\377\0" + "c\22\377\0U\17\377\0<\15\377\0B\34\377\0""3\30\377\0""8$\377\0""5\34" + "\377\0($\377\0.+\377\0()\377\0&3\377\0\37""6\377\0+.\377\0\40""5\377" + "\0""40\377\0@:\377\0>5\377\0A<\377\0FK\377\0fM\377\0mY\377\0s_\377\0" + "o_\377\0kW\377\0mS\377\0aZ\377\0ZX\377\0H_\377\0I_\377\0CT\377\0>c\377" + "\0""5[\377\0\77f\377\0""6n\377\0(q\377\0-j\377\0""5y\377\0C|\377\0:{" + "\377\0E{\377\0V\201\377\0_\203\377\0^g\377\0Ym\377\0Xi\377\0Zc\377\0" + "U`\377\0Gd\377\32R\227\377\0""9\202\377\0)g\377\0.s\377Q\15+\377.\0\31" + "\377\15\0\0\377\21\0\4\377\36.\16\377\31'\6\377\36\31\16\377\35\40\23" + "\377\35\22\25\377\20\15\27\377\34\25'\377\36\16\30\377\13\6\34\377\2" + "\40\"\377\17\16\13\377\0\16\27\377\0\16\36\377\15\36)\377\10\33(\377" + "\4\33""1\377\3\35""3\377\10\25""3\377\20\7#6\377\21\30-\377\0#\40\377" + "\6#%\377\0!$\377\0$*\377\0%1\377\0'1\377\0""3'\377\0""30\377\0*.\377" + "\0(\37\377\0""4!\377\2*\32\377\0""0&\377\0/\"\377\202\0""8,\377\36\0" + "B\35\377\0A'\377\4V\35\377\0V#\377\0R\"\377\2M\35\377\26f(\377\35g(\377" + "\10X'\377\5P&\377\26X\32\377\13b\"\377\15T!\377\22'(\377\21\4\24\377" + "\7\0\25\377\0\0\22\377\0\0\23\377\0\0\16\377\0\0\11\377\5\0\23\377\3" + "\0\27\377\0\0\24\377\0\0\27\377\0\0\24\377\0\0\26\377\0\0\32\377\0\0" + "\40\377\0\0#\377\0\0\37\377\202\0\0\27\377\27\0\0\25\377\0\0\7\377\0" + "\0\15\377\0\0\34\377\0\0\26\377\0\0\24\377\0\10\26\377\0G\20\377\0F\24" + "\377\0R\40\377\0M\31\377\0\\\27\377\0P!\377\0I\24\377\0\16\2\377\0\0" + "\0\377\0\0\11\377\0\0\7\377\0\0\0\377\0\0\12\377\0\0\3\377\0\0\7\377" + "\0\0\2\377\216\0\0\0\377\177\0\22\0\377\0K\0\377\0C\0\377\0=\0\377\0" + "I\0\377\0F\0\377\0H\0\377\0R\0\377\0J\0\377\0U\0\377\0K\0\377\0N\0\377" + "\0Q\0\377\0Z\0\377\0N\0\377\0@\0\377\0<\0\377\0""8\0\377\0""4\0\377\0" + ";\0\377\0""9\0\377\0""5\0\377\0>\0\377\0\16\0\377\0\0\0\377\0\4\0\377" + "\0\1\0\377\0\16\0\377\0\5\0\377\0\0\0\377\0\37\0\377\0G\0\377\0J\0\377" + "\0M\0\377\0O\0\377\0I\0\377\0L\0\377\0\77\0\377\0""8\0\377\0=\0\377\0" + "9\0\377\0\77\0\377\0""7\0\377\0N\0\377\0D\0\377\0""0\0\377\0<\0\377\0" + "\37\0\377\0\36\0\377\0$\0\377\0\40\0\377\0\27\0\377\0\"\0\377\0\23\0" + "\377\0\25\0\377\0%\0\377\0\27\0\377\0\36\0\377\0\27\0\377\0&\0\377\0" + "\36\0\377\0\32\0\377\0\31\0\377\0\30\0\377\0\26\0\377\0\22\0\377\0\27" + "\11\377\20;2\377\5(\27\377\10\"\33\377\4""8\40\377\7""4\40\377\7H4\377" + "\16I/\377\7E+\377\12""8\"\377\10""5#\377\5""9\37\377\6A\"\377\5\77\23" + "\377\5L\33\377\3H\25\377\3G\16\377\3@\20\377\2J\4\377\1L\7\377\1T\40" + "\377\0Y\21\377\0P\22\377\0X\16\377\0e\33\377\0Z!\377\0[\31\377\0b\23" + "\377\0W\31\377\0Y\16\377\0Z\33\377\0k\27\377\0_\27\377\0f%\377\0^#\377" + "\0f)\377\0N$\377\0""9\37\377\0""5(\377\0(\"\377\0(!\377\0)\35\377\0'" + "#\377\0\31'\377\0#6\377\0&4\377\0\40.\377\0%,\377\0""3#\377\0""71\377" + "\0""57\377\0<4\377\0V:\377\0PC\377\0^S\377\0sI\377\0vU\377\0\213T\377" + "\0oS\377\0gO\377\0aP\377\177\0UJ\377\0QW\377\0Cg\377\0;\\\377\0:i\377" + "\0""5j\377\0+n\377\0,x\377\0)o\377\0""6u\377\0At\377\0@t\377\0Nz\377" + "\0Qq\377\0Z{\377\0^\205\377\0[o\377\0_|\377\0^t\377\0[p\377\0Vl\377\0" + "Zi\377\22h\234\377\0C\216\377\0\40q\377\0$q\377Y\0,\3778\0\33\377\25" + "\0\6\377\26\0\0\377%*\16\377$'\4\377\23)\4\377\30\33\23\377!\16\33\377" + "\31\36\34\377\25\37\11\377\25\23\20\377\5\37\17\377\17\16\15\377\5\15" + "\25\377\0\10\25\377\7\20\37\377\4\16*\377\0\26&\377\0\26\"\377\11\27" + ")\377\6\23(\377\11\30&\377\5$!\377\14#\40\377\11\36\33\377\16\"(\377" + "\0#.\377\3\"\34\377\0-0\377\2/,\377\0\34*\377\0\33\34\377\0#'\377\0$" + "\24\377\0(\"\377\0.$\377\0""1)\377\0""4\"\377\0""4)\377\0C\30\377\0F" + "-\377\0J(\377\2K&\377\4Q\37\377\11K)\377\27V#\377\22[\17\377\16K'\377" + "\15P&\377\12S\26\377\0\"\35\377\0\0\16\3774:g\377Nl\271\377N\213\336" + "\377\\\214\327\377X\231\334\377Q\213\334\377T\220\327\377\\\216\345\377" + "D\215\342\377U\203\342\377S\216\347\377X\222\327\377N\200\346\377b\207" + "\357\377L\202\355\377O\220\347\377H\211\327\377T\212\324\377N\224\340" + "\377G\205\347\377;\211\331\377H\216\332\3779\212\337\3777\222\345\377" + ";\223\325\377\0\0\"\377\0C\36\377\0J\34\377\0M\23\377\0Z\16\377\0O\34" + "\377\0\33\22\377\0\11%\377\12a\204\377\33\237\300\377\32\244\313\377" + "\24\231\330\377\34\241\324\377\31\234\323\377\12\236\305\377\25\227\311" + "\377\23\245\306\377\25\232\313\377\21\241\322\377\21\247\304\377\5\246" + "\307\377\22\230\316\377\10\246\305\377\21\15\237\276\377\26\243\271\377" + "\14\243\267\377\16\245\275\377\20\234\263\377\27\235\262\377\16\235\254" + "\377\13\253\275\377\0\5\0\377\0J\0\377\0O\0\377\0Q\0\377\0J\0\377\0E" + "\0\377\0O\0\377\0K\0\377\0F\0\377\202\0O\0\377\7\0V\0\377\0O\0\377\0" + "Z\0\377\0J\0\377\0P\0\377\0D\0\377\0K\0\377\202\0:\0\377\26\0\77\0\377" + "\0""8\0\377\0A\0\377\0\26\0\377\0\260\250\377\2\262\252\377\0\303\260" + "\377\0\277\232\377\0\272\241\377\0\261\234\377\0L:\377\0-\0\377\0G\0" + "\377\0I\0\377\0H\0\377\0F\0\377\0C\0\377\0H\0\377\0:\0\377\0H\0\377\0" + "C\0\377\0D\0\377\202\0H\0\377\2\0F\0\377\0""7\0\377\202\0,\0\377\4\0" + "(\0\377\0%\0\377\0#\0\377\0%\0\377\202\0\33\0\377\3\0)\0\377\0/\0\377" + "\0\40\0\377\202\0)\0\377\202\0'\0\377\177\0\30\0\377\0\33\0\377\0$\0" + "\377\0\37\0\377\0\23\0\377\5(%\377\5.)\377\4""5\40\377\4,\33\377\6""8" + "\34\377\11L$\377\11M\36\377\5J\34\377\6A$\377\5G\25\377\5I\24\377\2L" + "\21\377\5J\23\377\3G\34\377\5X\33\377\4T\36\377\5A\31\377\4T\34\377\3" + "O\26\377\2R\31\377\1L\2\377\0X\7\377\0V\11\377\0Y\27\377\0^\31\377\0" + "W\31\377\0S\40\377\0V!\377\0Y\34\377\0V\20\377\0M\27\377\0V\31\377\0" + "O\32\377\0V!\377\0M\24\377\0X\25\377\0K$\377\0D\25\377\0B\32\377\0""1" + "\35\377\0$\13\377\0\31$\377\0!\26\377\0\33#\377\0""5*\377\0""2.\377\0" + "-8\377\0&%\377\0)4\377\0""74\377\0""9:\377\0L;\377\0OA\377\0VF\377\0" + "oQ\377\0}W\377\0\211^\377\0{[\377\0r^\377\0rb\377\0nE\377\0QU\377\0M" + "S\377\0Ma\377\0Ie\377\0Gd\377\0Cf\377\0" + "\31\377\4U\24\377\3S\22\377\22Y\33\377\2W\37\377\12O\30\377\12P\33\377" + "\2L\21\377\0\0\12\377En\261\377a\222\320\377E\215\340\377J\213\315\377" + "F\217\330\377S\204\314\377Q\202\333\377F\203\327\377A\201\344\377E\207" + "\337\377M\203\322\377D\210\323\377O\177\323\377Rw\345\377Q}\335\377K" + "\215\347\377V\212\317\377N\201\307\377F\220\326\377E\210\341\377C\222" + "\327\377;\220\323\377D\213\341\377F\223\323\377:\213\321\377A\213\320" + "\377\0\20\77\377\0""4\4\377\0N\26\377\0G\22\377\0R\22\377\0\31\21\377" + "\0\17O\377*\226\322\377.\220\332\377\27\226\326\377\14\232\330\377\32" + "\223\327\377\33\222\320\377\24\233\304\377\27\216\305\377\36\232\310" + "\377\30\244\305\377\17\234\310\377\40\264\311\377\40\235\306\377\16\233" + "\304\377!\230\275\377\"\233\271\377\26\253\273\377\31\244\301\377\31" + "\241\271\377\31\253\257\377\16\251\254\377\31\242\264\377\23\242\264" + "\377\5\253\261\377\0)\36\377\0""7\0\377\0M\0\377\0P\0\377\0T\0\377\0" + "P\0\377\0D\0\377\0B\0\377\0L\0\377\0I\0\377\0R\0\377\0H\0\377\0I\0\377" + "\0@\0\377\0H\0\377\0A\0\377\0""9\0\377\0B\0\377\0""7\0\377\0:\0\377\0" + ";\0\377\0A\0\377\0<\0\377\0\22\0\377\0\212\202\377\0\267\243\377\0\264" + "\246\377\0\255\241\377\0\270\245\377\0\245\241\377\0H>\377\0\35\0\377" + "\0;\0\377\0=\0\377\0M\0\377\0J\0\377\0U\0\377\0R\0\377\0S\0\377\0D\0" + "\377\0M\0\377\0@\0\377\0E\0\377\0A\0\377\0\77\0\377\0""9\0\377\0-\0\377" + "\0:\0\377\202\0,\0\377\177\0$\0\377\0\34\0\377\0\25\0\377\0)\0\377\0" + "\34\0\377\0$\0\377\0)\0\377\0""3\0\377\0""9\0\377\0""5\0\377\0!\0\377" + "\0\33\0\377\0\36\0\377\0\15\0\377\0\25\0\377\1\33\11\377\1\36\11\377" + "\2,\27\377\2""1\34\377\3=\36\377\5G$\377\5D\36\377\3P\33\377\2D\27\377" + "\3I\14\377\1J\12\377\3N\14\377\3P\21\377\2I\31\377\4Y)\377\5S\35\377" + "\5M\37\377\4P\36\377\4M\34\377\4U\30\377\2I\13\377\1K\11\377\0G\6\377" + "\0P\16\377\0^\6\377\0Z\27\377\0Y\25\377\0R\35\377\0X\25\377\0X\16\377" + "\0P\25\377\0J\25\377\0N\14\377\0C\35\377\0@\24\377\0E(\377\0J\31\377" + "\0F\35\377\0K\31\377\0B\32\377\0.\22\377\0.\17\377\0'\27\377\0\34\25" + "\377\0-+\377\0\77&\377\0D&\377\0""7,\377\0""35\377\0""1:\377\0>5\377" + "\0""9@\377\0L6\377\0[@\377\0gB\377\0fT\377\0~S\377\0\215Z\377\0\207`" + "\377\0{Y\377\0tS\377\0m;\377\0[N\377\0ZQ\377\0A_\377\0B_\377\0>^\377" + "\0Ll\377\0Ee\377\0Gs\377\0Ej\377\0Hp\377\0Gj\377\0K^\377\0Se\377\0Gd" + "\377\0Ou\377\0Oi\377\0Ta\377\0Iw\377\0Mj\377\0bl\377\0Tf\377\0Vl\377" + "\14d\245\377\0R\217\377\0>{\377\0>\177\377R\0B\3778\0\35\377\37\0\3\377" + "\17\0\0\377\33\33\2\377\32\"\12\377$\32\15\377)\25\10\377\37\12\14\377" + "\30\24\34\377\26\23\14\377\21\34\15\377\17\21\2\377\17\16\4\377\7\15" + "\13\377\15\26\17\377\0\15\12\377\2\16\13\377\14\33\0\377\11\7\13\377" + "\4\13\10\377\7\34\10\377\6\22\13\377\13\25\5\377~\16\27\6\377\22\35\20" + "\377\11\22\12\377\21\22\26\377\4\12\22\377\17\33\24\377\0\40\24\377\1" + "-\10\377\5\"\36\377\1""3\25\377\4/\30\377\0""6\25\377\0\37\25\377\0\"" + "\31\377\0""4\37\377\0""2\35\377\0=\17\377\0""3!\377\0B\22\377\0P\20\377" + "\0C\5\377\2D\14\377\4P\14\377\1>\6\377\0B\10\377\0J\0\377\0\30\3\377" + "\3\24O\377F\201\313\377\77}\312\377Dv\323\377Mu\306\3777\205\320\377" + "2x\320\377\"^\253\377\13-f\377\22\27j\377\21\16m\377\11\40o\377\6\34" + "o\377\21\26p\377\14\30n\377\14\34n\377\13\30`\377\0#B\377\13(]\377\14" + "!Z\377\6-[\377\0)e\377\0+Y\377\0>c\377\13""0a\377\5Li\377,n\236\377\13" + "3X\377\0\"\0\377\0M\0\377\0Q\14\377\0O\0\377\0\0\1\377\37r\260\377'\177" + "\301\377\31\206\307\377!\205\302\377#\214\312\377\34\222\304\377\21~" + "\265\377\0>S\377\0AH\377\0EQ\377\0CI\377\0JJ\377\0FY\377\0HI\377\0>@" + "\377\0EJ\377\0QV\377\0KI\377\0H;\377\0M7\377\0L+\377\0""99\377\0C<\377" + "\0WC\377\0{q\377\0SA\377\0)\0\377\0M\0\377\0D\0\377\0O\0\377\0>\0\377" + "\0""8\0\377\0""3\0\377\0""8\0\377\0C\0\377\0>\0\377\0""6\0\377\0>\0\377" + "\0\77\0\377\0""3\0\377\0&\0\377\0""7\0\377\0C\0\377\0K\0\377\0;\0\377" + "\0""9\0\377\0""6\0\377\0""7\0\377\0\0\0\377\0vv\377\0\240\250\377\0\230" + "\230\377\0\237\257\377\0\234\253\377\0\250\261\377\0OD\377\0&\0\377\0" + "L\0\377\0""8\0\377\0:\0\377\0L\0\377\0`\0\377\0T\0\377\0W\0\377\0J\0" + "\377\0H\0\377\202\0\77\0\377\3\0=\0\377\0*\0\377\0'\0\377\202\0*\0\377" + "\6\0,\0\377\0\35\0\377\0\24\0\377\0\31\0\377\0#\0\377\0\23\0\377\202" + "\0(\0\377\177\0#\0\377\0)\0\377\0""1\0\377\0&\0\377\0,\0\377\0\26\0\377" + "\0\30\0\377\0\24\0\377\0\15\0\377\3&\33\377\6)\"\377\3,\32\377\6/\35" + "\377\5<%\377\2H\"\377\4D#\377\3P\24\377\0S\7\377\1S\3\377\1O\4\377\1" + "W\5\377\1T\7\377\3]\21\377\3L\33\377\4K\26\377\4K\14\377\3E\22\377\4" + "D\25\377\2O\13\377\1=\7\377\1J\5\377\0H\16\377\0Q\6\377\0\\\13\377\0" + "[\14\377\0W\12\377\0W\11\377\0_\14\377\0X\15\377\0O\11\377\0L\23\377" + "\0""9\17\377\0=\27\377\0C\20\377\0:\27\377\0;(\377\0=\24\377\0H\30\377" + "\0""2\27\377\0""1\26\377\0""1\30\377\0(\20\377\0""9\32\377\0-\40\377" + "\0@&\377\0>\37\377\0H/\377\0=(\377\0@-\377\0V/\377\0P=\377\0_4\377\0" + "h9\377\0vA\377\0wD\377\0\213E\377\0\207L\377\0{O\377\0cE\377\0aJ\377" + "\0XD\377\0DT\377\0KM\377\0DQ\377\0\77\\\377\0NZ\377\0Ak\377\0Sf\377\0" + "Kj\377\0KZ\377\0Hf\377\0Sd\377\0G]\377\0E\\\377\0Jd\377\0L^\377\0BV\377" + "\0@S\377\0\77U\377\0R]\377\0_Z\377\0sh\377\0xd\377\23n\240\377\0U\215" + "\377\0Ds\377\0Ap\377W\0(\3770\0\11\377\31\0\0\377\13\0\0\377#\37\4\377" + ".#\0\377\"\22\4\377#\20\0\377\36\36\0\377\"\31\0\377\36\32\0\377\14\24" + "\0\377\14\35\0\377\15\30\2\377\6\21\6\377\1\25\0\377\15\30\1\377\16\33" + "\0\377\7\17\0\377\7\22\0\377\13\25\0\377\7\27\0\377\10\15\0\377\15\4" + "\3\377\20\13\0\377\13\31\0\377\7\32\2\377\2\25\4\377\7\31\1\377\3\35" + "\0\377#\7%\1\377\10\33\13\377\23-\4\377\13""6\23\377\7;\11\377\0""4\2" + "\377\0""1\13\377\0""4\7\377\0,\0\377\0<\0\377\0\77\4\377\0G\22\377\0" + "F\24\377\0E\6\377\0<\4\377\0@\15\377\0;\6\377\0;\1\377\0;\0\377\0C\0" + "\377\0\0\0\377,C\204\377I\200\303\377Mu\275\377D{\305\377=x\270\377F" + "u\306\377\77u\275\377\0\0\16\377\0\4\0\377\0\0\0\377\0\0\5\377\0\0\6" + "\377\0\0\22\377\0\0\20\377\204\0\0\0\377\177\0\2\0\377\0\5\0\377\0\4" + "\0\377\0\0\0\377\0\11\0\377\0\27\0\377\0\34\2\377\0\30\3\377\0\10\3\377" + "\0*\0\377\0@\15\377\0U\14\377\0I\3\377\0""7\0\377\0\0\17\377\"\212\257" + "\3771|\276\377+\200\270\377+\212\273\377\40\204\273\377\30\222\263\377" + "\0DU\377\0\21\0\377\0\35\0\377\0%\0\377\0\31\0\377\0\27\0\377\0\30\0" + "\377\0\23\0\377\0!\0\377\0\35\0\377\0%\0\377\0-\0\377\0\37\0\377\0\36" + "\0\377\0\33\0\377\0\27\0\377\0\32\0\377\0\20\0\377\0\12\0\377\0$\0\377" + "\0+\0\377\0@\0\377\0B\0\377\0A\0\377\0;\0\377\0""5\0\377\0""1\0\377\0" + "9\0\377\0)\0\377\0""1\0\377\0""0\0\377\0-\0\377\0+\0\377\0""0\0\377\0" + "*\0\377\0=\0\377\0""0\0\377\0B\0\377\0)\0\377\0""8\0\377\0""9\0\377\0" + "$\0\377\0\0\0\377\0io\377\0\214\251\377\0\226\270\377\0\232\253\377\0" + "\223\266\377\0\233\247\377\0HB\377\0$\0\377\0<\0\377\0R\0\377\0I\0\377" + "\0X\0\377\0`\0\377\0W\0\377\0I\0\377\0A\0\377\0E\0\377\0F\0\377\0E\0" + "\377\0""9\0\377\0.\0\377\0&\0\377\0,\0\377\0&\0\377\0\37\0\377\0\27\0" + "\377\0\32\0\377\0\40\0\377\0\36\0\377\0\40\0\377\0)\0\377\0\35\0\377" + "\0(\0\377\0;\0\377\0""6\0\377\0""5\0\377\0$\0\377\0\30\0\377\0\26\0\377" + "\0\17\0\377\0\31\0\377\5""2)\377\5""7)\377\15""4-\377\12""5-\377\11*" + "&\377\7/!\377\7@\31\377\5L\20\377\0\\\2\377\0Y\0\377\0U\1\377\0^\1\377" + "\1Y\3\377\1`\14\377\2R\7\377\3B\10\377\2D\16\377\1;\11\377\2:\16\377" + "\2=\13\377\2\77\11\377\1\\\5\377m\0i\16\377\0b\0\377\0X\0\377\0d\6\377" + "\0Z\17\377\0]\6\377\0]\2\377\0[\0\377\0I\7\377\0F\10\377\0;\7\377\0F" + "\25\377\0E\27\377\0F\25\377\0<\30\377\0G\12\377\0H\6\377\0;\17\377\0" + "6\30\377\0""6\20\377\0""1\21\377\0""8\33\377\0/\40\377\0F\21\377\0""9" + "\33\377\0@\34\377\0""9&\377\0F.\377\0O,\377\0\\/\377\0e5\377\0r;\377" + "\0x=\377\0y5\377\0\177C\377\0r2\377\0e4\377\0];\377\0_\77\377\0Y8\377" + "\0UC\377\0@A\377\0""9R\377\0IW\377\0:X\377\0\77a\377\0Dl\377\0Of\377" + "\0RZ\377\0PQ\377\0IM\377\0BC\377\0@M\377\0DL\377\0KF\377\0FL\377\0XP" + "\377\0PD\377\0SR\377\0dF\377\0wT\377\0oT\377\6p\240\377\0V|\377\0""4" + "g\377\0=^\377b\0""1\377@\0\10\377\24\0\0\377\27\0\0\377%%\0\377,\35\0" + "\377&%\0\3770\30\0\377\40\16\0\377/\20\0\377#\31\0\377\22\27\0\377\5" + "\20\0\377\30\24\0\377\26\17\0\377\16\17\0\377\14\21\0\377\12\31\0\377" + "\27\25\0\377\15\21\0\377\33\5\0\377\24\16\0\377\20\10\2\377\32\27\0\377" + "\16\23\0\377\30\22\1\377\32\20\4\377\21\36\0\377\20\24\3\377\24\30\3" + "\377\24\33\11\377\22\23\2\377\17%\0\377\7.\3\377\3/\12\377\0-\10\377" + "\0%\4\377\0""2\3\377\0""9\0\377\0""4\0\377\4G\13\377\0F\15\377\0L\0\377" + "\202\0<\0\377\202\0I\0\3770\0=\0\377\0A\0\377\0D\0\377\0\0\0\377,F\214" + "\377>q\274\377D\200\301\377Dz\257\377Hx\270\377>r\300\377;l\302\377\0" + "\0\0\377\0%\0\377\0\27\14\377\0\30\12\377\0\22\4\377\0\36\15\377\0\34" + "\0\377\0\36\0\377\0\26\0\377\0&\3\377\0#\0\377\0&\0\377\0#\0\377\0'\0" + "\377\0$\0\377\0/\0\377\0""2\0\377\0""8\0\377\0:\0\377\0H\0\377\0I\0\377" + "\0H\0\377\0L\4\377\0J\0\377\0""0\0\377\0\25\24\377&\205\256\377$\201" + "\266\377.\205\257\377\34\204\272\377\33\201\266\377\21\220\270\377\0" + "\0\377\202\0""2\0\377\2\0""9\0\377\0<\0\377\202\0.\0\377-\0""3\0\377" + "\0,\0\377\0""7\0\377\0-\0\377\0""4\0\377\0""0\0\377\0&\0\377\0""0\0\377" + "\0""6\0\377\0'\0\377\0""9\0\377\0.\0\377\0*\0\377\0\0\0\377\0Sd\377\0" + "\203\270\377\0\222\253\377\0\215\255\377\0\213\241\377\0\216\247\377" + "\0L;\377\0*\0\377\0<\0\377\0>\0\377\0I\0\377\0W\0\377\0V\0\377\0D\0\377" + "\0E\0\377\0D\0\377\0E\0\377\0>\0\377\0H\0\377\0""6\0\377\0""0\0\377\0" + ")\0\377\0#\0\377\0\26\0\377\0\40\0\377\0%\0\377\0-\0\377\0&\0\377\0'" + "\0\377\0\36\0\377\0$\0\377\202\0*\0\377\40\0I\0\377\0M\0\377\0""8\0\377" + "\0\40\0\377\0\33\0\377\0\25\0\377\0\20\0\377\0\24\0\377\14""5+\377\15" + ")'\377\14\"!\377\13\37\37\377\17\37\35\377\13-\33\377\7<\23\377\10S\15" + "\377G\216G\377\225\265\225\377\314\333\314\377\351\360\351\377\371\372" + "\371\377\340\351\340\377\234\274\235\377%`)\377\2E\7\377\3L\10\377\3" + "X\12\377\5P\13\377\4Z\12\377\1_\6\377\0h\1\377\0f\0\377\202\0b\0\377" + "@\0i\1\377\0o\10\377\0p\3\377\0X\16\377\2O\5\377:p>\377\216\260\221\377" + "\304\323\305\377\336\345\340\377\370\371\370\377\360\364\360\377\323" + "\336\324\377\201\240\204\377\11B\34\377\0""2\"\377\0""1\23\377\0""2\15" + "\377\0A%\377\0B'\377\0D*\377\0;#\377\0@!\377\0A\40\377\0G'\377\0Y\35" + "\377\0b)\377\1\207+\377T\263z\377\306\345\324\377\352\366\357\377\372" + "\374\373\377l\253\215\377\0b&\377\0P-\377\0S0\377\0R9\377\0IO\377\0>" + "G\377\0:T\377\0/M\377\0=O\377\0Ma\377\0GU\377\0NV\377\0SW\377\0HV\377" + "\0O[\377\0AF\377\0O;\377\0NM\377\0UK\377\0YB\377\0YM\377\0^I\377\0bJ" + "\377\0hH\377\0oX\377\0gW\377\7y\203\377\0gk\377\0CP\377\0BB\377^\0/\377" + ":\0\16\377\202\31\0\0\377\10#-\5\377)+\0\377*\40\0\377&\34\0\377#\30" + "\0\377\33\31\0\377#\32\0\377\35\26\0\377\202\34\20\0\377.\22\7\0\377" + "\22\11\0\377\22\17\0\377\25\23\0\377\31\12\0\377\34\26\0\377\21\11\0" + "\377!\17\0\377\16\34\2\377#\23\0\377$\25\0\377\40\20\0\377\31\33\10\377" + "\30\11\3\377\23\11\15\377\34\14\13\377\23\31\0\377\26\32\4\377\13\22" + "\4\377\13\"\14\377\6\36\14\377\10!\11\377\6(\10\377\21(\2\377\13(\0\377" + "\3""6\0\377\2K\0\377\0G\0\377\0E\0\377\0C\0\377\0H\0\377\0\77\0\377\0" + "B\0\377\0""5\0\377\0\77\0\377\0>\0\377\0\0\0\377-;\204\377Cj\275\377" + ";v\261\3778l\260\377>t\262\377:m\263\3775d\265\377\0\0\0\377\0\35\0\377" + "\202\0\30\0\377\5\0\32\0\377\0\22\4\377\0\24\0\377\0\32\0\377\0\26\0" + "\377\202\0\36\0\377e\0\25\0\377\0\"\0\377\0""1\0\377\0(\0\377\0,\0\377" + "\0""4\0\377\0""1\0\377\0""7\0\377\0""1\0\377\0C\0\377\0G\0\377\0;\0\377" + "\0G\0\377\0,\0\377\0\4\31\377\36\204\301\377\23\215\272\377!\222\276" + "\377\40\214\262\377\27\215\305\377\37\202\265\377\0""3V\377\0\36\0\377" + "\0L\0\377\0""1\0\377\0""0\0\377\0""2\0\377\0@\0\377\0""6\0\377\0;\0\377" + "\0>\0\377\0""7\0\377\0""6\0\377\0.\0\377\0=\0\377\0E\0\377\0+\0\377\0" + "1\0\377\0-\0\377\0""5\0\377\0""6\0\377\0""2\0\377\0<\0\377\0""7\0\377" + "\0:\0\377\0*\0\377\0+\0\377\0$\0\377\0#\0\377\0\23\0\377\0\32\0\377\0" + "\33\0\377\0\40\0\377\0\23\0\377\0\25\0\377\0\16\0\377\0\32\0\377\0\20" + "\0\377\0\16\0\377\0\15\0\377\0\25\0\377\0\32\0\377\0*\0\377\0\0\0\377" + "\0Bq\377\0\200\260\377\0\200\246\377\0y\247\377\0\214\240\377\0\231\241" + "\377\0""58\377\0\24\0\377\0""3\0\377\0:\0\377\0#\0\377\0(\0\377\0,\0" + "\377\0-\0\377\0""1\0\377\0-\0\377\0&\0\377\0+\0\377\0*\0\377\0""6\0\377" + "\0\77\0\377\0""2\0\377\0!\0\377\0\26\0\377\0\17\0\377\0\35\0\377\0\26" + "\0\377\0\40\0\377\0(\0\377\0\33\0\377\0'\0\377\0\"\0\377\0,\0\377\0/" + "\0\377\0""6\0\377\0;\0\377\0""9\0\377\202\0-\0\377\17\0\30\0\377\0\11" + "\0\377\3'\26\377\10!\34\377\12\40\35\377\14\31\26\377\11)\30\377\31""2" + "\37\377|\235\177\377\345\357\345\377\261\310\261\377\204\246\204\377" + "r\244r\377\227\275\227\377\353\361\353\377\202\377\377\377\377\25\367" + "\371\367\377H\211M\377\3L\12\377\5U\13\377\5X\14\377\5U\12\377\2Y\4\377" + "\0e\1\377\0d\0\377\0Z\0\377\0r\0\377\0n\0\377\0q\3\377\1`\1\377[\241" + "[\377\340\353\340\377\265\317\266\377x\243x\377X\210X\377z\243z\377\265" + "\310\265\377\203\377\377\377\377\16\300\317\303\377\2>\15\377\0<\5\377" + "\0A\0\377\0E\21\377\0H)\377\0""9\37\377\0;\"\377\0""8\34\377\0""8\33" + "\377\0E\17\377\0`\31\377\24\222B\377\300\351\312\377\203\377\377\377" + "\377\17\304\337\316\377\4e\"\377\0c%\377\0U,\377\0]0\377\0W9\377\0[5" + "\377\0QM\377\0\77M\377\0F\77\377\0E9\377\0""6C\377\0>P\377\0FP\377\0" + "EW\377\202\0NL\377O\0[H\377\0VE\377\0SA\377\0H=\377\0S<\377\0\\=\377" + "\0RK\377\0cI\377\0jG\377\0]T\377\0iS\377\13v\205\377\0Mq\377\0""8Y\377" + "\0-Y\377^\0-\377D\0\23\377\26\0\0\377\24\0\0\377\"3\0\3774+\0\377*&\0" + "\3772\30\0\377\"\34\0\377#\22\0\377\32\3\0\377\40\13\0\377\40\5\0\377" + "(\12\0\377\36\14\0\377\30\6\0\377$\17\0\377\31\5\0\377\25\7\0\377\34" + "\15\0\377\22\23\0\377\"\22\2\377\37\25\0\377\"\31\3\377%\24\10\377'\15" + "\0\377\36\12\0\377\40\0\4\377\30\2\0\377'\3\2\377\22\11\4\377\24\12\0" + "\377\22\11\0\377\15\22\17\377\16\6\7\377\25\14\15\377\25\35\0\377\23" + "-\3\377\0""7\0\377\0""4\0\377\0:\0\377\0""5\0\377\0@\0\377\0G\6\377\0" + "F\0\377\0;\0\377\0D\0\377\0H\0\377\0C\0\377\0""7\0\377\0\0\0\377/C\205" + "\3778q\260\377:g\274\3771Z\257\377'_\272\377*_\261\3777^\271\377\0\0" + "\0\377\0\37\0\377\0\17\0\377\0\31\0\377\0\23\0\377\0\35\0\377\202\0\34" + "\0\377\33\0\20\0\377\0#\0\377\0%\0\377\0\36\0\377\0\40\0\377\0\32\0\377" + "\0!\0\377\0\"\0\377\0'\0\377\0""5\0\377\0""1\0\377\0%\6\377\0""3\0\377" + "\0\35\2\377\0\33\0\377\0/\0\377\0\33\0\377\0\27""6\377(\211\321\377*" + "\217\312\377!\220\311\377\22\205\307\377\17\203\305\377\14}\275\377\0" + "1V\377\0\13\0\377\0""7\1\377\202\0""7\0\377\25\0<\0\377\0@\0\377\0""7" + "\0\377\0E\0\377\0A\0\377\0""7\0\377\0B\0\377\0J\0\377\0""9\0\377\0=\0" + "\377\0<\0\377\0)\0\377\0""1\0\377\0""9\0\377\0""2\0\377\0-\0\377\0=\0" + "\377\0""7\0\377\0!\0\377\0\37\0\377\0\25\0\377\202\0\0\0\377\15\0\33" + "\24\377\0\25\11\377\0\35\12\377\0\6\1\377\0\17\16\377\0\27\5\377\0\12" + "\10\377\0\7\12\377\0\16\10\377\0\26\15\377\0\23\23\377\0\10\15\377\0" + "\0\16\377\202\0\0\0\377\30\0Jq\377\0k\262\377\0z\252\377\0t\250\377\0" + "y\234\377\0y\242\377\0\":\377\0\0\0\377\0\34\0\377\0\35\0\377\0\31\0" + "\377\0\32\0\377\0\34\11\377\0\21\0\377\0\35\7\377\0!\0\377\0\33\1\377" + "\0\32\2\377\0\15\0\377\0\23\0\377\0""0\0\377\0""5\0\377\0%\0\377\0\12" + "\0\377\202\0\20\0\377\35\0\31\0\377\0\16\0\377\0\23\0\377\0\11\0\377" + "\0\0\0\377\0\35\0\377\0\32\0\377\0\35\0\377\0\36\4\377\0\3\0\377\0<\0" + "\377\0$\0\377\0\35\0\377\0\33\0\377\0\23\0\377\6\35\17\377\14#\25\377" + "\11\36\22\377\11\21\23\377Uj_\377\353\357\354\377\243\272\246\377\31" + "Z\35\377\0T\1\377\0T\0\377\0R\0\377\0c\1\377\21e\21\377\266\316\266\377" + "\202\377\377\377\377\25\355\363\355\377\33r\40\377\11d\14\377\10g\16" + "\377\10c\13\377\3b\5\377\1Q\1\377\0Z\0\377\0e\0\377\0c\0\377\0j\0\377" + "%\203&\377\306\337\306\377\276\327\276\377'\205'\377\0Z\0\377\0W\0\377" + "\0S\0\377\0V\0\377\0L\0\377U\177U\377\203\377\377\377\377]\25\377\0C\14\377\0B\37\377\0@\23\377\0@\13\377\0-" + "\26\377\0F\14\377'z=\377\334\354\340\377\244\340\257\377,\303N\377\16" + "\277U\377\14\242<\377\5\215&\377\0q\40\377\0h/\377\0P-\377\0R&\377\0" + "R'\377\0Q7\377\0B\77\377\0S8\377\0J=\377\0D=\377\0AN\377\0DR\377\0SU" + "\377\0J@\377\0IG\377\0PB\377\0`7\377\0O6\377\0\\C\377\0X;\377\0N@\377" + "\0JH\377\0PB\377\0SG\377\0hW\377\0OX\377\0Yb\377\15f\236\377\0C\214\377" + "\0\"m\377\0\40f\377Z\0\37\377<\0\4\377$\0\0\377/\0\0\37754\0\377\40," + "\0\3772*\5\377-0\0\3774\13\0\377,\22\0\3773\15\0\3772\14\0\377\33\12" + "\0\377\30\3\0\377\33\13\0\377\35\2\0\377#\0\0\377\26\11\0\377\25\4\0" + "\377\33\13\0\377(\12\0\377\37\32\0\3770\17\5\377-\31\0\377(\10\0\377" + "\"\20\0\377(\1\0\377\40\0\0\377\36\4\0\377&\3\0\377\22\13\0\377\31\0" + "\0\377\21\7\2\377#\16\0\377\"\3\0\377#\5\4\377\35\26\0\377\35\34\0\377" + "\16,\0\377\0;\0\377\11:\0\377\0B\0\377\0""5\0\377\0<\0\377\0""7\0\377" + "\202\0""8\0\377\21\0B\0\377\0>\0\377\0""8\0\377\0\0\0\377/4~\377=a\272" + "\377;U\267\377,W\262\377\36I\251\3776W\305\377;U\264\377\0\0\0\377\0" + "\17\0\377\0\31\0\377\0\33\0\377\0\17\0\377\0\30\0\377\202\0\21\0\377" + "\4\0\17\0\377\0'\0\377\0,\0\377\0\31\0\377\202\0\25\0\377\25\0\23\1\377" + "\0\"\0\377\0(\0\377\0%\0\377\0\37\0\377\0$\0\377\0\40\6\377\0,\0\377" + "\0/\20\377\0\"\0\377\0\32\2\377\0\0*\377!v\274\377\37v\313\377\33\203" + "\314\377+{\307\377\37~\313\377\26\177\304\377\0%[\377\0\15\0\377\0""8" + "\0\377\202\0@\0\377^\0E\0\377\0B\0\377\0A\0\377\0B\0\377\0@\0\377\0>" + "\0\377\0B\0\377\0=\0\377\0>\0\377\0""3\0\377\0""8\0\377\0""1\0\377\0" + "=\0\377\0""2\0\377\0/\0\377\0,\0\377\0+\0\377\0""4\0\377\0\"\0\377\0" + "\0\0\377\0\36\32\377\0m\215\377\0\207\233\377\0\222\257\377\0\212\253" + "\377\0\206\244\377\0|\231\377\0\207\227\377\0\206\226\377\0}\224\377" + "\0\200\227\377\0\200\232\377\0r\250\377\0\202\241\377\0\201\235\377\0" + "v\243\377\0n\254\377\0Hn\377\0Qy\377\0o\257\377\0k\256\377\0r\257\377" + "\0m\270\377\0a\224\377\0\34/\377\0\6\0\377\0#\0\377\0\30\0\377\0\0\0" + "\377\0qi\377\0\203\227\377\0\205\236\377\0{\250\377\0\210\241\377\0\220" + "\232\377\0\215\235\377\0\177\224\377\0\11\0\377\0\17\0\377\0\40\0\377" + "\0'\0\377\0\27\0\377\0\20\0\377\0\31\0\377\0\15\0\377\0\30\0\377\0\7" + "\0\377\0\0\0\377\0XO\377\0\205\227\377\0\213\222\377\0\201\211\377\0" + "$\14\377\0""8\0\377\0L\0\377\0""3\0\377\0%\0\377\0\33\0\377\0\36\0\377" + "\4\35\14\377\7\33\22\377\7\16\20\377\230\234\234\377\377\377\377\377" + "j\200s\377\2=\15\377\0P\2\377\0c\0\377\0Z\0\377\0a\0\377\0Y\0\377\0[" + "\0\377\13`\13\377\353\361\353\377\202\377\377\377\377S|\257\177\377\10" + "h\16\377\13]\16\377\10_\14\377\3[\4\377\1Y\1\377\0[\0\377\0Z\0\377\0" + "d\0\3778\2238\377\353\363\353\377\211\274\211\377\3q\3\377\0z\0\377\0" + "n\0\377\0m\0\377\0b\0\377\0T\0\377\0G\0\377\0=\0\377\257\303\257\377" + "\377\377\377\377\214\251\214\377\1T\1\377\0E\0\377\0@\1\377\0>\7\377" + "\0G\5\377\0<\7\377\0""0\0\377\0D\22\377\0A\15\377\37_3\377\352\362\354" + "\377\302\343\310\377\2\264*\377\0\3041\377\0\303B\377\0\2511\377\0\230" + "1\377\0{(\377\0f-\377\0X.\377\0R+\377\0Z2\377\0I8\377\0C,\377\0G+\377" + "\0N2\377\0TJ\377\0FL\377\0NE\377\0RO\377\0GK\377\0N[\377\0OD\377\0L9" + "\377\0NE\377\0KI\377\0HG\377\0QB\377\0KA\377\0SF\377\0aP\377\0dL\377" + "\0ad\377\0b_\377\5e\222\377\0>s\377\0(f\377\0!h\377W\0#\377\77\0\0\377" + "&\0\0\377#\0\0\3776\37\0\3779%\0\3775&\0\377;\"\2\3771\25\0\377*\20\0" + "\3774\25\0\377,\0\0\377\202\37\0\0\3772+\0\0\3770\2\0\377&\6\0\377-\15" + "\0\377!\21\3\3771\10\0\377.\2\0\377,\11\0\3777\5\0\3771\16\3\3772\14" + "\0\377-\15\7\3773\13\5\377%\3\7\377!\3\0\377#\3\2\377$\0\3\377\36\12" + "\0\377!\26\0\377+\17\0\377\40\32\0\377\"\34\0\377\21\24\0\377\26\35\0" + "\377\21,\0\377\11""4\0\377\0/\0\377\0""1\1\377\0=\0\377\0""4\0\377\7" + "1\0\377\6B\0\377\0B\0\377\0H\0\377\0F\0\377\0-\0\377\0\0\0\377+8q\377" + "@`\246\3775[\253\377,G\256\377!K\277\377,S\267\3776D\276\377\0\0\0\377" + "\0\10\0\377\0\13\0\377\0\0\0\377\0\1\0\377\0\6\0\377\203\0\0\0\377\1" + "\0\3\0\377\207\0\0\0\377P\0\7\0\377\0\3\0\377\0\12\4\377\0\22\6\377\0" + "\"\0\377\0*\0\377\0,\0\377\0\27\0\377\0\0'\377&w\305\377#v\301\377!w" + "\303\377\34o\313\377*k\315\377\35t\311\377\0(v\377\0\6\5\377\0\6\0\377" + "\0\26\0\377\0\23\0\377\0\32\0\377\0\26\0\377\0\24\0\377\0\3\0\377\0\20" + "\0\377\0\27\0\377\0\13\0\377\0\31\0\377\0\20\0\377\0\22\0\377\0\31\0" + "\377\0\40\0\377\0/\0\377\0""9\0\377\0""5\0\377\0&\0\377\0\40\0\377\0" + "(\0\377\0\24\0\377\0\23\22\377\0~\241\377\0\200\237\377\0\207\242\377" + "\0\216\250\377\0~\230\377\0p\236\377\0r\237\377\0}\240\377\0w\216\377" + "\0o\222\377\0v\237\377\0v\232\377\0t\234\377\0s\226\377\0x\237\377\0" + "n\260\377\0j\255\377\1o\245\377\0b\261\377\0c\264\377\0g\251\377\0_\257" + "\377\0_\253\377\0l\256\377\0\32""7\377\0\0\0\377\0\14\0\377\0\27\0\377" + "\0\11\0\377\0\0\0\377\0bq\377\0p\235\377\0v\227\377\0z\230\377\0~\243" + "\377\0}\232\377\0~\237\377\0^w\377\0\0\0\377\0\12\0\377\202\0\34\0\377" + "\1\0%\0\377\202\0\17\0\377\35\0\5\0\377\0\0\0\377\0ha\377\0\220\216\377" + "\3\206\210\377\0sa\377\0\2\0\377\0:\0\377\0o\0\377\0_\0\377\0B\0\377" + "\0$\0\377\0\34\0\377\0\35\0\377\2$\6\377\3#\7\377\216\221\222\377\377" + "\377\377\377\200\207\206\377\6'\24\377\5N\13\377\0U\1\377\0Y\1\377\0" + "X\1\377\0T\0\377\0N\0\377\0Z\0\377\1a\3\377~\256\202\377\202\377\377" + "\377\377V\266\323\267\377\7e\16\377\13^\16\377\12O\17\377\5S\13\377\1" + "M\3\377\0`\1\377\0]\0\377C\215C\377\366\371\366\377\223\276\223\377\1" + "e\1\377\0\210\0\377\0\204\0\377\0t\0\377\0s\0\377\0f\0\377\0Q\0\377\0" + "E\0\377\0K\0\377`\220`\377\214\252\214\377\1A\1\377\0L\0\377\0X\0\377" + "\0G\0\377\0L\0\377\0F\0\377\0B\2\377\0""6\11\377\0\77\4\377\2W\23\377" + "\313\336\320\377\377\377\377\377V\275o\377\0\304\37\377\0\3033\377\0" + "\310I\377\0\276D\377\0\2479\377\0\213/\377\0p%\377\0]2\377\0U/\377\0" + "P)\377\0N\35\377\0\77""1\377\0C\"\377\0D'\377\0ZD\377\0`<\377\0Z@\377" + "\0hC\377\0OG\377\0JE\377\0LB\377\0B\77\377\0BL\377\0JM\377\0O9\377\0" + "RK\377\0]N\377\0\\L\377\0RS\377\0YL\377\0cZ\377\0\\^\377\0l\215\377\0" + "Ng\377\0/Q\377\0+X\377c\0\40\377:\0\15\377#\0\0\377*\0\0\377:)\0\377" + "/\33\0\377C\33\0\377B\14\0\377<\16\0\3776\7\0\3774\5\0\3776\1\0\377-" + "\0\0\377/\0\0\3773\0\0\377\202:\7\0\377\37+\26\0\377%\3\0\3773\1\0\377" + ",\2\0\3771\14\0\3778\10\0\377,\22\0\3775\5\0\3778\11\0\3779\23\0\377" + "+\12\0\377,\10\0\377'\15\2\377\36\13\0\377\31\22\0\377%\22\0\377&\27" + "\0\377$\22\0\377\34!\0\377\22\33\0\377\16/\0\377\11""1\0\377\11""8\0" + "\377\7""7\0\377\6""9\0\377\1""9\0\377\10""8\0\377\0\77\0\377\0""9\0\377" + "\0=\0\377\0C\0\377\202\0;\0\377\10\0\0\0\377@7z\377EN\246\377GQ\267\377" + "6R\256\3775K\270\377>=\266\3778G\256\377\203\0\0\0\377S\0\0\32\377\0" + "\0\26\377\3\0\20\377\4\0\34\377\0\0\31\377\1\0#\377\0\0\33\377\0\0\34" + "\377\0\0%\377\0\0)\377\0\0(\377\0\0\40\377\0\0""1\377\0\0.\377\0\0\40" + "\377\0\0#\377\0\0,\377\0\0%\377\0\0'\377\0\0\0\377\0\40\0\377\0\26\0" + "\377\0\7+\377\33}\305\377\"g\273\377!h\303\377\32g\300\377*g\302\377" + "\36x\276\377\35e\263\377\0\"b\377\0\35V\377\0%T\377\0$I\377\0\"B\377" + "\0""0H\377\0*E\377\0&>\377\0\36H\377\0,I\377\0+@\377\0.>\377\0""38\377" + "\0""06\377\0""4+\377\0+7\377\0\10\0\377\0\2\0\377\0\23\0\377\0!\0\377" + "\0(\0\377\0$\0\377\0\0\0\377\0C\\\377\0\203\230\377\0|\241\377\0w\235" + "\377\0u\240\377\0r\241\377\0S\202\377\0\23\15\377\0\7\0\377\0\6\1\377" + "\0\0\0\377\0\6\4\377\0\0\0\377\0\0\2\377\0\0\6\377\0\0\15\377\0\0\14" + "\377\0\0\11\377\0\23""1\377\0c\246\377\0b\253\377\0`\236\377\0Z\241\377" + "\0Z\252\377\0d\242\377\0\25.\377\0\0\0\377\0\12\0\377\0\6\0\377\0\16" + "\0\377\202\0\0\0\377\15\0Im\377\0x\230\377\0z\231\377\0{\233\377\0\203" + "\241\377\0\202\230\377\0r\244\377\0iv\377\0\0\0\377\0\14\0\377\0\40\0" + "\377\0\30\0\377\0\22\0\377\202\0\0\0\377\34\0nw\377\0\227\217\377\0\215" + "\234\377\0p_\377\0\0\0\377\0""3\0\377\0i\0\377\0t\0\377\0h\0\377\0W\0" + "\377\0""7\0\377\0$\0\377\0\31\0\377\0\22\0\377jtk\377\377\377\377\377" + "\315\321\317\377\10%\30\377\6""9\26\377\5K\17\377\1d\11\377\1^\11\377" + "\2c\6\377\1`\2\377\1[\3\377\4O\10\377\6G\15\377*`4\377\202\377\377\377" + "\377\40\326\346\327\377\6k\16\377\6Z\20\377\11`\23\377\11]\17\377\4d" + "\7\377\0l\0\377\40v\40\377\355\363\355\377\302\330\302\377\3q\3\377\0" + "j\0\377\0x\0\377\0\201\0\377\0\207\0\377\0\202\0\377\0\203\0\377\0f\0" + "\377\0Z\0\377\0P\0\377\12Q\12\377\1Q\1\377\0K\0\377\0V\0\377\0W\0\377" + "\0H\1\377\0F\5\377\0I\0\377\0>\11\377\0L\6\377\0P\1\377P\210T\377\202" + "\377\377\377\377_\25\2425\377\0\273,\377\0\312=\377\0\300N\377\0\261" + "7\377\0\213\"\377\0\205\32\377\0x\40\377\0g$\377\0U)\377\0J(\377\0I!" + "\377\0L(\377\0E,\377\0P2\377\0W<\377\0^;\377\0jF\377\0]G\377\0WP\377" + "\0_M\377\0PO\377\0KP\377\0[P\377\0PK\377\0_O\377\0ZV\377\0UP\377\0VP" + "\377\0VQ\377\0YL\377\0_X\377\0^P\377\0g\214\377\0Jt\377\0-P\377\0""6" + "Z\377`\0+\377;\0\2\377$\0\0\3772\0\0\3777\30\0\3778\25\0\377@\26\0\377" + "4\17\0\377;\4\0\3775\11\0\3779\0\0\377-\3\0\3772\10\0\3777\10\0\377+" + "\4\0\3771\16\0\377/\25\0\3776\27\0\3774\11\0\377<\16\0\377<\12\0\377" + "0\7\0\377:\4\0\377A\10\0\377B\16\0\377@\13\0\3777\10\0\377\35\23\0\377" + "%\31\0\377$\24\0\377%\"\6\377&\31\2\377'\20\0\377)\23\0\377\31\33\0\377" + "\36\36\0\377\14&\0\377\16\"\0\377\16.\0\377\30>\0\377\6""8\0\377\1""7" + "\0\377\6""5\3\377\0:\0\377\0,\0\377\6=\0\377\4=\0\377\4""4\0\377\7=\0" + "\377\1>\0\377\0\0\0\377\77,y\377OI\260\377IK\257\377BI\253\377>@\265" + "\3778A\254\3774D\253\377\202\0\0\0\377=\5\0\20\377EB\246\377HQ\267\377" + "DB\264\377WB\262\377SE\265\377BE\261\3777J\261\3779G\261\377\33\377\4_\31\377\5X\23\377\6T\17\377\4_\14\377\5E\14\377\10E" + "\21\377\12\77\26\377\17E\30\377\376\376\376\377\377\377\377\377\365\371" + "\365\377\5c\15\377\10k\15\377\5l\16\377\5q\15\377\7p\13\377\12j\15\377" + "\315\341\315\377\371\373\371\377(\210(\377\0f\0\377\0l\0\377\202\0\204" + "\0\377s\0\233\0\377\0\224\0\377\0\211\0\377\0~\1\377\0d\5\377\0Y\11\377" + "\0Z\0\377\0L\0\377\0S\0\377\0c\0\377\0Y\0\377\0P\3\377\0W\12\377\0M\5" + "\377\0Q\2\377\0N\15\377\0a\14\377\277\327\300\377\377\377\377\377\322" + "\346\330\377\0\232/\377\0\2558\377\0\315=\377\0\304C\377\0\2501\377\0" + "\226\35\377\0\225\27\377\0\177\36\377\0i#\377\0c*\377\0c$\377\0\\.\377" + "\0P,\377\0Z0\377\0P7\377\0W:\377\0[B\377\0ZE\377\0[H\377\0XH\377\0aK" + "\377\0]L\377\0SR\377\0ZV\377\0`^\377\0[P\377\0[M\377\0`[\377\0[`\377" + "\0XZ\377\0\\U\377\0QW\377\0Zd\377\10[\233\377\0""9n\377\0\36^\377\0\37" + "b\377c\0(\3775\0\10\377\"\0\0\377$\0\0\377<\36\0\3773\7\0\377,\26\0\377" + "/\23\0\3772\10\0\3775\21\0\377+\6\0\377+\21\0\3776\27\0\3775\12\0\377" + "3\15\0\377%\15\0\3776\27\0\3772\30\0\377<\36\0\377B!\0\3773\27\0\377" + "8\2\0\3776\0\0\377;\1\0\377@\26\0\3777\4\0\3776\26\0\377#\31\0\377,\31" + "\0\377:\31\0\377,\34\0\377/\24\0\377#\35\0\377\35%\0\377\25\32\0\377" + "\35\40\3\377\36/\0\377\27F\0\377\0A\0\377\7>\0\377\10""8\0\377\10""7" + "\0\377\0""4\0\377\0""7\0\377\2""2\0\377\3.\0\377\1#\0\377\22(\0\377\24" + "\40\0\377\13\40\0\377\1\0\0\377G\40}\377G8\260\377N@\266\377G1\263\377" + "M5\261\377:\77\236\377;;\246\377\202\0\0\0\377`\0\0\11\377HD\255\377" + "BG\252\377KC\236\377Z:\254\377QQ\271\377>I\267\3771K\253\377*Q\266\377" + "-V\256\3770b\257\3779Q\245\3772T\256\377.d\245\3770R\263\377&Z\305\377" + "+^\303\377)b\266\377(^\260\377\0\15-\377\0\12\0\377\0(\0\377\0\20\0\377" + "\0\0\20\377)n\267\377%m\271\377$x\271\377\34l\255\377\34c\271\377\31" + "]\265\377\27b\253\377#t\233\377\26h\226\377\40i\235\377\16d\235\377\0" + "r\243\377\13x\245\377\11s\237\377\24s\241\377\6m\237\377\6q\230\377\0" + "n\232\377\0r\220\377\0k\227\377\2^\237\377\7m\237\377\5r\236\377\0m\232" + "\377\0k\252\377\0\23=\377\0\0\0\377\0\11\0\377\0\10\0\377\0\0\0\377\0" + "_\251\377\0c\257\377\0d\262\377\0m\250\377\0i\244\377\0g\231\377\0\0" + "\17\377\0\0\0\377\0\37\0\377\0\30\0\377\0\17\0\377\0\12\0\377\0\6\0\377" + "\0\25\0\377\0\21\0\377\0\36\0\377\0\33\0\377\0\24\0\377\0\0\0\377\0""8" + "\\\377\0b\235\377\0X\227\377\0W\236\377\0g\237\377\0v\235\377\0\40""2" + "\377\0\0\0\377\0\24\0\377\0\33\0\377\0\22\0\377\0\11\0\377\0\14\0\377" + "\0\0\0\377\0\10\0\377\0n\204\377\0|\224\377\5}\213\377\7~\212\377\0\212" + "\224\377\0\205\222\377\0z\214\377\0av\377\202\0\0\0\377\177\0\33\10\377" + "\0|\212\377\0\214\231\377\0\222\225\377\0""8#\377\0\12\0\377\0\24\0\377" + "\0""9\0\377\0""4\0\377\0L\0\377\0R\0\377\0b\0\377\0^\0\377\0P\0\377\0" + "9\0\377\0+\0\377\214\243\214\377\377\377\377\377\323\330\323\377\1+\5" + "\377\2%\12\377\6\77\24\377\5K\31\377\13W\36\377\15J\32\377\12;\25\377" + "\12@\23\377\10""8\26\377\11=\26\377\10""7\22\377\6K\21\377\345\355\346" + "\377\377\377\377\377\360\365\361\377\6o\21\377\4o\11\377\3o\7\377\6|" + "\7\377\5i\10\377z\267|\377\377\377\377\377\222\306\222\377\0n\0\377\0" + "r\0\377\0s\0\377\0w\0\377\0\211\0\377\0\237\13\377\0\241\2\377\0\234" + "\3\377\0\202\13\377\0}\20\377\0p\6\377\0g\0\377\0b\0\377\0O\0\377\0P" + "\1\377\0H\7\377\0V\0\377\0M\15\377\0S\24\377\0^\5\377\0a\4\377\22l\37" + "\377\374\375\374\377\377\377\377\377\221\306\241\377\0\235,\377\0\276" + "7\377\0\311>\377\0\275\77\377\0\245.\377\0\230\34\377\0\220!\377\0{)" + "\377\0\200$\377\0j#\377\0W5\377\0Z,\377\0c-\377\0P9\377\0V0\377\0MA\377" + "\0I\77\377\0XN\377\0ZK\377\0cG\377\0UA\377\0ZK\377\0TU\377\0Z[\377\0" + "cP\377\0[K\377\0f\\\377\0ed\377\0h]\377\0^X\377\0MU\377\0d`\377\0_m\377" + "\6O\226\377\0""4\201\377\0#a\377\0\36g\377T\0%\377C\0\6\377/\0\0\377" + "8\0\0\3774\33\0\377-\25\0\377/\10\0\377\"\7\0\377*\34\0\3770\16\0\377" + "/\11\0\377/\15\0\377)\14\0\3771\16\0\377;\26\0\3773\35\0\3778\40\0\377" + "\77\30\0\377>'\0\377:!\0\3777#\0\377<\24\0\377A\34\0\377#C\24\0\377B" + "\36\0\377=\40\0\3773\31\0\3774\36\0\3771'\0\3777!\0\377#\"\0\377)$\0" + "\377\32\37\0\37720\0\377)\"\0\377%$\0\377\11""6\0\377\15""9\0\377\23" + "(\0\377\24""4\0\377\0-\0\377\2'\0\377\12*\0\377\12+\0\377\13""5\0\377" + "\0""1\0\377\16)\0\377\20\32\0\377\20\"\0\377\21\35\0\377\0\0\0\377G\17" + "u\377PG\264\377FH\274\377O/\267\377C;\274\377G6\247\377ML\263\377\203" + "\0\0\0\377;\34\0""9\377\2\0\30\377\22\0\23\377\23\0\40\377\7\0\34\377" + "\4\0\32\377\7\0\21\377\0\0\26\377\0\0\17\377\0\0\21\377\0\0\24\377\0" + "\32R\3776_\251\3772j\271\377!g\271\377.[\301\377#e\262\377(Y\241\377" + "\0\0\27\377\0\24\0\377\0\34\0\377\0\37\0\377\0\0\0\377#]\241\377&s\236" + "\377,n\235\3771Y\265\377'^\256\377\37[\244\377\31_\242\377\27f\225\377" + "\23V\225\377\23d\216\377\11`\224\377\21i\224\377\20e\225\377\1r\225\377" + "\5o\225\377\3a\220\377\6l\215\377\0h\232\377\1b\230\377\0V\222\377\0" + "W\225\377\0_\221\377\15b\217\377\7Y\240\377\10M\237\377\0B\200\377\0" + "\0\0\377\0\7\0\377\0\5\0\377\0\0\0\377\0U\240\377\0]\264\377\0Z\267\377" + "\0[\243\377\0W\246\377\0[\247\377\202\0\0\0\377\31\0\14\0\377\0\7\0\377" + "\0\15\0\377\0\0\0\377\0\25\0\377\0\26\0\377\0\23\0\377\0\21\0\377\0\23" + "\0\377\0\20\0\377\0\0\0\377\0=^\377\0c\230\377\0P\244\377\0d\250\377" + "\0g\240\377\1V\233\377\0\16-\377\0\0\0\377\0\37\0\377\0\12\0\377\0\20" + "\0\377\0\24\0\377\0\7\0\377\0\3\0\377\202\0\0\0\377I\0sr\377\0}\210\377" + "\0\202\212\377\0\210\216\377\7\213\212\377\11\213\211\377\14\212\222" + "\377\0qk\377\0""1\17\377\10\220\226\377\6\234\216\377\11\227\212\377" + "\0\77\12\377\0\14\0\377\0#\0\377\0""8\0\377\0\77\0\377\0B\0\377\0J\0" + "\377\0i\0\377\0k\0\377\0c\0\377\0f\0\377\0U\0\377\10F\10\377\365\367" + "\365\377\377\377\377\377w\214w\377\1.\3\377\6,\21\377\6\77\31\377\7A" + "\25\377\6""8\24\377\11A\25\377\6F\26\377\10O\33\377\2F\27\377\4A\17\377" + "\3B\12\377\10B\22\377\344\355\346\377\377\377\377\377\333\352\335\377" + "\7h\23\377\5l\13\377\3|\7\377\2{\5\377\21\220\23\377\357\367\357\377" + "\377\377\377\377%\210%\377\0u\0\377\0x\0\377\0v\0\377\0\207\0\377\0\223" + "\0\377\0\233\0\377\0\247\0\377\0\240\25\377\0\234\22\377\0\205\5\377" + "\0w\0\377\0i\14\377\0R\12\377\0O\14\377\0I\1\377\0N\11\377\0N\2\377\0" + "G\22\377\0Z\20\377\0^\12\377\0Q\0\377Y\233c\377\202\377\377\377\377b" + "Q\244i\377\0\224%\377\0\2648\377\0\307E\377\0\302@\377\0\2635\377\0\213" + "/\377\0\201\37\377\0l\36\377\0b\32\377\0]\34\377\0T-\377\0[(\377\0\\" + ")\377\0`7\377\0L>\377\0I=\377\0B9\377\0HC\377\0NM\377\0KF\377\0RJ\377" + "\0UW\377\0NO\377\0QV\377\0bK\377\0^`\377\0ke\377\0_i\377\0ii\377\0Xm" + "\377\0Xl\377\0Zp\377\0dp\377\0\\\234\377\0=p\377\0&T\377\0/V\377f\0'" + "\377U\0\16\377>\0\0\377B\0\0\377;\37\0\377)\17\0\377/\40\0\377!\23\0" + "\377.\6\0\3777\22\0\377*\16\0\3770\33\0\377+\23\0\377:\15\0\3777\22\0" + "\3772\33\0\377@(\0\377B/\0\377*+\0\377.2\0\3772\36\0\3774%\0\377\77)" + "\0\377B(\0\377E#\0\377F\34\0\377/\34\0\3772\32\0\377+\37\0\377.\31\0" + "\377,$\0\377&-\0\377\30&\0\377\25%\0\377\36.\0\377\33*\0\377\24)\0\377" + "\21""2\0\377\13\37\0\377\14""1\0\377\1+\0\377\13-\0\377\27+\0\377\12" + "-\0\377\14/\0\377\16.\0\377\24\36\0\377\35\37\0\377\21\32\0\377\35\40" + "\0\377\0\0\0\377A\36\203\377SL\267\377P=\273\377R:\256\377K0\271\377" + "H>\261\377O:\272\377\0\0\0\377\0\23\0\377\214\0\0\0\3777\0\3""3\3776" + "X\255\377)[\250\3772X\253\3777Z\237\377)Y\242\377$V\255\377\0\0\10\377" + "\0\0\0\377\0%\0\377\0!\0\377\0\0\0\377\0\17-\3770O\232\3771V\237\377" + "\40L\224\377\40G\225\377.K\215\377\"S\216\377-]\234\377+W\225\377*h\214" + "\377\31n\225\377\20h\237\377\23l\215\377$a\216\377\33c\221\377\21d\232" + "\377\15b\223\377\13j\230\377\3f\205\377\7Y\220\377\5]\211\377\7L\210" + "\377\13V\233\377\0Z\251\377\0U\245\377\3S\232\377\0\0\0\377\0\4\0\377" + "\0\7\0\377\0\0\0\377\7P\242\377\12Y\235\377\0W\225\377\6Y\263\377\11" + "^\243\377\3b\240\377\0\0\11\377\0\0\0\377\0\11\0\377\0\10\0\377\0\0\0" + "\377\0\13\0\377\0\30\0\377\202\0\25\0\377\23\0\24\0\377\0\33\0\377\0" + "\"\0\377\0\0\0\377\0A\\\377\3[\235\377\0^\240\377\0b\227\377\2b\233\377" + "\0n\236\377\0\24""1\377\0\0\0\377\0\23\0\377\0\17\0\377\0\27\0\377\0" + "\4\0\377\0\2\0\377\0\0\0\377\0\25\0\377\202\0\0\0\377\17\0si\377\7z\202" + "\377\16\205\205\377\22\201\207\377\21|\202\377\7\206x\377\17\220t\377" + "\12\214s\377\3\220u\377\13\203j\377\0\17\0\377\0\7\0\377\0""1\0\377\0" + "/\0\377\0""7\0\377\202\0""9\0\377\7\0O\0\377\0c\0\377\0f\0\377\0s\0\377" + "\0x\0\377\0V\0\377HxH\377\202\377\377\377\377\177;^;\377\0,\0\377\4O" + "(\377\7:\26\377\7A\25\377\12T\30\377\5F\32\377\4N\34\377\4G\33\377\0" + "@\17\377\2G\13\377\2H\11\377\10Q\30\377\366\370\367\377\377\377\377\377" + "\303\332\311\377\7}\30\377\6\201\23\377\3\206\12\377\2\211\7\377\205" + "\320\206\377\377\377\377\377\301\346\301\377\0\233\0\377\0\215\0\377" + "\0z\0\377\0w\0\377\0\224\0\377\0\230\4\377\0\263\13\377\0\254\17\377" + "\0\263\20\377\0\261\23\377\0\255\21\377\0\227\22\377\0~\27\377\0^\32" + "\377\0Z\4\377\0U\0\377\0I\0\377\0K\13\377\0S\10\377\0Z\23\377\0Z\11\377" + "\0V\15\377\234\303\242\377\377\377\377\377\376\376\376\377\22oA\377\0" + "\203,\377\0\241<\377\0\274\77\377\0\277J\377\0\247S\377\0\230C\377\0" + "\207*\377\0g&\377\0U,\377\0X#\377\0T-\377\0g7\377\0V6\377\0X6\377\0\\" + "\77\377\0X6\377\0GK\377\0PI\377\0GR\377\0G@\377\0MJ\377\0XW\377\0UY\377" + "\0hS\377\0cR\377\0oe\377\0qj\377\0nc\377\0ir\377\0ck\377\0lq\377\0rj" + "\377\0df\377\2g\217\377\0Kt\377\0$Z\377\0\35T\377r\0+\377W\0\22\377;" + "\0\0\3772\0\0\377,\27\0\377*\32\0\377'\15\0\377!\25\0\377:\"\0\377@'" + "\0\3773\32\0\3774\23\0\3772\33\0\3773\24\0\377\77-\0\377:3\0\377\77-" + "\0\377=(\0\377D-\0\377;-\0\3775/\0\377>9\0\377G,\0\377=-\0\3778&\0\377" + "@%\0\3770!\0\3771$\0\377$\33\0\377\27$\0\377)'\0\377*.\0\377#+\0\377" + "\24""4\0\377\40&\0\377!+\0\377\31*\0\377!\36\0\377\26&\0\377\15+\0\377" + "\30\"\0\377\25\17,\0\377\15*\0\377\30%\0\377\16\34\0\377\31$\0\377\15" + "\30\0\377\20\35\0\377\7\21\0\377\3\34\0\377\0\0\0\377Q\32p\377ZE\255" + "\377VJ\245\377_7\251\377]/\262\377U3\271\377PB\257\377\0\0\0\377\0\6" + "\0\377\0\21\0\377\0\22\0\377\202\0\23\0\377\17\0\15\0\377\0\4\0\377\0" + "\24\0\377\0\14\0\377\0\7\0\377\0\0\0\377\0\5\0\377\0\0\0\377\15\26=\377" + "Hh\250\377\77\\\250\377=X\222\3777J\233\377EH\232\377DU\236\377\202\0" + "\0\0\377*\0\20\0\377\0\32\0\377\0\12\0\377\0\0\0\377\7\0\10\377!2[\377" + "0[\221\3779]\212\3775V\200\377.X\205\3772_\230\3779b\216\377\0\377]\377\30k\230\377\23j\231\377\37h\226\377\32t\203\377\34j" + "\211\377\0\7\30\377\204\0\0\0\377\6\0\6\0\377\0\10\0\377\0\31\0\377\0" + "\25\0\377\0\27\0\377\0(\0\377\202\0\0\0\377\36&\200h\377/\221y\377\"" + "\214j\377\32\230s\377\33\231o\377%\222r\377\24\220o\377\0X\"\377\0\14" + "\0\377\0\31\0\377\0,\0\377\0/\0\377\0""0\0\377\0D\0\377\0>\0\377\0X\0" + "\377\0d\0\377\0n\0\377\0\207\0\377\0\205\0\377\0o\0\377\303\326\303\377" + "\377\377\377\377\357\361\357\377\0""7\0\377\0""5\0\377\0""0\0\377\0H" + "\0\377\0T\0\377\0R\0\377\202\0W\0\377\5\0`\0\377\0c\0\377\0\\\0\377\0" + "b\0\377P\266s\377\202\377\377\377\377\5I\244U\377\4\230\16\377\4\230" + "\21\377\6\232\35\377>\256Q\377\202\377\377\377\377\7@\332@\377\0\325" + "\0\377\0\264\0\377\0\257\0\377\0\240\0\377\40\262\40\377\323\361\323" + "\377\207\377\377\377\377\11}\302\177\377\0~\10\377\0j\7\377\0o\23\377" + "\0^\15\377\0h\40\377\0h\17\377\0v\26\377\21v.\377\202\377\377\377\377" + "w\216\271\234\377\0v(\377\0v%\377\0\2331\377\0\270J\377\0\305U\377\0" + "\320W\377\0\310G\377\0\257;\377\0\232-\377\0\2000\377\0a\40\377\0e$\377" + "\0l0\377\0l'\377\0b5\377\0h1\377\0e3\377\0_4\377\0R6\377\0P7\377\0Y9" + "\377\0^>\377\0[J\377\0ZE\377\0kV\377\0nX\377\0j\\\377\0mT\377\0nL\377" + "\0q^\377\0yg\377\0\202U\377\0\177]\377\0vl\377\0j\240\377\0>x\377\0""3" + "f\377\0@k\377x\1<\377Y\0\27\3773\0\2\3775\0\0\377D\33\7\377D,\0\377:" + "'\0\377D7\0\377@.\0\377D,\0\37793\0\377<-\0\377J5\0\377C-\0\377B0\0\377" + "C)\0\377G2\0\377<2\0\377<-\0\377y\206\3776n\206\377;e\201\3777o\205\377.r\200\377\0\0\0\377\0\14\0\377" + "\0\22\0\377\0\0\0\377\"w\216\377&u\223\3776w\204\377)\204\204\377\36" + "yw\377%\202\216\377\0\0\4\377\0\0\0\377\0\30\0\377\0\12\0\377\0\5\0\377" + "\0\14\0\377\0\6\0\377\0\16\0\377\0\22\0\377\0\14\0\377\0\15\0\377\0\4" + "\0\377\0\0\0\377\0RF\377/r|\377%x\214\3771\177z\377(}{\377\40|r\377\0" + "\"\14\377\0\0\0\377\0\16\0\377\0\10\0\377\0\0\0\377\0\12\0\377\0\6\0" + "\377\0\15\0\377\0$\0\377\0\27\0\377\0\37\0\377\0\10\0\377\0\27\0\377" + "3\226m\377:\251}\3773\237p\377,\246e\3776\253m\377-\251v\377,\257\204" + "\377+\270|\377+\252\204\377\0n*\377\0\5\0\377\0!\0\377\0'\0\377\0@\0" + "\377\0=\0\377\0U\0\377\0k\0\377\0\221\0\377\0\251\0\377\0\243\0\377\0" + "\223\0\377\361\367\361\377\377\377\377\377\355\361\355\377\0""6\0\377" + "\0,\0\377\202\0""7\0\377\20\0B\0\377\0W\0\377\0c\0\377\0e\3\377\1_\3" + "\377\1d\7\377\1p\23\377\4\200\31\377\333\356\335\377\377\377\377\377" + "\203\274\207\377\1p\6\377\0v\7\377\0|\6\377\4~\25\377\245\323\245\377" + "\202\377\377\377\377\177\14\314\14\377\0\314\0\377\0\321\0\377\0\306" + "\0\377\0\267\0\377\0\275\0\377\0\300\0\377\0\322\16\377\0\323\25\377" + "\0\321\37\377\250\360\261\377\377\377\377\377\360\373\360\377\2\262\4" + "\377\0\223\5\377\0\206\3\377\0}\14\377\0r\13\377\0n\15\377\0u\3\377\0" + "u\2\377\0p\0\377\205\273\205\377\377\377\377\377\365\371\365\377\10p" + "\30\377\0f\10\377\0~\23\377\0\210\36\377\0\227-\377\0\274F\377\0\326" + "Q\377\0\361U\377\0\345A\377\0\266:\377\0\241\37\377\3\222-\377\0\205" + "5\377\0\177'\377\0g\34\377\0t\37\377\0d)\377\0j2\377\0j*\377\0j9\377" + "\0_9\377\0iB\377\0_8\377\0kI\377\0p>\377\0i>\377\0fJ\377\0gM\377\0{J" + "\377\0vO\377\0uN\377\0~X\377\0{P\377\0{U\377\0\206X\377\0t\220\377\0" + "Np\377\0:W\377\0""0S\377}\12A\377c\0\27\377=\0\12\3775\0\6\377E\"\13" + "\377M/\11\377Q3\4\377U6\34\377S3\13\377L=\23\377F<\6\377P>\4\377Q9\11" + "\377N=\0\377B5\12\377\77\77\0\377B9\4\377BA\0\37795\0\377@7\0\3776,\0" + "\377;#\0\377-(\0\377-2\0\377(%\0\377-&\0\377/1\0\377$,\0\377*0\0\377" + "\"B\0\377+7\0\377!>\0\377(0\0\377\"+\0\377\37(\0\377\"\40\0\377\"(\0" + "\377*!\0\377(&\0\377'\33\0\377-\14\0\377\33\0\0\377\40\15\0\377\22\20" + "\0\377\34\23\0\377&\16\0\377!\21\0\377!\7\0\377&\12\0\377\"\7\0\377\13" + "\0\0\377w&c\377\235V\241\377\241Y\256\377\236V\240\377\220Q\235\377\221" + "Z\231\377\207S\237\377\7\0\0\377\0\3\0\377\0\11\0\377\0\20\0\377\0\3" + "\0\377\4\0\6\0\377\2\14\0\377\5\22\0\377\10\22\0\377\203\0\0\0\377\12" + "\0\3\0\377\0\0\0\3779\0#\377}S\221\377uU\214\377rW\220\377g^\222\377" + "i`\224\377we\214\377\12\0\0\377\205\0\0\0\377\1\0\3\0\377\205\0\0\0\377" + "\7\0\14\0\377\0\25\0\377\0\6\0\377\0\21\0\377\0\17\0\377\0\40\0\377\0" + "\27\0\377\202\0\16\0\377\24\0\24\0\377\0\31\0\377\0\0\0\377\35eJ\377" + "E\207\203\377K{\201\377Nx\211\377Rs\205\3778z\177\3777p\206\377\0\0\0" + "\377\0\24\0\377\0\13\0\377\0\0\0\377As\221\377;z\212\377D\206\230\377" + "0\210\217\3772\214\200\3770\203\202\377\202\0\0\0\3774\0\7\0\377\0\25" + "\0\377\0\31\0\377\0\32\0\377\0\14\0\377\0\20\0\377\0\5\0\377\0\15\0\377" + "\0\24\0\377\0\14\0\377\0\0\0\377\0TP\3775\202\203\377-\177\204\377=\204" + "\177\377-v{\377=\210v\377\0\37\3\377\0\0\0\377\0\1\0\377\0\12\0\377\0" + "\2\0\377\0\11\0\377\0\24\0\377\0\31\0\377\0\30\0\377\0\36\0\377\0\0\0" + "\377\0""8\4\377:\241s\377F\251n\377H\254k\377\0g\27\377<\265i\377;\252" + "o\377>\264{\377;\272r\377=\274\200\3776\264|\3773\251z\377\0\77\0\377" + "\0\10\0\377\0.\0\377\0E\0\377\0A\0\377\0f\0\377\0g\0\377\0\231\0\377" + "\0\247\0\377\0\272\0\377\0\246\0\377\365\372\365\377\202\377\377\377" + "\377\24\14D\14\377\0,\0\377\0""4\0\377\0""9\0\377\0J\0\377\0Y\0\377\1" + "e\5\377\1e\12\377\4]\14\377\12l\31\377\13~\"\377J\261\\\377\377\377\377" + "\377\361\367\361\377\23{\31\377\1f\3\377\0h\2\377\0}\2\377\0\200\0\377" + "\303\337\303\377\202\377\377\377\377\177\17\256\17\377\0\272\0\377\0" + "\307\1\377\0\277\12\377\0\300\1\377\0\305\0\377\0\310\0\377\0\314\1\377" + "\0\341\20\377\1\340\37\377\347\375\351\377\377\377\377\377\265\366\270" + "\377\0\301\14\377\0\225\16\377\0\223\6\377\0|\2\377\0\205\5\377\0\204" + "\0\377\0z\7\377\0s\0\377\0r\0\377\307\337\307\377\377\377\377\377\257" + "\320\262\377\0p\5\377\0z\15\377\0\201\36\377\0\216\40\377\0\2151\377" + "\0\245;\377\0\313;\377\0\367J\377\0\351C\377\0\312<\377\0\2554\377s\305" + "\210\377#\221H\377\0\202-\377\0{)\377\0m%\377\0f$\377\0`4\377\0`<\377" + "\0h\77\377\0j9\377\0m;\377\0v>\377\0m7\377\0gE\377\0cO\377\0cG\377\0" + "sH\377\0tM\377\0\202N\377\0\205O\377\0\216K\377\0\222W\377\0\217c\377" + "\0\203V\377\0p\215\377\0Xl\377\0=W\377\0B`\377\204\26;\377e\0&\377E\0" + "\3\377<\0\7\377B$\5\377T+\6\377d/\10\377_-\23\377\\1\24\377W:\24\377" + "KD\14\377L>\33\377NE\17\377I;\0\377F<\14\377JG\15\377E=\27\377>8\12\377" + "A:\0\37768\0\377-3\0\37783\0\377:2\0\3772+\0\377\211\217\377\77\220\213\3774\212\215\3774\203\211\377\202\0\0\0" + "\377\2\0\17\0\377\0\30\0\377\202\0\36\0\377\24\0!\0\377\0\26\0\377\0" + "\27\0\377\0\"\0\377\0\23\0\377\0\15\0\377\0\0\0\377\7VH\3776\211|\377" + "<\223\210\377A\205\203\377<\206\206\377<\212n\377\0\37\17\377\0\0\0\377" + "\0\13\0\377\0\15\0\377\0\12\0\377\0\11\0\377\0\12\0\377\202\0\25\0\377" + "\32\0\0\0\377\0>\0\377R\257h\377S\246r\377\77\231^\377\0<\0\377\0\30" + "\0\377\0B\0\377F\262y\377J\272{\377=\305\202\377B\272\205\377G\274\202" + "\377@\266\202\377F\275\200\377\0T\3\377\0!\0\377\0\77\0\377\0K\0\377" + "\0Y\0\377\0o\0\377\0\232\0\377\0\275\0\377\0\307\0\377\0\257\0\377\326" + "\355\326\377\202\377\377\377\377\24/g/\377\0""8\0\377\0E\0\377\0J\0\377" + "\0Q\0\377\0^\0\377\5^\21\377\3k\25\377\4W\22\377\13j\34\377\13l\35\377" + "\305\343\311\377\377\377\377\377X\236^\377\1r\4\377\0z\2\377\0r\1\377" + "\0n\0\377\0m\0\377\316\343\316\377\202\377\377\377\377\12/\251/\377\0" + "\253\0\377\0\274\0\377\0\307\0\377\0\314\0\377\0\323\0\377\0\330\0\377" + "\0\316\0\377\0\332\0\377&\342+\377\202\377\377\377\377\6y\362\202\377" + "\0\315\1\377\0\254\0\377\0\213\0\377\0|\4\377\0w\0\377\202\0y\0\377\177" + "\0q\4\377\15z\15\377\374\375\374\377\377\377\377\377a\243d\377\0s\10" + "\377\0t\22\377\0v\25\377\0p\35\377\0q\36\377\0\216)\377\0\267'\377\0" + "\335:\377\0\347N\377\0\331M\377\15\317D\377\305\353\320\377\2\2150\377" + "\0\200.\377\0\203.\377\0x1\377\0m9\377\0mF\377\0`J\377\0e\77\377\0v8" + "\377\0x7\377\0m3\377\0xH\377\0pN\377\0mO\377\0iH\377\0qK\377\0jQ\377" + "\0|N\377\0\203N\377\0\215U\377\0\206X\377\0\222a\377\0\217V\377\0o\205" + "\377\0Sk\377\0GP\377\0\77R\377\207\7@\377\\\0\"\377E\0\0\377E\0\4\377" + "R\37\14\377Y)\17\377[(\22\377S/\15\377V0\20\377J*\12\377L5\20\377LA\27" + "\377C6\23\377D;\20\377N4\0\377P5\7\377D6\21\377O,\6\377>)\0\377<1\0\377" + "J7\0\377K-\0\377:.\0\377E3\0\377A0\0\377:1\0\377-6\0\3772:\0\3773-\0" + "\377(4\0\377&:\0\37719\0\377(7\0\377/1\0\377%6\0\377+>\0\377\40'\0\377" + "(\33\0\377%\40\0\377\"\27\0\377+\23\0\3771\32\0\377+\35\0\377\34\20\0" + "\377\37\17\0\377\"\31\0\377\30\21\0\377)\17\0\377\37\6\0\377/\14\0\377" + "'\0\0\377\2457y\377\271n\234\377\256n\240\377\251h\240\377\256m\250\377" + "\271k\234\377\257`\231\377\23\0\0\377\30\16\0\377\14\22\0\377\0\10\0" + "\377\17\13\0\377\21\22\0\377\0\17\0\377\1\17\0\377\0\12\0\377\10\0\0" + "\377\7\23\0\377\0\31\0\377\0\11\0\377\0\0\0\377A\6*\377\231r\231\377" + "\212y\222\377\223v\221\377\223q\230\377\215p\223\377zr\222\377\22\0\0" + "\377\0\0\0\377\0\15\0\377\0\7\0\377\202\0\5\0\377\207\0\0\0\377R\0\2" + "\0\377\0\0\0\377\0\3\0\377\0\13\0\377\0\5\0\377\0\12\0\377\0\16\0\377" + "\0\5\0\377\0\15\0\377\0\10\0\377\0\0\0\3776XD\377b\215\220\377T\202\205" + "\377`\211\206\377T\177\204\377M\205\177\377K\200\206\377\0\0\0\377\0" + "\11\0\377\0\3\0\377\0\0\0\377I}\207\377>\215\214\377J\227\223\377L\213" + "\223\377>}\220\3777\205\234\377\0\1\0\377\0\0\0\377\0\22\0\377\0\31\0" + "\377\0\40\0\377\0\30\0\377\0&\0\377\0(\0\377\0!\0\377\0*\0\377\0\25\0" + "\377\0\31\0\377\0\0\0\377\15fS\377U\226\202\377P\226w\377K\217v\377K" + "\236z\377F\221\200\377\0/\24\377\0\0\0\377\0\10\0\377\0\14\0\377\0!\0" + "\377\0\32\0\377\0$\0\377\0\7\0\377\0\0\0\377\16j\20\377L\302o\377G\265" + "g\377F\254f\377\0\36\0\377\0\27\0\377\0*\0\377\0\22\0\377\0Q\0\377S\302" + "u\377V\271x\377X\276~\377F\275\211\377D\302\213\377E\316\225\377J\304" + "\215\377\0W\10\377\0\37\0\377\0\77\0\377\0`\0\377\0~\0\377\0\244\0\377" + "\0\300\0\377\0\303\0\377\0\262\0\377\265\335\265\377\202\377\377\377" + "\377\24\224\267\224\377\0B\0\377\0H\0\377\0N\0\377\0Y\0\377\4P\10\377" + "\12v\30\377\5`\23\377\6`\13\377\6T\14\377|\263\200\377\377\377\377\377" + "\207\272\212\377\1k\6\377\0n\2\377\0m\0\377\0o\0\377\0q\0\377\0k\0\377" + "\256\320\256\377\202\377\377\377\377\4e\272e\377\0\220\0\377\0\245\0" + "\377\0\261\0\377\202\0\276\0\377\4\0\315\0\377\0\323\0\377\0\335\0\377" + "e\367n\377\202\377\377\377\377v=\353A\377\0\313\0\377\0\244\0\377\0\211" + "\2\377\0{\0\377\0z\10\377\0v\0\377\0j\6\377\0d\5\377g\243j\377\377\377" + "\377\377\320\342\323\377\6u\34\377\0x\37\377\0s\24\377\0n\15\377\0s\33" + "\377\0t\"\377\0\215\33\377\0\242\31\377\0\303&\377\0\345E\377\0\340H" + "\377}\362\236\377l\334\224\377\0\2437\377\0\2150\377\0\206A\377\0yB\377" + "\0yF\377\0m>\377\0w=\377\0h1\377\0jA\377\0sB\377\0pH\377\0mM\377\0h8" + "\377\0y\77\377\0nE\377\0i=\377\0fG\377\0hJ\377\0jD\377\0wN\377\0s\\\377" + "\0|a\377\0\215U\377\0x\214\377\0Oz\377\0""5W\377\0\77X\377\223\3<\377" + "k\0\33\377\77\0\0\377J\0\0\377R\"\12\377Z\"\0\377Z!\3\377Y%\30\377H&" + "\25\377^*\24\377W,\26\377S1\32\377W+\21\377W%\32\377\\/\31\377R-\21\377" + "L&\7\377G,\6\377H1\0\377J#\0\377C/\0\377G(\0\3775<\0\377D8\0\377@'\0" + "\377+<\0\37713\0\3774*\0\377/,\0\377(0\0\3771:\0\37729\0\377=9\0\377" + "&7\0\3771/\0\37774\0\377#!\0\377(\35\0\377\30\31\0\377*\"\0\377%\37\0" + "\3772\"\0\377\"%\0\377'\23\0\377)\31\0\377*\23\0\377>\16\0\3770\3\0\377" + "0\0\0\3776\15\0\377!\0\0\377\230\77r\377\305\201\233\377\273|\244\377" + "\314t\245\377\304l\262\377\270s\232\377\304z\243\377+\0\0\377\11\0\0" + "\377\13\0\0\377\2\0\0\377\13\0\0\377\6\0\0\377\0\0\0\377\7\0\0\377\204" + "\0\0\0\377\14\4\0\0\377\0\0\0\377h7D\377\252\207\234\377\246\210\235" + "\377\245s\240\377\244}\226\377\230v\242\377\224u\234\377\31\0\2\377\0" + "\0\0\377\0\13\0\377\225\0\0\0\377\7BcT\377^\212\211\377d\202\202\377" + "l\206\212\377d{\207\377ew\221\377[{\204\377\204\0\0\0\377\7Pv\213\377" + "Z\216\220\377Z\207\232\377L\212\260\377>\216\256\377H\214\231\377\0\23" + "$\377\206\0\0\0\377\1\0\3\0\377\205\0\0\0\377).{n\377S\240\211\377G\236" + "\177\377O\247\203\377H\255\215\377Q\236\210\377\0""5\37\377\0\0\0\377" + "\0\25\0\377\0\36\0\377\0!\0\377\0\34\0\377\0\3\0\377\0\0\0\377\33\227" + "Q\377F\274n\377J\270k\3774\233I\377\0\4\0\377\0$\0\377\0:\0\377\0>\0" + "\377\0C\0\377\0)\0\377\7`\22\377]\312z\377]\326\203\377O\326\225\377" + "N\332\235\377H\325\201\377C\323x\377M\337|\377\0]\17\377\0/\0\377\0M" + "\0\377\0b\0\377\0\206\0\377\0\265\0\377\0\304\0\377\0\262\0\377z\304" + "z\377\202\377\377\377\377\24\367\371\367\377\31`\32\377\6e\26\377\24" + "|'\377\35\2177\377\13x\25\377\13r\24\377\7g\15\377\4a\6\377^\217_\377" + "\371\373\371\377\202\254\204\377\3\\\12\377\1c\3\377\0f\0\377\0n\0\377" + "\0o\0\377\0p\0\377\0o\0\377\207\263\207\377\202\377\377\377\377\177\332" + "\354\332\377\4\217\4\377\0\221\0\377\0\252\0\377\0\271\0\377\0\275\0" + "\377\0\317\0\377\0\337\0\377'\356,\377\332\372\335\377\377\377\377\377" + "\371\376\371\377\10\341\24\377\0\256\2\377\0\231\10\377\0\204\0\377\0" + "y\5\377\0z\22\377\0}\5\377\0d\4\377\7r\15\377\333\352\334\377\336\355" + "\340\377\35\211$\377\0w\14\377\0u\11\377\0x\16\377\0}\24\377\0y\31\377" + "\0s\17\377\0\204\31\377\0\210\36\377\0\245'\377\0\314=\377<\344v\377" + "\352\375\357\377\15\345H\377\0\254<\377\0\226*\377\0|7\377\0pD\377\0" + "\200I\377\0q;\377\0j<\377\0m6\377\0iE\377\0qP\377\0zO\377\0{D\377\0x" + ">\377\0hD\377\0e;\377\0f\77\377\0gD\377\0_L\377\0fT\377\0ZD\377\0^\77" + "\377\0rL\377\0uQ\377\0_\215\377\0KZ\377\0""3G\377\0:R\377\200\11""2\377" + "p\0\34\377Z\0\1\377T\0\4\377T$\27\377R-\7\377O+\21\377\\-\21\377Z&\10" + "\377U5\13\377e@\32\377]2\22\377Z0\34\377V*\36\377V$\23\377]&\23\377T" + "'\17\377T#\0\377K(\0\377G\37\4\377F)\2\3778*\0\377B$\11\377A&\0\3772" + "%\0\377\77+\0\377;*\0\377(:\0\377/:\0\3778/\0\37711\0\37737\0\377\16\0\3777\7\0\3770\6\0\377%\12\0\377)" + "\0\0\377\247c\212\377\316\214\243\377\314\213\237\377\323{\255\377\311" + "\201\242\377\313x\251\377\302w\242\377\273w\251\377\301w\233\377\305" + "s\226\377\273f\201\377\303g{\377\302cy\377\275e\212\377\310x\212\377" + "\315n\202\377\304s\217\377\267x\212\377\274~\211\377\304\213\232\377" + "\314\204\240\377\301s\257\377f\275u\237\377\302\177\231\377\267w\227" + "\377\300q\244\377\302}\240\377N\0%\377\12\0\0\377\17\2\0\377\3\0\0\377" + "\37\0\6\377\247\220\243\377\245\212\216\377\245\207\211\377\250\225\230" + "\377\263\232\235\377\246\232\241\377\250\227\226\377\232\223\217\377" + "\227\231\225\377\202\220\227\377~\233\232\377y\232\220\377\177\225\214" + "\377}\224\221\377\200\232\213\377\202\241\215\377}\236\224\377\177\237" + "\211\377t\236\223\377r\227\226\377m\230\231\377g\234\237\377q\237\217" + "\377g\240\244\377^\217\221\377\0\0\0\377\0\11\0\377\0\13\0\377\0\25\0" + "\377\0\7\0\377\0\0\0\377W\234\232\377k\255\251\377l\253\254\377`\257" + "\246\377d\251\243\377`\254\253\377T\244\260\377J\243\264\377R\252\260" + "\377I\246\242\377C\261\244\377C\251\245\377\\\275\246\377N\273\246\377" + "H\274\243\377P\257\231\377G\271\232\377P\256\234\377O\266\216\377V\266" + "\221\377H\257\227\377Q\275\232\377M\254\222\377H\260\226\377\4fH\377" + "\0\0\0\377\0!\0\377\0\22\0\377\0\0\0\377\0\23\0\3779\261\203\377F\267" + "\216\377M\277\223\377\36iC\377\0\6\0\377\0\40\0\377\0)\0\377\0;\0\377" + "\0""1\0\377\0:\0\377\0<\0\377\0A\0\377\0:\0\377\0\33\0\377\3\2163\377" + "Y\350\203\377T\347}\377K\363\204\377N\345\220\377N\362\206\377U\370\203" + "\377V\375\226\377\0s\35\377\0)\0\377\0t\0\377\0\254\0\377\0\253\0\377" + "\0\254\0\377\0\237\0\377D\243D\377\365\372\365\377\202\377\377\377\377" + "\23\366\371\366\377\251\321\253\377\177\262\202\377\213\274\217\377\262" + "\317\263\377\353\362\353\377\202\254\203\377\15c\15\377\1d\1\377\2e\4" + "\377\0_\0\377\0Z\0\377\0]\0\377\0m\0\377\0q\0\377\0o\0\377\0k\0\377\0" + "d\0\377y\250y\377\203\377\377\377\377\7\341\361\341\377\241\324\241\377" + "\204\310\204\377\252\332\252\377\324\356\324\377v\330v\3776\3077\377" + "\202\377\377\377\377\7q\331\207\377\0\300)\377\0\255\26\377\0\232\15" + "\377\0\226\12\377\16\207\26\377\341\356\342\377\203\377\377\377\377\1" + "\376\376\376\377\206\374\375\374\377\206\377\377\377\377\177\365\374" + "\367\377\35\333Y\377\0\340M\377\0\315D\377\0\265O\377\0\236F\377\0\211" + "J\377\0nE\377\0n\77\377\0k[\377\0zO\377\0}H\377\0\177S\377\0zK\377\0" + "vC\377\0s8\377\0gG\377\0pO\377\0mT\377\0pP\377\0rS\377\0_Z\377\0PR\377" + "\0MI\377\0SR\377\0aL\377\0Y\220\377\0""2t\377\0%L\377\0*B\377\227\0E" + "\377j\0#\377Y\0\12\377W\0\12\377f\34\21\377a%\26\377d-\17\377i)\37\377" + "r3\20\377w*\34\377k6\33\377k0\37\377o2\26\377^-\20\377f\31\30\377l!\30" + "\377O\27\21\377L\33\17\377S\40\6\377X\31\15\377A\25\10\377K\20\14\377" + "M\40\2\377I\30\3\377H\37\0\377L*\0\3772'\0\37794\3\377<<\4\377E:\22\377" + "C7\12\377W8\10\377C3\1\377N*\0\377M3\10\377B-\0\377<&\0\377K$\0\377O" + "!\0\377Q(\0\377K\35\0\377=\22\0\377D\31\0\377C\31\0\377@\24\0\3775\17" + "\0\377<\7\0\3773\0\0\377+\10\0\377.\6\0\377%\0\0\377\40\0\0\377\32\0" + "\0\377k\16""4\377\253Zn\377\315\200\242\377\331{\250\377\323x\235\377" + "\312v\245\377\314p\234\377\315p\226\377\316y\217\377\306l\206\377\320" + "e\210\377\332^\211\377\324i|\377\327q\204\377\326n\207\377\320my\377" + "\320}\201\377\310\202\223\377\301^\205\377d\11$\377K\0\21\377\317z\246" + "\377\312s\230\377\312g\240\377\301s\232\377\274\201\237\377\230Bc\377" + "\11\0\0\377\13\13\0\377\12\1\0\377\5\0\0\377\277\205\225\377\271\207" + "\230\377\270\206\233\377\263\223\231\377\264\231\235\377\255\214\230" + "\377\242\232\235\377\222\222\224\377\227\223\227\377\225\206\242\377" + "\235\212\224\377\237\234\205\377\235\220\212\377\13\215\242\227\377}" + "\232\231\377\200\240\226\377\205\232\241\377\204\244\231\377z\253\236" + "\377u\252\223\377u\265\227\377y\256\242\377]\230\200\377*RS\377\202\0" + "\0\0\377\1\0(\0\377\202\0%\0\377^\0!\0\377\0\0\0\377\0\0\12\377$_d\377" + "U\232\220\377x\272\256\377p\244\251\377t\253\261\377d\267\261\377^\263" + "\251\377V\266\264\377T\277\245\377W\265\254\377`\273\246\377O\270\246" + "\377M\305\242\377Y\267\246\377V\266\235\377\\\274\244\377\0RA\377\0\6" + "\0\377X\305\234\377O\301\236\377R\266\235\377M\270\243\377W\256\226\377" + "B\254\204\377\0\0\0\377\0\22\0\377\0\2\0\377\0P<\377Z\304\235\377Z\300" + "\246\377a\303\227\377\40\202N\377\0\7\0\377\0\33\0\377\0""6\0\377\0." + "\0\377\0C\0\377\0@\0\377\0""0\0\377\0<\0\377\0""9\0\377\0""7\0\377\0" + "3\0\377\0\24\0\377(\256Y\377N\353\233\377Y\344\217\377k\361\177\377`" + "\366\214\377b\370\213\377X\366\200\377X\370\207\377\0\203\32\377\0R\0" + "\377\0\234\0\377\0\261\0\377\0\251\0\377\0\236\0\377\0\222\0\377#\224" + "#\377\230\307\232\377\335\353\336\377\370\373\370\377\357\366\357\377" + "\323\347\325\377\252\315\255\377[\241`\377\17p\21\377\1j\1\377\0`\0\377" + "\0f\0\377\0[\0\377\0^\0\377\0a\0\377\0j\0\377\0i\0\377\0c\0\377\0d\0" + "\377\0i\0\377\0b\0\377\0n\0\377Q\232Q\377\274\332\274\377\357\366\357" + "\377\364\371\364\377\334\355\334\377\245\321\246\377S\266V\377\4\232" + "\7\377\0\246\24\377d\311m\377\202\377\377\377\377e'\276C\377\0\254\40" + "\377\0\243\21\377\0\242\26\377\0\222\21\377w\274\202\377\330\351\335" + "\377\330\352\334\377\330\350\332\377\330\350\333\377\330\350\334\377" + "\330\350\332\377\330\352\333\377\330\354\334\377\333\353\337\377\341" + "\355\343\377\347\361\352\377\355\364\357\377\362\366\364\377\370\372" + "\371\377\376\376\376\377\370\373\371\377\320\352\331\377F\265r\377\0" + "\307A\377\0\313U\377\0\276V\377\0\267a\377\0\245M\377\0\211U\377\0uF" + "\377\0}K\377\0t[\377\0dF\377\0vW\377\0x:\377\0mP\377\0m;\377\0sG\377" + "\0dN\377\0iH\377\0hX\377\0gU\377\0`f\377\0hZ\377\0^_\377\0P]\377\0TQ" + "\377\0_C\377\0N\202\377\0*n\377\0\32P\377\0\36M\377\204\5R\377m\0""1" + "\377Y\0\7\377O\0\13\377R\30\37\377g)\36\377n#!\377x\32""4\377v\36\25" + "\377t$\26\377n1\"\377z\40\33\377g'$\377o\34\32\377u\23\30\377m\30\22" + "\377[\24\32\377b\34\"\377W\24\25\377_\26\14\377X\25\22\377X\30\10\377" + "T\20\7\377J\22\0\377D\30\2\377L#\0\377U*\4\377P<\6\377S1\15\377O5\3\377" + "W/\13\377V/\4\377Q&\12\377[+\20\377I,\24\377E)\4\377W$\1\377S(\0\377" + "X\"\5\377\\\27\0\377E\14\0\377>\12\0\377M\6\0\377B\5\0\377H\4\0\377H" + "\3\0\377=\0\0\3778\2\0\377\202.\0\0\377#1\0\0\3775\0\0\377%\0\0\377\34" + "\0\0\377\33\0\0\377#\0\0\377(\0\0\377\36\0\0\377\27\0\0\377\37\0\0\377" + "\24\0\0\377\21\0\0\377'\0\0\377$\0\0\377\40\0\0\377\37\0\0\377!\0\0\377" + "\15\0\0\377\26\0\0\377\35\0\0\377\20\0\0\377\30\0\0\377\40\0\0\377\"" + "\0\0\377\30\0\0\377\35\0\0\377\11\0\0\377\12\0\0\377\17\0\0\377\30\0" + "\0\377\35\0\0\377\4\0\0\377\15\0\0\377\11\0\0\377\1\0\0\377\227\0\0\0" + "\377\10\0\17\0\377\0'\0\377\0\37\0\377\0""5\0\377\0+\0\377\0""1\0\377" + "\0/\0\377\0\26\0\377\221\0\0\0\377\1\0\10\0\377\207\0\0\0\377\3\0\32" + "\0\377\0(\0\377\0\13\0\377\203\0\0\0\377\11\0\7\0\377\0\30\0\377\0""5" + "\0\377\0""2\0\377\0+\0\377\0G\0\377\0>\0\377\0@\0\377\0<\0\377\202\0" + "9\0\377\15\0%\0\377\0#\0\377\0\27\0\377\0\34\0\377\0\30\0\377\0\26\0" + "\377\0\20\0\377\0\27\0\377\0\17\0\377\0\31\0\377\0@\0\377\0x\0\377\0" + "\241\0\377\202\0\266\0\377D\0\233\0\377\0\200\0\377\0\204\0\377\0q\1" + "\377\1y\6\377\5u\16\377\5w\24\377\7p\22\377\4m\12\377\1r\4\377\0e\1\377" + "\0n\0\377\0i\0\377\0h\0\377\0f\0\377\0b\0\377\0j\0\377\0k\0\377\0e\0" + "\377\0f\0\377\0e\7\377\0g\6\377\0n\0\377\0o\0\377\0n\6\377\0a\7\377\0" + "t\7\377\0x\5\377\0}\27\377\0x\27\377\0|\21\377\0\202\12\377\0\216\"\377" + "\242\331\256\377\377\377\377\377\335\363\342\377\1\2402\377\0\2323\377" + "\0\221\23\377\0\2261\377\0\207-\377\0}0\377\0\2000\377\0\200\31\377\0" + "\177\16\377\0\203\33\377\0m&\377\0l&\377\0~1\377\0|%\377\0o(\377\0m3" + "\377\0q6\377\0c+\377\0i2\377\0i(\377\0p9\377\0`*\377\0f1\377\0\202>\377" + "\0\245K\377\0\277\\\377\1\274^\377\0\263]\377\0\230Q\377\0\227Z\377\0" + "\210P\377\0\203Q\377\202\0mO\377L\0uN\377\0jQ\377\0zK\377\0mG\377\0e" + "Q\377\0dR\377\0cZ\377\0lV\377\0VW\377\0SX\377\0X\\\377\0[g\377\0b^\377" + "\0[S\377\0UM\377\26G\207\377\0/n\377\0\16O\377\0\23X\377\214\0N\377n" + "\0.\377B\0\34\377\77\0\26\377`\32\37\377T\31\24\377k\40\36\377}\27""1" + "\377{\36'\377s+\33\377l%\36\377o\37+\377o\35#\377e\36%\377o&\33\377i" + "\22!\377e\23\17\377g\6\40\377a\21\32\377a\15\35\377_\16\16\377X\31\27" + "\377Q\22\7\377S\27\0\377U\34\0\377O$\2\377M'\6\377R4\4\377P6\1\377R6" + "\15\377V%\5\377e.\21\377\\4\0\377X7\4\377U'\4\377X\30\0\377S\23\0\377" + "Y\31\0\377W\25\0\377M\12\0\377L\12\0\377Q\0\0\377G\0\0\377L\0\0\377C" + "\0\0\377>\3\0\377D\2\0\377=\0\0\3775\0\0\3774\0\0\3776\0\0\3775\0\0\377" + "%\0\0\377\35\0\0\377/\0\0\3775\0\0\377*\0\0\377\202$\0\0\377\7\37\0\0" + "\377\31\0\0\377!\0\0\377-\0\0\377*\0\0\377&\0\0\377(\0\0\377\202$\0\0" + "\377\25!\0\0\377\33\4\0\377\31\0\0\377&\0\0\377+\14\0\377)\0\0\377$\7" + "\0\377\35\14\0\377\17\0\0\377\14\0\0\377\33\1\0\377\37\0\0\377\15\0\0" + "\377\24\1\0\377\17\12\0\377\0\0\0\377\0\2\0\377\0\0\0\377\7\6\0\377\1" + "\21\0\377\0\15\0\377\210\0\0\0\377\25\0\4\0\377\0\6\0\377\0\24\0\377" + "\0\7\0\377\0\22\0\377\0\21\0\377\0\32\0\377\0\30\0\377\0\34\0\377\0)" + "\0\377\0$\0\377\0\31\1\377\0""3\0\377\0.\0\377\0""8\0\377\0;\0\377\0" + "8\0\377\0.\0\377\0""2\0\377\0@\0\377\0""0\0\377\202\0""6\0\377\22\0""1" + "\1\377\0)\0\377\0-\0\377\0""8\0\377\0""6\0\377\0""5\0\377\0""8\0\377" + "\0""9\0\377\0""1\0\377\0""7\0\377\0,\0\377\0\40\0\377\0,\0\377\0""3\0" + "\377\0""2\0\377\0""8\0\377\0""0\0\377\0,\0\377\204\0""5\0\377\177\0:" + "\0\377\0-\0\377\0""5\0\377\0'\0\377\0%\0\377\0)\0\377\0""5\0\377\0:\0" + "\377\0E\0\377\0""7\0\377\0E\0\377\0""9\0\377\0<\0\377\0;\0\377\0<\0\377" + "\0*\0\377\0""7\0\377\0;\0\377\0D\0\377\0T\0\377\0D\0\377\0L\0\377\0O" + "\0\377\0M\0\377\0C\0\377\0Q\0\377\0n\0\377\0\213\0\377\0\264\0\377\0" + "\273\0\377\0\255\0\377\0\206\0\377\0~\0\377\0z\0\377\0{\0\377\0\202\0" + "\377\0z\0\377\0r\0\377\0e\0\377\0j\0\377\0_\0\377\0a\0\377\0n\0\377\0" + "e\0\377\0T\0\377\0\\\0\377\0a\0\377\0\\\0\377\0K\0\377\0`\0\377\0\\\0" + "\377\0]\0\377\0\\\0\377\0k\1\377\0h\3\377\0{\20\377\0x\20\377\0{\14\377" + "\0x\26\377\0w\12\377\0{\10\377\0z\37\377\0\204%\377\0\177%\377\341\362" + "\345\377\377\377\377\377\220\327\240\377\0\234+\377\0\216\34\377\0\207" + "$\377\0\206*\377\0\2027\377\0\207,\377\0~/\377\0\207!\377\0\2046\377" + "\0t1\377\0i%\377\0r.\377\0s:\377\0r=\377\0p$\377\0i+\377\0t)\377\0r'" + "\377\0h\40\377\0h%\377\0o1\377\0e+\377\0c$\377\0~;\377\0\215J\377\0\250" + "N\377\5\232f\377\0\244N\377\0\221N\377\0\230Z\377\0\223Q\377\0\203G\377" + "\0rV\377\0kT\377\0rR\377\0eQ\377\0rU\377\0oW\377\0lM\377\0c[\377\0^[" + "\377\0Yc\377\0G]\377\0CY\377\0JS\377\0aI\377\0bR\377\0UP\377\0NN\377" + "\26\77~\377\0""1f\377\0\23M\377\0\24Y\377\207\0E\377f\0'\377V\0\17\377" + "T\0\26\377e\25\36\377S\35\37\377q\24\35\377&y\31%\377e'\30\377e+\35\377" + "_!\31\377b$\37\377_&\23\377_-\30\377Y\31\16\377\\\36\21\377_\30\25\377" + "`\7&\377\\\26#\377g\35\15\377m\25\21\377^\20\0\377W\23\0\377L\30\0\377" + "D+\1\377E0\0\377Z2\0\377^,\0\377T.\0\377S0\0\377^.\0\377e.\0\377\\(\0" + "\377[\25\0\377`\36\0\377P!\0\377K\23\0\377Z\31\0\377T\25\0\377D\25\0" + "\377Q\20\0\377I\1\0\377M\4\0\377B\5\0\377G\10\0\377\202;\0\0\377\10""6" + "\3\0\3772\0\0\3775\0\0\377/\0\0\377'\0\0\3773\0\0\377+\0\0\3772\0\0\377" + "\202/\0\0\377\32,\0\0\377#\0\0\377$\0\0\377!\0\0\377.\0\0\377-\0\0\377" + "+\0\0\377-\0\0\377(\0\0\377)\0\0\377\40\1\0\377#\10\0\377\31\0\0\377" + "0\5\0\377!\1\0\377\36\0\0\377\21\0\0\377\35\11\0\377\26\4\0\377\6\17" + "\0\377\22\0\0\377\1\0\0\377\26\0\0\377\17\7\0\377\12\12\0\377\15\0\0" + "\377\202\0\0\0\377\2\10\0\0\377\3\7\0\377\204\0\0\0\377\1\0\12\0\377" + "\204\0\0\0\377\202\0\3\0\377\15\0\24\0\377\0\12\0\377\0\13\0\377\0\6" + "\0\377\0\11\0\377\0\20\0\377\0\10\0\377\0\14\0\377\0\26\0\377\0\35\0" + "\377\0+\6\377\0$\0\377\0""2\0\377\202\0/\0\377\5\0:\0\377\0>\0\377\0" + "<\0\377\0=\2\377\0@\0\377\202\0<\0\377\13\0""6\0\377\0""1\0\377\0""2" + "\0\377\0""1\0\377\0>\0\377\0:\0\377\0D\0\377\0<\0\377\0K\0\377\0G\7\377" + "\0<\0\377\202\0:\0\377\177\0""9\0\377\0;\0\377\0-\0\377\0<\0\377\0;\0" + "\377\0""1\0\377\0,\0\377\0""3\0\377\0E\0\377\0C\0\377\0>\0\377\0""6\0" + "\377\0;\0\377\0""7\0\377\0""4\0\377\0""8\0\377\0<\0\377\0G\0\377\0E\0" + "\377\0A\0\377\0O\0\377\0C\0\377\0;\0\377\0""6\0\377\0""2\0\377\0;\0\377" + "\0@\0\377\0E\0\377\0G\0\377\0N\0\377\0G\0\377\0H\0\377\0>\0\377\0I\0" + "\377\0Y\0\377\0n\0\377\0\204\0\377\0\252\0\377\0\263\0\377\0\244\0\377" + "\0\220\0\377\0\201\0\377\0\200\0\377\0y\0\377\0i\0\377\0X\0\377\0M\0" + "\377\0L\0\377\0V\0\377\0c\0\377\0b\0\377\0U\0\377\0B\0\377\0V\0\377\0" + "_\0\377\0c\0\377\0L\0\377\0a\0\377\0Q\0\377\0T\0\377\0W\0\377\0U\0\377" + "\0^\0\377\0^\4\377\0g\2\377\0l\0\377\0j\13\377\0k\13\377\0v\11\377\0" + "t\26\377\0p!\377\0q%\377\40\214A\377\377\377\377\377\373\374\373\377" + "\"\2157\377\0s\27\377\0t\32\377\0}\33\377\0t\26\377\0x.\377\0r-\377\0" + "z/\377\0pA\377\0l7\377\0lF\377\0\200:\377\0\2008\377\0h(\377\0g)\377" + "\0y,\377\0n(\377\0j\"\377\0r%\377\0f&\377\0u+\377\0l/\377\0s/\377\0i" + "\77\377\0sG\377\0}I\377\0\204N\377\0\177L\377\0\233J\377\0\226H\377\0" + "\216C\377\0~D\377\0xR\377\0pR\377\0u\\\377\0gY\377\0jR\377\0jV\377\0" + "nQ\377\0YM\377\0hM\377\0TT\377\0YL\377\0RS\377\0GI\377\0RQ\377\0cE\377" + "\0XW\377\0VK\377\0WQ\377\27Fy\377\0@`\377[\0\31L\377\0\22I\377|\0>\377" + "j\0\32\377L\0\14\377W\0\13\377T%\16\377Y\40\16\377`\40\14\377]#\24\377" + "\\/\23\377W4\31\377W>\33\377X8\35\377U3\20\377[-\21\377X1\32\377X\40" + "\24\377Y'\34\377O#\31\377Z\33\21\377_$\0\377`\27\2\377Z'\0\377O$\11\377" + "N(\16\377_)\0\377Y(\0\377Y)\0\377S)\0\377V,\0\377T!\0\377]2\0\377a.\0" + "\377]\"\0\377e0\0\377T\22\0\377J\16\0\377R$\0\377K\40\0\377J\26\0\377" + "J\21\0\377K\26\0\377E\13\0\377G\16\0\377O\30\0\377B\16\0\377G\14\0\377" + "5\0\0\3777\2\0\3770\0\0\377.\0\0\377)\0\0\3771\0\0\377/\0\0\3777\0\0" + "\377,\0\0\377#\0\0\377\40\0\0\377-\0\0\3772\0\0\3776\0\0\377(\0\0\377" + "4\0\0\377,\0\0\377-\0\0\377*\0\0\3773\0\0\377/\0\0\377\40\0\0\377\37" + "\0\0\377\34\0\0\377\40\0\0\377\23\0\0\377\26\0\0\377\23\0\0\377\10\14" + "\0\377\12\3\0\377\5\7\0\377\21\16\0\377\3\3\0\377\16\30\0\377\25\31\0" + "\377\6\21\0\377\15\11\0\377\5\0\0\377\0\13\0\377\0\6\0\377\2\0\0\377" + "\1\0\0\377\7\0\0\377\211\0\0\0\377\1\0\11\0\377\202\0\0\0\377\7\0\5\0" + "\377\0\16\0\377\0\10\0\377\0\0\0\377\0\11\0\377\0\22\0\377\0\36\0\377" + "\202\0\37\0\377\12\0#\0\377\0\33\0\377\0+\0\377\0.\0\377\0""5\12\377" + "\0\77\6\377\0\77\2\377\0=\0\377\0""8\0\377\0H\1\377\202\0H\0\377\10\0" + "0\4\377\0""8\0\377\0""5\0\377\0\77\0\377\0N\3\377\0\\\0\377\0W\0\377" + "\0Q\0\377\202\0M\0\377\10\0O\0\377\0""8\0\377\0)\0\377\0&\0\377\0'\0" + "\377\0/\0\377\0*\0\377\0(\0\377\202\0""9\0\377\5\0:\0\377\0A\0\377\0" + "D\0\377\0@\0\377\0""5\0\377\202\0""9\0\377\35\0""6\0\377\0""5\0\377\0" + "B\0\377\0A\0\377\0L\0\377\0J\0\377\0D\0\377\0X\0\377\0N\0\377\0O\0\377" + "\0A\0\377\0J\0\377\0L\0\377\0O\0\377\0H\0\377\0""5\0\377\0""7\0\377\0" + ">\0\377\0R\0\377\0n\0\377\0\214\0\377\0\256\0\377\0\300\3\377\0\303\11" + "\377\0\240\1\377\0\204\0\377\0s\3\377\0Z\0\377\0\\\0\377\202\0J\0\377" + "\177\0C\0\377\0I\0\377\0@\0\377\0M\0\377\0@\0\377\0""8\0\377\0I\0\377" + "\0B\0\377\0G\0\377\0I\0\377\0>\0\377\0\77\0\377\0=\0\377\0J\0\377\0N" + "\0\377\0U\0\377\0S\2\377\0U\5\377\0]\17\377\0c\7\377\0\\\2\377\0i\30" + "\377\0f\27\377\0d'\377\0]\37\377_\240q\377\377\377\377\377\214\271\226" + "\377\0h\25\377\0p\23\377\0m\24\377\0l%\377\0q%\377\0d%\377\0e+\377\0" + "g\33\377\0e5\377\0j8\377\0{4\377\0z\"\377\0{-\377\0u)\377\0r\37\377\0" + "s#\377\0l1\377\0h/\377\0f\40\377\0f.\377\0h&\377\0r0\377\0b4\377\0]C" + "\377\0d;\377\0nB\377\0rE\377\0r>\377\0w4\377\0s>\377\0q4\377\0^5\377" + "\0nN\377\0hM\377\0fM\377\0cN\377\0lU\377\0eM\377\0\\P\377\0[H\377\0W" + "G\377\0XS\377\0PP\377\0NI\377\0UF\377\0X@\377\0\\<\377\0TJ\377\0FN\377" + "\0VJ\377\21G|\377\0-f\377\0\27K\377\0\14Q\377\210\2D\377a\0*\377N\0\10" + "\377N\0\4\377^$\35\377N)\26\377V3\26\377W>\24\377Z2\24\377[>\30\377e" + "9\23\377`D\20\377c8\26\377a\77\23\377S9\20\377N-\34\377U0\2\377Q/\14" + "\377\\.\11\377T\"\12\377U)\0\377]\37\11\377],\10\377g-\10\377c4\0\377" + "i8\0\377],\0\377`-\0\377T*\0\377[*\0\377f9\0\377g$\0\377\\$\0\377Y*\0" + "\377a$\0\377V\24\0\377O\27\0\377R%\0\377\\\31\0\377Q&\0\377P\26\0\377" + "N!\0\377Q\27\0\377O\24\0\377I\16\0\377\6D\13\0\377J\14\0\377@\4\0\377" + "2\0\0\3774\0\0\377.\0\0\377\202%\0\0\377\15$\0\0\377*\0\0\377'\0\0\377" + "5\0\0\3771\0\0\377)\0\0\377,\0\0\377*\0\0\377.\0\0\3772\0\0\3775\0\0" + "\377:\0\0\377*\0\0\377\202(\0\0\377\23*\0\0\377+\0\0\377*\0\0\377\34" + "\0\0\377\21\4\0\377\32\2\0\377\11\6\0\377\34\0\0\377\26\17\0\377\36\13" + "\0\377\30\15\0\377\25\25\0\377\16\31\0\377\16\36\0\377\13\24\0\377\2" + "\7\0\377\17\16\0\377\21\11\0\377\10\15\0\377\202\11\0\0\377\211\0\0\0" + "\377\3\0\2\0\377\0\0\0\377\0\1\0\377\202\0\0\0\377%\0\6\0\377\0\2\0\377" + "\0\14\0\377\0\12\1\377\0\16\3\377\0\7\0\377\0\14\0\377\0\36\0\377\0\27" + "\0\377\0!\1\377\0$\2\377\0""0\21\377\0+\17\377\0""3\33\377\0""3\20\377" + "\0=\12\377\0@\15\377\0B\10\377\0>\6\377\0,\12\377\0E\0\377\0""3\7\377" + "\0\77\0\377\0I\0\377\0Q\0\377\0P\0\377\0]\0\377\0R\0\377\0T\0\377\0A" + "\2\377\0""5\2\377\0\37\0\377\0(\0\377\0+\0\377\0(\0\377\0&\0\377\0'\0" + "\377\202\0""7\0\377\177\0""1\0\377\0-\0\377\0,\0\377\0-\0\377\0*\1\377" + "\0(\0\377\0""4\0\377\0""8\0\377\0""5\0\377\0D\0\377\0I\0\377\0G\0\377" + "\0U\0\377\0P\0\377\0Q\0\377\0K\0\377\0D\1\377\0N\0\377\0M\0\377\0S\0" + "\377\0""6\0\377\0""7\0\377\0;\0\377\0.\0\377\0\77\0\377\0e\0\377\0\211" + "\0\377\0\260\0\377\0\277\23\377\0\304\26\377\0\254\20\377\0\222\4\377" + "\0|\3\377\0j\0\377\0U\3\377\0I\0\377\0=\3\377\0=\0\377\0<\0\377\0D\0" + "\377\0""8\0\377\0\77\0\377\0\77\2\377\0A\0\377\0<\6\377\0K\0\377\0E\0" + "\377\0;\0\377\0""9\2\377\0""6\0\377\0M\0\377\0I\0\377\0D\0\377\0M\23" + "\377\0]\21\377\0^\7\377\0d\24\377\0V\15\377\0`\25\377\0c'\377\0Z\32\377" + "\0]\37\377\0`\31\377\271\322\300\377\312\332\314\377\7V\25\377\0]\35" + "\377\0g\37\377\0V\27\377\0H\30\377\0P\34\377\0i\35\377\0\\!\377\0`-\377" + "\0r1\377\0t\37\377\0y(\377\0d\40\377\0o\40\377\0q.\377\0t!\377\0p*\377" + "\0h*\377\0k!\377\0b\25\377\0Y#\377\0]*\377\0X*\377\0Y,\377\0N5\377\0" + "SB\377\0[:\377\0TF\377\0W3\377\0f>\377\0o@\377\0j@\377\0Y9\377\0[/\377" + "\0\\.\377\0c;\377\0]>\377\0X<\377\0f\77\377\0P=\377\0OC\377\0aE\377\0" + "X=\377\0QG\377\0MC\377\0SA\377\0LN\377\0IO\377\0GP\377\0IH\377\0BC\377" + "\15""1z\377\0\14U\377\0\0\77\377\0\16E\377\200\5F\377h\0\24\377I\0\0" + "\377E\0\0\377T5\7\377R9\33\377R5\26\377>U=\30\377`7\7\377`<\22\377`T" + "\30\377aO\17\377bG\26\377W6\34\377U.\20\377S/\0\377Y*\11\377Z)\3\377" + "X\"\0\377V2\0\377X\40\0\377[.\2\377`9\0\377l4\0\377g+\0\377_4\0\377n" + "4\0\377o8\0\377c;\0\377f*\0\377_\37\0\377a*\0\377V'\0\377^\40\0\377b" + "\"\0\377V\26\0\377V\34\0\377g\21\0\377M\27\0\377S\"\0\377S\24\0\377H" + "\35\0\377L\22\0\377L\27\0\377N\15\0\377G\24\0\377<\20\0\3778\17\0\377" + ".\4\0\377/\0\0\3772\5\0\3777\5\0\377;\0\0\3774\0\0\3778\0\0\3777\0\0" + "\3774\0\0\377.\0\0\377'\0\0\3776\0\0\377/\10\0\377/\0\0\3775\0\0\377" + "D\0\0\377;\2\0\377/\0\0\3778\0\0\377,\0\0\377-\0\0\377\202*\0\0\377\23" + ")\12\0\377&\7\0\377$\3\0\377+\10\0\377\27\10\0\377\35\14\0\377\24\23" + "\0\377\27\37\0\377\13\40\0\377\7$\0\377\12\32\0\377\6\14\0\377\23\2\0" + "\377\14\3\0\377\0\25\0\377\0\11\0\377\0\3\0\377\0\0\0\377\3\3\0\377\210" + "\0\0\0\377\1\0\4\0\377\205\0\0\0\377\40\0\4\0\377\0\10\2\377\0\0\15\377" + "\0\5\0\377\0\0\0\377\0\16\21\377\0\4\0\377\0\16\0\377\0\23\11\377\0\22" + "\20\377\0\"\11\377\0$\24\377\0'\20\377\0""1\5\377\0""4\20\377\0:\21\377" + "\0A\23\377\0D\17\377\0H\0\377\0=\0\377\0""9\3\377\0\77\3\377\0S\0\377" + "\0M\0\377\0R\0\377\0P\0\377\0Q\0\377\0I\0\377\0""5\0\377\0/\0\377\0""6" + "\0\377\0""4\0\377\202\0/\0\377\177\0)\0\377\0\27\0\377\0#\0\377\0""3" + "\0\377\0)\0\377\0-\1\377\0+\6\377\0(\10\377\0&\10\377\0(\1\377\0B\4\377" + "\0;\5\377\0""9\0\377\0E\0\377\0\77\0\377\0K\3\377\0D\3\377\0J\4\377\0" + "E\12\377\0K\16\377\0M\24\377\0E\0\377\0F\0\377\0I\0\377\0B\0\377\0E\0" + "\377\0S\10\377\0M\14\377\0]\0\377\0h\6\377\0\200\13\377\0\257\10\377" + "\0\313\20\377\0\320\30\377\0\264\16\377\0\231\30\377\0\200\16\377\0_" + "\11\377\0[\3\377\0U\23\377\0K\2\377\0@\0\377\0""8\0\377\0\77\0\377\0" + "8\0\377\0""5\2\377\0""8\0\377\0;\0\377\0B\0\377\0G\7\377\0=\6\377\0E" + "\0\377\0F\0\377\0J\0\377\0E\0\377\0S\0\377\0L\4\377\0_\3\377\0[\12\377" + "\0U\17\377\0S\14\377\0M\34\377\0Y\27\377\0b\23\377\0M\34\377\0[\34\377" + "<|Y\377\325\343\327\377\25O)\377\0I\31\377\0R\37\377\0A%\377\0""8\40" + "\377\0C*\377\0N)\377\0S(\377\0S*\377\0R\27\377\0Y\21\377\0Q\22\377\0" + "S\23\377\0b\36\377\0a\27\377\0b#\377\0c\"\377\0d\24\377\0g\30\377\0a" + "\37\377\0`\27\377\0b+\377\0W%\377\0]\"\377\0Y\37\377\0O'\377\0I5\377" + "\0Y*\377\0X0\377\0W)\377\0[@\377\0`@\377\0Z=\377\0V-\377\0\\/\377\0U" + "9\377\0R2\377\0K3\377\0B.\377\0C4\377\0XA\377\0UD\377\0E9\377\0EB\377" + "\0MD\377\0CB\377\0\2\0\377=\4\0\377A\0\0" + "\377;\5\0\3778\0\0\3773\7\0\377'\0\0\3779\0\0\3776\0\0\3772\0\0\3778" + "\1\0\3771\0\0\377)\21\0\377\35\15\0\377\32\13\0\377%\12\0\377\33\21\0" + "\377\22\31\0\377\23.\0\377\15!\0\377\24\31\0\377\7\20\0\377\0\27\0\377" + "\0\23\0\377\0\32\0\377\3\23\0\377\20\10\0\377\11\2\0\377\213\0\0\0\377" + "\3\0\6\0\377\0\0\0\377\0\12\0\377\202\0\0\0\377\177\0\1\6\377\0\10\7" + "\377\0\13\2\377\0\12\10\377\0\21\0\377\0\23\6\377\0\35\10\377\0\35\14" + "\377\0\20\1\377\0\30\15\377\0\24\7\377\0\26\16\377\0""2\12\377\0,\5\377" + "\0""5\16\377\0G\22\377\0V\21\377\0E\0\377\0C\15\377\0""6\11\377\0Q\5" + "\377\0J\0\377\0N\0\377\0P\5\377\0X\6\377\0S\0\377\0B\5\377\0#\4\377\0" + "-\0\377\0""4\12\377\0-\0\377\0)\0\377\0""3\0\377\0-\0\377\0""3\0\377" + "\0)\0\377\0&\0\377\0""0\0\377\0,\0\377\0,\21\377\0\37\14\377\0\40\11" + "\377\0""1\20\377\0""0\6\377\0""4\6\377\0<\2\377\0B\20\377\0""2\7\377" + "\0\77\7\377\0<\15\377\0=\17\377\0""5\12\377\0D\30\377\0H\16\377\0K\16" + "\377\0;\0\377\0:\16\377\0D\14\377\0F\21\377\0H\12\377\0N\16\377\0N\13" + "\377\0^\3\377\0}\2\377\0\247\30\377\0\273\21\377\0\267\37\377\0\247\40" + "\377\0\224\25\377\0h\7\377\0`\7\377\0\\\21\377\0M\20\377\0H\30\377\0" + "<\25\377\0""1\4\377\0>\1\377\0>\0\377\0+\7\377\0""1\0\377\0>\7\377\0" + "E\14\377\0I\14\377\0O\3\377\0P\23\377\0Q\21\377\0[\12\377\0h\0\377\0" + "d\0\377\0c\21\377\0`\33\377\0f\27\377\0X\20\377\0X\25\377\0N\24\377\0" + "Q\21\377\1U\34\377\23]0\377Z\221p\377\273\316\303\377\34Z3\377\0""9\25" + "\377\0Q\30\377\0J\31\377\0*#\377\0-\37\377\0/&\377\0.#\377\0@,\377\0" + "\77*\377\0B\25\377\0;\31\377\0K\25\377\0B\27\377\0Q\25\377\0Y\36\377" + "\0h\27\377\0]\33\377\0Z\35\377\0^\31\377\0b\37\377\0Q)\377\0U#\377\0" + "I\31\377\0N#\377\0V\40\377\0Q)\377W\0G)\377\0T6\377\0N1\377\0A4\377\0" + "VA\377\0R5\377\0M9\377\0Q4\377\0RB\377\0EH\377\0;C\377\0@C\377\0>9\377" + "\0KB\377\0@A\377\0\77""9\377\0Q=\377\0C9\377\0GB\377\0G@\377\0@A\377" + "\0\77E\377\0LD\377\0""3N\377\0""6@\377\0\30\0\377U\2\0\377" + "W\0\0\377S\0\0\377N\0\0\377I\14\0\377J\0\0\377S\0\0\377\202B\0\0\377" + "\37P\0\0\377U\0\0\377E\0\0\377\77\10\0\377D\4\0\377M\10\0\3776\4\0\377" + "7\0\0\377E\0\0\377@\1\0\3779\4\0\377E\14\0\3770\5\0\3774\0\0\377#\4\0" + "\377(\1\0\377\31\16\0\377\34\22\0\377\20\36\0\377\27-\0\377#\34\0\377" + "\35!\0\377\0\27\0\377\0%\0\377\0\24\0\377\0\23\0\377\0\17\0\377\21\13" + "\0\377\0\26\0\377\0\20\0\377\3\14\0\377\204\0\0\0\377\1\5\0\0\377\206" + "\0\0\0\377+\0\13\0\377\0\27\0\377\0\17\0\377\0\4\20\377\0\34\14\377\0" + "\30\20\377\0\21\14\377\0\31\14\377\0\24\0\377\0\30\0\377\0\21\2\377\0" + "\24\12\377\0\26\4\377\0#\12\377\0\36\13\377\0\33\11\377\0'\20\377\0<" + "\14\377\0:\16\377\0G\7\377\0H\20\377\0J\22\377\0G\21\377\0D\25\377\0" + "S\0\377\0b\16\377\0i\10\377\0Z\2\377\0Z\14\377\0""9\13\377\0\77\15\377" + "\0""7\21\377\0""3\25\377\0""5\1\377\0""1\0\377\0@\0\377\0""9\0\377\0" + "1\0\377\0\40\5\377\0""4\5\377\0(\3\377\0%\12\377\0#\11\377\202\0#\4\377" + "5\0.\21\377\0+\3\377\0""2\13\377\0/\22\377\0,\37\377\0.\25\377\0C\31" + "\377\0""9\22\377\0""4\11\377\0""5\11\377\0""7\12\377\0>\6\377\0@\10\377" + "\0""7\24\377\0A\25\377\0""3\7\377\0""7\0\377\0@\5\377\0E\5\377\0:\4\377" + "\0C\7\377\0U\0\377\0k\25\377\0\206\31\377\0\247!\377\0\251$\377\0\240" + "\7\377\0\204\16\377\0f\13\377\0V\14\377\0M\34\377\0C\37\377\0>\12\377" + "\0B\16\377\0@\12\377\0""8\14\377\0:\11\377\0""3\5\377\0""9\20\377\0@" + "\22\377\0L\22\377\0O\15\377\0M\16\377\0P\23\377\0a\25\377\0n\16\377\0" + "m\20\377\0o'\377\0l'\377\0m\34\377\0h\35\377F\211V\377\375\375\375\377" + "\203\377\377\377\377\177\374\375\374\377\221\263\235\377\10Z\33\377\0" + "K\26\377\0N\37\377\0B\40\377\0\77\37\377\0""8\"\377\0$\36\377\0\"-\377" + "\0\40\35\377\0&\33\377\0-)\377\0*.\377\0""1#\377\0F.\377\0<4\377\0U(" + "\377\0P!\377\0\\\37\377\0M\30\377\0V&\377\0S#\377\0\\)\377\0M!\377\0" + ">5\377\0D,\377\0I.\377\0>3\377\0;3\377\0""82\377\0@-\377\0EA\377\0PQ" + "\377\0O0\377\0H1\377\0<>\377\0""0\77\377\0ID\377\0FJ\377\0""5Q\377\0" + ">J\377\0""1E\377\0\77D\377\0""83\377\0""7.\377\0""6A\377\0D:\377\0C=" + "\377\0EA\377\0:L\377\0""6E\377\0""2>\377\0""9C\377\0""6G\377\0""2F\377" + "\0+k\377\0\1M\377\0\0""7\377\0\0@\377\230\0L\377\203\0\"\377Z\0\0\377" + "U\0\0\377lH\16\377wW\40\377xS\22\377rc\21\377`_\10\377nh\10\377ga\0\377" + "tY\0\377hI\0\377l5\0\377n6\0\377j'\0\377\200'\0\377x#\0\377s$\0\377m" + "\33\0\377c\24\0\377p\26\0\377l\34\0\377j!\0\377d\36\0\377_'\0\377g'\0" + "\377l1\0\377_'\0\377`2\0\377d4\0\377Z+\0\377h\31\0\377l\37\0\377X\32" + "\0\377b\35\0\377f!\0\377i#\0\377P&\0\377K\33\0\377J\25\0\377W\14\0\377" + "S\6\0\377O\16\0\377E\11\0\377Y\1\0\377k\24\0\377d\31\0\377S\12\0\377" + "]\22\0\377Q\0\0\377U\0\0\377Q\4\0\377N\21\0\377^\0\0\377g\0\0\377_\0" + "\0\377W\0\0\377^\0\0\377X\0\0\377I\0\0\377N\6\0\377W\5\0\377U\5\0\377" + "E\12\0\377=\1\0\377=\15\0\377\32E\4\0\377A\16\0\377<\7\0\377.\0\0\377" + "0\13\0\377/\2\0\377\36\2\0\377\30\2\0\377\5\20\0\377\6\30\0\377\30\25" + "\0\377\17\35\0\377\12\31\0\377\7\33\0\377\11\21\0\377\0\24\0\377\0\35" + "\0\377\0\36\0\377\3\24\0\377\0\15\0\377\0\27\0\377\0\10\0\377\0\2\0\377" + "\0\0\0\377\5\0\0\377\0\7\0\377\206\0\0\0\377\177\0\6\3\377\0\15\7\377" + "\0\27\5\377\0\11\11\377\0\30\16\377\0\26\31\377\0\17\13\377\0\20\6\377" + "\0\24\7\377\0\31\4\377\0\30\6\377\0\34\21\377\0\12\0\377\0\12\3\377\0" + "\"\0\377\0\"\2\377\0\"\14\377\0.\23\377\0:\5\377\0>\7\377\0""6\16\377" + "\0;\34\377\0H\17\377\0Q\20\377\0O\25\377\0Y\11\377\0\\\16\377\0d\21\377" + "\0c\26\377\0U\32\377\0U\37\377\0G\31\377\0""8\21\377\0""1\11\377\0;\20" + "\377\0=\17\377\0""2\1\377\0""6\4\377\0(\0\377\0#\3\377\0$\10\377\0*\24" + "\377\0'\27\377\0\"\17\377\0\40\34\377\0*\32\377\0*\20\377\0-\21\377\0" + "2\2\377\0""1\20\377\0&\20\377\0""4\13\377\0""1\26\377\0""4\36\377\0'" + "\33\377\0)\21\377\0""0\32\377\0B\21\377\0\77\16\377\0/\21\377\0""2\22" + "\377\0""2\5\377\0""3\1\377\0""0\2\377\0""5\7\377\0""8\24\377\0-\12\377" + "\0""7\7\377\0M\10\377\0N\21\377\0v\16\377\0\212\17\377\0\214\36\377\0" + "q\4\377\0i\20\377\0K\32\377\0L\33\377\0C!\377\0C\17\377\0""2\23\377\0" + "4\3\377\0=\14\377\0=\24\377\0:\21\377\0>\0\377\0B\16\377\0M\37\377\0" + "<\20\377\0G\17\377\0Z\12\377\0f\30\377\0}\34\377\0\221!\377\0\221.\377" + "\0\2216\377\0\2170\377\0s1\377\12l,\377\260\317\271\377\320\340\325\377" + "\316\336\321\377\257\305\265\377{\250\221\377\32fA\377\0M,\377\0R2\377" + "\0H,\377\0<3\377\0@\37\377\0<)\377\0""1,\377\0\32""5\377\0\37""0\377" + "\0!8\377\0!%\377\0%+\377\0$'\377\0""52\377\0""40\377\0:3\377\0H(\377" + "\0\\9\377\0K\40\377\0M%\377\0K(\377\0Z!\377\0J$\377d\0G\40\377\0H,\377" + "\0""5)\377\0:0\377\0+/\377\0""14\377\0:G\377\0AL\377\0KE\377\0E@\377" + "\0AA\377\0""7G\377\0""86\377\0@B\377\0:J\377\0""4N\377\0+I\377\0""2B" + "\377\0""1:\377\0""30\377\0/8\377\0""0>\377\0""48\377\0""4:\377\0""3I" + "\377\0;@\377\0""5A\377\0@7\377\0.L\377\0""6D\377\0""1J\377\0""89\377" + "\1/j\377\0\34X\377\0\0\77\377\0\0A\377\216\1E\377t\0+\377^\0\0\377c\0" + "\2\377kP\14\377mG\32\377jY\22\377fP\15\377uW\0\377h\\\10\377|^\0\377" + "{L\0\377nD\0\377{3\0\377t:\0\377u\77\0\377y'\0\377w#\0\377i\25\0\377" + "m\32\0\377o\6\0\377_\5\0\377g\37\0\377m)\0\377a\34\0\377s!\0\377b&\0" + "\377e&\0\377Z+\0\377j\40\0\377c$\0\377g\32\0\377j\27\0\377[\37\0\377" + "`\33\0\377i\32\0\377^$\0\377[\31\0\377T%\0\377]\36\0\377X\23\0\377F\30" + "\0\377I\3\0\377R\1\0\377`\3\0\377\\\10\0\377^\20\0\377W\15\0\377`\12" + "\0\377Y\7\0\377e\1\0\377`\0\0\377~\24\5\377\246(W\377\2569R\377\2470" + "F\377\2302>\377l\20\0\377R\0\0\377\215\34(\377\230@Q\377\242AV\377\231" + "@K\377\2256\377\0""1+\377\0@\"\377\0B\40\377\0=,\377\0""8" + "-\377\0D.\377\0<\37\377\0D'\377\0@\37\377y\0""9/\377\0>0\377\0""5+\377" + "\0""72\377\0""04\377\0.6\377\0""6>\377\0<@\377\0DF\377\0OG\377\0=>\377" + "\0B4\377\0""4H\377\0+<\377\0-F\377\0'G\377\0+3\377\0)7\377\0""7:\377" + "\0""1\77\377\0""33\377\0/7\377\0'C\377\0.=\377\0*6\377\0B5\377\0F6\377" + "\0""2F\377\0""7K\377\0""8^\377\0FL\377\0AF\377\17""4k\377\0\21L\377\0" + "\0""2\377\0\0D\377\232\16:\377\202\0!\377e\0\2\377X\0\0\377s\77\15\377" + "rM\16\377pH\10\377lN\1\377p^\0\377yR\0\377~^\2\377vQ\0\377\177N\0\377" + "\177D\0\377~E\0\377\207\77\0\377w*\0\377s'\0\377i!\0\377t\34\0\377b\22" + "\0\377j\21\0\377p\34\0\377j\35\0\377l\32\0\377t\35\0\377[\33\0\377j(" + "\0\377m\"\0\377_%\0\377j\"\0\377m%\0\377^*\0\377f$\0\377j)\0\377c%\0" + "\377c*\0\377_\"\0\377`%\0\377V\21\0\377S\23\0\377e\6\0\377S\15\0\377" + "`\26\0\377j\34\0\377`\7\0\377_\6\0\377c\5\0\377_\3\0\377\\\10\0\377^" + "\7\0\377\200\36\3\377\260Ng\377\217/\32\377\216+\26\377\214-\40\377\205" + "0$\377e\3\0\377x%\3\377\253E}\377z3(\377y0,\377t7)\377{3B\377=\17\0\377" + "8\0\0\377\77\0\0\377F\0\0\377\\\21\0\377\232P\225\377z6>\377d0\"\377" + "c@,\377{Ys\377.#\0\377\32\32\0\3777;%\377zi\237\377\14\31\0\377\6\24" + "\0\377\10\13\0\377\3\12\0\377\3\2\0\377\4\13\0\377\1\0\0\377\203\0\0" + "\0\377\1\0\15\0\377\202\0\0\0\377\3\0\11\0\377\30.D\377\0\0\20\377\204" + "\0\0\0\377\177\0\16\0\377\0\7\10\377\0\21\13\377\0\10\20\377\0\33\12" + "\377\0\15\10\377\0*9\377\27Z\262\377\10N\203\377\0Fu\377\0!\33\377\0" + "\15\0\377\0\31\26\377\0\"\27\377\0\33\36\377\0\32\35\377\0\25\20\377" + "\0$\27\377\0&\33\377\0""1\"\377\0""7,\377\0B\35\377\0='\377\0.\30\377" + "\0""3\35\377\0QW\377\10\211\362\377\0u\244\377\0c\206\377\0d\222\377" + "\0\216\327\377\0gY\377\0RU\377\10y\333\377\0i\242\377\0X\234\377\0c\214" + "\377\0g\204\377\0""8(\377\0He\377\34m\317\377\0Jg\377\0Rv\377\0U\225" + "\377\7q\271\377\0)\13\377\0)\32\377\0(\27\377\0\26\32\377\0:W\3770x\361" + "\377\0X\214\377\0Tv\377\0Qt\377\0*G\377\0\"\26\377\0'\25\377\0)\24\377" + "\0'\30\377\0-\20\377\0$\14\377\0*\25\377\0/\22\377\0,\11\377\0#\25\377" + "\0\37\5\377\0#\7\377\0""3\22\377\0B\2\377\0K\15\377\0V\27\377\0^\33\377" + "D\213\334\377\27|x\377\0L\30\377\0I\"\377\0""6\15\377\0:\15\377\0""4" + "\20\377\0'\25\377\0""5\23\377\32hz\377V\235\342\377\0:\23\377\0;\21\377" + "\0""9\36\377\0""8\"\377\0>%\377\0J\35\377\0R\34\377\0d\27\377\0r!\377" + "\0\207#\377\0\237%\377\11\2709\377\3\253<\377\0\230;\377\0\2129\377\0" + "l2\377\0_\25\377\0Q\24\377\0T\32\377\0F\34\377\0T\34\377\0D(\377\0E1" + "\377\0=)\377\0>%\377\0:(\377\0*+\377\0-.\377\0(*\377\0\37\"\377\0&%\377" + "\0,\34\377\0\36&\377\0*%\377\0&/\377\0&!\377\0-#\377\0\77!\377\0""1)" + "\377\0""5#\377\0""70\377\0""8*\377\0))\377\0""5!\377\177\0""7)\377\0" + ",%\377\0""11\377\0""5#\377\0\40'\377\0/2\377\0;9\377\0\377\0" + "%H\377\0)8\377\0\37""9\377\0(=\377\0*A\377\0/\77\377\0)7\377\0)A\377" + "\0.9\377\0""5>\377\0""8B\377\0\77E\377\0MI\377\0]L\377\0SH\377\0IM\377" + "\16)o\377\0\13O\377\0\0/\377\0\0""3\377\223\11""7\377v\0\34\377\\\0\0" + "\377J\0\0\377h1\1\377j4\5\377\\:\0\377ZF\0\377\\M\0\377[W\1\377pN\0\377" + "qU\0\377|V\0\377\203Q\0\377\204Q\0\377{A\0\377\2027\0\377\1771\0\377" + "v#\0\377t\32\0\377e\21\0\377k\21\0\377w\30\0\377s\36\0\377x\32\0\377" + "k&\0\377j\27\0\377c%\0\377d-\0\377e'\0\377a0\0\377u6\0\377j;\0\377i<" + "\0\377i,\0\377`-\0\377e.\0\377Y\26\0\377a\36\0\377\\\33\0\377c\22\0\377" + "b\31\0\377Y\14\0\377a\33\0\377V\24\0\377S\12\0\377_\1\0\377W\5\0\377" + "K\13\0\377T\3\0\377\\\30\0\377\243Ib\377\23389\377Y\15\0\377S\27\0\377" + "V\26\0\377E\15\0\377N\2\0\377{'$\377\277O\213\377I\0\0\377C\2\0\377A" + "\10\0\377F\0\0\3777\0\0\377:\0\0\377\77\10\0\377;\10\0\377J'\17\377\231" + "k\233\377\77&\0\3770\24\0\3770\31\0\377\223o\232\377F,\0\377\23\27\0" + "\377K\77\77\377\212f\246\377\20\7\0\377A6.\377\"\30\0\377\0\0\0\377(" + ")\17\377\37\27\"\377\3\0\0\377\6\15\0\377(0<\377+,G\377\26""4A\377\20" + "&)\377\177\0\3\0\377\0\20\0\377\21/G\377\0\13\7\377\0\22\34\377\16/T" + "\377\33""7O\377\26:N\377\0\36#\377\0\11\0\377\0\21\0\377\0\11\22\377" + "\0\15\7\377\0\11\0\377\14N\213\3778q\345\377\6K\217\377\0\37\7\377\0" + "&\0\377\1Mr\377\7O\201\377\0D\200\377\5L\202\377\0\35\37\377\0#\30\377" + "\0Ii\377\0Mn\377\0c\226\377\0e\221\377\0@H\377\0""93\377\0""44\377\0" + "./\377\0JP\377\32\216\364\377\0Md\377\0""9,\377\0""1%\377$\215\372\377" + "\0^i\377\0[p\377\33\225\376\377\0Tg\377\0=6\377\0""5\37\377\0""4\27\377" + "\0""1\23\377\0;R\377\0It\377\0\33\13\377\0\35\36\377\0""7M\377%|\364" + "\377\0\37#\377\0\34\23\377\0\26#\377\0\36\22\377\0:X\377Cw\347\377\0" + "%H\377\0\24\7\377\0\27\20\377\0\32\12\377\0\40""1\377\17Gx\377\14Y\201" + "\377\1S\202\377\0I[\377\5Uw\377\12f\204\377\2o\177\377\0""0\0\377\0)" + "\11\377\0HU\377\0OP\377\0(\22\377\0<<\377\31d\202\377\0""2\11\377\0:" + "\26\377I\224\336\377\11t\203\377\0Q\25\377\0TR\377\15\\x\377\20k\202" + "\377\0Pl\377\0,\23\377\0<,\3779\213\261\377J\233\340\377\1Sc\377\0""4" + "\36\377\0H6\377(o\215\377\37m\217\377!k\221\377\30sy\377\0m!\377\3\202" + "B\377,\233\204\377\37\245p\3776\265\231\377(\246\206\377\0\235F\377\5" + "\203A\377\26\211\213\377\26\210w\377\35w\211\377\0G)\377\0P(\377\0G+" + "\377\0C\36\377\0""5#\377\0;\36\377\0D+\377\0-\36\377\0\40\35\377\0\37" + "(\377\0\32\35\377\0&\21\377\0,\25\377\0\40\35\377\0\33$\377\0$0\377\0" + "%'\377\0/%\377m\0""2\35\377\0""3\34\377\0""0)\377\0""02\377\0""10\377" + "\0,%\377\0""5'\377\0$)\377\0)1\377\0'!\377\0$)\377\0-,\377\0(.\377\0" + "&5\377\0""8\77\377\0""8F\377\0>D\377\0""4G\377\0>\77\377\0.:\377\0!=" + "\377\0,J\377\0#:\377\0%@\377\0#>\377\0\31;\377\0\"R\377\0+\77\377\0&" + "8\377\0&;\377\0""3@\377\0&D\377\0!9\377\0/7\377\0""3E\377\0""0F\377\0" + "BL\377\0[L\377\0[O\377\0[X\377\0SK\377\0+u\377\0\4Q\377\0\0.\377\0\0" + "8\377\215\2""7\377[\0\25\377M\0\1\377I\0\0\377V-\6\377T%\0\377K/\0\377" + "]:\0\377S\77\0\377aC\0\377gO\0\377eX\0\377tQ\0\377|f\0\377\200T\0\377" + "~W\0\377\205V\0\377\206M\0\377u/\0\377l\40\0\377n\36\0\377v\22\0\377" + "\203\23\0\377\200\22\0\377m\17\0\377j\36\0\377g\40\0\377g\36\0\377h)" + "\0\377Z,\0\377c3\0\377fL\0\377m7\0\377gD\0\377f>\0\377Z/\0\377^;\0\377" + "X)\0\377\\$\0\377H\37\0\377S(\0\377L\25\0\377Q\31\0\377N\20\0\377P\11" + "\0\377A\14\0\377@\26\0\377.\12\0\377:\21\0\377<\34\0\377b+\0\377\301" + "b\224\377l&\0\377\77\23\0\377K\37\0\377=\35\0\377\77\15\0\377A\1\0\377" + "x31\377\270Z\234\3777\25\0\377G\11\0\3770\15\0\3772\11\0\377\2020\0\0" + "\377\177.\11\0\377(\24\0\377H&\17\377\251c\267\377P\37\22\377$\13\0\377" + ")\7\0\377\227p\270\3772\40\2\377\37\0\0\377S0J\377\215j\247\377\12\6" + "\0\377\177c\235\377G.-\377\2\2\0\377bF{\377WXz\377\2\0\0\377G@`\377X" + "b\221\377GZ~\377Qq\251\377;N\205\377\0\0\0\377\0%\26\377Wo\251\377\0" + "\32\11\377%.H\377\\y\267\377%Ps\377(W\224\377\36Z\200\377\0\30\12\377" + "\0\32\0\377\0\17\0\377\0\25\3\377\0\13\15\377,p\304\377C\177\336\377" + ",k\270\377\0\30\10\377\2""2M\377=}\324\377\35^\264\377\36`\265\377/v" + "\321\377\0>n\377\0\37\37\377\24c\314\377\37|\336\377\33\203\353\377\12" + "\177\310\377\0DT\377\0<0\377\0""9$\377\0""2(\377\0Bc\377+\226\376\377" + "\0\77g\377\0""3=\377\0""1$\3776\226\377\377\0Ee\377\0Wo\3777\225\377" + "\377\0Mf\377\0)&\377\0-\36\377\0*\26\377\0(\22\377\0.\34\377\0!\36\377" + "\0\35\"\377\0!=\377\22[\233\377(q\326\377\0\36!\377\0\12!\377\0\4!\377" + "\0\24\25\377\0""6S\377D\177\343\377\0.B\377\0\26\32\377\0\21\21\377\0" + "\20\11\377\0(M\377J\204\346\3775u\274\377,j\245\377=\177\303\3778\216" + "\312\3772\206\245\3779\212\274\377\24Zs\377\0\30\16\3777{\255\377G|\265" + "\377\0\23\31\377\35Tj\377\\\224\334\377\0\37\31\377\0""1\35\377V\222" + "\366\377!c\207\377\0""9\22\377\3OU\377-}\260\377.}\266\377N\211\320\377" + "\0CO\377\0""7@\377H\210\311\377R\227\375\377\35v\233\377\0,#\377,y\256" + "\377Y\214\342\377H\205\274\377B\207\260\377K\222\313\377\27i_\377!}_" + "\377c\246\346\377h\247\326\377U\260\306\377\177>\256\240\377\0\222#\377" + "E\223\243\377Z\236\323\377N\227\272\377Q\215\267\377\0J(\377\0<%\377" + "\0;(\377\0""0$\377\0-\31\377\0+\21\377\0!\32\377\0+%\377\0*\32\377\0" + "%\36\377\0\32.\377\0\40$\377\0\25*\377\0\6&\377\0\11,\377\0#!\377\0\31" + "4\377\0$+\377\0""2#\377\0-'\377\0/-\377\0--\377\0/,\377\0\"'\377\0,\30" + "\377\0\33$\377\0\40\36\377\0\36+\377\0#-\377\0\35""1\377\0.#\377\0\40" + "<\377\0,@\377\0,=\377\0;>\377\0>=\377\0:1\377\0)'\377\0+D\377\0+6\377" + "\0\26""6\377\0\26@\377\0\"\77\377\0""2:\377\0""3\77\377\0&\77\377\0""7" + "2\377\0""3\77\377\0""1G\377\0\40@\377\0""9M\377\0+<\377\0-;\377\0""8" + "\77\377\0FC\377\0ZK\377\0VN\377\0kJ\377\0kN\377\17'q\377\0\0X\377\0\0" + "@\377\0\0""7\377\177\4""2\377g\0\20\377E\0\0\377\77\0\0\377Q(\0\377K" + "9\0\377Q6\0\377L7\0\377U9\0\377YF\0\377L\77\0\377TT\0\377kL\0\377pV\0" + "\377od\0\377\200]\0\377il\0\377sX\0\377sJ\0\377h4\0\377p7\0\377n\"\0" + "\377k\16\0\377c\33\0\377m!\0\377e&\0\377`+\0\377\\7\0\377_/\0\377Y(\0" + "\377]<\0\377mA\0\377_4\0\377SB\0\377]I\0\377X\77\0\377_6\0\377Q8\0\377" + "C)\0\377E3\0\377A%\0\377D\34\0\377F\33\0\377=\30\0\377,\24\0\377)%\0" + "\377-\25\0\377,\32\0\377-\37\0\3774\37\0\377T%\0\377\261t\231\377P%\0" + "\377I,\0\377U\"\5\377a/\2\377U\77\0\377@\25\0\377\177n7\25\377\253y\232" + "\377V0\0\377T*\0\377U\40\26\3777\22\0\377A\5\0\3776\11\0\3772\14\0\377" + "4\11\0\377T%\21\377\250p\272\377_0=\377E\33\23\3776\16\30\377\211`\231" + "\377(\22\15\377\32\6\0\377U\77M\377\226x\250\377\23\23\0\377\232u\252" + "\377A@B\377\1\3\0\377hV|\377lV|\377\0\0\0\377\201w\260\377:\77C\377\0" + "\7\0\377Bm\212\377Ecv\377\0\4\0\377\0\"\7\377oz\254\377\0,\12\377\22" + "D@\377Xv\275\377\0\21\0\377\0,\15\377T}\260\377\0""3\"\377\0\40\0\377" + "\0\25\10\377\0\24\5\377\0\26\0\377\0F/\377V\213\333\377\0""0\77\377\0" + "\15\13\377(p\251\377,a\252\377\0\15\3\377\0\20\17\377\16F\200\377)k\316" + "\377\0\27\36\377\32s\306\3774\206\367\377\0L\201\377\0+/\377\0-<\377" + "\0""16\377\0')\377\0&,\377\0Dn\3779\231\377\377\0f\222\377\0Mr\377\0" + "Rs\3777\215\377\377\0\77g\377\0GZ\377+\231\362\377\4_\205\377\0\77k\377" + "\0L\\\377\0""9\77\377\0\34\27\377\0*\22\377\0!!\377\0\33\37\377\5Q\205" + "\3776t\334\377\0\26G\377\0\7\37\377\0\16)\377\0\14\36\377\0\11\40\377" + "\0""2C\377Z\204\350\377\6Kl\377\0-M\377\0\"8\377\0\21\30\377\0\"B\377" + "Y\211\371\377\0*F\377\0\23\17\377V\212\351\377\20Hy\377\0\22\27\377\24" + "Qx\377f\233\352\377\0\30\30\377Tu\261\377Sy\265\377\0\23\7\377'_~\377" + "o\227\350\377\0!\27\377\0)\35\377q\213\350\3772f\211\377\0,\37\377\0" + "\"\22\377\0\40\37\377\0\32\35\377[\244\370\377\25`\222\377\0$\"\377\35" + "i\222\377m\243\370\377\0$\40\377\0,(\377r\254\376\377\37k\205\377m\0" + "-\25\377\0""2&\377U\203\301\3777b\212\377\22be\377z\227\356\377c\243" + "\310\377\3\244(\377\0\230/\377\2}'\377\201\246\364\377;\177\223\377\0" + "A\33\377\2D#\377\0""3\36\377\0'\27\377\0*\6\377\0(\11\377\0&\35\377\0" + "\35\36\377\0.\37\377\0*&\377\0&<\377\0)<\377\0'/\377\0\25""1\377\0\22" + ")\377\0\21,\377\0\22,\377\0!.\377\0%7\377\0)0\377\0""17\377\0%7\377\0" + "32\377\0+#\377\0-*\377\0""1)\377\0%:\377\0(%\377\0#'\377\0.\"\377\0(" + "$\377\0\34.\377\0#%\377\0""1*\377\0(5\377\1-7\377\0""3K\377\0""0C\377" + "\0""10\377\0\40:\377\0!/\377\0'=\377\0\30:\377\0'4\377\0+3\377\0""1:" + "\377\0""3B\377\0\"@\377\0""0=\377\0+N\377\0-G\377\0-C\377\0""7C\377\0" + "(G\377\0$G\377\0(O\377\0;J\377\0=H\377\0PT\377\0]\\\377\0k[\377\23\14" + "}\377\0\0f\377\0\0=\377\0\0H\377\203\2""0\377e\0\26\377>\0\0\3777\0\0" + "\377A!\0\377@.\0\377B4\0\377M7\0\377L8\0\377PB\0\377RB\0\377];\0\377" + "OS\0\377ZW\0\377Zl\0\377es\0\377ag\0\377`g\0\377dT\0\377^J\0\377eG\0" + "\377YA\0\377T5\0\377Z$\0\377d5\0\377d+\0\377e6\0\377\\/\0\377Q,\0\377" + "Y)\0\377]1\0\377\\/\0\377\202O:\0\377\177S-\0\377V8\0\377S,\0\377J<\0" + "\377K4\0\377M8\0\377F+\0\377E(\0\3773\"\0\3770#\0\377,%\0\377.*\0\377" + "\35\40\0\377\40/\0\377'\33\0\3772\27\0\377R7\0\377\262m\240\377U+\2\377" + "\245\\i\377\302\204\255\377\306\200\250\377\305u\236\377_+\0\377;\25" + "\0\377\232ou\377\273y\260\377\320\177\266\377\305s\251\377{O>\3775\30" + "\0\3775\16\0\377,\10\0\377%\26\0\377E/\22\377\265j\273\377\254n\265\377" + "\251v\270\377\246p\254\377RFS\377\30\15\0\377&\27\0\377XQ6\377\233{\246" + "\377\3\4\0\377\220\205\261\377=F;\377\0\7\0\377wgt\377r]q\377\0\21\0" + "\377\214\177\266\377@DE\377\0\10\0\377eq\201\377]f\177\377\0\1\0\377" + "\12""0\21\377j\221\262\377\0;\10\377\33N<\377s\215\264\377\0\30\0\377" + "\0G\27\377p\226\301\377\0>\34\377\0$\0\377\0\35\0\377\0\33\0\377\0!\0" + "\377\0B0\377o\206\332\377\0""7=\377\0\"\0\377/u\267\3777`\275\377\0\1" + "\20\377\0\7\24\377\7G\213\377\37[\303\377\0\20(\377)p\317\377+f\313\377" + "\0\36/\377\0),\377\0)4\377\0-6\377\0%,\377\0""12\377\0Pz\377^\244\377" + "\377M\253\377\377O\253\377\377N\264\377\377\13p\264\377\0""6=\377\0""0" + "(\377\22q\221\377[\260\377\377^\240\377\377X\231\377\377\"s\270\377\0" + "+2\377\0!\34\377\0\36\36\377\0""2J\377i\215\377\377\32P\220\377\0\13" + "\34\377\0\17\32\377\0\16\27\377\0\12\20\377\0\12\31\377\0""3W\377j\201" + "\371\377m\214\363\377o\177\371\377Hk\277\377\0\12\7\377\0\35G\377h\215" + "\356\377\0#H\377\0\6\15\377n\212\342\377\25Q\210\377\0\16\15\377*J\206" + "\377g~\232\354\377\0\15\13\377Or\266\377Gt\267\377\0\22\34\3772c\215" + "\377w\243\370\377\0$\40\377\0**\377x\235\366\377.v\210\377\0%\26\377" + "\0""8*\377\6HY\377\5@I\377}\264\374\377(p\212\377\0-\37\377\"l\211\377" + "\177\264\377\377\0'\37\377\0&\40\377s\250\347\3776b\201\377\0\37'\377" + "\0\34.\377Y\211\307\377\377\0""62\377\0" + ":8\377\0""8/\377\0C9\377\0A)\377\0""68\377\0""5<\377\0""36\377\0/@\377" + "\0.8\377\0#1\377\0""1@\377\0\34>\377\3\32G\377\0&R\377\0$I\377\0/8\377" + "\12\40A\377\0,I\377\0\40A\377\0\37C\377\0\"F\377\0\22<\377\0\34B\377" + "\0\36S\377\0\27N\377\0\27F\377\0#F\377\0/H\377\0+S\377\0%R\377\0\36M" + "\377\0+G\377\0\36;\377\0\30K\377\0&W\377\0""4W\377\0J\\\377\0`d\377\0" + "hZ\377\36\13~\377\10\0^\377\0\0L\377\0\0K\377\207\0\35\377j\0\0\377\202" + "<\0\0\377\177T1\0\377O+\0\377F<\0\377D@\0\377G8\0\377E>\0\377G\77\0\377" + "\77@\0\377RJ\0\377VG\0\377Qg\0\377Wl\0\377ep\0\377`x\0\377Vn\0\377]j" + "\0\377^Z\0\377`J\0\377dC\0\377X8\0\377Z:\0\377V>\0\377P\77\0\377Y;\0" + "\377U>\0\377T@\0\377D6\0\377A/\0\377IA\0\377[;\0\377J8\0\377I-\0\377" + "H\77\0\377\77A\0\377SA\0\377WA\0\377>8\0\377:/\0\3773.\0\377E-\0\377" + "@$\0\3777\34\0\377\32&\0\377\36.\0\377*\40\0\377*#\0\377L6\0\377\304" + "\200\225\377E>\1\377\37!\0\377/\30\0\377J3\3\377\306y\257\377P-\11\377" + "#!\0\377\26\"\0\377'#\0\377+$\0\377T2\13\377\331\206\270\3777\27\0\377" + "\"\26\0\377*\31\0\377'\11\0\377Y1\1\377\277\203\265\377B/\15\377\20\14" + "\0\377\13\16\0\377\13\33\0\377\20\24\0\377\14\30\0\377LV5\377\230}\243" + "\377\0\22\0\377\252\215\256\377DX9\377\0\33\0\377uqw\377zkl\377\0\7\0" + "\377\252\203\246\377MH:\377\0\7\0\377ckt\377`p\177\377\0\1\0\377\5+\1" + "\377}\234\276\377\0""6\34\377#YF\377\212\237\271\377\0\32\0\377\1""6" + "*\377z\226\312\377\3N\"\377\0""7\0\377\0'\0\377\0/\0\377\0&\3\377\26" + "90\377x\241\347\377\0@A\377\0\20\12\377>h\275\377Ie\273\377\0\3%\377" + "\0\2\32\377\5A\210\377*n\300\377\0\5&\377:h\326\377;f\315\377\0\20\40" + "\377\0#+\377\0\34""0\377\0*.\377\0+,\377\0$<\377\0Hr\377t\241\377\377" + "\0Ug\377\0""00\377\0()\377\0/3\377\0*2\377\0.-\377\177\0.'\377\0!,\377" + "\0\30(\377\0\26""3\377u\227\377\377\0""6b\377\0\22)\377\0\7&\377^|\311" + "\377-M\225\377\0\24\35\377\0\5\32\377\0\7\"\377\0\0\40\377\0\3$\377\0" + "\17(\377\11*X\377\203\220\375\377\14$Q\377\0\3\35\377\0\14\21\377\0\15" + "\31\377\24-K\377y\207\355\377\2(G\377\0\0\31\377v\214\377\3777D\206\377" + "\0\5\24\377/O\211\377|\223\367\377\0\0\26\377So\310\377Qz\276\377\0\14" + "\"\3770h\214\377\200\244\377\377\0-\33\377\0.*\377y\252\377\377'j\224" + "\377\0""8\32\3770g\226\377\205\266\377\377\227\261\377\377\222\260\376" + "\3773i\205\377\0\36\34\377>k\217\377}\256\366\377\0+\27\377\0.\27\377" + "\210\256\352\377D\\\211\377\0!\30\377\0\13\"\377bn\274\377JK\221\377" + "$Te\377\225\244\373\377%xu\377\13\2137\377\13\2000\377\34l-\377<`X\377" + "\244\237\377\377\247\256\374\377\1""9#\377\0""4\26\377\0+\17\377\2\36" + "\23\377\7(\34\377\0\35\35\377\0\32\"\377\0""6\34\377\0C)\377\0""34\377" + "\0C\377\0D=\377\0+0\377\0*7\377\0\36\35\377\0#(\377\0).\377" + "\0""3*\377\0+:\377\0A<\377\0I6\377\0M\77\377\0Q:\377\0QA\377\0AG\377" + "\0""9B\377\0'7\377\0\37;\377\0\26""6\377\0\17\77\377\0\37""9\377\0\33" + "=\377\0\36P\377\0!A\377\1""1<\377\6%E\377\22#K\377\22/J\377\10\27M\377" + "\4\30I\377\0\24G\377\0\37\77\377\0\25B\377\0\32P\377\0\17G\377\0\27N" + "\377\0!J\377\4\36W\377\0(J\377\0\35M\377\0\31M\377\0\27>\377\0\24D\377" + "\0\16U\377\0\24W\377\0""1P\377\0""9R\377\0P_\377\0fV\377\177\23\0\207" + "\377\0\0a\377\0\0C\377\0\0""9\377\205\0#\377j\0\2\377P\0\0\377G\0\0\377" + "M.\0\377K*\0\377Q>\0\377O6\0\377S<\0\377H:\0\377\\I\0\377X\77\0\377O" + "H\0\377JJ\0\377TR\0\377`[\0\377RR\0\377`W\0\377`Y\0\377Mi\0\377Yd\0\377" + "SR\0\377QD\0\377\\O\0\377GH\0\377JO\0\377FB\0\377G;\0\377>3\0\377C:\0" + "\3777A\0\3775=\0\377F>\0\377L7\0\377='\0\3779/\0\377F/\0\377H/\0\377" + "I4\0\377;-\0\377>+\0\377B.\0\377;.\0\377;0\0\3772!\0\3770\32\0\377'%" + "\0\377!2\0\377!\31\0\377&\37\0\377S=\0\377\313\240\241\377\77@\0\377" + "!%\0\377\"&\0\377K4\0\377\313\234\246\377DI\0\377!)\0\377\40&\0\377\33" + "\27\0\377\36\24\0\377Z6\14\377\340\222\264\377+&\0\377.\23\0\377!!\0" + "\377\36%\0\3778/\0\377\275\221\260\37720\14\377\6\36\0\377\0\37\0\377" + "\5\32\0\377\21\40\0\377\0\27\0\377]N-\377\245\224\246\377\1\21\0\377" + "\241\224\260\377P[<\377\1\23\0\377\205ss\377tyi\377\0\32\0\377\236\225" + "\261\377T^2\377\0\33\0\377us|\377hx~\377\0\25\0\377\31""0\27\377\226" + "\245\312\377\15,\32\3775[O\377\202\242\311\377\0\30\0\377\13B\25\377" + "\220\253\315\377\22H&\377\0(\0\377\0'\0\377\0\32\0\377\0&\0\377\12@+" + "\377z\222\334\377\0+.\377\0\23\4\377Kl\260\3775j\262\377\0\6\12\377\0" + "\5\14\377\16@\212\3779c\320\377\0\0\37\377;m\300\377\77f\272\377\0\21" + "\35\377\0\35\"\377\0\36\40\377\0\36\25\377\0!\40\377\0\31!\377\177\0" + "7e\377~\250\377\377\3Gl\377\0%,\377\0""0+\377\0'#\377\0\34/\377\0'\34" + "\377\0'+\377\0).\377\0\36""6\377\0\13'\377\200\226\377\377\0""0b\377" + "\0\7\35\377Xt\310\377]w\304\377\0\14$\377\0\7\34\377\0\10\27\377\0\0" + "\27\377\0\0/\377\0\10$\377\0\0\34\377\16,\\\377\226\235\361\377\16$I" + "\377\0\23\22\377\0\11\20\377\0\25\16\377\16""9E\377\220\213\352\377\21" + "-L\377\0\12\3\377\215\224\362\377@F\203\377\0\0\1\377AH\220\377\221\222" + "\375\377\0\5\27\377g\204\314\377l{\313\377\0\12\37\377/\\\224\377\217" + "\245\377\377\0'1\377\0""06\377\221\270\377\377:o\223\377\36U[\377\230" + "\257\375\377\33Be\377\0-.\377\243\277\377\377Hi\217\377\0(\40\377:^\236" + "\377\237\267\377\377\0""5!\377\0(\30\377\231\266\377\377FZ\231\377\0" + "\33,\377\0\17%\377rz\323\377A_\234\377+S[\377\260\260\374\377:yc\377" + "\35u0\377\27\1770\377\33m0\377\14W&\377\1P\20\377Lj\221\377\241\257\377" + "\377\0,\36\377\0*\"\377\0\33\37\377\0\34#\377\0-*\377\0#1\377\0""50\377" + "\0)4\377\0\77""0\377\0D:\377\0A;\377\0<>\377\0<=\377\0/8\377\0""46\377" + "\0&2\377\0\27""5\377\0\37""3\377\0#9\377\0)8\377\0-D\377\0<=\377\0""9" + "D\377\0""9H\377\0>Q\377\0-G\377\2+:\377\2\30@\377\0\36@\377\0\30""2\377" + "\0\32/\377\0\37D\377\0\37B\377\10%8\377\1#\77\377\11':\377\4.A\377\11" + "\36F\377\20(=\377\7\34D\377\21\35=\377\12\27""9\377\5\22@\377\6\17Q\377" + "\0\23W\377\0\15O\377\6\37C\377\5\36O\377\0\13C\377\0\27C\377\0\15B\377" + "r\0\26P\377\0\17V\377\0\31K\377\0\26H\377\0-F\377\0""7H\377\0""8\\\377" + "\0KT\377\26\10\201\377\0\0c\377\0\0I\377\0\0E\377\217\11'\377i\0\6\377" + "P\0\0\377L\0\0\377^\77\0\377[4\0\377KD\0\377]J\0\377PD\0\377IL\0\377" + "IB\0\377HK\0\377JH\0\377RJ\0\377PW\0\377VW\0\377eN\0\377ZT\0\377SR\0" + "\377Lo\0\377Rc\0\377P\\\0\377HZ\0\377SX\0\377U\\\0\377KQ\0\377L@\0\377" + "\77""9\0\377=6\0\377;,\0\377D8\0\377@D\0\377B6\0\3776!\0\377:*\0\377" + "88\0\377L/\0\3775+\0\3773%\0\3774-\0\377=2\0\377I=\0\377I>\0\377<7\0" + "\377B0\0\3779)\0\3773&\0\37776\0\377&%\0\377(\35\0\3775=\0\377\236}X" + "\377\330\254\255\377\24\"\0\377\33)\0\377JO\0\377\327\250\260\377MP\0" + "\377\30\27\0\377%\34\0\377\"\21\0\377\37\24\0\377bD\10\377\346\227\303" + "\377+\26\0\377\17!\0\377%\40\0\377\16*\0\377@=\2\377\315\242\266\377" + "1V\20\377\0'\0\377\0\36\0\377\1!\0\377\0\"\0\377\0\27\0\377Xj(\377\303" + "\246\250\377\0\36\0\377\260\256\234\377Xc@\377\1!\0\377\211\217m\377" + "\207{\177\377\0\32\0\377\250\263\300\377T_K\377\0\37\0\377~\200\206\377" + "\200\231\205\377\0\36\0\377(<\21\377\243\254\300\377\17""1\27\377G`O" + "\377\226\245\311\377\0!\0\377\20""6\"\377\231\256\317\377\24\77\27\377" + "\0""0\0\377\0\40\0\377\202\0&\0\377\177\13C%\377\216\226\337\377\14/" + "7\377\0\12\0\377Xl\255\377Lx\273\377\0\20\1\377\0\21\12\377\40W}\377" + "Jq\302\377\0\10\24\377Lo\310\377Hp\307\377\0\3\34\377\0\20\25\377\0\26" + "\31\377\0-\20\377\0(\"\377\0\34\32\377\16L\\\377\231\244\377\377\0Sh" + "\377\0-0\377\0""5-\377\0""03\377\0\34%\377\0\"\"\377\0*\31\377\0(#\377" + "\0%5\377\0$0\377\226\252\377\377\0""0T\377-U\214\377\213\244\377\377" + "\0(R\377\0\12\32\377\0\5\26\377\0\3\32\377\0\0\36\377\0\3\22\377\0\5" + "\24\377\0\2\32\377\33%Q\377\252\221\377\377\40/K\377\0\1\15\377\0\3\17" + "\377\0\0\4\377\31.E\377\237\231\346\377\15.G\377\0\27\2\377\251\224\356" + "\377K`\205\377\0\20\22\3778F\201\377\225\223\361\377\0\0\22\377yx\324" + "\377i|\302\377\0\12\26\377<_\201\377\234\266\375\377\0&$\377\0*/\377" + "\231\257\377\377Cz\233\377\35LT\377\241\270\377\377\33\77g\377\0\33\34" + "\377\234\277\377\377Nm\217\377\0\33,\377Ll\227\377\251\265\377\377\0" + "0(\377\0\26""0\377\244\272\377\377Mi\223\377\0\21""3\377\0\31(\377w\207" + "\317\377Qf\243\377&6Y\377\271\252\377\3776tV\377\25e/\377&a;\377\33h" + "+\377\16T(\377\16Q#\377b\206\230\377\251\277\377\377\0'6\377\0$3\377" + "\0#2\377\0)8\377\0.,\377\0-&\377\0D-\377\0""37\377\0;4\377\0M6\377\0" + "QE\377\0LA\377\0D>\377\0\77.\377\0-5\377\0\36""6\377\0#0\377\0\37=\377" + "\0*;\377\0/B\377\0\36""5\377\0/D\377\0""5=\377\0\377\3\36D\377\11\35;\377\177\15" + "\31B\377\0%3\377\1.D\377\15\35G\377\16'\77\377\12%>\377\24\36""7\377" + "\23!<\377\17\33""8\377\14\36C\377\16\26X\377\14\23e\377\12\25[\377\13" + "\23X\377\23\32[\377\3\22H\377\15\11H\377\7\16L\377\0\3Z\377\0\7a\377" + "\0\0[\377\0\17U\377\0\20Z\377\0\32V\377\0+Z\377\0.S\377\0:J\377\36\12" + "\203\377\0\0i\377\0\0Z\377\0\0W\377\220\2!\377u\0\0\377W\0\0\377Y\0\0" + "\377M2\0\377W=\0\377ZI\0\377iH\0\377LH\0\377GF\0\377JH\0\377M=\0\377" + "VC\0\377]=\0\377\\J\0\377\\F\0\377UC\0\377\\H\0\377RN\0\377AT\0\377@" + "b\0\377Ab\0\377PN\0\377NX\0\377HP\0\377\77R\0\377LN\0\377M9\0\377B0\0" + "\377=\77\0\377D7\0\377K;\0\377B4\0\377;5\0\377@/\0\377G4\0\377:1\0\377" + ":*\0\3778#\0\377-$\0\37732\0\377=A\0\3773>\0\377::\0\377\77""2\0\377" + "A3\0\37703\0\377.)\0\377+'\0\377\37""5\0\377/*\0\377H>\0\377\234\207" + "]\377\262\212\200\377\260\227\201\377\273\227\205\377\333\252\261\377" + "LC\0\377m\\\36\377\265\224\177\377\257\207\204\377\261~\223\377\277\217" + "\243\377yY\77\377\36\26\0\377\25!\0\377\30,\0\377\16$\0\377=Q\2\377\315" + "\267\277\377=]\22\377\12/\0\377\3;\0\377\0+\0\377\0\34\0\377\0#\0\377" + "e_<\377\272\261\244\377\0,\0\377Ug5\377\257\253\244\377\230\225v\377" + "\266\246\237\377\216\222|\377\0\37\0\377I]5\377\236\237\227\377\200\212" + "}\377\254\253\256\377\203\204\203\377\0\32\0\377\33H\16\377\255\266\310" + "\377\36;\33\377EfT\377\247\251\323\377\177\0\21\0\377\21\77\34\377\233" + "\252\307\377\10@#\377\0+\0\377\0\30\0\377\0-\0\377\0&\0\377\14""9'\377" + "\237\246\324\377\12""9,\377\0\5\0\377\0+&\377|\221\327\377e~\261\377" + "Py\272\377l\220\340\377\0\20D\377\0\0\23\377^r\301\377cx\275\377\0\14" + "\13\377\0\27\16\377\0\37\21\377\0(!\377\0\36\27\377\0\25\33\377\7Hc\377" + "\211\262\377\377\0G\\\377\0\37%\377\0\36'\377\0\26-\377\0#\40\377\0:" + "P\377W\216\345\377e\224\335\377g\215\321\377b\177\333\377T\203\314\377" + "\0\37""8\3775`\233\377\234\236\377\377fx\336\377jw\317\377ns\315\377" + "{\177\304\377\0\7\35\377\0\0\35\377\0\2\32\377\0\0\31\377*1T\377\261" + "\237\374\377\213y\313\377zz\274\377\210x\275\377B2i\377\35->\377\261" + "\246\375\377\36DO\377\0\21\13\377\274\242\374\377SS\200\377\0\20\22\377" + "@Q\210\377\251\252\356\377\0\0\0\377\10\30C\377\241\246\357\377\206\222" + "\277\377\232\241\352\377\243\310\377\377\0!\21\377\0\"\17\377\256\303" + "\377\377D\203\223\377\0""87\377p\201\300\377\205\245\346\377~\240\320" + "\377\272\300\377\377ai\231\377\0\12#\377\10\40C\377a|\276\377_\205\265" + "\377\0\"0\377Af\222\377\226\247\371\377|\215\352\377\211\207\343\377" + "\213\215\347\377\15""0A\3772De\377\307\302\377\3779_W\377\16N5\377\40" + "`;\377\25bH\377\253\250\340\377\223\247\316\377\256\271\371\377,Zs\377" + "\0""3-\377\0,-\377\7\"8\377\4\35""9\377\0/4\377\0""35\377\0""0B\377\0" + ";=\377\0""82\377\0<6\377\0F0\377\0AF\377\0""2\77\377\0D8\377\0""0B\377" + "\0$:\377\0\"@\377\1$I\377\0&;\377\0\23F\377\0\25""0\377\0\"8\377\0""0" + "I\377\0.R\377p\0AG\377\0,K\377\0:K\377\0""2O\377\0\35=\377\3\32;\377" + "\10\14E\377\0\25""6\377\2\35>\377\0\37J\377\17%C\377\23-;\377\17%H\377" + "\26(J\377\26.<\377\20'D\377\13-I\377\14\40P\377\3\40]\377\22\23S\377" + "\15\25X\377\5\27W\377\0\20`\377\6\24X\377\0\5S\377\0\6S\377\0\0U\377" + "\0\5W\377\1\0V\377\0\4X\377\0\22\\\377\0\17Y\377\0\25V\377\0\35Y\377" + "\0.]\377\"\0\200\377\5\0\\\377\0\0K\377\0\0`\377\223\16\30\377x\0\0\377" + "T\0\0\377C\0\0\377S1\0\377S5\0\377b7\0\377S;\0\377E4\0\377MD\0\377P@" + "\0\377J<\0\377I9\0\377VB\0\377\\9\0\377[5\0\377W.\0\377W2\0\377TA\0\377" + "YA\0\377WL\0\377LM\0\377OW\0\377TU\0\377PP\0\377KN\0\377PA\0\377T;\0" + "\377PC\0\377=\77\0\377@@\0\377D5\0\377<6\0\377;2\0\377A5\0\377E<\0\377" + "A&\0\377C6\0\3777@\0\377.D\0\377*5\0\3779+\0\3778*\0\377;3\0\3778,\0" + "\3776,\0\377&0\0\377-\33\0\377\")\0\377\"5\0\377\"7\0\377\32A\0\377W" + "K\10\377\216mF\377\200o\77\377\214q;\377\211r4\377\77C\0\377SW\1\377" + "\201pB\377\211w@\377\201oO\377\206\\C\3775=\0\377\24%\0\377\16\40\0\377" + "\10$\0\377\14&\0\377*\77\0\377svE\377*F\0\377\0""9\0\377\0D\0\377\202" + "\0""9\0\377\177\0+\0\377:U\0\377ioC\377\0,\0\377\24;\0\377iqS\377ksR" + "\377cnG\377Cg'\377\0%\0\377\14A\0\377Oz;\377[{O\377\232\242\262\377\214" + "\223\210\377\0\"\0\377\14""0\0\377K`T\377\0""4\0\377\34D\25\377>kX\377" + "\0\30\0\377\0-\5\377:aR\377\0""0\0\377\0\21\0\377\0\33\0\377\0\30\0\377" + "\0\33\0\377\0,\12\377Bbp\377\0\36\16\377\0\13\0\377\0\21\0\377\77`n\377" + "4Xm\3770Z{\3770St\377\0\7\1\377\0\20\0\377\7Ie\377\10Vk\377\0\37\21\377" + "\0\37\15\377\0*\30\377\0&\24\377\0%\34\377\0""1\36\377\0""3B\3777w\240" + "\377\0""0<\377\0\37/\377\0\35)\377\0!+\377\0#,\377\0""2D\377+n\242\377" + "4p\230\377+k\245\377/g\241\377\0""9`\377\0\4""4\377\24'g\377FW\236\377" + ";Y\234\377\77`\244\377AT\211\377JY\225\377\0\7\37\377\0\2\31\377\0\1" + "\17\377\0\3\14\377\7\27""4\377UQ~\377Z]\200\377\\[\215\377ce\224\377" + "->H\377\10&#\377Wf\211\377\6""0/\377\0\24\11\377_f\217\377*\77L\377\0" + "\23\15\377$9R\377WY\207\377\0\0\26\377\0\3\2\377bO\206\377\\S\207\377" + "R]\211\377W^\212\377\0\13\17\377\0\37\26\377Ym\210\377%TT\377\0\37\37" + "\377\34F\\\377St\251\377[h\234\377[s\244\3776Fd\377\1\7+\377\0\24/\377" + "/Cg\377ET\221\377\0\14""1\377\5+C\377dq\242\377aj\246\377ae\244\377K" + "O\212\377\0\33\34\377\27(=\377ul\224\377&DL\377\27C1\377\30[(\377\35" + "O:\377s\223\235\377m\211\250\377g\221\266\377\0""24\377\0'7\377\0\36" + "6\377\0-5\377:\0,1\377\0\27.\377\0)9\377\0\37<\377\0,A\377\0/D\377\0" + "<;\377\14""2I\377\0""7\77\377\0(H\377\0""3U\377\0\37D\377\0\32B\377\0" + "\40\77\377\4\31C\377\6\30""9\377\3\24C\377\2%4\377\3\37E\377\4\36N\377" + "\0'F\377\0""5E\377\0*J\377\0+R\377\17""3T\377\5&M\377\3\24F\377\7\30" + "L\377\10\"H\377\3\34T\377\2\37I\377\24-J\377\15""3B\377\24'V\377\13#" + "I\377\24*A\377\14%E\377\33(K\377\15\27N\377\13!O\377\4\23M\377\14\30" + "N\377\6\14D\377\5\26P\377\14\1M\377\1\11K\377\2\0O\377\0\0L\377\0\0Q" + "\377\7\6O\377\10\11S\377\0\7R\377\4\27S\377\0\35S\377\0\32T\377\0\26" + "T\377'\0\200\377\10\0}\377\202\0\0V\377\177\211\13\5\377n\0\0\377E\0" + "\0\377C\0\0\377M9\0\377X<\0\377U>\0\377H1\0\377A4\0\377HC\0\377O-\0\377" + "Y9\0\377L@\0\377TH\0\377SC\0\377Y7\0\377V1\0\377V0\0\377N3\0\377N6\0" + "\377Y8\0\377QI\0\377MM\0\377TK\0\377SR\0\377LS\0\377QL\0\377VB\0\377" + "EC\0\377JD\0\377F@\0\377G6\0\377>'\0\37769\0\3774>\0\377>D\0\3772:\0" + "\377:2\0\3774E\0\377(@\0\377/2\0\377(<\0\377+/\0\377-3\0\3776&\0\377" + "&)\0\377+\40\0\377+\"\0\377(\40\0\377\33*\0\377*#\0\377\31""3\0\377\32" + "*\0\377\34-\0\377\31""0\0\377\34%\0\377\36(\0\377\24""4\0\377\17""8\0" + "\377\31$\0\377\27.\0\377\24'\0\377\34$\0\377\2""6\0\377\3-\0\377\0,\0" + "\377\2%\0\377\5(\0\377\6-\0\377\23""4\0\377\16""9\0\377\0""5\0\377\0" + "D\0\377\0+\0\377\0-\0\377\0&\0\377\0""8\0\377\5""2\0\377\2.\0\377\5""1" + "\0\377\0""9\0\377\0""2\0\377\0'\0\377\0""7\0\377\0+\0\377\24Y\0\377\212" + "\262\205\377\211\243\222\377\276\273\277\377Eg\77\377\0,\0\377\0\37\0" + "\377\0\27\0\377\0\25\0\377\0\32\0\377\0\15\0\377\0\16\0\377\0\27\0\377" + "\0\30\0\377\0\35\0\377\0\30\0\377\0\32\0\377\0\33\0\377\0\31\0\377\0" + "%\0\377\0\33\0\377\0\14\0\377\0\21\0\377\0\26\0\377\0\7\0\377\0\0\0\377" + "\0\4\0\377\0\3\0\377\0\17\0\377\0\36\0\377\0\27\4\377\0\32\0\377\0\31" + "\26\377\0\27\36\377\0\24\34\377\0&\25\377\0\35\37\377\0\32\36\377\0\37" + "$\377\0\30.\377\0\37*\377\0$:\377\177\0*(\377\0\34""2\377\0\25""5\377" + "\0\40,\377\0\37""2\377\0\31.\377\0\23%\377\0\14\"\377\0\2%\377\0\3+\377" + "\0\3-\377\0\12*\377\0\17.\377\0\13\37\377\0\1)\377\0\0/\377\0\0%\377" + "\0\1\"\377\0\3\27\377\0\1\34\377\0\20\17\377\0\17\33\377\0\11!\377\0" + "\26\31\377\0\35%\377\0&\32\377\0\"\24\377\0\22\2\377\0\22\7\377\0\20" + "\16\377\0\16\17\377\2\17\14\377\0\13\31\377\2\11\20\377\0\12\22\377\0" + "\0\15\377\0\0\32\377\0\6\30\377\0\0\37\377\4\0\35\377\0\0\23\377\0\0" + "\30\377\1\21\13\377\0!\25\377\0$\35\377\0\20\35\377\4\33!\377\11\32)" + "\377\7\31""3\377\11\6.\377\20\6*\377\20\10""1\377\12\13""0\377\1\1,\377" + "\4\4""1\377\0\2$\377\15\27/\377\6\22""1\377\14\33-\377\11\26%\377\17" + "\16*\377\12\24(\377\27\22(\377\13\32\"\377\7()\377\10""51\377\22>3\377" + "\32E7\377\27F.\377\5F>\377\0""4<\377\6-:\377\12#/\377\3'7\377\0-8\377" + "\0\34;\377\0\21""0\377\5\22D\377\4\26\77\377\12\25""9\377\4\"C\377\20" + "$>\377\16!P\377\6\31@\377\4&J\377\1#@\377\0\31E\377\0\26""3\377\4\13" + ";\377\11\13;\377\14\12>\377\7\16<\377\20\30D\377\7%M\377\4#H\377\17\37" + "E\377\6%K\377\14$U\377\16'J\377\31""2J\377\25*C\377\22\34J\377\13\34" + "V\377\21\27T\377\20'X\377\34""0N\377\33&Q\377\35$S\377#\24T\377\31\31" + "[\377\27\36R\377\40\33T\377\15\33R\377\21\31K\377\10\15J\377\34\10A\377" + "\33\12I\377\25\12G\377\21\12N\377\11\15A\377\22\6C\377\26\5H\377\15\4" + "M\377\2\1T\377\17\16R\377\14\10^\377\15\10e\377w\10\36W\377\0\35\\\377" + "\0\34M\377\4\35X\377'\0\212\377\22\0i\377\0\0N\377\0\0S\377v\6\0\377" + "V\0\0\377<\0\0\377J\0\0\377J3\0\377X,\0\377L.\0\377D6\0\377L3\0\377O" + "8\0\377R7\0\377U8\0\377O:\0\377R>\0\377O9\0\377J4\0\377T)\0\377L<\0\377" + "P=\0\377@=\0\377A8\0\377PD\0\377WE\0\377PD\0\377UB\0\377GT\0\377NC\0" + "\377JM\0\377RC\0\377MN\0\377M.\0\377C.\0\3772.\0\3777*\0\37742\0\377" + "55\0\377+8\0\3770;\0\3779\77\0\377'/\0\377*+\0\377&-\0\377*\37\0\377" + "',\0\377\40)\0\377!&\0\377\")\0\377\31-\0\377\23\33\0\377\21\36\0\377" + "\13\32\0\377\26\36\0\377\0,\0\377\10%\0\377\16+\0\377\13%\0\377\22""2" + "\0\377\34""6\0\377\17$\0\377\22-\0\377\20(\0\377\5-\0\377\2""6\0\377" + "\5,\0\377\0""4\0\377\6""6\0\377\0-\0\377\2/\0\377\5-\0\377\0(\0\377\0" + "0\0\377\3""9\0\377\0""8\0\377\3/\0\377\0""5\0\377\0;\0\377\0<\0\377\2" + "3\0\377\0""7\0\377\0""1\0\377\0:\0\377\0@\0\377\0<\0\377\0=\0\377\0""8" + "\0\377\37V\14\377\226\243\223\377\230\245\232\377\243\244\242\377\0""4" + "\0\377\0.\0\377\0(\0\377\0*\0\377\0\26\0\377\0\32\0\377\0\36\0\377\0" + "\23\0\377\0\20\0\377\0\25\0\377\0\26\0\377\0\35\0\377\0\26\0\377\0\36" + "\0\377\0\20\0\377\0\34\0\377\0\13\0\377\0\0\0\377\0\11\0\377\0\0\0\377" + "\0\10\0\377\0\25\0\377\202\0\0\0\377\177\0\15\0\377\0\16\0\377\0\17\0" + "\377\0\13\35\377\0!\24\377\0\"\21\377\0\13\15\377\0\10\11\377\0\25\25" + "\377\0\21\35\377\0\14#\377\0\22%\377\0\22(\377\0\31.\377\0\20/\377\0" + "!1\377\0\36""6\377\0\26;\377\0\22=\377\0\36""5\377\0\16,\377\0\25,\377" + "\0\26:\377\0\16=\377\0\31""9\377\0\27.\377\0\10(\377\0\3%\377\0\11)\377" + "\0\0)\377\0\3.\377\0\10\"\377\0\13&\377\0\11\26\377\0\4\31\377\0\3\13" + "\377\0\1\7\377\0\31\12\377\0\12\24\377\0\24\17\377\0\11\6\377\4\17\13" + "\377\5\13\24\377\13\10\16\377\12\5\10\377\0\0\6\377\4\0\16\377\12\0\14" + "\377\13\0\31\377\13\0\37\377\6\0\34\377\12\0\26\377\16\0\24\377\11\0" + "\35\377\20\0\27\377\13\0\21\377\11\17\21\377\5\4\35\377\4\14\25\377\22" + "\26,\377\25\14,\377\17\1-\377\15\15""6\377\13\1""5\377\31\0.\377\31\0" + "1\377\23\0$\377\22\0&\377\20\0)\377\26\13\33\377\6\5""1\377\27\22*\377" + "\31\12-\377\23\21)\377\20\36""0\377\30\25)\377\30\22,\377\23\21)\377" + "\37\25""2\377\34!D\377.)9\377%/@\377\36(H\377\24""3\77\377!.;\377\17" + "!D\377\17#6\377\17\35""1\377\17\21""8\377\22\14""6\377\5\17""6\377\5" + "\7:\377\1\10<\377\10\2:\377\23\4""7\377\11\15G\377\20\14<\377\23\15J" + "\377\26\25@\377\4\24;\377\13\7""5\377\22\5""9\377\11\0B\377\2\1\77\377" + "\2\10>\377\15\21P\377\11\15P\377\17!V\377\26\33P\377\27\40R\377\37\16" + "H\377\35\40O\377\26#Q\377\35\40b\377\34\32W\377\21\22\\\377\37\27V\377" + "\25\40[\377\30!Z\377\34\26^\377(\36Y\377\27\17U\377\30\15J\377\32\11" + "T\377\33\14S\377!\25X\377\"\14P\377{!\12P\377\27\13B\377\32\12@\377\40" + "\3F\377\11\12K\377\5\7M\377\25\15S\377\37\12O\377\16\11S\377\23\0N\377" + "\17\0b\377\32\3a\377\32\0`\377\36\12Q\377\34\21Y\377\24\22I\377\3\25" + "G\377\0'[\3772\6\203\377\22\0c\377\0\0C\377\0\0U\377~\15\0\377m\0\0\377" + "D\0\0\377\77\0\0\377>%\0\377O#\0\377\77!\0\377R#\0\377P.\0\377J6\0\377" + "N7\0\377\77""6\0\377C2\0\377C-\0\377U@\0\377T<\0\377;>\0\377CG\0\377" + "C>\0\377E.\0\377N;\0\377L3\0\377X8\0\377Q7\0\377H6\0\377-\0\377@A\0\377<=\0\37782\0\3779D\0\377\77;\0\377\77" + "7\0\377E:\0\377C3\0\3778+\0\377L(\0\377J.\0\377\77""7\0\3770>\0\377:" + "H\0\377@H\0\377:E\0\3779H\0\3779I\0\377'1\0\377-0\0\377)+\0\377,%\0\377" + "',\0\377*(\0\377((\0\377()\0\377'\"\0\377\23\37\0\377\17(\0\377\35,\0" + "\377\12*\0\377\30\35\0\377\5\32\0\377\3\36\0\377\20\25\0\377\0+\0\377" + "\12'\0\377\2!\0\377\0/\0\377\22\40\0\377\0&\0\377\0%\0\377\0'\0\377\0" + ")\0\377\0*\0\377\0+\0\377\0'\0\377\0+\0\377\0,\0\377\0""0\0\377\0""3" + "\0\377\0""4\0\377\0(\0\377\0+\0\377\0""4\0\377\0,\0\377\0%\0\377\0$\0" + "\377\0""3\0\377\1)\0\377\0(\0\377\0'\0\377\0.\0\377\0$\0\377\0\36\0\377" + "\0)\0\377\0""3\0\377\0.\0\377\0""9\0\377\0E\0\377\0A\0\377\202\0=\0\377" + "\13\0""6\0\377\0I\0\377\0M\0\377\0H\0\377\0""7\0\377\0""8\0\377\0(\0" + "\377\0*\0\377\0%\0\377\0(\0\377\0&\0\377\202\0\33\0\377\177\0\31\0\377" + "\0\22\0\377\0\23\0\377\0\14\0\377\0\25\0\377\0\15\0\377\0\27\0\377\0" + "\7\0\377\0\7\6\377\0\3\4\377\0\14\0\377\0\0\6\377\0\1\2\377\0\5\0\377" + "\0\1\7\377\0\0\6\377\0\1\20\377\0\2\13\377\0\0\13\377\0\16\20\377\0\14" + "\15\377\0\0\30\377\0\3\25\377\0\5\36\377\0\21!\377\0\16\37\377\0\26#" + "\377\0\24%\377\0\35""0\377\0\31.\377\0!.\377\0!'\377\0\22*\377\0\35\"" + "\377\0\26\30\377\0\35\31\377\0!%\377\0\16\"\377\0\30""9\377\0\24""1\377" + "\0\17(\377\0\0\"\377\0\5""3\377\0\4(\377\0\0,\377\0\6,\377\0\6\"\377" + "\0\21!\377\0\0!\377\0\0\33\377\0\7\31\377\4\10\30\377\10\20\32\377\14" + "\7\31\377\20\0\25\377\14\6\25\377\11\0\15\377\27\0\27\377\11\0\11\377" + "\30\0#\377\26\0\32\377\30\0\37\377#\0\25\377+\0!\377*\0\32\377+\0!\377" + "\37\0\37\377\34\0$\377\35\0\32\377\37\0\20\377+\0\20\377.\0\20\377\35" + "\0\26\377\40\0\34\377\"\0,\377'\0\33\377\35\0)\377\32\0+\377/\0/\377" + "+\0""7\377\"\0/\377*\0'\377\30\0'\377&\0$\377\23\0)\377\25\0#\377(\0" + ",\377-\0;\377*\0+\377\35\0@\377'\0""4\377\"\0*\377/\0.\377/\14<\377*" + "\16""6\377:\25\77\377)\36G\377-\40\77\377#&<\377\40\15E\3772\14B\377" + "\37\5\77\377\33\0D\377\26\0""1\377\30\0""7\377\33\0\77\377\26\0A\377" + "\21\0""8\377%\0;\377\"\0""0\377\23\2=\377\23\7\77\377\24\2@\377\32\0" + "7\377\26\0\77\377\21\0B\377\35\0=\377\32\0\77\377&\0\77\377!\0Z\377\30" + "\0Z\377\"\0V\377\26\0R\377\27\0T\377#\3I\377\20\3K\377\32\6Y\377\177" + "\26\1[\377\33\0\\\377\36\7\\\377*\0`\377$\0`\377'\0T\377!\7]\3776\0J" + "\377*\14N\3773\21]\377%\5i\377-\0Q\377'\13A\377!\0O\377*\0Q\377%\0Q\377" + "'\2U\377!\0N\377\30\0W\377\24\0X\377\34\0U\377\27\13\\\377\34\11e\377" + "\27\1^\377\31\0d\377\27\0Y\377#\0\\\377\33\0`\377$\4b\377\"\2X\377\"" + "\0Y\377\26\11W\377\30\3P\377e\26\233\377A\0\205\377\14\0Y\377\14\0R\377" + "\213$\0\377\177$\0\377[\0\0\377:\0\0\377/+\0\37735\0\377:)\0\3778(\0" + "\3773'\0\377:0\0\37771\0\377@(\0\377\77""8\0\3771<\0\37788\0\37797\0" + "\377,<\0\37705\0\37768\0\37790\0\37782\0\377=&\0\37727\0\377:/\0\377" + ".7\0\3774D\0\3770<\0\3774G\0\3776A\0\377*E\0\377'=\0\377\40""3\0\377" + "\30,\0\377\31""7\0\377*1\0\377/'\0\377#%\0\377\14&\0\377\24+\0\377\15" + "$\0\377\21&\0\377\15$\0\377\22%\0\377\20(\0\377\22.\0\377\15#\0\377\0" + "2\0\377\0)\0\377\0""5\0\377\0)\0\377\0\35\0\377\0'\0\377\0\40\0\377\0" + "\"\0\377\0\40\0\377\0&\0\377\0$\0\377\0#\0\377\0.\0\377\0""6\0\377\0" + "#\0\377\0""2\0\377\0!\0\377\0'\0\377\0\30\0\377\0\40\0\377\0\34\0\377" + "\0\37\0\377\0'\0\377\0(\0\377\0&\0\377\0'\0\377\0&\0\377\0#\0\377\0\40" + "\0\377\0'\0\377\0#\0\377\0\40\0\377\0#\0\377\0""1\0\377\0<\0\377\0:\0" + "\377\0;\0\377\0)\0\377\0:\0\377\0""7\0\377\0\77\0\377\0A\0\377\0I\0\377" + "\0;\0\377\16\0""4\0\377\0(\0\377\0\32\0\377\0\40\0\377\0!\0\377\0\17" + "\0\377\0\14\0\377\0\12\0\377\0\26\0\377\0\6\0\377\0\15\0\377\0\23\0\377" + "\0\7\0\377\0\0\0\377\202\0\7\0\377&\0\20\0\377\0\12\6\377\0\14\32\377" + "\0\2\4\377\0\0\2\377\0\0\3\377\0\3\7\377\0\0\6\377\0\7\2\377\0\22\23" + "\377\0\25\15\377\0\7\30\377\0\0\26\377\0\0\23\377\0\0\34\377\0\12\"\377" + "\0\26,\377\0\13*\377\0\20""0\377\0\27\"\377\0\15,\377\0\14%\377\0\27" + "\36\377\0\30#\377\0!\33\377\0\37\40\377\0\34&\377\0#\40\377\0\40""2\377" + "\0\22)\377\0\7""3\377\0\15-\377\0\4\"\377\0\3+\377\0\10&\377\0\3!\377" + "\0\3(\377\0\0#\377\202\0\0&\377\177\6\0\21\377\3\0\13\377\0\0\34\377" + "\0\0\32\377\0\0\36\377\7\7\7\377\6\12\30\377\10\21\34\377\12\0\32\377" + "\23\1\35\377\36\0\27\377\36\0\34\377\24\0\27\377\34\0\36\377\36\0\24" + "\377*\0\35\377\36\0!\377\36\0'\377\40\0\37\3771\0)\377.\0\34\377$\0*" + "\377,\0\"\3775\0)\377,\0,\3770\0.\377:\0:\377.\0,\3774\0""2\377%\0$\377" + "'\0+\377.\0""5\377\35\0*\377\37\0+\377\32\0/\377\"\0""6\3770\0""6\377" + "4\0""7\377,\0:\377-\0""7\377,\0""8\3777\0""4\3773\0""8\3772\0-\377.\0" + "1\3774\0""8\3775\0""3\377.\0;\377.\1""6\377)\12""7\377&\22""2\377$\7" + "D\3770\0>\377&\0F\377!\0@\377\40\0>\377$\0B\377\36\0\77\377\32\0D\377" + "\27\0""2\377*\0F\377\"\0E\377\35\0A\377#\0""7\377\30\0<\377\23\0""3\377" + "\13\0>\377\22\0""0\377\37\0""9\377#\0J\377\"\0J\377!\0L\377\40\0S\377" + "/\0_\377+\0\\\3773\0H\377\36\0K\377)\0W\377#\0[\377#\0X\377\27\0`\377" + "\35\0g\3771\0_\377/\0U\3774\0\\\3772\0U\377<\0b\377;\0V\377(\7`\377/" + "\2_\377/\0S\377.\0M\377\36\0Y\377'\0T\377%\0P\377\40\0Z\377\33\0Y\377" + "\25\0S\377\21\0^\377\31\0X\377,\0e\377&\1d\377\"\0^\377+\0V\377)\1f\377" + "\"\3j\377)\4i\3770\10p\3774\13h\377)\0^\377/\0b\377#\0g\377\207\22\275" + "\377N\0~\377\30\0V\377\25\0^\377\205'\0\377v!\0\377]\16\0\3774\0\0\377" + ">3\0\377\0\377\";\0\377\26""4\0\377\34""5\0\377\34'\0\377,$\0\377(-\0\377\10" + ")\0\377\14(\0\377\24\"\0\377\33%\0\377\20""1\0\377\13(\0\377\5*\0\377" + "\34,\0\377\10%\0\377\10(\0\377\0,\0\377\0;\0\377\0""0\0\377\0""4\0\377" + "\0.\0\377\0-\0\377\0\36\0\377\0\35\0\377\0(\0\377\0%\0\377\0*\0\377\0" + "'\0\377\0,\0\377\202\0*\0\377(\0\37\0\377\0$\0\377\0%\0\377\0\23\0\377" + "\0\34\0\377\0\40\0\377\0-\0\377\0'\0\377\0$\0\377\0\37\0\377\0+\0\377" + "\0!\0\377\0#\0\377\0&\0\377\0\36\0\377\0\32\0\377\0\37\0\377\0\40\0\377" + "\0=\0\377\0B\0\377\0*\0\377\0)\0\377\0\"\0\377\0!\0\377\0""0\0\377\0" + ",\0\377\0.\0\377\0""3\0\377\0""2\0\377\0;\0\377\0\"\0\377\0\40\0\377" + "\0#\1\377\0\25\0\377\0\21\2\377\0\26\3\377\0\17\0\377\0\14\7\377\0\12" + "\0\377\0\16\0\377\202\0\0\0\377\1\0\10\0\377\203\0\0\0\377\177\0\0\7" + "\377\0\0\22\377\0\0\14\377\0\0\16\377\0\10\17\377\0\4\10\377\0\0\2\377" + "\0\10\7\377\0\3\6\377\0\15\23\377\0\3\23\377\0\23\10\377\0\14'\377\0" + "\31$\377\0\10&\377\0\31.\377\0\25)\377\0\36(\377\0\27&\377\0\32(\377" + "\0\23'\377\0\23+\377\0\24""0\377\0\31""5\377\0\21(\377\0\17(\377\0\32" + "'\377\0\22$\377\0\0*\377\0\0\"\377\0\1+\377\0\0""0\377\0\1%\377\0\4\27" + "\377\0\0!\377\0\0(\377\0\1(\377\0\0#\377\0\0\37\377\0\0\13\377\0\0\34" + "\377\0\0\13\377\0\0\20\377\7\0\27\377\2\0\31\377\15\0\32\377\24\0\23" + "\377\20\1(\377\16\0\30\377\13\0\27\377\11\0\"\377\11\0\37\377\22\0\34" + "\377\37\0\37\377\21\0$\377-\0\34\377!\0\40\377$\0(\3770\0/\377%\0/\377" + "8\0""2\377.\0""0\377+\0""5\3778\0""2\3774\0F\377B\0=\3779\0""6\377\"" + "\0""5\377\"\0(\377\36\0*\377\36\0""4\377&\0\34\377$\0%\377%\0:\3779\0" + "8\377,\0""8\377=\0""9\377;\0.\3779\0:\377-\0""3\377.\0""5\377;\0A\377" + "<\0""8\377\77\0A\3776\0=\377=\0<\377D\0>\377:\0;\3777\4:\3775\6:\377" + "0\0C\3773\0C\377%\0F\3772\0<\377'\0A\377/\0K\377\33\0F\377(\0C\377!\0" + ";\377#\0;\377(\0B\377.\0""1\377\32\0A\377\40\0""6\377\31\0=\377\23\0" + ":\3771\0C\377-\0K\377.\0V\377(\0J\3773\0J\377\77\0O\377:\0R\3777\0X\377" + "6\0M\3775\0N\377;\0P\377*\0`\377(\0[\377/\0[\377/\0X\3777\0e\3772\0\\" + "\3775\0L\3773\0N\3770\0W\377.\0Z\377^%\0_\377)\0\\\377'\0U\377\36\0X" + "\377\40\0]\377\"\0^\377\33\0[\377\34\0^\377\40\0g\377\40\0d\377)\0Z\377" + "$\0X\377;\0\\\3774\0]\377.\0X\3772\0e\3772\0^\377#\20e\377/\11_\3776" + "\2h\3777\1z\3771\0w\377<\0r\3774\0l\377\235\15\324\377a\0\221\3775\0" + "k\377.\0h\377n*\0\377r)\0\377c!\0\377T\11\0\3772E\0\377\0\377" + "==\0\37726\0\3776-\0\377D&\0\377A'\0\37705\0\3774#\0\3774-\0\377$1\0" + "\377.*\0\377,'\0\3775*\0\377*:\0\377+D\0\377*9\0\377.;\0\377+:\0\377" + ",0\0\377&3\0\377&/\0\377\37\"\0\377&&\0\377!:\0\377!\40\0\377\26(\0\377" + "\35%\0\377\34\40\0\377\24(\0\377\21""2\0\377'!\0\377$+\0\377\34""4\0" + "\377&3\0\377\14.\0\377\10""6\0\377\12\36\0\377\26\37\0\377\0%\0\377\0" + "'\0\377\4""7\0\377\7""9\0\377\0""2\0\377\0.\0\377\0""8\0\377\0(\0\377" + "\0""7\0\377\0""0\0\377\0\30\0\377\0\33\0\377\0*\0\377\0)\0\377\0\36\0" + "\377\0$\0\377\0\34\0\377\0)\0\377\0&\0\377\0\40\0\377\0\37\0\377\0&\0" + "\377\202\0$\0\377\6\0\23\0\377\0%\0\377\0\34\0\377\0!\0\377\0\35\0\377" + "\0#\0\377\202\0\37\0\377\177\0%\0\377\0&\0\377\0%\0\377\0.\0\377\0&\0" + "\377\0\40\0\377\0)\0\377\0\"\0\377\0/\0\377\0'\0\377\0-\0\377\0""2\0" + "\377\0(\0\377\0)\0\377\0*\0\377\0,\0\377\0+\0\377\0\32\5\377\0\32\0\377" + "\0\34\0\377\0\25\0\377\0\20\2\377\0\20\5\377\0\30\0\377\0\17\0\377\0" + "\21\0\377\0\13\0\377\0\11\0\377\0\24\0\377\0\3\0\377\0\0\0\377\0\0\5" + "\377\0\11\0\377\0\0\24\377\0\5\0\377\0\10\5\377\0\16\16\377\0\12\5\377" + "\0\14\10\377\0\24\15\377\0\21\24\377\0\6\33\377\0\33\31\377\0\34)\377" + "\0\25""0\377\0\30)\377\0\37-\377\0\40&\377\0&\32\377\0\31.\377\0\24&" + "\377\0\31+\377\0\21$\377\0\14*\377\0\23\34\377\0\20'\377\0\13%\377\0" + "\22$\377\0\11\37\377\0\4!\377\0\6$\377\0\0""0\377\0\0!\377\0\0&\377\0" + "\5\27\377\0\11\23\377\0\0!\377\0\0\40\377\4\0\20\377\0\0\20\377\0\0\22" + "\377\10\0\12\377\0\0\7\377\4\0\25\377\21\0\40\377\3\0\35\377\23\0\"\377" + "\23\0'\377\14\0#\377\20\0#\377\11\0\35\377\23\0\14\377\2\0\27\377\7\0" + "&\377\16\0/\377\"\0\"\377(\0""4\377\31\0""7\377\20\0""7\377!\0F\377&" + "\0,\377+\0""0\377'\0""9\377-\0@\377+\0.\377*\0""3\377=\0:\377;\0\77\377" + "5\0""1\377-\0(\377\35\0""8\377!\0""5\377\35\0""4\377\"\0""9\3771\0""7" + "\3774\0""1\377<\0""2\377\77\0=\3777\0""7\377C\0\77\377C\0G\377@\0J\377" + "I\0E\377<\0C\377>\0""6\3770\0:\3774\0F\3779\0E\377D\0D\377C\0G\377J\0" + "B\3779\0F\3775\0G\3771\0F\377$\0B\377'\0N\377*\0I\377\177$\0J\377&\0" + "X\377'\0F\377(\0;\377)\0A\377\25\0=\377%\0""5\377\40\0A\377,\0J\3775" + "\0""7\3775\0G\3770\0G\377%\0H\3777\0P\377<\0A\377B\0R\377M\0U\377;\0" + "W\377A\0^\3777\0`\377<\0e\3771\0c\377/\0`\3770\0`\3771\0\\\3775\0V\377" + "5\0_\377,\0W\377.\0M\3772\0b\377!\0o\377'\0b\377&\0`\377\40\0\\\377\37" + "\0d\377(\0T\377+\0S\377\"\0a\377\36\0i\377'\0[\377-\0Z\377+\0U\377'\0" + "`\377-\0f\377.\0a\3770\0`\3770\0_\3777\5g\3778\5a\377@\0s\377B\0v\377" + "D\0\177\377E\0{\377:\0u\377G\0u\377\232\4\316\377e\0\205\377\77\0l\377" + "2\0`\377J\0\0\377L\12\0\377H\0\0\377=\0\0\377\77\0\0\377Z\16\0\377\177" + "/\0\377\217G\0\377\246R\0\377\256T\0\377\236L\15\377\240W\5\377\260Q" + "\0\377\260H\21\377\257B\10\377\255D\5\377\234C\5\377\252;\13\377\226" + "E\2\377\234H\7\377\221G\0\377\241F\4\377\231R\0\377\242P\13\377\213I" + "\3\377\220E\13\377\221:\17\377\206\77\11\377\203F\0\377\220;\12\377\210" + "<\0\377\205E\0\377\210<\0\377\211F\0\377\200>\11\377\227<\11\377\213" + "8\15\377\223;\25\377\211K\16\377~J\17\377\177A\23\377vF\22\377\201B\26" + "\377\200I\40\377mG+\377kK%\377jF9\377mM,\377bT,\377hI/\377R;0\377YD3" + "\377ZH\40\377LF,\377H5(\377:C1\377W=6\377SE4\377YG6\377VA7\377E>6\377" + "C8C\377R4=\377I1<\377L):\377S,:\377A(3\377H(6\377\177H7:\377K&3\377X" + "'9\377Q1D\377S6\77\377N08\377[7\77\377V,5\377gA>\377m1L\377kAF\377oB" + "G\377o;I\377[MK\377bIR\377Z\77F\377d7G\377Z:C\377Q8H\377\\0`\377Z7`\377" + "R9i\377U2h\377S@a\377_;`\377a4h\377M7{\377H1z\377J7z\377S4m\377F1g\377" + "M;d\377X\77k\377S8s\377F@v\377>:d\377G5_\3774.c\377:+w\37708\206\377" + "1/\207\37761\203\377,A\204\3774Bu\377\77\77t\3776>\202\377CI\203\377" + "JE\210\377BA\213\3773P\210\377\231" + "\377PK\225\377NC\217\377HF\231\377L9\243\377@:\223\377B@\220\377;\77" + "\220\377>C\227\377@=\220\377A<\220\377MC\223\377M6\222\377E5\232\377" + "I2\230\377M#\232\377T/\207\377Z-\227\377a#\226\377Z*\225\377^%\225\377" + "b+\224\377j7\224\377v*\224\377o-\223\377m)\212\377q)\212\377u*\177\377" + "y\34\213\377\204\"\226\377v\40\213\377\206)\225\377\221&\214\377}\15" + "\232\377\215\14\224\377\215\11\214\377\214\23\221\377\216\17\217\377" + "\233\17\227\377\231\20\235\377\235\27\244\377\224\17\247\377\234\16\260" + "\377\234\22\265\377\227\25\271\377\246\17\270\377\244\12\266\377\251" + "\15\266\377\253\27\253\377\243\24\252\377\227\6\262\377\220\30\251\377" + "\240\33\253\377\234\23\252\377\230\21\246\377\235\36\244\377\232\23\250" + "\377\227\12\251\377\240\31\255\377\243\25\257\377\244$\260\377\243\22" + "\261\377\252\33\250\377\262\31\253\377\255\13\252\377\254\21\273\377" + "\252\23\271\377\247\25\271\377\253\40\260\377\237!\304\377\250\27\271" + "\377\241\"\264\377\254\30\260\377\262\36\254\377~\263\10\261\377\251" + "\22\255\377\241\27\262\377\246\40\255\377\250\27\253\377\252\31\277\377" + "\246\23\264\377\241\26\275\377\251\16\273\377\247\10\305\377\232\0\272" + "\377\237\0\265\377\232\0\245\377\242\0\263\377\232\4\266\377\226\0\257" + "\377\245\0\254\377\254\0\250\377\235\1\264\377\235\0\276\377\253\0\276" + "\377\255\0\275\377\272\0\303\377\272\3\307\377\253\0\302\377\255\3\322" + "\377\256\0\332\377\256\0\337\377\263\0\331\377\256\0\334\377\241\0\310" + "\377\233\0\322\377\250\0\324\377\240\12\334\377\237\14\333\377\243\0" + "\334\377\235\10\332\377\241\0\327\377\225\0\336\377\221\0\315\377\224" + "\0\311\377\221\1\312\377\230\1\313\377\234\22\322\377\234\17\320\377" + "\217\0\334\377\214\14\337\377\232\34\325\377\220\26\332\377\252\26\333" + "\377\266\34\323\377\263\37\326\377\252\30\325\377\245\21\330\377\252" + "\13\321\377\241\34\330\377\264\"\336\377\263\27\347\377\265\27\362\377" + "\265\26\365\377\307\22\362\377\274\21\347\377\261\0\313\377m\0\221\377" + "Z\0o\377G\0q\377F\0d\377B\0\0\377>\0\0\377<\0\0\377=\0\0\3773\0\0\377" + ">\0\0\377M\0\0\377Y\0\0\377e\16\0\377s\7\0\377b\17\0\377c\22\0\377g\21" + "\0\377j\15\0\377h\12\0\377d\3\0\377g\12\0\377a\0\0\377[\3\0\377Z\7\0" + "\377R\3\0\377P\0\0\377R\6\0\377U\0\0\377S\2\0\377S\0\0\377J\0\0\377N" + "\0\0\377M\4\0\377J\0\0\377H\0\0\377Q\0\0\377L\0\0\377@\0\0\377E\0\0\377" + "D\0\0\377;\0\0\377\77\0\0\377D\0\0\377>\2\0\3775\17\0\377:\0\0\377<\0" + "\0\377<\4\0\3773\13\0\377+\4\0\377*\14\0\377\35\11\0\377#\6\0\377$\6" + "\0\377\36\0\0\377\21\0\0\377\24\0\0\377\7\0\0\377\11\0\0\377\12\0\0\377" + "\21\0\0\377\0\0\0\377\2\0\0\377\202\14\0\0\377\3\16\0\0\377\6\0\0\377" + "\26\0\0\377\202\17\0\0\377\202\22\0\0\377\177\21\0\0\377\15\0\1\377\20" + "\0\0\377\20\0\6\377\37\0\0\377\31\0\0\377\25\0\0\377\27\0\1\377$\0\1" + "\377\31\0\13\377\35\0\15\377\34\0\16\377*\0\0\377&\13\0\377&\0\1\377" + "\40\0\12\377\37\0\17\377\20\0\31\377\27\0\25\377\37\0\11\377\33\0!\377" + "\23\0$\377\17\0)\377\11\3""2\377\27\0""4\377\15\0.\377\7\0:\377\5\0""7" + "\377\13\0""8\377\14\0""8\377\15\0)\377\30\0""5\377\23\0""6\377\4\0-\377" + "\0\0""5\377\0\0""0\377\3\1!\377\0\4.\377\0\0,\377\0\0""3\377\0\0""7\377" + "\0\0""8\377\0\0:\377\0\5/\377\0\0@\377\0\13""4\377\2\3>\377\6\7""0\377" + "\4\6""4\377\0\1>\377\0\0F\377\13\4U\377\6\17U\377\0\22R\377\0\24R\377" + "\0\0O\377\0\0X\377\0\1g\377\5\0Z\377\0\0P\377\2\4^\377\11\0R\377\4\0" + "P\377\3\1R\377\2\0Q\377\23\0K\377\6\0F\377\21\0M\377\23\0S\377\32\0X" + "\377\34\0P\377\34\0N\377\37\0H\377\37\0E\377\33\0N\377$\0Y\377/\0S\377" + "&\0L\377%\0I\377$\0@\3776\0J\377:\0N\3778\0P\377Q\0M\377J\0K\377M\0R" + "\377Q\0Y\377Y\0S\377W\0R\377`\0C\377X\0O\377K\0S\377[\0`\377[\0g\377" + "T\0m\377Z\0q\377V\0r\377S\0n\377V\0j\377`\0j\377g\0g\377d\0r\377P\0l" + "\377U\0d\377_\0d\377_\0_\377U\0^\377S\0c\377`\0c\377_\0o\377_\0h\377" + "c\0i\377T\0`\377S\0k\377_\0j\377c\0l\377_\0f\377\\\0l\377f\0r\377`\0" + "n\377g\0f\377\\\0h\377b\0n\377k\0p\377Z\0k\377l\0j\377q\0n\377ds\0l\377" + "i\0o\377n\0t\377c\0x\377i\0k\377m\0l\377`\0\206\377_\0~\377b\0s\377`" + "\0j\377k\0u\377l\0s\377`\0u\377e\0v\377W\0x\377T\0p\377X\0u\377b\0g\377" + "g\0o\377`\0o\377g\0s\377n\0o\377h\0w\377t\0\207\377h\0\213\377h\0\211" + "\377p\0\232\377u\0\240\377n\0\233\377d\0\226\377b\0\237\377e\0\243\377" + "c\0\224\377a\0\220\377]\0\226\377J\0\221\377T\0\225\377X\0\223\377^\0" + "\221\377J\0\212\377R\0\214\377X\0\211\377\\\0\231\377`\0\230\377Z\0\241" + "\377[\0\226\377Q\0\233\377W\0\226\377U\0\231\377l\0\213\377n\0\212\377" + "i\0\220\377r\0\227\377h\0\227\377o\0\225\377x\0\242\377v\0\255\377u\0" + "\255\377|\0\250\377y\0\245\377|\0\223\377|\0\204\377[\0e\377P\0g\377" + "]\0s\377N\0r\377N\0h\3778\0\0\3775\0\0\377=\0\0\377>\0\0\3778\0\0\377" + "C\0\0\377;\0\0\377B\0\0\3770\0\0\3779\0\0\3773\0\0\3770\0\0\377;\0\0" + "\377G\0\0\377B\0\0\377\77\0\0\3774\0\0\3776\0\0\377\"\0\0\377'\0\0\377" + "\32\0\0\377\25\0\0\377\16\0\0\377\37\0\0\377#\0\0\377\26\0\0\377\31\0" + "\0\377\34\0\0\377\32\0\0\377\31\0\0\377\14\0\0\377\31\0\0\377\14\0\0" + "\377\203\15\0\0\377\10\10\0\0\377\5\0\0\377\20\0\0\377\21\0\0\377\10" + "\0\0\377\24\0\0\377\14\0\0\377\4\0\0\377\260\0\0\0\377\5\0\0\5\377\0" + "\0\0\377\0\0\11\377\0\0\0\377\0\0\7\377\202\0\0\6\377\211\0\0\0\377\36" + "\0\0\16\377\0\0\21\377\0\0\13\377\0\0\5\377\0\0\15\377\0\0\10\377\0\0" + "\12\377\0\0\2\377\0\0\6\377\0\0\15\377\0\0\11\377\0\0\27\377\0\0\35\377" + "\0\0\37\377\0\0\17\377\0\0\"\377\0\0+\377\0\0\37\377\0\0&\377\0\0$\377" + "\0\0\"\377\0\0\32\377\0\0\31\377\0\0\17\377\0\0\35\377\0\0\17\377\0\0" + "\24\377\0\0\27\377\0\0\20\377\0\0\37\377\202\0\0\20\377{\0\0\22\377\0" + "\0!\377\0\0\27\377\0\0\24\377\0\0\37\377\0\0\30\377\0\0\26\377\0\0\37" + "\377\1\0\26\377\21\0\34\377\24\0\34\377\23\0\15\377\26\0\32\377\32\0" + ")\377(\0*\377'\0\"\377&\0\"\377'\0\31\377\37\0#\377\37\0\40\377\"\0\37" + "\377%\0'\377,\0)\377$\0""2\377)\0B\377\37\0\77\377'\0=\377,\0\77\377" + "$\0""6\377*\0""3\377/\0""6\377'\0/\377%\0""3\377\40\0+\377$\0)\377\37" + "\0-\377'\0""8\377\33\0:\377*\0=\377-\0""6\377\34\0I\377\34\0@\377*\0" + "/\377-\0;\3772\0""8\377,\0""5\3774\0""4\3771\0""4\377$\0""2\3773\0""6" + "\3779\0<\377,\0""8\3774\0@\3779\0K\377;\0;\3777\0A\3778\0""7\377@\0A" + "\377<\0A\3773\0:\377C\0>\377C\0@\3778\0C\3777\0=\3776\0/\377A\0=\377" + "6\0<\3779\0C\3776\0G\3774\0<\3777\0<\377-\0>\377A\0@\3778\0""9\3771\0" + "A\3772\0I\377B\0R\377;\0G\377A\0W\377D\0U\377;\0d\377<\0k\377=\0n\377" + "@\0f\377:\0c\377>\0k\3774\0b\377.\0g\3770\0U\377%\0]\377\34\0]\377\32" + "\0T\377%\0^\377\36\0W\377\32\0^\377\34\0b\377\32\0f\377&\0U\377)\0m\377" + "-\0e\377%\0d\377$\0[\377.\0d\377-\0\\\377<\0]\377\77\0^\377:\0Y\377A" + "\0]\377G\0Z\377B\0Z\377F\0r\377C\0r\377G\0|\377O\0r\377N\0n\377X\0q\377" + "Z\0n\377Z\0i\377O\0t\377T\0g\377I\0h\377L\0w\377<\0\0\377\2027\0\0\377" + "\17>\0\0\377;\0\0\377G\0\0\377I\0\0\377<\0\0\377:\0\0\3772\0\0\377;\0" + "\0\3775\0\0\3779\0\0\377H\0\0\377F\0\0\3779\0\0\377B\0\0\3778\0\0\377" + "\202\"\0\0\377\12(\0\0\377\"\0\0\377\35\0\0\377\26\0\0\377\33\0\0\377" + "\36\0\0\377\35\0\0\377$\0\0\377%\0\0\377\32\0\0\377\202\21\0\0\377\12" + "\23\0\0\377\15\0\0\377\13\0\0\377\17\0\0\377\10\0\0\377\4\0\0\377\6\0" + "\0\377\12\0\0\377\30\0\0\377\24\0\0\377\202\10\0\0\377\1\1\0\0\377\260" + "\0\0\0\377\12\0\0\11\377\0\0\0\377\0\0\7\377\0\0\13\377\0\0\25\377\0" + "\0\14\377\0\0\10\377\0\0\0\377\0\0\5\377\0\0\3\377\204\0\0\0\377\3\0" + "\0\7\377\0\0\1\377\0\0\16\377\202\0\0\11\377\30\0\0\0\377\0\0\5\377\0" + "\0\4\377\0\0\0\377\0\0\17\377\0\0\20\377\0\0\22\377\0\0\40\377\0\0\32" + "\377\0\0\34\377\0\0\21\377\0\0\34\377\0\0#\377\0\0\"\377\0\0\25\377\0" + "\0\31\377\0\0&\377\0\0*\377\0\0\34\377\0\0\21\377\0\0\25\377\0\0\26\377" + "\0\0\25\377\0\0\27\377\202\0\0\26\377|\0\0\24\377\0\0\20\377\0\0\26\377" + "\0\0\32\377\0\0!\377\0\0\26\377\0\0\"\377\0\0\31\377\0\0\35\377\0\0\26" + "\377\0\0\31\377\15\0\25\377\31\0\30\377\23\0\17\377\26\0\37\377\"\0\37" + "\377$\0\"\377)\0\35\377(\0&\377\40\0!\377'\0#\377\33\0&\377\32\0""0\377" + "(\0#\3771\0(\377.\0""3\377#\0>\377-\0G\377$\0@\377!\0=\377,\0:\377\"" + "\0=\377-\0""0\3770\0+\377$\0""3\377,\0'\377#\0*\377#\0""7\377\37\0""9" + "\377#\0:\377,\0;\377.\0:\377\37\0""7\377&\0:\377+\0>\377$\0""1\377#\0" + "5\3772\0""0\3771\0>\3772\0\77\377.\0;\377-\0<\377:\0H\3770\0=\3777\0" + "B\3779\0M\3774\0D\3779\0B\377B\0<\377<\0>\377@\0G\3779\0;\377>\0;\377" + "8\0A\377<\0@\3775\0\77\3778\0:\377@\0""6\3779\0@\377\77\0D\377<\0C\377" + "7\0G\3772\0F\377<\0A\377A\0E\377@\0""4\3776\0F\3775\0I\3779\0F\3779\0" + "M\3778\0_\377B\0]\377>\0a\3773\0e\377;\0i\377;\0]\377<\0W\3771\0e\377" + "5\0`\377.\0i\3771\0b\377&\0U\377\31\0P\377\27\0N\377\30\0^\377\24\0W" + "\377\32\0`\377&\0a\377'\0f\377\30\0_\377#\0_\377\40\0^\377'\0f\377&\0" + "_\377*\0g\3775\0g\377<\0h\377>\0h\3778\0Z\3774\0d\377C\0c\377;\0]\377" + "K\0`\377E\0p\377Z\0v\377L\0h\377T\0n\377^\0j\377V\0o\377Y\0i\377Z\0o" + "\377T\0w\377P\0{\377T\0r\377", +}; + + diff --git a/plugins/GSdx/res/logo-ogl.bmp b/plugins/GSdx/res/logo-ogl.bmp new file mode 100644 index 0000000000000000000000000000000000000000..1c3d92b4371f95e85fe832245936d5e9303fe4d9 GIT binary patch literal 74462 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 *DB;n7j{>5fke(iwOppfzu+v)K&`THP#u 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%0DBVcoNcUECilc=7B;Aq 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 literal 0 HcmV?d00001 From 969c2be7f728dfb510151c8ac71849691bbc05ab Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 8 Jan 2012 05:54:48 +0000 Subject: [PATCH 42/56] gsdx-ogl: Added the hacks section to the dialog. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5060 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSLinuxDialog.cpp | 35 ++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 1837fffb19..5631498b40 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -117,7 +117,9 @@ GtkWidget* CreateMsaaComboBox() GtkWidget *render_combo_box; GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; GtkWidget *msaa_combo_box, *resx_spin, *resy_spin; - + +GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skidraw_spin; + void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) { int render_type; @@ -178,6 +180,8 @@ bool RunLinuxDialog() GtkWidget *hw_table, *res_frame, *hw_frame, *sw_frame; GtkWidget *interlace_combo_box, *threads_spin; GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label; + + GtkWidget *hack_skipdraw_label, *hack_box, *hack_frame; int return_value; GdkPixbuf* logo_pixmap; @@ -214,10 +218,14 @@ bool RunLinuxDialog() sw_frame = gtk_frame_new ("Software Mode Settings"); gtk_container_add(GTK_CONTAINER(sw_frame), sw_box); + // The hack frame and container. + hack_box = gtk_hbox_new(false, 5); + hack_frame = gtk_frame_new ("Hacks"); + gtk_container_add(GTK_CONTAINER(hack_frame), hack_box); + // Grab a logo, to make things look nice. logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL); logo_image = gtk_image_new_from_pixbuf(logo_pixmap); - //gtk_container_add(GTK_CONTAINER(main_box), logo_image); gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0); // Create the renderer combo box and label, and stash them in a box. @@ -266,6 +274,17 @@ bool RunLinuxDialog() gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5); + // Create our hack settings. + hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack"); + hack_offset_check = gtk_check_button_new_with_label("Offset Hack"); + hack_skipdraw_label = gtk_label_new("Skipdraw:"); + hack_skidraw_spin = gtk_spin_button_new_with_range(0,1000,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skidraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0)); + gtk_box_pack_start(GTK_BOX(hack_box), hack_alpha_check, false, false, 5); + gtk_box_pack_start(GTK_BOX(hack_box), hack_offset_check, false, false, 5); + gtk_box_pack_start(GTK_BOX(hack_box), hack_skipdraw_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(hack_box), hack_skidraw_spin, false, false, 0); + // Create our checkboxes. filter_check = gtk_check_button_new_with_label("Texture Filtering"); logz_check = gtk_check_button_new_with_label("Logarithmic Z"); @@ -282,6 +301,9 @@ bool RunLinuxDialog() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0)); + // Populate all those boxes we created earlier with widgets. gtk_container_add(GTK_CONTAINER(res_box), native_box); gtk_container_add(GTK_CONTAINER(res_box), msaa_box); @@ -302,6 +324,11 @@ bool RunLinuxDialog() gtk_container_add(GTK_CONTAINER(main_box), res_frame); gtk_container_add(GTK_CONTAINER(main_box), hw_frame); gtk_container_add(GTK_CONTAINER(main_box), sw_frame); + + if (!!theApp.GetConfig("allowHacks", 0)) + { + gtk_container_add(GTK_CONTAINER(main_box), hack_frame); + } g_signal_connect(render_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL); g_signal_connect(msaa_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL); @@ -352,6 +379,10 @@ bool RunLinuxDialog() theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin))); theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin))); + theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skidraw_spin))); + theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check))); + theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check))); + // Let's just be windowed for the moment. theApp.SetConfig("windowed", 1); From 47985bc4fae754252c66232a38a6efe322347e93 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 8 Jan 2012 06:24:10 +0000 Subject: [PATCH 43/56] gsdx-ogl: Since Texture Filtering has 3 states in Windows, change it to a combo box in Linux. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5061 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSLinuxDialog.cpp | 73 +++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 5631498b40..4a0ccd57ab 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -24,6 +24,12 @@ #include "GSdx.h" #include "GSLinuxLogo.h" +GtkWidget *msaa_combo_box, *render_combo_box, *filter_combo_box; +GtkWidget *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; +GtkWidget *resx_spin, *resy_spin; + +GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skidraw_spin; + static void SysMessage(const char *fmt, ...) { va_list list; @@ -79,8 +85,8 @@ GtkWidget* CreateRenderComboBox() GtkWidget* CreateInterlaceComboBox() { - GtkWidget *interlace_combo_box; - interlace_combo_box = gtk_combo_box_new_text (); + GtkWidget *combo_box; + combo_box = gtk_combo_box_new_text (); for(size_t i = 0; i < theApp.m_gs_interlace.size(); i++) { @@ -90,35 +96,42 @@ GtkWidget* CreateInterlaceComboBox() if(!s.note.empty()) label += format(" (%s)", s.note.c_str()); - gtk_combo_box_append_text(GTK_COMBO_BOX(interlace_combo_box), label.c_str()); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), label.c_str()); } - gtk_combo_box_set_active(GTK_COMBO_BOX(interlace_combo_box), theApp.GetConfig("interlace", 0)); - return interlace_combo_box; + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), theApp.GetConfig("interlace", 0)); + return combo_box; } GtkWidget* CreateMsaaComboBox() { - GtkWidget *msaa_combo_box; - msaa_combo_box = gtk_combo_box_new_text (); + GtkWidget *combo_box; + combo_box = gtk_combo_box_new_text (); // For now, let's just put in the same vaues that show up in the windows combo box. - gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "Custom"); - gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "2x"); - gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "3x"); - gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "4x"); - gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "5x"); - gtk_combo_box_append_text(GTK_COMBO_BOX(msaa_combo_box), "6x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Custom"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "2x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "3x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "4x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "5x"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "6x"); - gtk_combo_box_set_active(GTK_COMBO_BOX(msaa_combo_box), theApp.GetConfig("msaa", 0)); - return msaa_combo_box; + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), theApp.GetConfig("msaa", 0)); + return combo_box; } -GtkWidget *render_combo_box; -GtkWidget *filter_check, *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; -GtkWidget *msaa_combo_box, *resx_spin, *resy_spin; +GtkWidget* CreateFilterComboBox() +{ + GtkWidget *combo_box; + combo_box = gtk_combo_box_new_text (); + + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Off"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Normal"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Forced"); -GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skidraw_spin; + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), theApp.GetConfig("filter", 0)); + return combo_box; +} void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) { @@ -130,7 +143,7 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) if (hardware_render) { - gtk_widget_set_sensitive(filter_check, true); + gtk_widget_set_sensitive(filter_combo_box, true); gtk_widget_set_sensitive(logz_check, true); gtk_widget_set_sensitive(paltex_check, true); gtk_widget_set_sensitive(fba_check, true); @@ -160,7 +173,7 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) } else { - gtk_widget_set_sensitive(filter_check, false); + gtk_widget_set_sensitive(filter_combo_box, false); gtk_widget_set_sensitive(logz_check, false); gtk_widget_set_sensitive(paltex_check, false); gtk_widget_set_sensitive(fba_check, false); @@ -176,10 +189,10 @@ bool RunLinuxDialog() { GtkWidget *dialog; GtkWidget *main_box, *res_box, *hw_box, *sw_box; - GtkWidget *native_box, *msaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box; + GtkWidget *native_box, *msaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box; GtkWidget *hw_table, *res_frame, *hw_frame, *sw_frame; GtkWidget *interlace_combo_box, *threads_spin; - GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label; + GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label, *filter_label; GtkWidget *hack_skipdraw_label, *hack_box, *hack_frame; int return_value; @@ -243,6 +256,13 @@ bool RunLinuxDialog() gtk_box_pack_start(GTK_BOX(interlace_box), interlace_label, false, false, 5); gtk_box_pack_start(GTK_BOX(interlace_box), interlace_combo_box, false, false, 5); + // Create the filter combo box. + filter_label = gtk_label_new ("Texture Filtering:"); + filter_combo_box = CreateFilterComboBox(); + filter_box = gtk_hbox_new(false, 5); + gtk_box_pack_start(GTK_BOX(filter_box), filter_label, false, false, 5); + gtk_box_pack_start(GTK_BOX(filter_box), filter_combo_box, false, false, 0); + // Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.) threads_label = gtk_label_new("Extra rendering threads:"); threads_spin = gtk_spin_button_new_with_range(0,100,1); @@ -286,15 +306,12 @@ bool RunLinuxDialog() gtk_box_pack_start(GTK_BOX(hack_box), hack_skidraw_spin, false, false, 0); // Create our checkboxes. - filter_check = gtk_check_button_new_with_label("Texture Filtering"); logz_check = gtk_check_button_new_with_label("Logarithmic Z"); paltex_check = gtk_check_button_new_with_label("Allow 8 bit textures"); fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)"); aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)"); // Set the checkboxes. - // Filter should have 3 states, not 2. - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filter_check), theApp.GetConfig("filter", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(logz_check), theApp.GetConfig("logz", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1)); @@ -313,7 +330,7 @@ bool RunLinuxDialog() gtk_container_add(GTK_CONTAINER(sw_box), aa_check); // Tables are strange. The numbers are for their position: left, right, top, bottom. - gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_check, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(hw_table), logz_check, 1, 2, 0, 1); gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2); @@ -368,7 +385,7 @@ bool RunLinuxDialog() theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin))); - theApp.SetConfig("filter", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_check))); + theApp.SetConfig("filter", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(filter_combo_box))); theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check))); theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check))); theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); From 14b0572b61323ab350cec85002c8f25171578e3b Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 8 Jan 2012 21:59:42 +0000 Subject: [PATCH 44/56] gsdx-ogl: * fix bad setup issue for constant blend factor * Use a read framebuffer to read back the texture (less disruptive) * cmake separate the loader to the main plugins git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5064 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 70 +++++++++++++++++++++-------------- plugins/GSdx/GS.cpp | 10 +++-- plugins/GSdx/GSDeviceOGL.cpp | 56 ++++++++++++++-------------- plugins/GSdx/GSDeviceOGL.h | 18 +++++++-- plugins/GSdx/GSTextureOGL.cpp | 40 ++++++-------------- plugins/GSdx/GSTextureOGL.h | 3 +- plugins/GSdx/GSWnd.cpp | 2 +- 7 files changed, 104 insertions(+), 95 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 37658aef3d..cac8bfee05 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -8,8 +8,6 @@ endif(NOT TOP_CMAKE_WAS_SOURCED) # plugin name set(Output GSdx-0.1.16) -set(Replay pcsx2_GSReplayLoader) -set(Static GSdx-static) set(CommonFlags -D_LINUX @@ -186,10 +184,6 @@ include_directories(.) add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders}) -add_library(${Static} STATIC ${GSdxSources} ${GSdxHeaders}) - -add_executable(${Replay} linux_replay.cpp) - target_link_libraries(${Output} ${X11_LIBRARIES}) target_link_libraries(${Output} ${GLEW_LIBRARY}) target_link_libraries(${Output} ${OPENGL_LIBRARIES}) @@ -197,14 +191,37 @@ if(projectSDL) target_link_libraries(${Output} ${SDL_LIBRARY}) endif(projectSDL) -target_link_libraries(${Replay} ${OPENGL_LIBRARIES}) -target_link_libraries(${Replay} ${X11_LIBRARIES}) -target_link_libraries(${Replay} ${GLEW_LIBRARY}) -target_link_libraries(${Replay} ${GTK2_LIBRARIES}) -target_link_libraries(${Replay} ${Static}) -if(projectSDL) - target_link_libraries(${Replay} ${SDL_LIBRARY}) -endif(projectSDL) +if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") + target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}") +endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") + +if(PACKAGE_MODE) + install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) + + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR}) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${PLUGIN_DIR}) +else(PACKAGE_MODE) + install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) +endif(PACKAGE_MODE) + +################################### Replay Loader +set(Replay pcsx2_GSReplayLoader) +set(Static GSdx-static) + +# We can have separate option for gsdx inside the player. It will only +# cost a 2nd rebuild of gsdx... +#add_definitions(${CommonFlags} ${SDLFlags} ${OptimizationFlags} -W) + +add_library(${Static} STATIC ${GSdxSources} ${GSdxHeaders}) + +add_executable(${Replay} linux_replay.cpp) target_link_libraries(${Static} ${OPENGL_LIBRARIES}) target_link_libraries(${Static} ${X11_LIBRARIES}) @@ -214,26 +231,23 @@ if(projectSDL) target_link_libraries(${Static} ${SDL_LIBRARY}) endif(projectSDL) +target_link_libraries(${Replay} ${Static}) +# Warning others lib must be linked after GSdx... +target_link_libraries(${Replay} ${OPENGL_LIBRARIES}) +target_link_libraries(${Replay} ${X11_LIBRARIES}) +target_link_libraries(${Replay} ${GLEW_LIBRARY}) +target_link_libraries(${Replay} ${GTK2_LIBRARIES}) +if(projectSDL) + target_link_libraries(${Replay} ${SDL_LIBRARY}) +endif(projectSDL) + + if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}") endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") if(PACKAGE_MODE) install(TARGETS ${Replay} DESTINATION bin) - - install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) - - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${PLUGIN_DIR}) else(PACKAGE_MODE) install(TARGETS ${Replay} DESTINATION ${CMAKE_SOURCE_DIR}/bin) - - install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) endif(PACKAGE_MODE) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index bb5a8c5b4b..c65df40ef3 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1205,13 +1205,14 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) packets.push_back(p); } - sleep(10); + sleep(1); // FIXME too slow :p // sleep(100); //while(IsWindowVisible(hWnd)) //FIXME map? - while(true) + bool finished = false; + while(!finished) { for(auto i = packets.begin(); i != packets.end(); i++) { @@ -1252,6 +1253,9 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) break; } } + + sleep(5); + finished = true; } for(auto i = packets.begin(); i != packets.end(); i++) @@ -1261,7 +1265,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) packets.clear(); - sleep(100); + sleep(1); GSclose(); GSshutdown(); diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 742b9b078c..8f6753e718 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -45,22 +45,16 @@ //GL EXT: recompiling and managing multiple shaders, while still retaining most of //GL EXT: the performance of specialized shaders. // -// ************************** Uniform buffer -// // Note don't know how to chose block_binding_point (probably managed like texture unit -// maybe any number will be fine) -// index=glGetUniformBlockIndex(program, "BlockName"); -// glBindBufferBase(GL_UNIFORM_BUFFER, block_binding_point, some_buffer_object); -// glUniformBlockBinding(program, block_index, block_binding_point); -//#define LOUD_DEBUGGING +#define LOUD_DEBUGGING #define SHADER_DEBUG -//#define DUMP_START (70) -//#define DUMP_LENGTH (130) +#define DUMP_START (500) +#define DUMP_LENGTH (5) //#define PRINT_FRAME_NUMBER //#define ONLY_LINES // It seems dual blending does not work on AMD !!! -//#define DISABLE_DUAL_BLEND +#define DISABLE_DUAL_BLEND #ifdef DUMP_START static uint32 g_draw_count = 0; @@ -73,13 +67,14 @@ GSDeviceOGL::GSDeviceOGL() , m_window(NULL) , m_pipeline(0) , m_fbo(0) + , m_fbo_read(0) , m_vb_sr(NULL) , m_srv_changed(false) , m_ss_changed(false) { m_msaa = theApp.GetConfig("msaa", 0); - memset(&m_merge, 0, sizeof(m_merge)); + memset(&m_merge_obj, 0, sizeof(m_merge_obj)); memset(&m_interlace, 0, sizeof(m_interlace)); memset(&m_convert, 0, sizeof(m_convert)); memset(&m_date, 0, sizeof(m_date)); @@ -91,11 +86,11 @@ GSDeviceOGL::~GSDeviceOGL() // Clean vertex buffer state delete (m_vb_sr); - // Clean m_merge + // Clean m_merge_obj for (uint i = 0; i < 2; i++) - glDeleteProgram(m_merge.ps[i]); - delete (m_merge.cb); - delete (m_merge.bs); + glDeleteProgram(m_merge_obj.ps[i]); + delete (m_merge_obj.cb); + delete (m_merge_obj.bs); // Clean m_interlace for (uint i = 0; i < 2; i++) @@ -118,6 +113,7 @@ GSDeviceOGL::~GSDeviceOGL() // Clean various opengl allocation glDeleteProgramPipelines(1, &m_pipeline); glDeleteFramebuffers(1, &m_fbo); + glDeleteFramebuffers(1, &m_fbo_read); // Delete HW FX delete m_vs_cb; @@ -141,7 +137,7 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int for { // A wrapper to call GSTextureOGL, with the different kind of parameter GSTextureOGL* t = NULL; - t = new GSTextureOGL(type, w, h, msaa, format); + t = new GSTextureOGL(type, w, h, msaa, format, m_fbo_read); switch(type) { @@ -234,6 +230,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glBindProgramPipeline(m_pipeline); glGenFramebuffers(1, &m_fbo); + glGenFramebuffers(1, &m_fbo_read); // Setup FBO fragment output // OMSetFBO(m_fbo); // glDrawBuffer(GL_COLOR_ATTACHMENT0); @@ -312,14 +309,14 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** // merge // **************************************************************** - m_merge.cb = new GSUniformBufferOGL(1, sizeof(MergeConstantBuffer)); + m_merge_obj.cb = new GSUniformBufferOGL(1, sizeof(MergeConstantBuffer)); - for(int i = 0; i < countof(m_merge.ps); i++) - CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge.ps[i]); + for(int i = 0; i < countof(m_merge_obj.ps); i++) + CompileShaderFromSource("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_merge_obj.ps[i]); - m_merge.bs = new GSBlendStateOGL(); - m_merge.bs->EnableBlend(); - m_merge.bs->SetRGB(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + m_merge_obj.bs = new GSBlendStateOGL(); + m_merge_obj.bs->EnableBlend(); + m_merge_obj.bs->SetRGB(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // **************************************************************** // interlace @@ -508,7 +505,7 @@ bool GSDeviceOGL::Reset(int w, int h) // Opengl allocate the backbuffer with the window. The render is done in the backbuffer when // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done // in the backbuffer - m_backbuffer = new GSTextureOGL(GSTextureOGL::Backbuffer, w, h, false, 0); + m_backbuffer = new GSTextureOGL(GSTextureOGL::Backbuffer, w, h, false, 0, m_fbo_read); return true; } @@ -542,7 +539,8 @@ void GSDeviceOGL::DrawPrimitive() m_state.ps_srv[i]->Save(format("/tmp/in_%d__%d.bmp", g_draw_count, i)); } } - if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/in_current_out_%d.bmp", g_draw_count)); + //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); @@ -558,7 +556,7 @@ void GSDeviceOGL::DrawPrimitive() #ifdef DUMP_START if ( dump_me ) { if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_%d.bmp", g_draw_count)); - if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); + //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); fprintf(stderr, "\n"); @@ -849,15 +847,15 @@ void GSDeviceOGL::DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVect if(st[1] && !slbg) { - StretchRect(st[1], sr[1], dt, dr[1], m_merge.ps[0]); + StretchRect(st[1], sr[1], dt, dr[1], m_merge_obj.ps[0]); } if(st[0]) { - SetUniformBuffer(m_merge.cb); - m_merge.cb->upload(&c.v); + SetUniformBuffer(m_merge_obj.cb); + m_merge_obj.cb->upload(&c.v); - StretchRect(st[0], sr[0], dt, dr[0], m_merge.ps[mmod ? 1 : 0], m_merge.bs); + StretchRect(st[0], sr[0], dt, dr[0], m_merge_obj.ps[mmod ? 1 : 0], m_merge_obj.bs); } } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 2e727d3922..cd10698802 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -41,6 +41,7 @@ class GSBlendStateOGL { bool m_g_msk; bool m_a_msk; bool constant_factor; + float debug_factor; public: @@ -55,7 +56,7 @@ public: , m_b_msk(GL_TRUE) , m_g_msk(GL_TRUE) , m_a_msk(GL_TRUE) - , constant_factor(true) + , constant_factor(false) {} void SetRGB(GLenum op, GLenum src, GLenum dst) @@ -100,7 +101,10 @@ public: if (m_enable) { glEnable(GL_BLEND); - if (HasConstantFactor()) glBlendColor(factor, factor, factor, 0); + if (HasConstantFactor()) { + debug_factor = factor; + glBlendColor(factor, factor, factor, 0); + } glBlendEquationSeparate(m_equation_RGB, m_equation_ALPHA); glBlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA); @@ -135,6 +139,7 @@ public: { if (!m_enable) return; fprintf(stderr,"Blend op: %s; src:%s; dst:%s\n", NameOfParam(m_equation_RGB), NameOfParam(m_func_sRGB), NameOfParam(m_func_dRGB)); + if (HasConstantFactor()) fprintf(stderr, "Blend constant: %f\n", debug_factor); fprintf(stderr,"Mask. R:%d B:%d G:%d A:%d\n", m_r_msk, m_b_msk, m_g_msk, m_a_msk); } }; @@ -315,10 +320,12 @@ public: void upload(const void* src, uint32 count) { +#ifdef OGL_DEBUG GLint b_size = -1; glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); if (b_size <= 0) return; +#endif m_count = count; @@ -345,10 +352,12 @@ public: // Upload the data to the buffer uint8* dst = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); +#ifdef OGL_DEBUG if (dst == NULL) { fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n"); return; } +#endif memcpy(dst, src, m_stride*m_count); glUnmapBuffer(m_target); } @@ -412,7 +421,7 @@ public: topo = "triangle strip"; break; } - fprintf(stderr, "%d elements of %s\n", element, topo.c_str()); + fprintf(stderr, "%d primitives of %s\n", element, topo.c_str()); } }; @@ -661,6 +670,7 @@ class GSDeviceOGL : public GSDevice GLuint m_pipeline; // pipeline to attach program shader GLuint m_fbo; // frame buffer container + GLuint m_fbo_read; // frame buffer container only for reading GSVertexBufferStateOGL* m_vb; // vb_state for HW renderer GSVertexBufferStateOGL* m_vb_sr; // vb_state for StretchRect @@ -669,7 +679,7 @@ class GSDeviceOGL : public GSDevice GLuint ps[2]; // program object GSUniformBufferOGL* cb; // uniform buffer object GSBlendStateOGL* bs; - } m_merge; + } m_merge_obj; struct { GLuint ps[4]; // program object diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 269da857b6..f7ff075ccc 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -25,23 +25,13 @@ static int g_state_texture_unit = -1; static int g_state_texture_id = -1; -GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) +GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint fbo_read) : m_extra_buffer_id(0), m_pbo_size(0) { // ************************************************************* // Opengl world - // http://www.opengl.org/wiki/Renderbuffer_Object - // render: constructor -> glGenRenderbuffers, glDeleteRenderbuffers - // info -> glGetRenderbufferParameteriv, glIsRenderbuffer - // binding -> glBindRenderbuffer (only 1 target), glFramebufferRenderbuffer (attach actually) - // setup param -> glRenderbufferStorageMultisample (after this call the buffer is unitialized) - // - // the only way to use a renderbuffer object is to attach it to a Framebuffer Object. After you bind that - // FBO to the context, and set up the draw or read buffers appropriately, you can use pixel transfer operations - // to read and write to it. Of course, you can also render to it. The standard glClear function will also clear the appropriate buffer. - // // Render work in parallal with framebuffer object (FBO) http://www.opengl.org/wiki/Framebuffer_Objects // render are attached to FBO through : glFramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS // FBO : constructor -> glGenFramebuffers, glDeleteFramebuffers @@ -57,28 +47,13 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format) // glReadBuffer // glBlitFramebuffer - // TODO: we can render directly into a texture so I'm not sure rendertarget are useful anymore !!! // ************************************************************* m_size.x = w; m_size.y = h; m_format = format; m_type = type; m_msaa = msaa; - - // == Then generate the texture or buffer. - // D3D11_BIND_RENDER_TARGET: Bind a texture as a render target for the output-merger stage. - // => glGenRenderbuffers with GL_COLOR_ATTACHMENTi (Hum glGenTextures might work too) - // D3D11_BIND_DEPTH_STENCIL: Bind a texture as a depth-stencil target for the output-merger stage. - // => glGenRenderbuffers with GL_DEPTH_STENCIL_ATTACHMENT - // D3D11_BIND_SHADER_RESOURCE: Bind a buffer or texture to a shader stage - // => glGenTextures - // D3D11_USAGE_STAGING: A resource that supports data transfer (copy) from the GPU to the CPU. - // glGenTextures - // glReadPixels seems to use a framebuffer. In this case you can setup the source - // with glReadBuffer(GL_COLOR_ATTACHMENTi) - // glGetTexImage: read pixels of a bound texture - // => To allow map/unmap. I think we can use a pixel buffer (target GL_PIXEL_UNPACK_BUFFER) - // http://www.opengl.org/wiki/Pixel_Buffer_Objects + m_fbo_read = fbo_read; // Generate the buffer switch (m_type) { @@ -396,8 +371,15 @@ bool GSTextureOGL::Save(const string& fn, bool dds) EnableUnit(1); glGetTexImage(m_texture_target, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image); } else { - EnableUnit(0); - glGetTexImage(m_texture_target, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); + + EnableUnit(1); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, m_texture_target, m_texture_id, 0); + + glReadBuffer(GL_COLOR_ATTACHMENT1); + glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); } Save(fn, image, pitch); diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 92c9010928..3842842b15 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -30,9 +30,10 @@ class GSTextureOGL : public GSTexture GLuint m_texture_id; // the texture id uint m_extra_buffer_id; int m_pbo_size; + GLuint m_fbo_read; public: - explicit GSTextureOGL(int type, int w, int h, bool msaa, int format); + explicit GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint fbo_read); virtual ~GSTextureOGL(); bool Update(const GSVector4i& r, const void* data, int pitch); diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 75147c4eb6..c4a17a1920 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -572,7 +572,7 @@ GSVector4i GSWnd::GetClientRect() bool GSWnd::SetWindowText(const char* title) { -#if ENABLE_SDL_DEV +#ifdef ENABLE_SDL_DEV if (!m_managed) return true; // Do not find anyway to check the current fullscreen status From cfedf41441c16ef217388555144218dafa4650d0 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 12 Jan 2012 07:29:31 +0000 Subject: [PATCH 45/56] gsdx-ogl: linux only * Fix some issue on wnd management, mix between sdl/ogl render * create new gsdx option for ogl debug + debug_ogl_dump: start frame to dump when not 0 + debug_ogl_dump_length: length of the dump + debug_ogl_shader: print shader debug Note current dump option must be fixed to use linux path. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5067 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 2 +- plugins/GSdx/GS.cpp | 22 +++- plugins/GSdx/GSDeviceOGL.cpp | 105 ++++----------- plugins/GSdx/GSWnd.cpp | 245 ++++++++++++----------------------- plugins/GSdx/res/tfx.glsl | 8 +- 5 files changed, 132 insertions(+), 250 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index cac8bfee05..0cbc9f0131 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -243,7 +243,7 @@ endif(projectSDL) if(NOT USER_CMAKE_LD_FLAGS STREQUAL "") - target_link_libraries(${Output} "${USER_CMAKE_LD_FLAGS}") + target_link_libraries(${Replay} "${USER_CMAKE_LD_FLAGS}") endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") if(PACKAGE_MODE) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index c65df40ef3..5f74ddba22 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1087,6 +1087,17 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow #ifdef _LINUX +#include +#include // ftime(), struct timeb + +inline unsigned long timeGetTime() +{ + timeb t; + ftime(&t); + + return (unsigned long)(t.time*1000 + t.millitm); +} + // Note EXPORT_C GSReplay(char* lpszCmdLine, int renderer) { @@ -1206,14 +1217,14 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) } sleep(1); - // FIXME too slow :p - // sleep(100); //while(IsWindowVisible(hWnd)) //FIXME map? bool finished = false; while(!finished) { + unsigned long start = timeGetTime(); + unsigned long frame_number = 0; for(auto i = packets.begin(); i != packets.end(); i++) { Packet* p = *i; @@ -1235,6 +1246,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) case 1: GSvsync(p->param); + frame_number++; break; @@ -1253,11 +1265,15 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) break; } } + unsigned long end = timeGetTime(); + fprintf(stderr, "The %d frames of the scene was render on %dms\n", frame_number, end - start); + fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); - sleep(5); + sleep(1); finished = true; } + for(auto i = packets.begin(); i != packets.end(); i++) { delete *i; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 8f6753e718..8131d591bc 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -21,45 +21,15 @@ #include "GSDeviceOGL.h" -// Various Note: separate build of shader -// ************************** BUILD METHOD 1 -// 1/ create a stand alone prog -// uint CreateShaderProgramv( enum type, sizei count, const char **strings ); -// 2/ Create various prog pipeline (maybe 1 foreach combination or only 1) -// glGenProgramPipelines -// 3/ Attach a program to a pipeline -// void UseProgramStages( uint pipeline, bitfield stages, uint program ); -// ... -// ... -// 5/ Before the use of the program, we can validate it. (mandatory or not ?) -// glValidateProgramPipeline -// -// ************************** BUILD METHOD 2 -// Humm, there is another solutions. You can setup function pointer in GLSL and configure them with OPENGL. shader_subroutine. glUseProgram must be replace with glUseProgramInstance in this case (and instance must be managed) -//GL EXT: Overview -//GL EXT: -//GL EXT: This extension adds support to shaders for "indirect subroutine calls", -//GL EXT: where a single shader can include many subroutines and dynamically select -//GL EXT: through the API which subroutine is called from each call site. -//GL EXT: Switching subroutines dynamically in this fashion can avoid the cost of -//GL EXT: recompiling and managing multiple shaders, while still retaining most of -//GL EXT: the performance of specialized shaders. -// - -#define LOUD_DEBUGGING -#define SHADER_DEBUG -#define DUMP_START (500) -#define DUMP_LENGTH (5) +//#define LOUD_DEBUGGING //#define PRINT_FRAME_NUMBER //#define ONLY_LINES // It seems dual blending does not work on AMD !!! #define DISABLE_DUAL_BLEND -#ifdef DUMP_START static uint32 g_draw_count = 0; -static uint32 g_frame_count = 0; -#endif +static uint32 g_frame_count = 1; GSDeviceOGL::GSDeviceOGL() @@ -231,10 +201,6 @@ bool GSDeviceOGL::Create(GSWnd* wnd) glGenFramebuffers(1, &m_fbo); glGenFramebuffers(1, &m_fbo_read); - // Setup FBO fragment output - // OMSetFBO(m_fbo); - // glDrawBuffer(GL_COLOR_ATTACHMENT0); - // OMSetFBO(0); // **************************************************************** // Vertex buffer state @@ -518,28 +484,30 @@ void GSDeviceOGL::Flip() #ifdef PRINT_FRAME_NUMBER fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); #endif -#ifdef DUMP_START - g_frame_count++; +#ifdef OGL_DEBUG + if (theApp.GetConfig("debug_ogl_dump", 0) != 0) + g_frame_count++; #endif } void GSDeviceOGL::DrawPrimitive() { -#ifdef DUMP_START +#ifdef OGL_DEBUG bool dump_me = false; - if ( (g_frame_count > DUMP_START && g_frame_count < (DUMP_START+DUMP_LENGTH)) ) - dump_me = true; + uint32 start = theApp.GetConfig("debug_ogl_dump", 0); + uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); + if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; #endif // DUMP INPUT -#ifdef DUMP_START +#ifdef OGL_DEBUG if ( dump_me ) { for (auto i = 0 ; i < 3 ; i++) { if (m_state.ps_srv[i] != NULL) { - m_state.ps_srv[i]->Save(format("/tmp/in_%d__%d.bmp", g_draw_count, i)); + m_state.ps_srv[i]->Save(format("/tmp/in_f%d__d%d__%d.bmp", g_frame_count, g_draw_count, i)); } } - if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/in_current_out_%d.bmp", g_draw_count)); + //if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/in_current_out_%d.bmp", g_draw_count)); //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); @@ -553,9 +521,9 @@ void GSDeviceOGL::DrawPrimitive() m_state.vb->draw_arrays(); // DUMP OUTPUT -#ifdef DUMP_START +#ifdef OGL_DEBUG if ( dump_me ) { - if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_%d.bmp", g_draw_count)); + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d.bmp", g_frame_count, g_draw_count)); //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); fprintf(stderr, "\n"); @@ -926,9 +894,6 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver // -#ifdef DUMP_START - fprintf(stderr, "draw date!!!\n"); -#endif DrawPrimitive(); // @@ -1067,21 +1032,6 @@ void GSDeviceOGL::PSSetShader(GLuint ps) } } } -#if 0 - if (m_srv_changed) - { - m_ctx->PSSetShaderResources(0, 3, m_state.ps_srv); - - m_srv_changed = false; - } - - if(m_ss_changed) - { - m_ctx->PSSetSamplers(0, 3, m_state.ps_ss); - - m_ss_changed = false; - } -#endif } void GSDeviceOGL::OMSetFBO(GLuint fbo) @@ -1164,9 +1114,6 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto { m_state.scissor = r; glScissor( r.x, r.y, r.width(), r.height() ); -#if 0 - m_ctx->RSSetScissorRects(1, r); -#endif } } @@ -1176,7 +1123,7 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st // Build a header string // ***************************************************** // First select the version (must be the first line so we need to generate it - std::string version = "#version 330\n#extension GL_ARB_shading_language_420pack: enable\n#extension GL_ARB_separate_shader_objects : enable\n"; + std::string version = "#version 330\n#extension GL_ARB_shading_language_420pack: require\n#extension GL_ARB_separate_shader_objects : require\n"; //std::string version = "#version 420\n"; // Allow to puts several shader in 1 files @@ -1248,19 +1195,19 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st free(header_str); free(sources_array); -#ifdef SHADER_DEBUG - // Print a nice debug log - GLint log_length = 0; - glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length); + if (theApp.GetConfig("debug_ogl_shader", 1) == 1) { + // Print a nice debug log + GLint log_length = 0; + glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length); - char* log = (char*)malloc(log_length); - glGetProgramInfoLog(*program, log_length, NULL, log); + char* log = (char*)malloc(log_length); + glGetProgramInfoLog(*program, log_length, NULL, log); - fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), *program); - fprintf(stderr, "\n%s", macro_sel.c_str()); - fprintf(stderr, "%s\n", log); - free(log); -#endif + fprintf(stderr, "%s (entry %s, prog %d) :", glsl_file.c_str(), entry.c_str(), *program); + fprintf(stderr, "\n%s", macro_sel.c_str()); + fprintf(stderr, "%s\n", log); + free(log); + } } void GSDeviceOGL::CheckDebugLog() diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index c4a17a1920..aee95c24ba 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -212,105 +212,6 @@ void GSWnd::HideFrame() #else -/* -GSWnd::GSWnd() - : m_display(NULL) - , m_window(0) - , m_managed(true) - , m_frame(true) -{ -} - -GSWnd::~GSWnd() -{ - if(m_display != NULL) - { - if(m_window != 0) - { - XDestroyWindow(m_display, m_window); - } - - XCloseDisplay(m_display); - } -} - -bool GSWnd::Create(const string& title, int w, int h) -{ - if(m_display != NULL) return false; - - if(!XInitThreads()) return false; - - m_display = XOpenDisplay(0); - - if(m_display == NULL) return false; - - m_window = XCreateSimpleWindow(m_display, RootWindow(m_display, 0), 0, 0, 640, 480, 0, BlackPixel(m_display, 0), BlackPixel(m_display, 0)); - - XFlush(m_display); - - return true; -} - -GSVector4i GSWnd::GetClientRect() -{ - int x, y; - unsigned int w, h; - unsigned int border, depth; - Window root; - - XLockDisplay(m_display); - XGetGeometry(m_display, m_window, &root, &x, &y, &w, &h, &border, &depth); - XUnlockDisplay(m_display); - - return GSVector4i(0, 0, w, h); -} - -// Returns FALSE if the window has no title, or if th window title is under the strict -// management of the emulator. - -bool GSWnd::SetWindowText(const char* title) -{ - if(!m_managed) return false; - - XTextProperty p; - - p.value = (unsigned char*)title; - p.encoding = XA_STRING; - p.format = 8; - p.nitems = strlen(title); - - XSetWMName(m_display, m_window, &p); - XFlush(m_display); - - return m_frame; -} - -void GSWnd::Show() -{ - if(!m_managed) return; - - XMapWindow(m_display, m_window); - XFlush(m_display); -} - -void GSWnd::Hide() -{ - if(!m_managed) return; - - XUnmapWindow(m_display, m_window); - XFlush(m_display); -} - -void GSWnd::HideFrame() -{ - if(!m_managed) return; - - // TODO - - m_frame = false; -} -*/ - GSWnd::GSWnd() : m_window(NULL), m_Xwindow(0), m_XDisplay(NULL) { @@ -443,7 +344,6 @@ void GSWnd::Detach() bool GSWnd::Create(const string& title, int w, int h) { -#ifdef ENABLE_SDL_DEV if(m_window != NULL) return false; if(w <= 0 || h <= 0) { @@ -451,75 +351,78 @@ bool GSWnd::Create(const string& title, int w, int h) h = theApp.GetConfig("ModeHeight", 480); } + m_managed = true; + + if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV + #ifdef _LINUX - // When you reconfigure the plugins during the play, SDL is shutdown so SDL_GetNumVideoDisplays return 0 - // and the plugins is badly closed. NOTE: SDL is initialized in SDL_CreateWindow. - // - // I'm not sure this sanity check is still useful, normally (I hope) SDL_CreateWindow will return a null - // hence a false for this current function. - // For the moment do an init -- Gregory - if(!SDL_WasInit(SDL_INIT_VIDEO)) - if(SDL_Init(SDL_INIT_VIDEO) < 0) return false; + // When you reconfigure the plugins during the play, SDL is shutdown so SDL_GetNumVideoDisplays return 0 + // and the plugins is badly closed. NOTE: SDL is initialized in SDL_CreateWindow. + // + // I'm not sure this sanity check is still useful, normally (I hope) SDL_CreateWindow will return a null + // hence a false for this current function. + // For the moment do an init -- Gregory + if(!SDL_WasInit(SDL_INIT_VIDEO)) + if(SDL_Init(SDL_INIT_VIDEO) < 0) return false; - // Sanity check; if there aren't any video displays available, we can't create a window. - if (SDL_GetNumVideoDisplays() <= 0) return false; + // Sanity check; if there aren't any video displays available, we can't create a window. + if (SDL_GetNumVideoDisplays() <= 0) return false; #endif - m_managed = true; + m_window = SDL_CreateWindow(title.c_str(), 100, 100, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); - m_window = SDL_CreateWindow(title.c_str(), 100, 100, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); + // Get the X window from the newly created window + // It would be needed to get the current size + SDL_SysWMinfo wminfo; + memset(&wminfo, 0, sizeof(wminfo)); - // Get the X window from the newly created window - // It would be needed to get the current size - SDL_SysWMinfo wminfo; - memset(&wminfo, 0, sizeof(wminfo)); + wminfo.version.major = SDL_MAJOR_VERSION; + wminfo.version.minor = SDL_MINOR_VERSION; - wminfo.version.major = SDL_MAJOR_VERSION; - wminfo.version.minor = SDL_MINOR_VERSION; + SDL_GetWindowWMInfo(m_window, &wminfo); + m_Xwindow = wminfo.info.x11.window; - SDL_GetWindowWMInfo(m_window, &wminfo); - m_Xwindow = wminfo.info.x11.window; - - return (m_window != NULL); -#else - - // note this part must be only executed when replaying .gs debug file - m_managed = true; - - m_XDisplay = XOpenDisplay(NULL); - - int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_DEPTH_SIZE, 24, - None - }; - XVisualInfo* vi = glXChooseVisual(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl); - - /* create a color map */ - XSetWindowAttributes attr; - attr.colormap = XCreateColormap(m_XDisplay, RootWindow(m_XDisplay, vi->screen), - vi->visual, AllocNone); - attr.border_pixel = 0; - attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | - StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | - EnterWindowMask | LeaveWindowMask | FocusChangeMask ; - - // Create a window at the last position/size - m_Xwindow = XCreateWindow(m_XDisplay, RootWindow(m_XDisplay, vi->screen), - 0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask, &attr); - - XMapWindow (m_XDisplay, m_Xwindow); - XFree(vi); - - if (!CreateContext(3, 3)) return false; - - AttachContext(); - - return (m_Xwindow != 0); #endif + return (m_window != NULL); + + } else { + + // note this part must be only executed when replaying .gs debug file + m_XDisplay = XOpenDisplay(NULL); + + int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_DEPTH_SIZE, 24, + None + }; + XVisualInfo* vi = glXChooseVisual(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl); + + /* create a color map */ + XSetWindowAttributes attr; + attr.colormap = XCreateColormap(m_XDisplay, RootWindow(m_XDisplay, vi->screen), + vi->visual, AllocNone); + attr.border_pixel = 0; + attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | + StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | + EnterWindowMask | LeaveWindowMask | FocusChangeMask ; + + // Create a window at the last position/size + m_Xwindow = XCreateWindow(m_XDisplay, RootWindow(m_XDisplay, vi->screen), + 0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask, &attr); + + XMapWindow (m_XDisplay, m_Xwindow); + XFree(vi); + + if (!CreateContext(3, 3)) return false; + + AttachContext(); + + return (m_Xwindow != 0); + } } Display* GSWnd::GetDisplay() @@ -572,9 +475,11 @@ GSVector4i GSWnd::GetClientRect() bool GSWnd::SetWindowText(const char* title) { -#ifdef ENABLE_SDL_DEV if (!m_managed) return true; + if (m_renderer == 2) { +#ifdef ENABLE_SDL_DEV + // Do not find anyway to check the current fullscreen status // Better than nothing heuristic, check the window position. Fullscreen = (0,0) // if(!(m_window->flags & SDL_WINDOW_FULLSCREEN) ) // Do not compile @@ -583,15 +488,27 @@ bool GSWnd::SetWindowText(const char* title) // but we not use this function anyway. // FIXME: it does not feel a good solution -- Gregory // NOte: it might be more thread safe to use a call to XGetGeometry - int x,y = 0; - if (m_renderer == 2) { + int x,y = 0; SDL_PumpEvents(); SDL_GetWindowPosition(m_window, &x, &y); if ( x && y ) SDL_SetWindowTitle(m_window, title); - } #endif + } else { + XTextProperty prop; + + memset(&prop, 0, sizeof(prop)); + + char* ptitle = (char*)title; + if (XStringListToTextProperty(&ptitle, 1, &prop)) { + XSetWMName(m_XDisplay, m_Xwindow, &prop); + } + + XFree(prop.value); + XFlush(m_XDisplay); + } + return true; } diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 2bf22ca9ff..e836be3c29 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -623,9 +623,8 @@ void ps_main() // FIXME: I'm not sure about the value of others field // output.c1 = c.a * 2; // used for alpha blending -#ifndef DISABLE_DUAL_BLEND - SV_Target0 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2); -#endif + + float alpha = c.a * 2; if(PS_AOUT != 0) // 16 bit output { @@ -638,6 +637,9 @@ void ps_main() if(c.a < 0.5) c.a += 0.5; } +#ifndef DISABLE_DUAL_BLEND + SV_Target0 = vec4(alpha, alpha, alpha, alpha); +#endif SV_Target1 = c; } #endif From 86a9910027cb6bb3d3c1c0046c906bbcd3a12c7d Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 15 Jan 2012 17:25:49 +0000 Subject: [PATCH 46/56] gsdx-ogl: linux only compilation fix, add bits for the index buffer. current status is blackscreen :p git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5070 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 1 + plugins/GSdx/GSDeviceOGL.cpp | 53 +- plugins/GSdx/GSDeviceOGL.h | 175 +++++-- plugins/GSdx/GSRendererOGL.cpp | 855 +++++++++++++++++++++++++++++++- plugins/GSdx/GSRendererOGL.h | 425 +--------------- plugins/GSdx/GSTextureFXOGL.cpp | 5 +- plugins/GSdx/linux_replay.cpp | 2 +- 7 files changed, 1050 insertions(+), 466 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 0cbc9f0131..fb428260a6 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -83,6 +83,7 @@ set(GSdxSources GSPerfMon.cpp GSRasterizer.cpp GSRenderer.cpp + GSRendererHW.cpp GSRendererNull.cpp GSRendererOGL.cpp GSRendererSW.cpp diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 8131d591bc..fe7756d796 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -490,17 +490,13 @@ void GSDeviceOGL::Flip() #endif } -void GSDeviceOGL::DrawPrimitive() +void GSDeviceOGL::DebugInput() { -#ifdef OGL_DEBUG bool dump_me = false; uint32 start = theApp.GetConfig("debug_ogl_dump", 0); uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; -#endif - - // DUMP INPUT -#ifdef OGL_DEBUG + if ( dump_me ) { for (auto i = 0 ; i < 3 ; i++) { if (m_state.ps_srv[i] != NULL) { @@ -516,12 +512,15 @@ void GSDeviceOGL::DrawPrimitive() m_state.bs->debug(); m_state.dss->debug(); } -#endif +} - m_state.vb->draw_arrays(); +void GSDeviceOGL::DebugOutput() +{ + bool dump_me = false; + uint32 start = theApp.GetConfig("debug_ogl_dump", 0); + uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); + if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; - // DUMP OUTPUT -#ifdef OGL_DEBUG if ( dump_me ) { if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d.bmp", g_frame_count, g_draw_count)); //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); @@ -529,7 +528,32 @@ void GSDeviceOGL::DrawPrimitive() fprintf(stderr, "\n"); } +} +void GSDeviceOGL::DrawPrimitive() +{ +#ifdef OGL_DEBUG + DebugInput(); +#endif + + m_state.vb->DrawPrimitive(); + +#ifdef OGL_DEBUG + DebugOutput(); + g_draw_count++; +#endif +} + +void GSDeviceOGL::DrawIndexedPrimitive() +{ +#ifdef OGL_DEBUG + DebugInput(); +#endif + + m_state.vb->DrawIndexedPrimitive(); + +#ifdef OGL_DEBUG + DebugOutput(); g_draw_count++; #endif } @@ -929,7 +953,7 @@ GSTexture* GSDeviceOGL::Resolve(GSTexture* t) void GSDeviceOGL::EndScene() { - m_state.vb->draw_done(); + m_state.vb->EndScene(); } void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) @@ -950,7 +974,12 @@ void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb) void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count) { - m_state.vb->upload(vertices, count); + m_state.vb->UploadVB(vertices, count); +} + +void GSDeviceOGL::IASetIndexBuffer(const void* index, size_t count) +{ + m_state.vb->UploadIB(index, count); } void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index cd10698802..474eb37aec 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -283,41 +283,135 @@ struct GSInputLayoutOGL { }; class GSVertexBufferStateOGL { - size_t m_stride; - size_t m_start; - size_t m_count; - size_t m_limit; - GLuint m_vb; - GLuint m_va; - const GLenum m_target; - GLenum m_topology; + class GSBufferOGL { + size_t m_stride; + size_t m_start; + size_t m_count; + size_t m_limit; + GLenum m_target; + GLuint m_buffer; + size_t m_default_size; - void allocate(size_t new_limit) - { - m_start = 0; - m_limit = new_limit; - glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW); - } + public: + GSBufferOGL(GLenum target, size_t stride) : + m_stride(stride) + , m_start(0) + , m_count(0) + , m_limit(0) + , m_target(target) + { + glGenBuffers(1, &m_buffer); + // Opengl works best with 1-4MB buffer. + m_default_size = 2 * 1024 * 1024 / m_stride; + } + + ~GSBufferOGL() { glDeleteBuffers(1, &m_buffer); } + + void allocate() { allocate(m_default_size); } + + void allocate(size_t new_limit) + { + m_start = 0; + m_limit = new_limit; + glBufferData(GL_ARRAY_BUFFER, m_limit * m_stride, NULL, GL_STREAM_DRAW); + } + + void bind() + { + glBindBuffer(m_target, m_buffer); + } + + void upload(const void* src, uint32 count) + { +#ifdef OGL_DEBUG + GLint b_size = -1; + glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); + + if (b_size <= 0) return; +#endif + + m_count = count; + + // Note: For an explanation of the map flag + // see http://www.opengl.org/wiki/Buffer_Object_Streaming + uint32 map_flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; + + // Current GPU buffer is really too small need to allocate a new one + if (m_count > m_limit) { + allocate(std::max(count * 3 / 2, m_default_size)); + + } else if (m_count > (m_limit - m_start) ) { + // Not enough left free room. Just go back at the beginning + m_start = 0; + + // Tell the driver that it can orphan previous buffer and restart from a scratch buffer. + // Technically the buffer will not be accessible by the application anymore but the + // GL will effectively remove it when draws call are finised. + map_flags |= GL_MAP_INVALIDATE_BUFFER_BIT; + } else { + // Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map + map_flags |= GL_MAP_INVALIDATE_RANGE_BIT; + } + + // Upload the data to the buffer + uint8* dst = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); +#ifdef OGL_DEBUG + if (dst == NULL) { + fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n"); + return; + } +#endif + memcpy(dst, src, m_stride*m_count); + glUnmapBuffer(m_target); + } + + void EndScene() + { + m_start += m_count; + m_count = 0; + } + + void Draw(GLenum mode) + { + glDrawArrays(mode, m_start, m_count); + } + + void Draw(GLenum mode, GLint basevertex) + { + glDrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex); + } + + size_t GetStart() { return m_start; } + + } *m_vb, *m_ib; + + GLuint m_va; + GLenum m_topology; public: GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr) - : m_stride(stride) - , m_count(0) - , m_target(GL_ARRAY_BUFFER) { - glGenBuffers(1, &m_vb); glGenVertexArrays(1, &m_va); + + m_vb = new GSBufferOGL(GL_ARRAY_BUFFER, stride); + m_ib = new GSBufferOGL(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32)); + bind(); - allocate(60000); // Opengl works best with 1-4MB buffer. 60k element seems a good value. Note stride is 32 + // Note: index array are part of the VA state so it need to be bind only once. + m_ib->bind(); + + m_vb->allocate(); + m_ib->allocate(); set_internal_format(layout, layout_nbr); } void bind() { glBindVertexArray(m_va); - glBindBuffer(m_target, m_vb); + m_vb->bind(); } +#if 0 void upload(const void* src, uint32 count) { #ifdef OGL_DEBUG @@ -361,6 +455,7 @@ public: memcpy(dst, src, m_stride*m_count); glUnmapBuffer(m_target); } +#endif void set_internal_format(GSInputLayoutOGL* layout, uint32 layout_nbr) { @@ -380,44 +475,52 @@ public: } } - void draw_arrays() + void EndScene() { - glDrawArrays(m_topology, m_start, m_count); + m_vb->EndScene(); + m_ib->EndScene(); } - void draw_done() - { - m_start += m_count; - m_count = 0; - } + void DrawPrimitive() { m_vb->Draw(m_topology); } + + void DrawIndexedPrimitive() { m_ib->Draw(m_topology, m_vb->GetStart() ); } void SetTopology(GLenum topology) { m_topology = topology; } + void UploadVB(const void* vertices, size_t count) + { + m_vb->upload(vertices, count); + } + + void UploadIB(const void* index, size_t count) + { + m_ib->upload(index, count); + } + ~GSVertexBufferStateOGL() { - glDeleteBuffers(1, &m_vb); glDeleteVertexArrays(1, &m_va); } void debug() { - uint32 element; + uint32 element = 0; string topo; switch (m_topology) { case GL_POINTS: - element = m_count; + //element = m_count; topo = "point"; break; case GL_LINES: - element = m_count/2; + //element = m_count/2; topo = "line"; break; case GL_TRIANGLES: - element = m_count/3; + //element = m_count/3; topo = "triangle"; break; case GL_TRIANGLE_STRIP: - element = m_count - 2; + //element = m_count - 2; topo = "triangle strip"; break; } @@ -788,6 +891,8 @@ class GSDeviceOGL : public GSDevice void CheckDebugLog(); static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); + void DebugOutput(); + void DebugInput(); bool HasStencil() { return true; } bool HasDepth32() { return true; } @@ -797,6 +902,7 @@ class GSDeviceOGL : public GSDevice void Flip(); void DrawPrimitive(); + void DrawIndexedPrimitive(); void ClearRenderTarget(GSTexture* t, const GSVector4& c); void ClearRenderTarget(GSTexture* t, uint32 c); @@ -825,6 +931,7 @@ class GSDeviceOGL : public GSDevice void IASetPrimitiveTopology(GLenum topology); void IASetVertexBuffer(const void* vertices, size_t count); + void IASetIndexBuffer(const void* index, size_t count); void IASetVertexState(GSVertexBufferStateOGL* vb); void SetUniformBuffer(GSUniformBufferOGL* cb); @@ -844,7 +951,7 @@ class GSDeviceOGL : public GSDevice void CreateTextureFX(); - void SetupIA(const void* vertices, int count, GLenum prim); + void SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim); void SetupVS(VSSelector sel, const VSConstantBuffer* cb); void SetupGS(GSSelector sel); void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel); diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index e7d982b54d..5686d8555d 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -26,7 +26,8 @@ GSRendererOGL::GSRendererOGL() // FIXME //: GSRendererHW(new GSTextureCacheOGL(this)) - : GSRendererHW(new GSTextureCacheOGL(this)) + //: GSRendererHW(new GSTextureCacheOGL(this)) + : GSRendererHW(new GSVertexTraceDX11(this), sizeof(GSVertexHW11), new GSTextureCacheOGL(this)) , m_topology(0) { m_logz = !!theApp.GetConfig("logz", 0); @@ -36,7 +37,7 @@ GSRendererOGL::GSRendererOGL() // TODO must be implementer with macro InitVertexKick(GSRendererOGL) // template void VertexKick(bool skip); - InitVertexKick(GSRendererOGL); + InitConvertVertex(GSRendererOGL); } bool GSRendererOGL::CreateDevice(GSDevice* dev) @@ -47,6 +48,27 @@ bool GSRendererOGL::CreateDevice(GSDevice* dev) return true; } +template +void GSRendererOGL::ConvertVertex(size_t dst_index, size_t src_index) +{ + GSVertex* s = (GSVertex*)((GSVertexHW11*)m_vertex.buff + src_index); + GSVertexHW11* d = (GSVertexHW11*)m_vertex.buff + dst_index; + + GSVector4i v0 = ((GSVector4i*)s)[0]; + GSVector4i v1 = ((GSVector4i*)s)[1]; + + if(tme && fst) + { + // TODO: modify VertexTrace and the shaders to read uv from v1.u16[0], v1.u16[1], then this step is not needed + + v0 = GSVector4i::cast(GSVector4(v1.uph16()).xyzw(GSVector4::cast(v0))); // uv => st + } + + ((GSVector4i*)d)[0] = v0; + ((GSVector4i*)d)[1] = v1; +} + +#if 0 template void GSRendererOGL::VertexKick(bool skip) { @@ -222,3 +244,832 @@ void GSRendererOGL::VertexKick(bool skip) m_count += count; } } +#endif + +#if 0 + { + + switch(m_vt.m_primclass) + { + case GS_POINT_CLASS: + m_topology = GL_POINTS; + m_perfmon.Put(GSPerfMon::Prim, m_count); + break; + case GS_LINE_CLASS: + case GS_SPRITE_CLASS: + m_topology = GL_LINES; + m_perfmon.Put(GSPerfMon::Prim, m_count / 2); + break; + case GS_TRIANGLE_CLASS: + m_topology = GL_TRIANGLES; + m_perfmon.Put(GSPerfMon::Prim, m_count / 3); + break; + default: + __assume(0); + } + + + GSDrawingEnvironment& env = m_env; + GSDrawingContext* context = m_context; + + const GSVector2i& rtsize = rt->GetSize(); + const GSVector2& rtscale = rt->GetScale(); + + bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24; + + GSTexture *rtcopy = NULL; + + ASSERT(m_dev != NULL); + + GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; + + if(DATE) + { + if(dev->HasStencil()) + { + GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); + GSVector4 o = GSVector4(-1.0f, 1.0f); + + GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); + GSVector4 dst = src * 2.0f + o.xxxx(); + + GSVertexPT1 vertices[] = + { + {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, + {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, + {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, + {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, + }; + + dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); + } + else + { + rtcopy = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); + + // I'll use VertexTrace when I consider it more trustworthy + + dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); + } + } + + // + + dev->BeginScene(); + + // om + + GSDeviceOGL::OMDepthStencilSelector om_dssel; + + if(context->TEST.ZTE) + { + om_dssel.ztst = context->TEST.ZTST; + om_dssel.zwe = !context->ZBUF.ZMSK; + } + else + { + om_dssel.ztst = ZTST_ALWAYS; + } + + if(m_fba) + { + om_dssel.fba = context->FBA.FBA; + } + + GSDeviceOGL::OMBlendSelector om_bsel; + + if(!IsOpaque()) + { + om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS; + + om_bsel.a = context->ALPHA.A; + om_bsel.b = context->ALPHA.B; + om_bsel.c = context->ALPHA.C; + om_bsel.d = context->ALPHA.D; + + if(env.PABE.PABE) + { + if(om_bsel.a == 0 && om_bsel.b == 1 && om_bsel.c == 0 && om_bsel.d == 1) + { + // this works because with PABE alpha blending is on when alpha >= 0x80, but since the pixel shader + // cannot output anything over 0x80 (== 1.0) blending with 0x80 or turning it off gives the same result + + om_bsel.abe = 0; + } + else + { + //Breath of Fire Dragon Quarter triggers this in battles. Graphics are fine though. + //ASSERT(0); + } + } + } + + om_bsel.wrgba = ~GSVector4i::load((int)context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask(); + + // vs + + GSDeviceOGL::VSSelector vs_sel; + + vs_sel.tme = PRIM->TME; + vs_sel.fst = PRIM->FST; + vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0; + vs_sel.rtcopy = !!rtcopy; + + // The real GS appears to do no masking based on the Z buffer format and writing larger Z values + // than the buffer supports seems to be an error condition on the real GS, causing it to crash. + // We are probably receiving bad coordinates from VU1 in these cases. + + if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe) + { + if(context->ZBUF.PSM == PSM_PSMZ24) + { + if(m_vt.m_max.p.z > 0xffffff) + { + ASSERT(m_vt.m_min.p.z > 0xffffff); + // Fixme :Following conditional fixes some dialog frame in Wild Arms 3, but may not be what was intended. + if (m_vt.m_min.p.z > 0xffffff) + { + vs_sel.bppz = 1; + om_dssel.ztst = ZTST_ALWAYS; + } + } + } + else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) + { + if(m_vt.m_max.p.z > 0xffff) + { + ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo + // Fixme : Same as above, I guess. + if (m_vt.m_min.p.z > 0xffff) + { + vs_sel.bppz = 2; + om_dssel.ztst = ZTST_ALWAYS; + } + } + } + } + + // FIXME Opengl support half pixel center (as dx10). Code could be easier!!! + GSDeviceOGL::VSConstantBuffer vs_cb; + + float sx = 2.0f * rtscale.x / (rtsize.x << 4); + float sy = 2.0f * rtscale.y / (rtsize.y << 4); + float ox = (float)(int)context->XYOFFSET.OFX; + float oy = (float)(int)context->XYOFFSET.OFY; + float ox2 = 2.0f * m_pixelcenter.x / rtsize.x; + float oy2 = 2.0f * m_pixelcenter.y / rtsize.y; + + //This hack subtracts around half a pixel from OFX and OFY. (Cannot do this directly, + //because DX10 and DX9 have a different pixel center.) + // + //The resulting shifted output aligns better with common blending / corona / blurring effects, + //but introduces a few bad pixels on the edges. + + if(rt->LikelyOffset) + { + // DX9 has pixelcenter set to 0.0, so give it some value here + + if(m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } + + ox2 *= rt->OffsetHack_modx; + oy2 *= rt->OffsetHack_mody; + } + + vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); + vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); + // END of FIXME + + // gs + + GSDeviceOGL::GSSelector gs_sel; + + gs_sel.iip = PRIM->IIP; + gs_sel.prim = m_vt.m_primclass; + + // ps + + GSDeviceOGL::PSSelector ps_sel; + GSDeviceOGL::PSSamplerSelector ps_ssel; + GSDeviceOGL::PSConstantBuffer ps_cb; + + if(DATE) + { + if(dev->HasStencil()) + { + om_dssel.date = 1; + } + else + { + ps_sel.date = 1 + context->TEST.DATM; + } + } + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + ps_sel.colclip = 1; + } + + ps_sel.clr1 = om_bsel.IsCLR1(); + ps_sel.fba = context->FBA.FBA; + ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0; + + if(UserHacks_AlphaHack) ps_sel.aout = 1; + + if(PRIM->FGE) + { + ps_sel.fog = 1; + + ps_cb.FogColor_AREF = GSVector4::rgba32(env.FOGCOL.u32[0]) / 255; + } + + if(context->TEST.ATE) + { + ps_sel.atst = context->TEST.ATST; + + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + } + else + { + ps_sel.atst = ATST_ALWAYS; + } + + if(tex) + { + ps_sel.wms = context->CLAMP.WMS; + ps_sel.wmt = context->CLAMP.WMT; + ps_sel.fmt = tex->m_fmt; + ps_sel.aem = env.TEXA.AEM; + ps_sel.tfx = context->TEX0.TFX; + ps_sel.tcc = context->TEX0.TCC; + ps_sel.ltf = m_filter == 2 ? m_vt.IsLinear() : m_filter; + ps_sel.rt = tex->m_target; + + int w = tex->m_texture->GetWidth(); + int h = tex->m_texture->GetHeight(); + + int tw = (int)(1 << context->TEX0.TW); + int th = (int)(1 << context->TEX0.TH); + + GSVector4 WH(tw, th, w, h); + + if(PRIM->FST) + { + vs_cb.TextureScale = GSVector4(1.0f / 16) / WH.xyxy(); + //Maybe better? + //vs_cb.TextureScale = GSVector4(1.0f / 16) * GSVector4(tex->m_texture->GetScale()).xyxy() / WH.zwzw(); + ps_sel.fst = 1; + } + + ps_cb.WH = WH; + ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw(); + ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV); + + GSVector4 clamp(ps_cb.MskFix); + GSVector4 ta(env.TEXA & GSVector4i::x000000ff()); + + ps_cb.MinMax = clamp / WH.xyxy(); + ps_cb.MinF_TA = (clamp + 0.5f).xyxy(ta) / WH.xyxy(GSVector4(255, 255)); + + ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; + ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; + ps_ssel.ltf = ps_sel.ltf; + } + else + { + ps_sel.tfx = 4; + } + + // rs + + GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy()); + + dev->OMSetRenderTargets(rt, ds, &scissor); + dev->PSSetShaderResource(0, tex ? tex->m_texture : 0); + dev->PSSetShaderResource(1, tex ? tex->m_palette : 0); + dev->PSSetShaderResource(2, rtcopy); + + uint8 afix = context->ALPHA.FIX; + + dev->SetupOM(om_dssel, om_bsel, afix); + dev->SetupIA(m_vertices, m_count, m_topology); + dev->SetupVS(vs_sel, &vs_cb); + dev->SetupGS(gs_sel); + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); + + // draw + + if(context->TEST.DoFirstPass()) + { + dev->DrawPrimitive(); + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); + GSDeviceOGL::PSSelector ps_selneg(ps_sel); + + om_bselneg.negative = 1; + ps_selneg.colclip = 2; + + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); + + dev->DrawPrimitive(); + } + } + + if(context->TEST.DoSecondPass()) + { + ASSERT(!env.PABE.PABE); + + static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; + + ps_sel.atst = iatst[ps_sel.atst]; + + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); + + bool z = om_dssel.zwe; + bool r = om_bsel.wr; + bool g = om_bsel.wg; + bool b = om_bsel.wb; + bool a = om_bsel.wa; + + switch(context->TEST.AFAIL) + { + case 0: z = r = g = b = a = false; break; // none + case 1: z = false; break; // rgba + case 2: r = g = b = a = false; break; // z + case 3: z = a = false; break; // rgb + default: __assume(0); + } + + if(z || r || g || b || a) + { + om_dssel.zwe = z; + om_bsel.wr = r; + om_bsel.wg = g; + om_bsel.wb = b; + om_bsel.wa = a; + + dev->SetupOM(om_dssel, om_bsel, afix); + + dev->DrawPrimitive(); + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); + GSDeviceOGL::PSSelector ps_selneg(ps_sel); + + om_bselneg.negative = 1; + ps_selneg.colclip = 2; + + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); + + dev->DrawPrimitive(); + } + } + } + + dev->EndScene(); + + dev->Recycle(rtcopy); + + if(om_dssel.fba) UpdateFBA(rt); + } +#endif + +void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) +{ + switch(m_vt->m_primclass) + { + case GS_POINT_CLASS: + m_topology = GL_POINTS; + break; + case GS_LINE_CLASS: + case GS_SPRITE_CLASS: + m_topology = GL_LINES; + break; + case GS_TRIANGLE_CLASS: + m_topology = GL_TRIANGLES; + break; + default: + __assume(0); + } + + GSDrawingEnvironment& env = m_env; + GSDrawingContext* context = m_context; + + const GSVector2i& rtsize = rt->GetSize(); + const GSVector2& rtscale = rt->GetScale(); + + bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24; + + //OGL GSTexture* rtcopy = NULL; + + ASSERT(m_dev != NULL); + + GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; + + if(DATE) + { + // Note at the moment OGL has always stencil. Rt can be disabled + if(dev->HasStencil()) + { + GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); + GSVector4 o = GSVector4(-1.0f, 1.0f); + + GSVector4 src = ((m_vt->m_min.p.xyxy(m_vt->m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); + GSVector4 dst = src * 2.0f + o.xxxx(); + + GSVertexPT1 vertices[] = + { + {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, + {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, + {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, + {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, + }; + + dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); + } + else + { + //OGL rtcopy = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); + + //OGL // I'll use VertexTrace when I consider it more trustworthy + + //OGL dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); + } + } + + // + + dev->BeginScene(); + + // om + + GSDeviceOGL::OMDepthStencilSelector om_dssel; + + if(context->TEST.ZTE) + { + om_dssel.ztst = context->TEST.ZTST; + om_dssel.zwe = !context->ZBUF.ZMSK; + } + else + { + om_dssel.ztst = ZTST_ALWAYS; + } + + if(m_fba) + { + om_dssel.fba = context->FBA.FBA; + } + + GSDeviceOGL::OMBlendSelector om_bsel; + + if(!IsOpaque()) + { + om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt->m_primclass == GS_LINE_CLASS; + + om_bsel.a = context->ALPHA.A; + om_bsel.b = context->ALPHA.B; + om_bsel.c = context->ALPHA.C; + om_bsel.d = context->ALPHA.D; + + if(env.PABE.PABE) + { + if(om_bsel.a == 0 && om_bsel.b == 1 && om_bsel.c == 0 && om_bsel.d == 1) + { + // this works because with PABE alpha blending is on when alpha >= 0x80, but since the pixel shader + // cannot output anything over 0x80 (== 1.0) blending with 0x80 or turning it off gives the same result + + om_bsel.abe = 0; + } + else + { + //Breath of Fire Dragon Quarter triggers this in battles. Graphics are fine though. + //ASSERT(0); + } + } + } + + om_bsel.wrgba = ~GSVector4i::load((int)context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask(); + + // vs + + GSDeviceOGL::VSSelector vs_sel; + + vs_sel.tme = PRIM->TME; + vs_sel.fst = PRIM->FST; + vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0; + //OGL vs_sel.rtcopy = !!rtcopy; + vs_sel.rtcopy = false; + + // The real GS appears to do no masking based on the Z buffer format and writing larger Z values + // than the buffer supports seems to be an error condition on the real GS, causing it to crash. + // We are probably receiving bad coordinates from VU1 in these cases. + + if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe) + { + if(context->ZBUF.PSM == PSM_PSMZ24) + { + if(m_vt->m_max.p.z > 0xffffff) + { + ASSERT(m_vt->m_min.p.z > 0xffffff); + // Fixme :Following conditional fixes some dialog frame in Wild Arms 3, but may not be what was intended. + if (m_vt->m_min.p.z > 0xffffff) + { + vs_sel.bppz = 1; + om_dssel.ztst = ZTST_ALWAYS; + } + } + } + else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) + { + if(m_vt->m_max.p.z > 0xffff) + { + ASSERT(m_vt->m_min.p.z > 0xffff); // sfex capcom logo + // Fixme : Same as above, I guess. + if (m_vt->m_min.p.z > 0xffff) + { + vs_sel.bppz = 2; + om_dssel.ztst = ZTST_ALWAYS; + } + } + } + } + + // FIXME Opengl support half pixel center (as dx10). Code could be easier!!! + GSDeviceOGL::VSConstantBuffer vs_cb; + + float sx = 2.0f * rtscale.x / (rtsize.x << 4); + float sy = 2.0f * rtscale.y / (rtsize.y << 4); + float ox = (float)(int)context->XYOFFSET.OFX; + float oy = (float)(int)context->XYOFFSET.OFY; + float ox2 = 2.0f * m_pixelcenter.x / rtsize.x; + float oy2 = 2.0f * m_pixelcenter.y / rtsize.y; + + //This hack subtracts around half a pixel from OFX and OFY. (Cannot do this directly, + //because DX10 and DX9 have a different pixel center.) + // + //The resulting shifted output aligns better with common blending / corona / blurring effects, + //but introduces a few bad pixels on the edges. + + if(rt->LikelyOffset) + { + // DX9 has pixelcenter set to 0.0, so give it some value here + + if(m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } + + ox2 *= rt->OffsetHack_modx; + oy2 *= rt->OffsetHack_mody; + } + + vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); + vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); + // END of FIXME + + // gs + + GSDeviceOGL::GSSelector gs_sel; + + gs_sel.iip = PRIM->IIP; + gs_sel.prim = m_vt->m_primclass; + + // ps + + GSDeviceOGL::PSSelector ps_sel; + GSDeviceOGL::PSSamplerSelector ps_ssel; + GSDeviceOGL::PSConstantBuffer ps_cb; + + if(DATE) + { + if(dev->HasStencil()) + { + om_dssel.date = 1; + } + else + { + ps_sel.date = 1 + context->TEST.DATM; + } + } + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + ps_sel.colclip = 1; + } + + ps_sel.clr1 = om_bsel.IsCLR1(); + ps_sel.fba = context->FBA.FBA; + ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0; + + if(UserHacks_AlphaHack) ps_sel.aout = 1; + + if(PRIM->FGE) + { + ps_sel.fog = 1; + + ps_cb.FogColor_AREF = GSVector4::rgba32(env.FOGCOL.u32[0]) / 255; + } + + if(context->TEST.ATE) + { + ps_sel.atst = context->TEST.ATST; + + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + } + else + { + ps_sel.atst = ATST_ALWAYS; + } + + if(tex) + { + ps_sel.wms = context->CLAMP.WMS; + ps_sel.wmt = context->CLAMP.WMT; + ps_sel.fmt = tex->m_fmt; + ps_sel.aem = env.TEXA.AEM; + ps_sel.tfx = context->TEX0.TFX; + ps_sel.tcc = context->TEX0.TCC; + ps_sel.ltf = m_filter == 2 ? m_vt->IsLinear() : m_filter; + ps_sel.rt = tex->m_target; + + int w = tex->m_texture->GetWidth(); + int h = tex->m_texture->GetHeight(); + + int tw = (int)(1 << context->TEX0.TW); + int th = (int)(1 << context->TEX0.TH); + + GSVector4 WH(tw, th, w, h); + + if(PRIM->FST) + { + vs_cb.TextureScale = GSVector4(1.0f / 16) / WH.xyxy(); + //Maybe better? + //vs_cb.TextureScale = GSVector4(1.0f / 16) * GSVector4(tex->m_texture->GetScale()).xyxy() / WH.zwzw(); + ps_sel.fst = 1; + } + + ps_cb.WH = WH; + ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw(); + ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV); + + GSVector4 clamp(ps_cb.MskFix); + GSVector4 ta(env.TEXA & GSVector4i::x000000ff()); + + ps_cb.MinMax = clamp / WH.xyxy(); + ps_cb.MinF_TA = (clamp + 0.5f).xyxy(ta) / WH.xyxy(GSVector4(255, 255)); + + ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; + ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; + ps_ssel.ltf = ps_sel.ltf; + } + else + { + ps_sel.tfx = 4; + } + + // rs + + GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy()); + + dev->OMSetRenderTargets(rt, ds, &scissor); + dev->PSSetShaderResource(0, tex ? tex->m_texture : NULL); + dev->PSSetShaderResource(1, tex ? tex->m_palette : NULL); + //OGL dev->PSSetShaderResource(2, rtcopy); + + uint8 afix = context->ALPHA.FIX; + + dev->SetupOM(om_dssel, om_bsel, afix); + dev->SetupIA(m_vertex.buff, m_vertex.next, m_index.buff, m_index.tail, m_topology); + dev->SetupVS(vs_sel, &vs_cb); + dev->SetupGS(gs_sel); + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); + + // draw + + if(context->TEST.DoFirstPass()) + { + dev->DrawIndexedPrimitive(); + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); + GSDeviceOGL::PSSelector ps_selneg(ps_sel); + + om_bselneg.negative = 1; + ps_selneg.colclip = 2; + + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); + + dev->DrawIndexedPrimitive(); + } + } + + if(context->TEST.DoSecondPass()) + { + ASSERT(!env.PABE.PABE); + + static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; + + ps_sel.atst = iatst[ps_sel.atst]; + + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); + + bool z = om_dssel.zwe; + bool r = om_bsel.wr; + bool g = om_bsel.wg; + bool b = om_bsel.wb; + bool a = om_bsel.wa; + + switch(context->TEST.AFAIL) + { + case 0: z = r = g = b = a = false; break; // none + case 1: z = false; break; // rgba + case 2: r = g = b = a = false; break; // z + case 3: z = a = false; break; // rgb + default: __assume(0); + } + + if(z || r || g || b || a) + { + om_dssel.zwe = z; + om_bsel.wr = r; + om_bsel.wg = g; + om_bsel.wb = b; + om_bsel.wa = a; + + dev->SetupOM(om_dssel, om_bsel, afix); + + dev->DrawIndexedPrimitive(); + + if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + { + GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); + GSDeviceOGL::PSSelector ps_selneg(ps_sel); + + om_bselneg.negative = 1; + ps_selneg.colclip = 2; + + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); + + dev->DrawIndexedPrimitive(); + } + } + } + + dev->EndScene(); + + //OGL dev->Recycle(rtcopy); + + if(om_dssel.fba) UpdateFBA(rt); +} diff --git a/plugins/GSdx/GSRendererOGL.h b/plugins/GSdx/GSRendererOGL.h index 32109a6f5e..62736d5c04 100644 --- a/plugins/GSdx/GSRendererOGL.h +++ b/plugins/GSdx/GSRendererOGL.h @@ -30,7 +30,7 @@ // FIXME does it need a GSVertexHWOGL ??? Data order can be easily programmed on opengl (the only potential // issue is the unsupported praga push/pop // Note it impact GSVertexTrace.cpp => void GSVertexTrace::Update(const GSVertexHWOGL* v, int count, GS_PRIM_CLASS primclass) -class GSRendererOGL : public GSRendererHW +class GSRendererOGL : public GSRendererHW //class GSRendererOGL : public GSRendererHW { private: @@ -42,6 +42,14 @@ class GSRendererOGL : public GSRendererHW protected: GLenum m_topology; + template + void ConvertVertex(size_t dst_index, size_t src_index); + + int GetPosX(const void* vertex) const {return (int)((const GSVertexHW11*)vertex)->p.x;} + int GetPosY(const void* vertex) const {return (int)((const GSVertexHW11*)vertex)->p.y;} + uint32 GetColor(const void* vertex) const {return ((const GSVertexHW11*)vertex)->c0;} + void SetColor(void* vertex, uint32 c) const {((GSVertexHW11*)vertex)->c0 = c;} + public: GSRendererOGL(); virtual ~GSRendererOGL() {}; @@ -52,418 +60,5 @@ class GSRendererOGL : public GSRendererHW void UpdateFBA(GSTexture* rt) {} - void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) - { - - switch(m_vt.m_primclass) - { - case GS_POINT_CLASS: - m_topology = GL_POINTS; - m_perfmon.Put(GSPerfMon::Prim, m_count); - break; - case GS_LINE_CLASS: - case GS_SPRITE_CLASS: - m_topology = GL_LINES; - m_perfmon.Put(GSPerfMon::Prim, m_count / 2); - break; - case GS_TRIANGLE_CLASS: - m_topology = GL_TRIANGLES; - m_perfmon.Put(GSPerfMon::Prim, m_count / 3); - break; - default: - __assume(0); - } - - - GSDrawingEnvironment& env = m_env; - GSDrawingContext* context = m_context; - - const GSVector2i& rtsize = rt->GetSize(); - const GSVector2& rtscale = rt->GetScale(); - - bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24; - - GSTexture *rtcopy = NULL; - - ASSERT(m_dev != NULL); - - GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; - - if(DATE) - { - if(dev->HasStencil()) - { - GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); - GSVector4 o = GSVector4(-1.0f, 1.0f); - - GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); - GSVector4 dst = src * 2.0f + o.xxxx(); - - GSVertexPT1 vertices[] = - { - {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, - {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, - {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, - {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, - }; - - dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); - } - else - { - rtcopy = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); - - // I'll use VertexTrace when I consider it more trustworthy - - dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); - } - } - - // - - dev->BeginScene(); - - // om - - GSDeviceOGL::OMDepthStencilSelector om_dssel; - - if(context->TEST.ZTE) - { - om_dssel.ztst = context->TEST.ZTST; - om_dssel.zwe = !context->ZBUF.ZMSK; - } - else - { - om_dssel.ztst = ZTST_ALWAYS; - } - - if(m_fba) - { - om_dssel.fba = context->FBA.FBA; - } - - GSDeviceOGL::OMBlendSelector om_bsel; - - if(!IsOpaque()) - { - om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS; - - om_bsel.a = context->ALPHA.A; - om_bsel.b = context->ALPHA.B; - om_bsel.c = context->ALPHA.C; - om_bsel.d = context->ALPHA.D; - - if(env.PABE.PABE) - { - if(om_bsel.a == 0 && om_bsel.b == 1 && om_bsel.c == 0 && om_bsel.d == 1) - { - // this works because with PABE alpha blending is on when alpha >= 0x80, but since the pixel shader - // cannot output anything over 0x80 (== 1.0) blending with 0x80 or turning it off gives the same result - - om_bsel.abe = 0; - } - else - { - //Breath of Fire Dragon Quarter triggers this in battles. Graphics are fine though. - //ASSERT(0); - } - } - } - - om_bsel.wrgba = ~GSVector4i::load((int)context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask(); - - // vs - - GSDeviceOGL::VSSelector vs_sel; - - vs_sel.tme = PRIM->TME; - vs_sel.fst = PRIM->FST; - vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0; - vs_sel.rtcopy = !!rtcopy; - - // The real GS appears to do no masking based on the Z buffer format and writing larger Z values - // than the buffer supports seems to be an error condition on the real GS, causing it to crash. - // We are probably receiving bad coordinates from VU1 in these cases. - - if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe) - { - if(context->ZBUF.PSM == PSM_PSMZ24) - { - if(m_vt.m_max.p.z > 0xffffff) - { - ASSERT(m_vt.m_min.p.z > 0xffffff); - // Fixme :Following conditional fixes some dialog frame in Wild Arms 3, but may not be what was intended. - if (m_vt.m_min.p.z > 0xffffff) - { - vs_sel.bppz = 1; - om_dssel.ztst = ZTST_ALWAYS; - } - } - } - else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) - { - if(m_vt.m_max.p.z > 0xffff) - { - ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo - // Fixme : Same as above, I guess. - if (m_vt.m_min.p.z > 0xffff) - { - vs_sel.bppz = 2; - om_dssel.ztst = ZTST_ALWAYS; - } - } - } - } - - // FIXME Opengl support half pixel center (as dx10). Code could be easier!!! - GSDeviceOGL::VSConstantBuffer vs_cb; - - float sx = 2.0f * rtscale.x / (rtsize.x << 4); - float sy = 2.0f * rtscale.y / (rtsize.y << 4); - float ox = (float)(int)context->XYOFFSET.OFX; - float oy = (float)(int)context->XYOFFSET.OFY; - float ox2 = 2.0f * m_pixelcenter.x / rtsize.x; - float oy2 = 2.0f * m_pixelcenter.y / rtsize.y; - - //This hack subtracts around half a pixel from OFX and OFY. (Cannot do this directly, - //because DX10 and DX9 have a different pixel center.) - // - //The resulting shifted output aligns better with common blending / corona / blurring effects, - //but introduces a few bad pixels on the edges. - - if(rt->LikelyOffset) - { - // DX9 has pixelcenter set to 0.0, so give it some value here - - if(m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } - - ox2 *= rt->OffsetHack_modx; - oy2 *= rt->OffsetHack_mody; - } - - vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); - vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); - // END of FIXME - - // gs - - GSDeviceOGL::GSSelector gs_sel; - - gs_sel.iip = PRIM->IIP; - gs_sel.prim = m_vt.m_primclass; - - // ps - - GSDeviceOGL::PSSelector ps_sel; - GSDeviceOGL::PSSamplerSelector ps_ssel; - GSDeviceOGL::PSConstantBuffer ps_cb; - - if(DATE) - { - if(dev->HasStencil()) - { - om_dssel.date = 1; - } - else - { - ps_sel.date = 1 + context->TEST.DATM; - } - } - - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) - { - ps_sel.colclip = 1; - } - - ps_sel.clr1 = om_bsel.IsCLR1(); - ps_sel.fba = context->FBA.FBA; - ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0; - - if(UserHacks_AlphaHack) ps_sel.aout = 1; - - if(PRIM->FGE) - { - ps_sel.fog = 1; - - ps_cb.FogColor_AREF = GSVector4::rgba32(env.FOGCOL.u32[0]) / 255; - } - - if(context->TEST.ATE) - { - ps_sel.atst = context->TEST.ATST; - - switch(ps_sel.atst) - { - case ATST_LESS: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); - break; - case ATST_GREATER: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); - break; - default: - ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; - break; - } - } - else - { - ps_sel.atst = ATST_ALWAYS; - } - - if(tex) - { - ps_sel.wms = context->CLAMP.WMS; - ps_sel.wmt = context->CLAMP.WMT; - ps_sel.fmt = tex->m_fmt; - ps_sel.aem = env.TEXA.AEM; - ps_sel.tfx = context->TEX0.TFX; - ps_sel.tcc = context->TEX0.TCC; - ps_sel.ltf = m_filter == 2 ? m_vt.IsLinear() : m_filter; - ps_sel.rt = tex->m_target; - - int w = tex->m_texture->GetWidth(); - int h = tex->m_texture->GetHeight(); - - int tw = (int)(1 << context->TEX0.TW); - int th = (int)(1 << context->TEX0.TH); - - GSVector4 WH(tw, th, w, h); - - if(PRIM->FST) - { - vs_cb.TextureScale = GSVector4(1.0f / 16) / WH.xyxy(); - //Maybe better? - //vs_cb.TextureScale = GSVector4(1.0f / 16) * GSVector4(tex->m_texture->GetScale()).xyxy() / WH.zwzw(); - ps_sel.fst = 1; - } - - ps_cb.WH = WH; - ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw(); - ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV); - - GSVector4 clamp(ps_cb.MskFix); - GSVector4 ta(env.TEXA & GSVector4i::x000000ff()); - - ps_cb.MinMax = clamp / WH.xyxy(); - ps_cb.MinF_TA = (clamp + 0.5f).xyxy(ta) / WH.xyxy(GSVector4(255, 255)); - - ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; - ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; - ps_ssel.ltf = ps_sel.ltf; - } - else - { - ps_sel.tfx = 4; - } - - // rs - - GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy()); - - dev->OMSetRenderTargets(rt, ds, &scissor); - dev->PSSetShaderResource(0, tex ? tex->m_texture : 0); - dev->PSSetShaderResource(1, tex ? tex->m_palette : 0); - dev->PSSetShaderResource(2, rtcopy); - - uint8 afix = context->ALPHA.FIX; - - dev->SetupOM(om_dssel, om_bsel, afix); - dev->SetupIA(m_vertices, m_count, m_topology); - dev->SetupVS(vs_sel, &vs_cb); - dev->SetupGS(gs_sel); - dev->SetupPS(ps_sel, &ps_cb, ps_ssel); - - // draw - - if(context->TEST.DoFirstPass()) - { - dev->DrawPrimitive(); - - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) - { - GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); - GSDeviceOGL::PSSelector ps_selneg(ps_sel); - - om_bselneg.negative = 1; - ps_selneg.colclip = 2; - - dev->SetupOM(om_dssel, om_bselneg, afix); - dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); - - dev->DrawPrimitive(); - } - } - - if(context->TEST.DoSecondPass()) - { - ASSERT(!env.PABE.PABE); - - static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; - - ps_sel.atst = iatst[ps_sel.atst]; - - switch(ps_sel.atst) - { - case ATST_LESS: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); - break; - case ATST_GREATER: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); - break; - default: - ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; - break; - } - - dev->SetupPS(ps_sel, &ps_cb, ps_ssel); - - bool z = om_dssel.zwe; - bool r = om_bsel.wr; - bool g = om_bsel.wg; - bool b = om_bsel.wb; - bool a = om_bsel.wa; - - switch(context->TEST.AFAIL) - { - case 0: z = r = g = b = a = false; break; // none - case 1: z = false; break; // rgba - case 2: r = g = b = a = false; break; // z - case 3: z = a = false; break; // rgb - default: __assume(0); - } - - if(z || r || g || b || a) - { - om_dssel.zwe = z; - om_bsel.wr = r; - om_bsel.wg = g; - om_bsel.wb = b; - om_bsel.wa = a; - - dev->SetupOM(om_dssel, om_bsel, afix); - - dev->DrawPrimitive(); - - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) - { - GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); - GSDeviceOGL::PSSelector ps_selneg(ps_sel); - - om_bselneg.negative = 1; - ps_selneg.colclip = 2; - - dev->SetupOM(om_dssel, om_bselneg, afix); - dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); - - dev->DrawPrimitive(); - } - } - } - - dev->EndScene(); - - dev->Recycle(rtcopy); - - if(om_dssel.fba) UpdateFBA(rt); - } + void DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); }; diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 0e61c2b7bc..5616a72078 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -75,10 +75,11 @@ void GSDeviceOGL::CreateTextureFX() m_vb = new GSVertexBufferStateOGL(sizeof(GSVertexHW11), vert_format, countof(vert_format)); } -void GSDeviceOGL::SetupIA(const void* vertices, int count, GLenum prim) +void GSDeviceOGL::SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim) { IASetVertexState(m_vb); - IASetVertexBuffer(vertices, count); + IASetVertexBuffer(vertex, vertex_count); + IASetIndexBuffer(index, index_count); IASetPrimitiveTopology(prim); } diff --git a/plugins/GSdx/linux_replay.cpp b/plugins/GSdx/linux_replay.cpp index f2d25ab8c9..0de8a06825 100644 --- a/plugins/GSdx/linux_replay.cpp +++ b/plugins/GSdx/linux_replay.cpp @@ -37,5 +37,5 @@ int main ( int argc, char *argv[] ) if ( argc != 3 ) help(); GSsetSettingsDir(argv[1]); - GSReplay(argv[2], 12); + GSReplay(argv[2], 15); } From e0004b5027b0d8e340453603e65d63a475678245 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 15 Jan 2012 18:11:48 +0000 Subject: [PATCH 47/56] gsdx-ogl: linux only * Was easy, I forgot to set the type of the buffer. * align shader change too git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5071 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.h | 16 +++++++++------- plugins/GSdx/res/tfx.glsl | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 474eb37aec..873cc20479 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -313,7 +313,7 @@ class GSVertexBufferStateOGL { { m_start = 0; m_limit = new_limit; - glBufferData(GL_ARRAY_BUFFER, m_limit * m_stride, NULL, GL_STREAM_DRAW); + glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW); } void bind() @@ -383,6 +383,11 @@ class GSVertexBufferStateOGL { size_t GetStart() { return m_start; } + void debug() + { + fprintf(stderr, "data buffer: start %d, count %d\n", m_start, m_count); + } + } *m_vb, *m_ib; GLuint m_va; @@ -504,27 +509,24 @@ public: void debug() { - uint32 element = 0; string topo; switch (m_topology) { case GL_POINTS: - //element = m_count; topo = "point"; break; case GL_LINES: - //element = m_count/2; topo = "line"; break; case GL_TRIANGLES: - //element = m_count/3; topo = "triangle"; break; case GL_TRIANGLE_STRIP: - //element = m_count - 2; topo = "triangle strip"; break; } - fprintf(stderr, "%d primitives of %s\n", element, topo.c_str()); + m_vb->debug(); + m_ib->debug(); + fprintf(stderr, "primitives of %s\n", topo.c_str()); } }; diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index e836be3c29..7eb9f7330f 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -117,7 +117,7 @@ void vs_main() } VSout.c = i_c; - VSout.t.z = i_f.a; + VSout.t.z = i_f.r; } #endif From 6680d285eac378012de3e252f2744143f43aedd1 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Tue, 31 Jan 2012 17:08:05 +0000 Subject: [PATCH 48/56] gsdx-ogl: linux only * implement some missing shader for DATE, invert coordinate like strech rectangle * Use glCopyImageSubDataNV nvidia extension to copy image (you need latest AMD drivers) git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5086 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 2 +- plugins/GSdx/GS.cpp | 6 +- plugins/GSdx/GSDeviceOGL.cpp | 57 +-- plugins/GSdx/GSDeviceOGL.h | 33 +- plugins/GSdx/GSRendererOGL.cpp | 609 +-------------------------------- plugins/GSdx/GSTextureOGL.cpp | 10 +- plugins/GSdx/GSTextureOGL.h | 2 + plugins/GSdx/res/convert.glsl | 61 +--- plugins/GSdx/res/tfx.glsl | 2 +- 9 files changed, 68 insertions(+), 714 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index fb428260a6..d89ed12b76 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -19,7 +19,7 @@ set(CommonFlags -std=c++0x -fno-strict-aliasing -DOGL_DEBUG # FIXME remove me when code is ready - -DAMD_DRIVER_WORKAROUND + -DAMD_DRIVER_WORKAROUND ) set(OptimizationFlags diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 5d968ab8e5..d16e1af9ef 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1360,8 +1360,8 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) //while(IsWindowVisible(hWnd)) //FIXME map? - bool finished = false; - while(!finished) + int finished = 2; + while(finished > 0) { unsigned long start = timeGetTime(); unsigned long frame_number = 0; @@ -1410,7 +1410,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); sleep(1); - finished = true; + finished--; } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index fe7756d796..2d7ef96c53 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -26,7 +26,7 @@ //#define ONLY_LINES // It seems dual blending does not work on AMD !!! -#define DISABLE_DUAL_BLEND +//#define DISABLE_DUAL_BLEND static uint32 g_draw_count = 0; static uint32 g_frame_count = 1; @@ -49,6 +49,10 @@ GSDeviceOGL::GSDeviceOGL() memset(&m_convert, 0, sizeof(m_convert)); memset(&m_date, 0, sizeof(m_date)); memset(&m_state, 0, sizeof(m_state)); + + // Reset the debug file + FILE* f = fopen("Debug.txt","w"); + fclose(f); } GSDeviceOGL::~GSDeviceOGL() @@ -522,7 +526,11 @@ void GSDeviceOGL::DebugOutput() if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; if ( dump_me ) { - if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d.bmp", g_frame_count, g_draw_count)); + if (m_state.rtv == m_backbuffer) { + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d__back.bmp", g_frame_count, g_draw_count)); + } else { + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d__tex.bmp", g_frame_count, g_draw_count)); + } //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); fprintf(stderr, "\n"); @@ -689,6 +697,18 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) // GL_NV_copy_image seem like the good extension but not supported on AMD... // Maybe opengl 4.3 ! // FIXME check those function work as expected + // FIXME: it is an NVIDIA extension. Hopefully lastest AMD driver support it too. + // An EXT extensions might be release later. + // void CopyImageSubDataNV( + // uint srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ, + // uint dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ, + // sizei width, sizei height, sizei depth); + glCopyImageSubDataNV( static_cast(st)->GetID(), GL_TEXTURE_2D, + 0, r.x, r.y, 0, + static_cast(dt)->GetID(), GL_TEXTURE_2D, + 0, r.x, r.y, 0, + r.width(), r.height(), 1); +#if 0 // FIXME FBO GLuint fbo_old = m_state.fbo; @@ -703,24 +723,8 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, dt->GetWidth(), dt->GetHeight()); OMSetFBO(fbo_old); - -#if 0 - // FIXME attach the texture to the FBO - GSTextureOGL* st_ogl = (GSTextureOGL*) st; - GSTextureOGL* dt_ogl = (GSTextureOGL*) dt; - dt_ogl->Attach(GL_COLOR_ATTACHMENT0); - st_ogl->Attach(GL_COLOR_ATTACHMENT1); - - glReadBuffer(GL_COLOR_ATTACHMENT1); - // FIXME I'not sure how to select the destination - // const GLenum draw_buffer[1] = { GL_COLOR_ATTACHMENT0 }; - // glDrawBuffers(draw_buffer); - dt_ogl->EnableUnit(0); - // FIXME need acess of target and it probably need to be same for both - //glCopyTexSubImage2D(dt_ogl.m_texture_target, 0, 0, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom); - // FIXME I'm not sure GL_TEXTURE_RECTANGLE is supported!!! - //glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, r.left, r.bottom, r.right-r.left, r.top-r.bottom); #endif + #if 0 D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, 0, 0, 0, *(GSTexture11*)st, 0, &box); @@ -790,6 +794,8 @@ void GSDeviceOGL::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, {GSVector4(left, top, 0.5f, 1.0f), GSVector2(flip_sr.x, flip_sr.w)}, {GSVector4(right, top, 0.5f, 1.0f), GSVector2(flip_sr.z, flip_sr.w)}, }; + //fprintf(stderr, "A:%fx%f B:%fx%f\n", left, top, bottom, right); + //fprintf(stderr, "SR: %f %f %f %f\n", sr.x, sr.y, sr.z, sr.w); IASetVertexState(m_vb_sr); IASetVertexBuffer(vertices, 4); @@ -871,8 +877,6 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm) { - assert(0); - const GSVector2i& size = rt->GetSize(); if(GSTexture* t = CreateRenderTarget(size.x, size.y, rt->IsMSAA())) @@ -1009,7 +1013,7 @@ void GSDeviceOGL::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) { PSSetShaderResource(0, sr0); PSSetShaderResource(1, sr1); - PSSetShaderResource(2, NULL); + //PSSetShaderResource(2, NULL); } void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr) @@ -1026,11 +1030,12 @@ void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr) void GSDeviceOGL::PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2) { - if(m_state.ps_ss[0] != ss0 || m_state.ps_ss[1] != ss1 || m_state.ps_ss[2] != ss2) + if(m_state.ps_ss[0] != ss0 || m_state.ps_ss[1] != ss1) + //if(m_state.ps_ss[0] != ss0 || m_state.ps_ss[1] != ss1 || m_state.ps_ss[2] != ss2) { m_state.ps_ss[0] = ss0; m_state.ps_ss[1] = ss1; - m_state.ps_ss[2] = ss2; + //m_state.ps_ss[2] = ss2; m_ss_changed = true; } @@ -1054,7 +1059,7 @@ void GSDeviceOGL::PSSetShader(GLuint ps) // 4/ set the sampler state // glBindSampler(1 , sampler); if (m_srv_changed || m_ss_changed) { - for (uint i=0 ; i < 3; i++) { + for (uint i=0 ; i < 1; i++) { if (m_state.ps_srv[i] != NULL) { m_state.ps_srv[i]->EnableUnit(i); glBindSampler(i, m_state.ps_ss[i]); @@ -1129,14 +1134,12 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto static_cast(ds)->Attach(GL_DEPTH_STENCIL_ATTACHMENT); } - // Viewport -> glViewport if(m_state.viewport != rt->GetSize()) { m_state.viewport = rt->GetSize(); glViewport(0, 0, rt->GetWidth(), rt->GetHeight()); } - // Scissor -> glScissor (note must be enabled) GSVector4i r = scissor ? *scissor : GSVector4i(rt->GetSize()).zwxy(); if(!m_state.scissor.eq(r)) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 873cc20479..21121f7403 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -801,20 +801,17 @@ class GSDeviceOGL : public GSDevice GSBlendStateOGL* bs; } m_convert; - struct - { + struct { GLuint ps; GSUniformBufferOGL *cb; } m_fxaa; - struct - { + struct { GSDepthStencilOGL* dss; GSBlendStateOGL* bs; } m_date; - struct - { + struct { GSVertexBufferStateOGL* vb; GLuint vs; // program GSUniformBufferOGL* cb; // uniform current buffer @@ -841,26 +838,6 @@ class GSDeviceOGL : public GSDevice bool m_srv_changed; bool m_ss_changed; -#if 0 - CComPtr m_dev; - CComPtr m_ctx; - CComPtr m_swapchain; - - CComPtr m_rs; - - - // Shaders... - - CComPtr m_palette_ss; - CComPtr m_rt_ss; - -#endif - // hash_map m_vs; - // hash_map > m_gs; - // hash_map > m_ps; - // hash_map > m_ps_ss; - // hash_map > m_om_dss; - // hash_map > m_om_bs; hash_map m_vs; hash_map m_gs; hash_map m_ps; @@ -868,13 +845,9 @@ class GSDeviceOGL : public GSDevice hash_map m_om_dss; hash_map m_om_bs; - //CComPtr m_palette_ss; - //CComPtr m_rt_ss; GLuint m_palette_ss; GLuint m_rt_ss; - //CComPtr m_vs_cb; - //CComPtr m_ps_cb; GSUniformBufferOGL* m_vs_cb; GSUniformBufferOGL* m_ps_cb; diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 5686d8555d..1a86704ff2 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -24,9 +24,6 @@ GSRendererOGL::GSRendererOGL() - // FIXME - //: GSRendererHW(new GSTextureCacheOGL(this)) - //: GSRendererHW(new GSTextureCacheOGL(this)) : GSRendererHW(new GSVertexTraceDX11(this), sizeof(GSVertexHW11), new GSTextureCacheOGL(this)) , m_topology(0) { @@ -35,8 +32,6 @@ GSRendererOGL::GSRendererOGL() UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0); m_pixelcenter = GSVector2(-0.5f, -0.5f); - // TODO must be implementer with macro InitVertexKick(GSRendererOGL) - // template void VertexKick(bool skip); InitConvertVertex(GSRendererOGL); } @@ -68,600 +63,6 @@ void GSRendererOGL::ConvertVertex(size_t dst_index, size_t src_index) ((GSVector4i*)d)[1] = v1; } -#if 0 -template -void GSRendererOGL::VertexKick(bool skip) -{ - GSVertexHW11& dst = m_vl.AddTail(); - - dst = *(GSVertexHW11*)&m_v; - -#ifdef ENABLE_UPSCALE_HACKS - - if(tme && fst) - { - //GSVector4::storel(&dst.ST, m_v.GetUV()); - - int Udiff = 0; - int Vdiff = 0; - int Uadjust = 0; - int Vadjust = 0; - - int multiplier = GetUpscaleMultiplier(); - - if(multiplier > 1) - { - Udiff = m_v.UV.U & 4095; - Vdiff = m_v.UV.V & 4095; - - if(Udiff != 0) - { - if (Udiff >= 4080) {/*printf("U+ %d %d\n", Udiff, m_v.UV.U);*/ Uadjust = -1; } - else if (Udiff <= 16) {/*printf("U- %d %d\n", Udiff, m_v.UV.U);*/ Uadjust = 1; } - } - - if(Vdiff != 0) - { - if (Vdiff >= 4080) {/*printf("V+ %d %d\n", Vdiff, m_v.UV.V);*/ Vadjust = -1; } - else if (Vdiff <= 16) {/*printf("V- %d %d\n", Vdiff, m_v.UV.V);*/ Vadjust = 1; } - } - - Udiff = m_v.UV.U & 255; - Vdiff = m_v.UV.V & 255; - - if(Udiff != 0) - { - if (Udiff >= 248) { Uadjust = -1; } - else if (Udiff <= 8) { Uadjust = 1; } - } - - if(Vdiff != 0) - { - if (Vdiff >= 248) { Vadjust = -1; } - else if (Vdiff <= 8) { Vadjust = 1; } - } - - Udiff = m_v.UV.U & 15; - Vdiff = m_v.UV.V & 15; - - if(Udiff != 0) - { - if (Udiff >= 15) { Uadjust = -1; } - else if (Udiff <= 1) { Uadjust = 1; } - } - - if(Vdiff != 0) - { - if (Vdiff >= 15) { Vadjust = -1; } - else if (Vdiff <= 1) { Vadjust = 1; } - } - } - - dst.ST.S = (float)m_v.UV.U - Uadjust; - dst.ST.T = (float)m_v.UV.V - Vadjust; - } - else if(tme) - { - // Wip :p - //dst.XYZ.X += 5; - //dst.XYZ.Y += 5; - } - -#else - - if(tme && fst) - { - GSVector4::storel(&dst.ST, m_v.GetUV()); - } - -#endif - - int count = 0; - - if(GSVertexHW11* v = DrawingKick(skip, count)) - { - GSVector4i scissor = m_context->scissor.dx10; - - GSVector4i pmin, pmax; - - #if _M_SSE >= 0x401 - - GSVector4i v0, v1, v2; - - switch(prim) - { - case GS_POINTLIST: - v0 = GSVector4i::load((int)v[0].p.xy).upl16(); - pmin = v0; - pmax = v0; - break; - case GS_LINELIST: - case GS_LINESTRIP: - case GS_SPRITE: - v0 = GSVector4i::load((int)v[0].p.xy); - v1 = GSVector4i::load((int)v[1].p.xy); - pmin = v0.min_u16(v1).upl16(); - pmax = v0.max_u16(v1).upl16(); - break; - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: - v0 = GSVector4i::load((int)v[0].p.xy); - v1 = GSVector4i::load((int)v[1].p.xy); - v2 = GSVector4i::load((int)v[2].p.xy); - pmin = v0.min_u16(v1).min_u16(v2).upl16(); - pmax = v0.max_u16(v1).max_u16(v2).upl16(); - break; - } - - #else - - switch(prim) - { - case GS_POINTLIST: - pmin.x = v[0].p.x; - pmin.y = v[0].p.y; - pmax.x = v[0].p.x; - pmax.y = v[0].p.y; - break; - case GS_LINELIST: - case GS_LINESTRIP: - case GS_SPRITE: - pmin.x = std::min(v[0].p.x, v[1].p.x); - pmin.y = std::min(v[0].p.y, v[1].p.y); - pmax.x = std::max(v[0].p.x, v[1].p.x); - pmax.y = std::max(v[0].p.y, v[1].p.y); - break; - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: - pmin.x = std::min(std::min(v[0].p.x, v[1].p.x), v[2].p.x); - pmin.y = std::min(std::min(v[0].p.y, v[1].p.y), v[2].p.y); - pmax.x = std::max(std::max(v[0].p.x, v[1].p.x), v[2].p.x); - pmax.y = std::max(std::max(v[0].p.y, v[1].p.y), v[2].p.y); - break; - } - - #endif - - GSVector4i test = (pmax < scissor) | (pmin > scissor.zwxy()); - - switch(prim) - { - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: - case GS_SPRITE: - test |= pmin == pmax; - break; - } - - if(test.mask() & 0xff) - { - return; - } - - m_count += count; - } -} -#endif - -#if 0 - { - - switch(m_vt.m_primclass) - { - case GS_POINT_CLASS: - m_topology = GL_POINTS; - m_perfmon.Put(GSPerfMon::Prim, m_count); - break; - case GS_LINE_CLASS: - case GS_SPRITE_CLASS: - m_topology = GL_LINES; - m_perfmon.Put(GSPerfMon::Prim, m_count / 2); - break; - case GS_TRIANGLE_CLASS: - m_topology = GL_TRIANGLES; - m_perfmon.Put(GSPerfMon::Prim, m_count / 3); - break; - default: - __assume(0); - } - - - GSDrawingEnvironment& env = m_env; - GSDrawingContext* context = m_context; - - const GSVector2i& rtsize = rt->GetSize(); - const GSVector2& rtscale = rt->GetScale(); - - bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24; - - GSTexture *rtcopy = NULL; - - ASSERT(m_dev != NULL); - - GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; - - if(DATE) - { - if(dev->HasStencil()) - { - GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); - GSVector4 o = GSVector4(-1.0f, 1.0f); - - GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); - GSVector4 dst = src * 2.0f + o.xxxx(); - - GSVertexPT1 vertices[] = - { - {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, - {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, - {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, - {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, - }; - - dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); - } - else - { - rtcopy = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); - - // I'll use VertexTrace when I consider it more trustworthy - - dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); - } - } - - // - - dev->BeginScene(); - - // om - - GSDeviceOGL::OMDepthStencilSelector om_dssel; - - if(context->TEST.ZTE) - { - om_dssel.ztst = context->TEST.ZTST; - om_dssel.zwe = !context->ZBUF.ZMSK; - } - else - { - om_dssel.ztst = ZTST_ALWAYS; - } - - if(m_fba) - { - om_dssel.fba = context->FBA.FBA; - } - - GSDeviceOGL::OMBlendSelector om_bsel; - - if(!IsOpaque()) - { - om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS; - - om_bsel.a = context->ALPHA.A; - om_bsel.b = context->ALPHA.B; - om_bsel.c = context->ALPHA.C; - om_bsel.d = context->ALPHA.D; - - if(env.PABE.PABE) - { - if(om_bsel.a == 0 && om_bsel.b == 1 && om_bsel.c == 0 && om_bsel.d == 1) - { - // this works because with PABE alpha blending is on when alpha >= 0x80, but since the pixel shader - // cannot output anything over 0x80 (== 1.0) blending with 0x80 or turning it off gives the same result - - om_bsel.abe = 0; - } - else - { - //Breath of Fire Dragon Quarter triggers this in battles. Graphics are fine though. - //ASSERT(0); - } - } - } - - om_bsel.wrgba = ~GSVector4i::load((int)context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask(); - - // vs - - GSDeviceOGL::VSSelector vs_sel; - - vs_sel.tme = PRIM->TME; - vs_sel.fst = PRIM->FST; - vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0; - vs_sel.rtcopy = !!rtcopy; - - // The real GS appears to do no masking based on the Z buffer format and writing larger Z values - // than the buffer supports seems to be an error condition on the real GS, causing it to crash. - // We are probably receiving bad coordinates from VU1 in these cases. - - if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe) - { - if(context->ZBUF.PSM == PSM_PSMZ24) - { - if(m_vt.m_max.p.z > 0xffffff) - { - ASSERT(m_vt.m_min.p.z > 0xffffff); - // Fixme :Following conditional fixes some dialog frame in Wild Arms 3, but may not be what was intended. - if (m_vt.m_min.p.z > 0xffffff) - { - vs_sel.bppz = 1; - om_dssel.ztst = ZTST_ALWAYS; - } - } - } - else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) - { - if(m_vt.m_max.p.z > 0xffff) - { - ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo - // Fixme : Same as above, I guess. - if (m_vt.m_min.p.z > 0xffff) - { - vs_sel.bppz = 2; - om_dssel.ztst = ZTST_ALWAYS; - } - } - } - } - - // FIXME Opengl support half pixel center (as dx10). Code could be easier!!! - GSDeviceOGL::VSConstantBuffer vs_cb; - - float sx = 2.0f * rtscale.x / (rtsize.x << 4); - float sy = 2.0f * rtscale.y / (rtsize.y << 4); - float ox = (float)(int)context->XYOFFSET.OFX; - float oy = (float)(int)context->XYOFFSET.OFY; - float ox2 = 2.0f * m_pixelcenter.x / rtsize.x; - float oy2 = 2.0f * m_pixelcenter.y / rtsize.y; - - //This hack subtracts around half a pixel from OFX and OFY. (Cannot do this directly, - //because DX10 and DX9 have a different pixel center.) - // - //The resulting shifted output aligns better with common blending / corona / blurring effects, - //but introduces a few bad pixels on the edges. - - if(rt->LikelyOffset) - { - // DX9 has pixelcenter set to 0.0, so give it some value here - - if(m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } - - ox2 *= rt->OffsetHack_modx; - oy2 *= rt->OffsetHack_mody; - } - - vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); - vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); - // END of FIXME - - // gs - - GSDeviceOGL::GSSelector gs_sel; - - gs_sel.iip = PRIM->IIP; - gs_sel.prim = m_vt.m_primclass; - - // ps - - GSDeviceOGL::PSSelector ps_sel; - GSDeviceOGL::PSSamplerSelector ps_ssel; - GSDeviceOGL::PSConstantBuffer ps_cb; - - if(DATE) - { - if(dev->HasStencil()) - { - om_dssel.date = 1; - } - else - { - ps_sel.date = 1 + context->TEST.DATM; - } - } - - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) - { - ps_sel.colclip = 1; - } - - ps_sel.clr1 = om_bsel.IsCLR1(); - ps_sel.fba = context->FBA.FBA; - ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0; - - if(UserHacks_AlphaHack) ps_sel.aout = 1; - - if(PRIM->FGE) - { - ps_sel.fog = 1; - - ps_cb.FogColor_AREF = GSVector4::rgba32(env.FOGCOL.u32[0]) / 255; - } - - if(context->TEST.ATE) - { - ps_sel.atst = context->TEST.ATST; - - switch(ps_sel.atst) - { - case ATST_LESS: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); - break; - case ATST_GREATER: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); - break; - default: - ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; - break; - } - } - else - { - ps_sel.atst = ATST_ALWAYS; - } - - if(tex) - { - ps_sel.wms = context->CLAMP.WMS; - ps_sel.wmt = context->CLAMP.WMT; - ps_sel.fmt = tex->m_fmt; - ps_sel.aem = env.TEXA.AEM; - ps_sel.tfx = context->TEX0.TFX; - ps_sel.tcc = context->TEX0.TCC; - ps_sel.ltf = m_filter == 2 ? m_vt.IsLinear() : m_filter; - ps_sel.rt = tex->m_target; - - int w = tex->m_texture->GetWidth(); - int h = tex->m_texture->GetHeight(); - - int tw = (int)(1 << context->TEX0.TW); - int th = (int)(1 << context->TEX0.TH); - - GSVector4 WH(tw, th, w, h); - - if(PRIM->FST) - { - vs_cb.TextureScale = GSVector4(1.0f / 16) / WH.xyxy(); - //Maybe better? - //vs_cb.TextureScale = GSVector4(1.0f / 16) * GSVector4(tex->m_texture->GetScale()).xyxy() / WH.zwzw(); - ps_sel.fst = 1; - } - - ps_cb.WH = WH; - ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw(); - ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV); - - GSVector4 clamp(ps_cb.MskFix); - GSVector4 ta(env.TEXA & GSVector4i::x000000ff()); - - ps_cb.MinMax = clamp / WH.xyxy(); - ps_cb.MinF_TA = (clamp + 0.5f).xyxy(ta) / WH.xyxy(GSVector4(255, 255)); - - ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; - ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; - ps_ssel.ltf = ps_sel.ltf; - } - else - { - ps_sel.tfx = 4; - } - - // rs - - GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy()); - - dev->OMSetRenderTargets(rt, ds, &scissor); - dev->PSSetShaderResource(0, tex ? tex->m_texture : 0); - dev->PSSetShaderResource(1, tex ? tex->m_palette : 0); - dev->PSSetShaderResource(2, rtcopy); - - uint8 afix = context->ALPHA.FIX; - - dev->SetupOM(om_dssel, om_bsel, afix); - dev->SetupIA(m_vertices, m_count, m_topology); - dev->SetupVS(vs_sel, &vs_cb); - dev->SetupGS(gs_sel); - dev->SetupPS(ps_sel, &ps_cb, ps_ssel); - - // draw - - if(context->TEST.DoFirstPass()) - { - dev->DrawPrimitive(); - - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) - { - GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); - GSDeviceOGL::PSSelector ps_selneg(ps_sel); - - om_bselneg.negative = 1; - ps_selneg.colclip = 2; - - dev->SetupOM(om_dssel, om_bselneg, afix); - dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); - - dev->DrawPrimitive(); - } - } - - if(context->TEST.DoSecondPass()) - { - ASSERT(!env.PABE.PABE); - - static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; - - ps_sel.atst = iatst[ps_sel.atst]; - - switch(ps_sel.atst) - { - case ATST_LESS: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); - break; - case ATST_GREATER: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); - break; - default: - ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; - break; - } - - dev->SetupPS(ps_sel, &ps_cb, ps_ssel); - - bool z = om_dssel.zwe; - bool r = om_bsel.wr; - bool g = om_bsel.wg; - bool b = om_bsel.wb; - bool a = om_bsel.wa; - - switch(context->TEST.AFAIL) - { - case 0: z = r = g = b = a = false; break; // none - case 1: z = false; break; // rgba - case 2: r = g = b = a = false; break; // z - case 3: z = a = false; break; // rgb - default: __assume(0); - } - - if(z || r || g || b || a) - { - om_dssel.zwe = z; - om_bsel.wr = r; - om_bsel.wg = g; - om_bsel.wb = b; - om_bsel.wa = a; - - dev->SetupOM(om_dssel, om_bsel, afix); - - dev->DrawPrimitive(); - - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) - { - GSDeviceOGL::OMBlendSelector om_bselneg(om_bsel); - GSDeviceOGL::PSSelector ps_selneg(ps_sel); - - om_bselneg.negative = 1; - ps_selneg.colclip = 2; - - dev->SetupOM(om_dssel, om_bselneg, afix); - dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); - - dev->DrawPrimitive(); - } - } - } - - dev->EndScene(); - - dev->Recycle(rtcopy); - - if(om_dssel.fba) UpdateFBA(rt); - } -#endif - void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) { switch(m_vt->m_primclass) @@ -707,11 +108,21 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour GSVertexPT1 vertices[] = { +#if 0 {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, +#else + {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.y)}, + {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.y)}, + {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.w)}, + {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.w)}, +#endif }; + //fprintf(stderr, "DATE A:%fx%f B:%fx%f\n", dst.x, -dst.y, dst.z, -dst.w); + //fprintf(stderr, "DATE SR: %f %f %f %f\n", src.x, src.y, src.z, src.w); + //fprintf(stderr, "DATE offset: %f\n", o.x); dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); } diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index f7ff075ccc..d26c1d3f0d 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -93,7 +93,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // Allocate the buffer switch (m_type) { case GSTexture::DepthStencil: - EnableUnit(1); + EnableUnit(2); glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); break; case GSTexture::RenderTarget: @@ -102,7 +102,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // Howto allocate the texture unit !!! // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother - EnableUnit(0); + EnableUnit(2); if (m_format == GL_RGBA8) { glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); } @@ -140,7 +140,7 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // FIXME warning order of the y axis // FIXME I'm not confident with GL_UNSIGNED_BYTE type - EnableUnit(0); + EnableUnit(2); if (m_format != GL_RGBA8) { fprintf(stderr, "wrong pixel format\n"); @@ -368,12 +368,12 @@ bool GSTextureOGL::Save(const string& fn, bool dds) glReadBuffer(GL_BACK); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); } else if(IsDss()) { - EnableUnit(1); + EnableUnit(2); glGetTexImage(m_texture_target, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image); } else { glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); - EnableUnit(1); + EnableUnit(2); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, m_texture_target, m_texture_id, 0); glReadBuffer(GL_COLOR_ATTACHMENT1); diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 3842842b15..657d922435 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -47,4 +47,6 @@ class GSTextureOGL : public GSTexture bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); } bool IsDss() { return (m_type == GSTexture::DepthStencil); } + + GLuint GetID() { return m_texture_id; } }; diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 4cb6e2c63c..11fb55a058 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -141,62 +141,27 @@ void ps_main6() // diagonal SV_Target0 = c; } -// Avoid to log useless error compilation failure void ps_main2() { + if((sample_c().a - 128.0f / 255) < 0) // >= 0x80 pass + discard; + + SV_Target0 = vec4(0.0f, 0.0f, 0.0f, 0.0f); } void ps_main3() { + if((127.95f / 255 - sample_c().a) <0) // < 0x80 pass (== 0x80 should not pass) + discard; + + SV_Target0 = vec4(0.0f, 0.0f, 0.0f, 0.0f); } void ps_main4() { + // FIXME mod and fmod are different when value are negative + // output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255; + vec4 c = mod(sample_c() * 255 + 0.5f, 256) / 255; + + SV_Target0 = c; } - -// Texture2D Texture; -// SamplerState TextureSampler; -// -// uint ps_main1(PS_INPUT input) : SV_Target0 -// { -// float4 c = sample_c(input.t); -// -// c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 -// -// uint4 i = c * float4(0x001f, 0x03e0, 0x7c00, 0x8000); -// -// return (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); -// } -// -// PS_OUTPUT ps_main2(PS_INPUT input) -// { -// PS_OUTPUT output; -// -// clip(sample_c(input.t).a - 128.0f / 255); // >= 0x80 pass -// -// output.c = 0; -// -// return output; -// } -// -// PS_OUTPUT ps_main3(PS_INPUT input) -// { -// PS_OUTPUT output; -// -// clip(127.95f / 255 - sample_c(input.t).a); // < 0x80 pass (== 0x80 should not pass) -// -// output.c = 0; -// -// return output; -// } -// -// PS_OUTPUT ps_main4(PS_INPUT input) -// { -// PS_OUTPUT output; -// -// output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255; -// -// return output; -// } -// - #endif diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 7eb9f7330f..892af3178e 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -637,9 +637,9 @@ void ps_main() if(c.a < 0.5) c.a += 0.5; } + SV_Target1 = c; #ifndef DISABLE_DUAL_BLEND SV_Target0 = vec4(alpha, alpha, alpha, alpha); #endif - SV_Target1 = c; } #endif From 92f2ab38ae287f1bb9a58bd41010dd6a85499675 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 11 Feb 2012 10:22:02 +0000 Subject: [PATCH 49/56] GSdx-ogl: LINUX only * Use the new map interface/separate texture coordinate inside shader * support new format on texture Note: it is quite instable with various crashes and GL error but at least it compiles now :p git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5094 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GS.cpp | 14 ++++- plugins/GSdx/GSDeviceOGL.cpp | 47 ++++++++++++-- plugins/GSdx/GSDeviceOGL.h | 99 +++++++++++------------------- plugins/GSdx/GSLinuxDialog.cpp | 8 +-- plugins/GSdx/GSRendererOGL.cpp | 69 +++++++++++---------- plugins/GSdx/GSRendererOGL.h | 12 +--- plugins/GSdx/GSTextureCacheOGL.cpp | 1 + plugins/GSdx/GSTextureCacheOGL.h | 2 +- plugins/GSdx/GSTextureFXOGL.cpp | 25 +++----- plugins/GSdx/GSTextureOGL.cpp | 42 +++++++++---- plugins/GSdx/GSThread.h | 2 + plugins/GSdx/res/tfx.glsl | 11 ++-- 12 files changed, 180 insertions(+), 152 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 582556ae8e..8c448348fc 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -246,7 +246,7 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1) case 2: dev = new GSDeviceSDL(); break; #endif case 3: dev = new GSDeviceNull(); break; - case 5: dev = new GSDeviceOGL(); break; + case 4: dev = new GSDeviceOGL(); break; } if(dev == NULL) @@ -429,11 +429,15 @@ EXPORT_C GSreadFIFO(uint8* mem) #ifdef _LINUX // FIXME: double check which thread call this function // See fifo2 issue below - if (theApp.GetConfig("renderer", 0) == 12) { + if (theApp.GetConfig("renderer", 0) / 3 == 4) { fprintf(stderr, "Disable FIFO1 on opengl\n"); } #endif + s_gs->m_wnd.AttachContext(); + s_gs->ReadFIFO(mem, 1); + + s_gs->m_wnd.DetachContext(); } EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) @@ -441,14 +445,18 @@ EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) #ifdef _LINUX // FIXME called from EE core thread not MTGS which cause // invalidate data for opengl - if (theApp.GetConfig("renderer", 0) == 12) { + if (theApp.GetConfig("renderer", 0) / 3 == 4) { #ifdef OGL_DEBUG fprintf(stderr, "Disable FIFO2(%d) on opengl\n", size); #endif //return; } #endif + s_gs->m_wnd.AttachContext(); + s_gs->ReadFIFO(mem, size); + + s_gs->m_wnd.DetachContext(); } EXPORT_C GSgifTransfer(const uint8* mem, uint32 size) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 2d7ef96c53..63a5078d41 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -536,6 +536,7 @@ void GSDeviceOGL::DebugOutput() fprintf(stderr, "\n"); } + CheckDebugLog(); } void GSDeviceOGL::DrawPrimitive() @@ -566,6 +567,20 @@ void GSDeviceOGL::DrawIndexedPrimitive() #endif } +void GSDeviceOGL::DrawIndexedPrimitive(int offset, int count) +{ + ASSERT(offset + count <= m_index.count); +#ifdef OGL_DEBUG + DebugInput(); +#endif + + m_state.vb->DrawIndexedPrimitive(offset, count); +#ifdef OGL_DEBUG + DebugOutput(); + g_draw_count++; +#endif +} + void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) { GLuint fbo_old = m_state.fbo; @@ -578,9 +593,15 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) // glClearColor(c.x, c.y, c.z, c.w); // glClear(GL_COLOR_BUFFER_BIT); } else { - // FIXME I need to clarify this FBO attachment stuff + // FIXME1 I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); + // FIXME2: + // it would be better to attach the texture to another slot (like 3) + // but it crash for an unknow reason + // The following error appears "glClearBufferfv failed because the currently set GL_DRAW_FRAMEBUFFER binding has incomplete status" + // Maybe glDrawBuffer must be updated but it does not solve the crash... + // FIXME3: I still have another crash on GOW... static_cast(t)->Attach(GL_COLOR_ATTACHMENT0); glClearBufferfv(GL_COLOR, 0, c.v); } @@ -970,6 +991,8 @@ void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb) void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb) { + if (vb == NULL) vb = m_vb; + if (m_state.vb != vb) { m_state.vb = vb; vb->bind(); @@ -981,6 +1004,16 @@ void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count) m_state.vb->UploadVB(vertices, count); } +bool GSDeviceOGL::IAMapVertexBuffer(void** vertex, size_t stride, size_t count) +{ + return m_state.vb->MapVB(vertex, count); +} + +void GSDeviceOGL::IAUnmapVertexBuffer() +{ + m_state.vb->UnmapVB(); +} + void GSDeviceOGL::IASetIndexBuffer(const void* index, size_t count) { m_state.vb->UploadIB(index, count); @@ -1073,6 +1106,8 @@ void GSDeviceOGL::OMSetFBO(GLuint fbo) if (m_state.fbo != fbo) { m_state.fbo = fbo; glBindFramebuffer(GL_FRAMEBUFFER, fbo); + // FIXME DEBUG + //if (fbo) fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); } } @@ -1277,6 +1312,7 @@ void GSDeviceOGL::CheckDebugLog() void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message) { char debType[20], debSev[5]; + static int sev_counter = 0; if(type == GL_DEBUG_TYPE_ERROR_ARB) strcpy(debType, "Error"); @@ -1293,23 +1329,26 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi else strcpy(debType, "UNKNOWN"); - if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) + if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) { strcpy(debSev, "High"); + sev_counter++; + } else if(severity == GL_DEBUG_SEVERITY_MEDIUM_ARB) strcpy(debSev, "Med"); else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) strcpy(debSev, "Low"); #ifdef LOUD_DEBUGGING - fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType, g_draw_count, debSev,message); #endif FILE* f = fopen("Debug.txt","a"); if(f) { - fprintf(f,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + fprintf(f,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType, g_draw_count, debSev,message); fclose(f); } + //if (sev_counter > 2) assert(0); } // (A - B) * C + D diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 21121f7403..fc574a5229 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -323,11 +323,22 @@ class GSVertexBufferStateOGL { void upload(const void* src, uint32 count) { + // Upload the data to the buffer + void* dst; + if (Map(&dst, count)) { + // FIXME which one to use + // GSVector4i::storent(dst, src, m_count * m_stride); + memcpy(dst, src, m_stride*m_count); + Unmap(); + } + } + + bool Map(void** pointer, uint32 count ) { #ifdef OGL_DEBUG GLint b_size = -1; glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); - if (b_size <= 0) return; + if (b_size <= 0) return false; #endif m_count = count; @@ -338,7 +349,7 @@ class GSVertexBufferStateOGL { // Current GPU buffer is really too small need to allocate a new one if (m_count > m_limit) { - allocate(std::max(count * 3 / 2, m_default_size)); + allocate(std::max(m_count * 3 / 2, m_default_size)); } else if (m_count > (m_limit - m_start) ) { // Not enough left free room. Just go back at the beginning @@ -354,17 +365,19 @@ class GSVertexBufferStateOGL { } // Upload the data to the buffer - uint8* dst = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); + *pointer = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); + //fprintf(stderr, "Map %x from %d to %d\n", *pointer, m_start, m_start+m_count); #ifdef OGL_DEBUG - if (dst == NULL) { + if (*pointer == NULL) { fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n"); - return; + return false; } #endif - memcpy(dst, src, m_stride*m_count); - glUnmapBuffer(m_target); + return true; } + void Unmap() { glUnmapBuffer(m_target); } + void EndScene() { m_start += m_count; @@ -381,6 +394,11 @@ class GSVertexBufferStateOGL { glDrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex); } + void Draw(GLenum mode, GLint basevertex, int offset, int count) + { + glDrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex); + } + size_t GetStart() { return m_start; } void debug() @@ -416,52 +434,6 @@ public: m_vb->bind(); } -#if 0 - void upload(const void* src, uint32 count) - { -#ifdef OGL_DEBUG - GLint b_size = -1; - glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size); - - if (b_size <= 0) return; -#endif - - m_count = count; - - // Note: For an explanation of the map flag - // see http://www.opengl.org/wiki/Buffer_Object_Streaming - uint32 map_flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; - - // Current GPU buffer is really too small need to allocate a new one - if (m_count > m_limit) { - allocate(std::max(count * 3 / 2, 60000)); - - } else if (m_count > (m_limit - m_start) ) { - // Not enough left free room. Just go back at the beginning - m_start = 0; - - // Tell the driver that it can orphan previous buffer and restart from a scratch buffer. - // Technically the buffer will not be accessible by the application anymore but the - // GL will effectively remove it when draws call are finised. - map_flags |= GL_MAP_INVALIDATE_BUFFER_BIT; - } else { - // Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map - map_flags |= GL_MAP_INVALIDATE_RANGE_BIT; - } - - // Upload the data to the buffer - uint8* dst = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags); -#ifdef OGL_DEBUG - if (dst == NULL) { - fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n"); - return; - } -#endif - memcpy(dst, src, m_stride*m_count); - glUnmapBuffer(m_target); - } -#endif - void set_internal_format(GSInputLayoutOGL* layout, uint32 layout_nbr) { for (int i = 0; i < layout_nbr; i++) { @@ -490,17 +462,17 @@ public: void DrawIndexedPrimitive() { m_ib->Draw(m_topology, m_vb->GetStart() ); } + void DrawIndexedPrimitive(int offset, int count) { m_ib->Draw(m_topology, m_vb->GetStart(), offset, count ); } + void SetTopology(GLenum topology) { m_topology = topology; } - void UploadVB(const void* vertices, size_t count) - { - m_vb->upload(vertices, count); - } + void UploadVB(const void* vertices, size_t count) { m_vb->upload(vertices, count); } - void UploadIB(const void* index, size_t count) - { - m_ib->upload(index, count); - } + void UploadIB(const void* index, size_t count) { m_ib->upload(index, count); } + + bool MapVB(void **pointer, size_t count) { return m_vb->Map(pointer, count); } + + void UnmapVB() { m_vb->Unmap(); } ~GSVertexBufferStateOGL() { @@ -878,6 +850,7 @@ class GSDeviceOGL : public GSDevice void DrawPrimitive(); void DrawIndexedPrimitive(); + void DrawIndexedPrimitive(int offset, int count); void ClearRenderTarget(GSTexture* t, const GSVector4& c); void ClearRenderTarget(GSTexture* t, uint32 c); @@ -906,8 +879,10 @@ class GSDeviceOGL : public GSDevice void IASetPrimitiveTopology(GLenum topology); void IASetVertexBuffer(const void* vertices, size_t count); + bool IAMapVertexBuffer(void** vertex, size_t stride, size_t count); + void IAUnmapVertexBuffer(); void IASetIndexBuffer(const void* index, size_t count); - void IASetVertexState(GSVertexBufferStateOGL* vb); + void IASetVertexState(GSVertexBufferStateOGL* vb = NULL); void SetUniformBuffer(GSUniformBufferOGL* cb); diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 97b4a2648c..4a0ccd57ab 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -76,8 +76,8 @@ GtkWidget* CreateRenderComboBox() case 8 : renderer_box_position = 1; break; case 10: renderer_box_position = 2; break; case 11: renderer_box_position = 3; break; - case 15: renderer_box_position = 4; break; - case 16: renderer_box_position = 5; break; + case 12: renderer_box_position = 4; break; + case 13: renderer_box_position = 5; break; } gtk_combo_box_set_active(GTK_COMBO_BOX(render_combo_box), renderer_box_position); return render_combo_box; @@ -375,8 +375,8 @@ bool RunLinuxDialog() case 1: theApp.SetConfig("renderer", 8); break; case 2: theApp.SetConfig("renderer", 10); break; case 3: theApp.SetConfig("renderer", 11); break; - case 4: theApp.SetConfig("renderer", 15); break; - case 5: theApp.SetConfig("renderer", 16); break; + case 4: theApp.SetConfig("renderer", 12); break; + case 5: theApp.SetConfig("renderer", 13); break; } } diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 1a86704ff2..418aceba61 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -24,15 +24,12 @@ GSRendererOGL::GSRendererOGL() - : GSRendererHW(new GSVertexTraceDX11(this), sizeof(GSVertexHW11), new GSTextureCacheOGL(this)) - , m_topology(0) + : GSRendererHW(new GSTextureCacheOGL(this)) { m_logz = !!theApp.GetConfig("logz", 0); m_fba = !!theApp.GetConfig("fba", 1); UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0); m_pixelcenter = GSVector2(-0.5f, -0.5f); - - InitConvertVertex(GSRendererOGL); } bool GSRendererOGL::CreateDevice(GSDevice* dev) @@ -43,44 +40,47 @@ bool GSRendererOGL::CreateDevice(GSDevice* dev) return true; } -template -void GSRendererOGL::ConvertVertex(size_t dst_index, size_t src_index) +void GSRendererOGL::SetupIA() { - GSVertex* s = (GSVertex*)((GSVertexHW11*)m_vertex.buff + src_index); - GSVertexHW11* d = (GSVertexHW11*)m_vertex.buff + dst_index; + GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; - GSVector4i v0 = ((GSVector4i*)s)[0]; - GSVector4i v1 = ((GSVector4i*)s)[1]; + void* ptr = NULL; - if(tme && fst) + dev->IASetVertexState(); + + if(dev->IAMapVertexBuffer(&ptr, sizeof(GSVertex), m_vertex.next)) { - // TODO: modify VertexTrace and the shaders to read uv from v1.u16[0], v1.u16[1], then this step is not needed + GSVector4i::storent(ptr, m_vertex.buff, sizeof(GSVertex) * m_vertex.next); - v0 = GSVector4i::cast(GSVector4(v1.uph16()).xyzw(GSVector4::cast(v0))); // uv => st + dev->IAUnmapVertexBuffer(); } - ((GSVector4i*)d)[0] = v0; - ((GSVector4i*)d)[1] = v1; -} + dev->IASetIndexBuffer(m_index.buff, m_index.tail); -void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) -{ - switch(m_vt->m_primclass) + GLenum t; + + switch(m_vt.m_primclass) { case GS_POINT_CLASS: - m_topology = GL_POINTS; + t = GL_POINTS; break; case GS_LINE_CLASS: case GS_SPRITE_CLASS: - m_topology = GL_LINES; + t = GL_LINES; break; case GS_TRIANGLE_CLASS: - m_topology = GL_TRIANGLES; + t = GL_TRIANGLES; break; default: __assume(0); } + dev->IASetPrimitiveTopology(t); +} + + +void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) +{ GSDrawingEnvironment& env = m_env; GSDrawingContext* context = m_context; @@ -103,7 +103,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); GSVector4 o = GSVector4(-1.0f, 1.0f); - GSVector4 src = ((m_vt->m_min.p.xyxy(m_vt->m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); + GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); GSVector4 dst = src * 2.0f + o.xxxx(); GSVertexPT1 vertices[] = @@ -163,7 +163,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour if(!IsOpaque()) { - om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt->m_primclass == GS_LINE_CLASS; + om_bsel.abe = PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS; om_bsel.a = context->ALPHA.A; om_bsel.b = context->ALPHA.B; @@ -207,11 +207,11 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour { if(context->ZBUF.PSM == PSM_PSMZ24) { - if(m_vt->m_max.p.z > 0xffffff) + if(m_vt.m_max.p.z > 0xffffff) { - ASSERT(m_vt->m_min.p.z > 0xffffff); + ASSERT(m_vt.m_min.p.z > 0xffffff); // Fixme :Following conditional fixes some dialog frame in Wild Arms 3, but may not be what was intended. - if (m_vt->m_min.p.z > 0xffffff) + if (m_vt.m_min.p.z > 0xffffff) { vs_sel.bppz = 1; om_dssel.ztst = ZTST_ALWAYS; @@ -220,11 +220,11 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour } else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) { - if(m_vt->m_max.p.z > 0xffff) + if(m_vt.m_max.p.z > 0xffff) { - ASSERT(m_vt->m_min.p.z > 0xffff); // sfex capcom logo + ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo // Fixme : Same as above, I guess. - if (m_vt->m_min.p.z > 0xffff) + if (m_vt.m_min.p.z > 0xffff) { vs_sel.bppz = 2; om_dssel.ztst = ZTST_ALWAYS; @@ -268,7 +268,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour GSDeviceOGL::GSSelector gs_sel; gs_sel.iip = PRIM->IIP; - gs_sel.prim = m_vt->m_primclass; + gs_sel.prim = m_vt.m_primclass; // ps @@ -288,7 +288,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour } } - if (env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + if(env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) { ps_sel.colclip = 1; } @@ -336,7 +336,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour ps_sel.aem = env.TEXA.AEM; ps_sel.tfx = context->TEX0.TFX; ps_sel.tcc = context->TEX0.TCC; - ps_sel.ltf = m_filter == 2 ? m_vt->IsLinear() : m_filter; + ps_sel.ltf = m_filter == 2 ? m_vt.IsLinear() : m_filter; ps_sel.rt = tex->m_target; int w = tex->m_texture->GetWidth(); @@ -385,8 +385,9 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour uint8 afix = context->ALPHA.FIX; + SetupIA(); + dev->SetupOM(om_dssel, om_bsel, afix); - dev->SetupIA(m_vertex.buff, m_vertex.next, m_index.buff, m_index.tail, m_topology); dev->SetupVS(vs_sel, &vs_cb); dev->SetupGS(gs_sel); dev->SetupPS(ps_sel, &ps_cb, ps_ssel); diff --git a/plugins/GSdx/GSRendererOGL.h b/plugins/GSdx/GSRendererOGL.h index 62736d5c04..7cef97af87 100644 --- a/plugins/GSdx/GSRendererOGL.h +++ b/plugins/GSdx/GSRendererOGL.h @@ -40,22 +40,12 @@ class GSRendererOGL : public GSRendererHW bool UserHacks_AlphaHack; protected: - GLenum m_topology; - - template - void ConvertVertex(size_t dst_index, size_t src_index); - - int GetPosX(const void* vertex) const {return (int)((const GSVertexHW11*)vertex)->p.x;} - int GetPosY(const void* vertex) const {return (int)((const GSVertexHW11*)vertex)->p.y;} - uint32 GetColor(const void* vertex) const {return ((const GSVertexHW11*)vertex)->c0;} - void SetColor(void* vertex, uint32 c) const {((GSVertexHW11*)vertex)->c0 = c;} + void SetupIA(); public: GSRendererOGL(); virtual ~GSRendererOGL() {}; - template void VertexKick(bool skip); - bool CreateDevice(GSDevice* dev); void UpdateFBA(GSTexture* rt) {} diff --git a/plugins/GSdx/GSTextureCacheOGL.cpp b/plugins/GSdx/GSTextureCacheOGL.cpp index b248d1dcf1..74eba438a0 100644 --- a/plugins/GSdx/GSTextureCacheOGL.cpp +++ b/plugins/GSdx/GSTextureCacheOGL.cpp @@ -62,6 +62,7 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) GSVector4 src = GSVector4(r) * GSVector4(t->m_texture->GetScale()).xyxy() / GSVector4(t->m_texture->GetSize()).xyxy(); GLuint format = TEX0.PSM == PSM_PSMCT16 || TEX0.PSM == PSM_PSMCT16S ? GL_R16UI : GL_RGBA8; + //if (format == GL_R16UI) fprintf(stderr, "Format 16 bits integer\n"); #if 0 DXGI_FORMAT format = TEX0.PSM == PSM_PSMCT16 || TEX0.PSM == PSM_PSMCT16S ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R8G8B8A8_UNORM; #endif diff --git a/plugins/GSdx/GSTextureCacheOGL.h b/plugins/GSdx/GSTextureCacheOGL.h index 11bf6210ad..f86554c84a 100644 --- a/plugins/GSdx/GSTextureCacheOGL.h +++ b/plugins/GSdx/GSTextureCacheOGL.h @@ -28,7 +28,7 @@ class GSTextureCacheOGL : public GSTextureCache { protected: - int Get8bitFormat() {/* TODO return DXGI_FORMAT_A8_UNORM;*/} + int Get8bitFormat() { return GL_R8; /* TODO return DXGI_FORMAT_A8_UNORM;*/} void Read(Target* t, const GSVector4i& r); diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index 5616a72078..ba194377db 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -61,26 +61,19 @@ void GSDeviceOGL::CreateTextureFX() //float4 c : COLOR0; //float4 f : COLOR1; - GSInputLayoutOGL vert_format[6] = + GSInputLayoutOGL vert_format[] = { // FIXME - {0 , 2 , GL_FLOAT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(0) } , - {1 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertexHW11) , (const GLvoid*)(8) } , - {2 , 1 , GL_FLOAT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(12) } , - {3 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(16) } , - {4 , 1 , GL_UNSIGNED_INT , GL_FALSE , sizeof(GSVertexHW11) , (const GLvoid*)(20) } , + {0 , 2 , GL_FLOAT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(0) } , + {1 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertex) , (const GLvoid*)(8) } , + {2 , 1 , GL_FLOAT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(12) } , + {3 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(16) } , + {4 , 1 , GL_UNSIGNED_INT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(20) } , // note: there is a 32 bits pad - {5 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertexHW11) , (const GLvoid*)(28) } , + {5 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(24) } , + {6 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertex) , (const GLvoid*)(28) } , }; - m_vb = new GSVertexBufferStateOGL(sizeof(GSVertexHW11), vert_format, countof(vert_format)); -} - -void GSDeviceOGL::SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim) -{ - IASetVertexState(m_vb); - IASetVertexBuffer(vertex, vertex_count); - IASetIndexBuffer(index, index_count); - IASetPrimitiveTopology(prim); + m_vb = new GSVertexBufferStateOGL(sizeof(GSVertex), vert_format, countof(vert_format)); } void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb) diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index d26c1d3f0d..2590bbc3be 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -103,11 +103,16 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother EnableUnit(2); - if (m_format == GL_RGBA8) { + if (m_format == GL_RGBA8) glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - } - else + else if (m_format == GL_R16UI) + glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, NULL); + else if (m_format == GL_R8) + glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RED, GL_UNSIGNED_BYTE, NULL); + else { + fprintf(stderr, "wrong texture pixel format :%x\n", m_format); assert(0); // TODO Later + } break; case GSTexture::Offscreen: if (m_type == GL_RGBA8) m_pbo_size = m_size.x * m_size.y * 4; @@ -130,7 +135,10 @@ GSTextureOGL::~GSTextureOGL() void GSTextureOGL::Attach(GLenum attachment) { + //fprintf(stderr, "format %d,%x\n", m_type, m_format); glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); + // FIXME DEBUG + //fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); } bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) @@ -142,18 +150,22 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) EnableUnit(2); - if (m_format != GL_RGBA8) { - fprintf(stderr, "wrong pixel format\n"); - assert(0); - } - // pitch could be different of width*element_size glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>2); // FIXME : it crash on colin mcrae rally 3 (others game too) when the size is 16 //fprintf(stderr, "Texture %dx%d with a pitch of %d\n", m_size.x, m_size.y, pitch >>2); //fprintf(stderr, "Box (%d,%d)x(%d,%d)\n", r.x, r.y, r.width(), r.height()); - glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); + if (m_format == GL_RGBA8) + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data); + else if (m_format == GL_R16UI) + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RED_INTEGER, GL_R16UI, data); + else if (m_format == GL_R8) + glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RED, GL_R8, data); + else { + fprintf(stderr, "wrong texture pixel format :%x\n", m_format); + assert(0); + } #if 0 //if (m_size.x != 16) if (r.width() > 16 && r.height() > 16) @@ -216,12 +228,16 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) // FIXME It might be possible to only map a subrange of the texture based on r object // Load the PBO - if (m_format == GL_R16UI) - glReadPixels(0, 0, m_size.x, m_size.y, GL_RED, GL_UNSIGNED_SHORT, 0); - else if (m_format == GL_RGBA8) + if (m_format == GL_RGBA8) glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0); - else + else if (m_format == GL_R16UI) + glReadPixels(0, 0, m_size.x, m_size.y, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 0); + else if (m_format == GL_R8) + glReadPixels(0, 0, m_size.x, m_size.y, GL_RED, GL_UNSIGNED_BYTE, 0); + else { + fprintf(stderr, "wrong texture pixel format :%x\n", m_format); assert(0); + } // Give access from the CPU uint32 map_flags = GL_MAP_READ_BIT; diff --git a/plugins/GSdx/GSThread.h b/plugins/GSdx/GSThread.h index 4a9e7223dc..160bd541cd 100644 --- a/plugins/GSdx/GSThread.h +++ b/plugins/GSdx/GSThread.h @@ -182,6 +182,8 @@ public: void Lock() {pthread_mutex_lock(&m_mutex);} bool TryLock() {return pthread_mutex_trylock(&m_mutex) == 0;} void Unlock() {pthread_mutex_unlock(&m_mutex);} + + operator pthread_mutex_t* () {return &m_mutex;} }; class GSEvent : public IGSEvent diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 892af3178e..c45dcd9063 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -48,12 +48,13 @@ struct vertex }; #ifdef VERTEX_SHADER -layout(location = 0) in vec2 i_t; +layout(location = 0) in vec2 i_st; layout(location = 1) in vec4 i_c; layout(location = 2) in float i_q; layout(location = 3) in uvec2 i_p; layout(location = 4) in uint i_z; -layout(location = 5) in vec4 i_f; +layout(location = 5) in uvec2 i_uv; +layout(location = 6) in vec4 i_f; layout(location = 0) out vertex VSout; @@ -101,12 +102,14 @@ void vs_main() { if(VS_FST != 0) { - VSout.t.xy = i_t * TextureScale; + //VSout.t.xy = i_t * TextureScale; + VSout.t.xy = i_uv * TextureScale; VSout.t.w = 1.0f; } else { - VSout.t.xy = i_t; + //VSout.t.xy = i_t; + VSout.t.xy = i_st; VSout.t.w = i_q; } } From d6e7ea4a4ed9deb196e5d101e1e8226e39f86113 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Mon, 5 Mar 2012 20:16:26 +0000 Subject: [PATCH 50/56] GSdx-ogl: LINUX only * request a minimum of 1 for texture dimension * Use offscreen texture likes DX11. * add more bits for extra texture format * do operation on texture unit 0 to avoid ping-pong between unit 0/2 git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5114 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 49 +++++-------- plugins/GSdx/GSLinuxDialog.cpp | 25 +++++-- plugins/GSdx/GSTextureCacheOGL.cpp | 2 +- plugins/GSdx/GSTextureOGL.cpp | 111 +++++++++++++++++++---------- plugins/GSdx/GSTextureOGL.h | 3 +- 5 files changed, 116 insertions(+), 74 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 63a5078d41..40ecf105ca 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -21,6 +21,10 @@ #include "GSDeviceOGL.h" +// TODO performance cost to investigate +// Texture attachment/glDrawBuffer. For the moment it set every draw and potentially multiple time (first time in clear, second time in rendering) +// Attachment 1 is only used with the GL_16UI format + //#define LOUD_DEBUGGING //#define PRINT_FRAME_NUMBER //#define ONLY_LINES @@ -507,7 +511,7 @@ void GSDeviceOGL::DebugInput() m_state.ps_srv[i]->Save(format("/tmp/in_f%d__d%d__%d.bmp", g_frame_count, g_draw_count, i)); } } - //if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/in_current_out_%d.bmp", g_draw_count)); + //if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/target_f%d__d%d__tex.bmp", g_frame_count, g_draw_count)); //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); @@ -520,6 +524,8 @@ void GSDeviceOGL::DebugInput() void GSDeviceOGL::DebugOutput() { + CheckDebugLog(); + bool dump_me = false; uint32 start = theApp.GetConfig("debug_ogl_dump", 0); uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); @@ -536,7 +542,6 @@ void GSDeviceOGL::DebugOutput() fprintf(stderr, "\n"); } - CheckDebugLog(); } void GSDeviceOGL::DrawPrimitive() @@ -596,12 +601,7 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) // FIXME1 I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); - // FIXME2: - // it would be better to attach the texture to another slot (like 3) - // but it crash for an unknow reason - // The following error appears "glClearBufferfv failed because the currently set GL_DRAW_FRAMEBUFFER binding has incomplete status" - // Maybe glDrawBuffer must be updated but it does not solve the crash... - // FIXME3: I still have another crash on GOW... + glDrawBuffer(GL_COLOR_ATTACHMENT0); static_cast(t)->Attach(GL_COLOR_ATTACHMENT0); glClearBufferfv(GL_COLOR, 0, c.v); } @@ -673,8 +673,8 @@ GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w return false; } - // FIXME: I used directly an offscreen texture because they are the same on Opengl - //if(GSTexture* rt = CreateRenderTarget(w, h, false, format)) + // FIXME: It is possible to bypass completely offscreen-buffer on opengl but it needs some re-thinking of the code. + // For the moment mimic dx11 GSTexture* rt = CreateRenderTarget(w, h, false, format); if(rt) { @@ -687,9 +687,12 @@ GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w if(src2 != src) Recycle(src2); } -#if 0 + + GSVector4i dor(0, 0, w, h); dst = CreateOffscreen(w, h, format); + if (dst) CopyRect(rt, dst, dor); +#if 0 if(dst) { m_ctx->CopyResource(*(GSTexture11*)dst, *(GSTexture11*)rt); @@ -699,8 +702,8 @@ GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w Recycle(rt); } - //return dst; - return rt; + return dst; + //return rt; } // Copy a sub part of a texture into another @@ -724,27 +727,11 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) // uint srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ, // uint dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ, // sizei width, sizei height, sizei depth); - glCopyImageSubDataNV( static_cast(st)->GetID(), GL_TEXTURE_2D, + glCopyImageSubDataNV( static_cast(st)->GetID(), static_cast(st)->GetTarget(), 0, r.x, r.y, 0, - static_cast(dt)->GetID(), GL_TEXTURE_2D, + static_cast(dt)->GetID(), static_cast(dt)->GetTarget(), 0, r.x, r.y, 0, r.width(), r.height(), 1); -#if 0 - - // FIXME FBO - GLuint fbo_old = m_state.fbo; - OMSetFBO(m_fbo); - - // Set the input of glCopyTexSubImage2D - static_cast(st)->Attach(GL_COLOR_ATTACHMENT1); - glReadBuffer(GL_COLOR_ATTACHMENT1); - - // Copy the full image - static_cast(dt)->EnableUnit(0); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, dt->GetWidth(), dt->GetHeight()); - - OMSetFBO(fbo_old); -#endif #if 0 D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 4a0ccd57ab..255e3a55e6 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -62,10 +62,27 @@ GtkWidget* CreateRenderComboBox() if(!s.note.empty()) label += format(" (%s)", s.note.c_str()); - // (dev only) for any NULL stuff - if (i >= 7 && i <= 9) label += " (debug only)"; - // (experimental) for opengl stuff - if (i == 10 || i == 11) label += " (experimental)"; + // Add some tags to ease users selection + switch (i) { + // better use opengl instead of SDL + case 6: + label += " (deprecated)"; + break; + + // (dev only) for any NULL stuff + case 7: + case 8: + case 9: + label += " (debug only)"; + break; + + // opengl harware is not yet finished + case 10: + label += " (experimental)"; + break; + default: + break; + } gtk_combo_box_append_text(GTK_COMBO_BOX(render_combo_box), label.c_str()); } diff --git a/plugins/GSdx/GSTextureCacheOGL.cpp b/plugins/GSdx/GSTextureCacheOGL.cpp index 74eba438a0..98023ae518 100644 --- a/plugins/GSdx/GSTextureCacheOGL.cpp +++ b/plugins/GSdx/GSTextureCacheOGL.cpp @@ -96,7 +96,7 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) offscreen->Unmap(); } - //m_renderer->m_dev->Recycle(offscreen); + m_renderer->m_dev->Recycle(offscreen); } } diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 2590bbc3be..00f4cffd37 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -26,7 +26,7 @@ static int g_state_texture_unit = -1; static int g_state_texture_id = -1; GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint fbo_read) - : m_extra_buffer_id(0), + : m_pbo_id(0), m_pbo_size(0) { // ************************************************************* @@ -48,8 +48,11 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // glBlitFramebuffer // ************************************************************* - m_size.x = w; - m_size.y = h; + // m_size.x = w; + // m_size.y = h; + // FIXME + m_size.x = max(1,w); + m_size.y = max(1,h); m_format = format; m_type = type; m_msaa = msaa; @@ -80,7 +83,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint break; } // Extra buffer to handle various pixel transfer - glGenBuffers(1, &m_extra_buffer_id); + glGenBuffers(1, &m_pbo_id); uint msaa_level; if (m_msaa) { @@ -93,16 +96,30 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // Allocate the buffer switch (m_type) { case GSTexture::DepthStencil: - EnableUnit(2); + EnableUnit(0); glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); break; + + case GSTexture::Offscreen: + // Allocate a pbo with the texture + if (m_format == GL_RGBA8) m_pbo_size = m_size.x * m_size.y * 4; + else if (m_format == GL_R16UI) m_pbo_size = m_size.x * m_size.y * 2; + else { + fprintf(stderr, "wrong texture pixel format :%x\n", m_format); + assert(0); // TODO Later + } + + glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id); + glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + case GSTexture::RenderTarget: case GSTexture::Texture: // FIXME // Howto allocate the texture unit !!! // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother - EnableUnit(2); + EnableUnit(0); if (m_format == GL_RGBA8) glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); else if (m_format == GL_R16UI) @@ -114,22 +131,13 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint assert(0); // TODO Later } break; - case GSTexture::Offscreen: - if (m_type == GL_RGBA8) m_pbo_size = m_size.x * m_size.y * 4; - else if (m_type == GL_R16UI) m_pbo_size = m_size.x * m_size.y * 2; - else assert(0); - - glBindBuffer(GL_PIXEL_PACK_BUFFER, m_extra_buffer_id); - glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW); - glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); - break; default: break; } } GSTextureOGL::~GSTextureOGL() { - glDeleteBuffers(1, &m_extra_buffer_id); + glDeleteBuffers(1, &m_pbo_id); glDeleteTextures(1, &m_texture_id); } @@ -148,7 +156,7 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) // FIXME warning order of the y axis // FIXME I'm not confident with GL_UNSIGNED_BYTE type - EnableUnit(2); + EnableUnit(0); // pitch could be different of width*element_size glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>2); @@ -224,29 +232,41 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) // glMapBuffer — map a buffer object's data store // Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER if (m_type == GSTexture::Offscreen) { - glBindBuffer(GL_PIXEL_PACK_BUFFER, m_extra_buffer_id); - // FIXME It might be possible to only map a subrange of the texture based on r object + // Bind the texture to the read framebuffer to avoid any disturbance + EnableUnit(0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0); + glReadBuffer(GL_COLOR_ATTACHMENT0); - // Load the PBO - if (m_format == GL_RGBA8) + // FIXME It might be possible to only read a subrange of the texture based on r object + // Load the PBO with the data + glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id); + if (m_format == GL_RGBA8) { + glPixelStorei(GL_PACK_ALIGNMENT, 4); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0); - else if (m_format == GL_R16UI) + } else if (m_format == GL_R16UI) { + glPixelStorei(GL_PACK_ALIGNMENT, 2); glReadPixels(0, 0, m_size.x, m_size.y, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 0); - else if (m_format == GL_R8) + } else if (m_format == GL_R8) { + glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, m_size.x, m_size.y, GL_RED, GL_UNSIGNED_BYTE, 0); - else { + } else { fprintf(stderr, "wrong texture pixel format :%x\n", m_format); assert(0); } + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); // Give access from the CPU - uint32 map_flags = GL_MAP_READ_BIT; - m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, map_flags); + m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT); m.pitch = m_size.x; - glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); - - return true; + if ( m.bits ) { + return true; + } else { + fprintf(stderr, "bad mapping of the pbo\n"); + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + return false; + } } return false; @@ -272,6 +292,8 @@ void GSTextureOGL::Unmap() { if (m_type == GSTexture::Offscreen) { glUnmapBuffer(GL_PIXEL_PACK_BUFFER); + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + } } @@ -377,30 +399,45 @@ bool GSTextureOGL::Save(const string& fn, bool dds) uint32 pitch = 4 * m_size.x; if (IsDss()) pitch *= 2; char* image = (char*)malloc(pitch * m_size.y); + bool status = true; // FIXME instead of swapping manually B and R maybe you can request the driver to do it // for us if (IsBackbuffer()) { - glReadBuffer(GL_BACK); + //glReadBuffer(GL_BACK); + //glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); } else if(IsDss()) { - EnableUnit(2); + EnableUnit(0); glGetTexImage(m_texture_target, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image); } else { glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); - EnableUnit(2); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, m_texture_target, m_texture_id, 0); + EnableUnit(0); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0); - glReadBuffer(GL_COLOR_ATTACHMENT1); - glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); + glReadBuffer(GL_COLOR_ATTACHMENT0); + if (m_format == GL_RGBA8) + glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); + else if (m_format == GL_R16UI) + { + glReadPixels(0, 0, m_size.x, m_size.y, GL_RED_INTEGER, GL_UNSIGNED_SHORT, image); + // Not supported in Save function + status = false; + } + else if (m_format == GL_R8) + { + glReadPixels(0, 0, m_size.x, m_size.y, GL_RED, GL_UNSIGNED_BYTE, image); + // Not supported in Save function + status = false; + } glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); } - Save(fn, image, pitch); + if (status) Save(fn, image, pitch); free(image); - return true; + return status; } diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 657d922435..017431a128 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -28,7 +28,7 @@ class GSTextureOGL : public GSTexture private: GLenum m_texture_target; // texture target: 2D, rectangle etc... GLuint m_texture_id; // the texture id - uint m_extra_buffer_id; + uint m_pbo_id; int m_pbo_size; GLuint m_fbo_read; @@ -49,4 +49,5 @@ class GSTextureOGL : public GSTexture bool IsDss() { return (m_type == GSTexture::DepthStencil); } GLuint GetID() { return m_texture_id; } + GLenum GetTarget() { return m_texture_target; } }; From 16a1fded965254b8addb674d62f78550e4c49854 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 30 Mar 2012 19:02:37 +0000 Subject: [PATCH 51/56] gsdx-ogl: LINUX ONLY * Keep the state of the draw buffer (save few opengl call) * AMD fix the shader unloading (12.2 and above). So disable the workaround git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5137 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 3 +- plugins/GSdx/GS.cpp | 7 +++ plugins/GSdx/GSDeviceOGL.cpp | 92 ++++++++++++++++++++++++----------- plugins/GSdx/GSDeviceOGL.h | 4 +- plugins/GSdx/GSTextureOGL.cpp | 7 ++- plugins/GSdx/linux_replay.cpp | 2 +- 6 files changed, 82 insertions(+), 33 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 5fa1f3b991..51cf2e5b49 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -19,7 +19,8 @@ set(CommonFlags -std=c++0x -fno-strict-aliasing -DOGL_DEBUG # FIXME remove me when code is ready - -DAMD_DRIVER_WORKAROUND + # Unload of Geometry shader was fixed in Cat 12.3 (ie OpenGL version string: 4.2.11554) + #-DAMD_DRIVER_WORKAROUND ) set(OptimizationFlags diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 8c448348fc..df1a20fdc5 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1269,6 +1269,13 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); #endif + // Allow to easyly switch between SW/HW renderer + renderer = theApp.GetConfig("renderer", 12); + if (renderer != 12 && renderer != 13) + { + fprintf(stderr, "wrong renderer selected %d\n", renderer); + return; + } if(FILE* fp = fopen(lpszCmdLine, "rb")) { diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 40ecf105ca..914cebd66f 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -488,7 +488,9 @@ void GSDeviceOGL::Flip() { // FIXME: disable it when code is working CheckDebugLog(); + m_wnd->Flip(); + #ifdef PRINT_FRAME_NUMBER fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); #endif @@ -498,6 +500,33 @@ void GSDeviceOGL::Flip() #endif } +void GSDeviceOGL::DebugBB() +{ + bool dump_me = false; + uint32 start = theApp.GetConfig("debug_ogl_dump", 0); + uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); + if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; + + if (!dump_me) return; + + GLuint fbo_old = m_state.fbo; + OMSetFBO(m_fbo); + + GSVector2i size = m_backbuffer->GetSize(); + GSTexture* rt = CreateRenderTarget(size.x, size.y, false); + + static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); + + glBlitFramebuffer(0, 0, size.x, size.y, + 0, 0, size.x, size.y, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + rt->Save(format("/tmp/out_f%d__d%d__bb.bmp", g_frame_count, g_draw_count)); + + delete rt; + OMSetFBO(fbo_old); +} + void GSDeviceOGL::DebugInput() { bool dump_me = false; @@ -505,21 +534,21 @@ void GSDeviceOGL::DebugInput() uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; - if ( dump_me ) { - for (auto i = 0 ; i < 3 ; i++) { - if (m_state.ps_srv[i] != NULL) { - m_state.ps_srv[i]->Save(format("/tmp/in_f%d__d%d__%d.bmp", g_frame_count, g_draw_count, i)); - } - } - //if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/target_f%d__d%d__tex.bmp", g_frame_count, g_draw_count)); - //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); + if (!dump_me) return; - fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); - fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); - m_state.vb->debug(); - m_state.bs->debug(); - m_state.dss->debug(); + for (auto i = 0 ; i < 3 ; i++) { + if (m_state.ps_srv[i] != NULL) { + m_state.ps_srv[i]->Save(format("/tmp/in_f%d__d%d__%d.bmp", g_frame_count, g_draw_count, i)); + } } + //if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/target_f%d__d%d__tex.bmp", g_frame_count, g_draw_count)); + //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count)); + + fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count); + fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps); + m_state.vb->debug(); + m_state.bs->debug(); + m_state.dss->debug(); } void GSDeviceOGL::DebugOutput() @@ -531,17 +560,17 @@ void GSDeviceOGL::DebugOutput() uint32 length = theApp.GetConfig("debug_ogl_dump_length", 5); if ( (start != 0 && g_frame_count >= start && g_frame_count < (start + length)) ) dump_me = true; - if ( dump_me ) { - if (m_state.rtv == m_backbuffer) { - if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d__back.bmp", g_frame_count, g_draw_count)); - } else { - if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d__tex.bmp", g_frame_count, g_draw_count)); - } - //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); - - fprintf(stderr, "\n"); + if (!dump_me) return; + if (m_state.rtv == m_backbuffer) { + m_state.rtv->Save(format("/tmp/out_f%d__d%d__back.bmp", g_frame_count, g_draw_count)); + } else { + if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d__tex.bmp", g_frame_count, g_draw_count)); } + //if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count)); + + fprintf(stderr, "\n"); + //DebugBB(); } void GSDeviceOGL::DrawPrimitive() @@ -580,6 +609,7 @@ void GSDeviceOGL::DrawIndexedPrimitive(int offset, int count) #endif m_state.vb->DrawIndexedPrimitive(offset, count); + #ifdef OGL_DEBUG DebugOutput(); g_draw_count++; @@ -601,7 +631,6 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) // FIXME1 I need to clarify this FBO attachment stuff // I would like to avoid FBO for a basic clean operation OMSetFBO(m_fbo); - glDrawBuffer(GL_COLOR_ATTACHMENT0); static_cast(t)->Attach(GL_COLOR_ATTACHMENT0); glClearBufferfv(GL_COLOR, 0, c.v); } @@ -1088,7 +1117,7 @@ void GSDeviceOGL::PSSetShader(GLuint ps) } } -void GSDeviceOGL::OMSetFBO(GLuint fbo) +void GSDeviceOGL::OMSetFBO(GLuint fbo, GLenum buffer) { if (m_state.fbo != fbo) { m_state.fbo = fbo; @@ -1096,6 +1125,12 @@ void GSDeviceOGL::OMSetFBO(GLuint fbo) // FIXME DEBUG //if (fbo) fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); } + + if (m_state.draw != buffer) { + m_state.draw = buffer; + glDrawBuffer(buffer); + } + } void GSDeviceOGL::OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref) @@ -1135,20 +1170,19 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto m_state.dsv = static_cast(ds); if (static_cast(rt)->IsBackbuffer()) { + assert(ds == NULL); // no depth-stencil without FBO + OMSetFBO(0); - assert(ds == NULL); // no depth-stencil without FBO } else { - OMSetFBO(m_fbo); - assert(rt != NULL); // a render target must exists // FIXME DEBUG special case for GL_R16UI if (rt->GetFormat() == GL_R16UI) { - glDrawBuffer(GL_COLOR_ATTACHMENT1); + OMSetFBO(m_fbo, GL_COLOR_ATTACHMENT1); static_cast(rt)->Attach(GL_COLOR_ATTACHMENT1); } else { - glDrawBuffer(GL_COLOR_ATTACHMENT0); + OMSetFBO(m_fbo, GL_COLOR_ATTACHMENT0); static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index fc574a5229..0ab52b8853 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -805,6 +805,7 @@ class GSDeviceOGL : public GSDevice GSTextureOGL* rtv; GSTextureOGL* dsv; GLuint fbo; ++ GLenum draw; } m_state; bool m_srv_changed; @@ -840,6 +841,7 @@ class GSDeviceOGL : public GSDevice static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message); void DebugOutput(); void DebugInput(); + void DebugBB(); bool HasStencil() { return true; } bool HasDepth32() { return true; } @@ -894,7 +896,7 @@ class GSDeviceOGL : public GSDevice void PSSetSamplerState(GLuint ss0, GLuint ss1, GLuint ss2 = 0); void PSSetShader(GLuint ps); - void OMSetFBO(GLuint fbo); + void OMSetFBO(GLuint fbo, GLenum buffer = GL_COLOR_ATTACHMENT0); void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref); void OMSetBlendState(GSBlendStateOGL* bs, float bf); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 00f4cffd37..73aef4a5d9 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -120,6 +120,11 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint // In worst case the HW renderer seems to use 3 texture unit // For the moment SW renderer only use 1 so don't bother EnableUnit(0); + // Did we need to setup a default sampler of the texture now? + // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); if (m_format == GL_RGBA8) glTexImage2D(m_texture_target, 0, m_format, m_size.x, m_size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); else if (m_format == GL_R16UI) @@ -144,7 +149,7 @@ GSTextureOGL::~GSTextureOGL() void GSTextureOGL::Attach(GLenum attachment) { //fprintf(stderr, "format %d,%x\n", m_type, m_format); - glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0); // FIXME DEBUG //fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); } diff --git a/plugins/GSdx/linux_replay.cpp b/plugins/GSdx/linux_replay.cpp index 0de8a06825..f2d25ab8c9 100644 --- a/plugins/GSdx/linux_replay.cpp +++ b/plugins/GSdx/linux_replay.cpp @@ -37,5 +37,5 @@ int main ( int argc, char *argv[] ) if ( argc != 3 ) help(); GSsetSettingsDir(argv[1]); - GSReplay(argv[2], 15); + GSReplay(argv[2], 12); } From bda3cbe86f4194089c7309993dacb7617951707d Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Mon, 2 Apr 2012 16:46:54 +0000 Subject: [PATCH 52/56] gsdx-ogl: fix build failure due to a leftover of a patch conflict git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5140 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 0ab52b8853..fcbfd399ec 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -805,7 +805,7 @@ class GSDeviceOGL : public GSDevice GSTextureOGL* rtv; GSTextureOGL* dsv; GLuint fbo; -+ GLenum draw; + GLenum draw; } m_state; bool m_srv_changed; From 6fd47b29077344518089939593e6b1323ee2c047 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 26 Apr 2012 21:42:16 +0000 Subject: [PATCH 53/56] gsdx-ogl: * implement shadeboost (only test the compilation) Note: gui must be updated with new user hack git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5181 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/CMakeLists.txt | 14 ++++++-------- plugins/GSdx/GSDeviceOGL.cpp | 33 ++++++++++++++++++++++++++++++++- plugins/GSdx/GSDeviceOGL.h | 11 +++++++++++ plugins/GSdx/GSRendererOGL.cpp | 12 +++++++++++- plugins/GSdx/GSRendererOGL.h | 1 + plugins/GSdx/GSTextureFXOGL.cpp | 3 ++- plugins/GSdx/res/tfx.glsl | 12 +++++++++++- 7 files changed, 74 insertions(+), 12 deletions(-) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 57f4e93286..7c9b213e56 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -200,17 +200,15 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") if(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${PLUGIN_DIR}) + foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${PLUGIN_DIR}) + endforeach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl) else(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/convert.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/interlace.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/merge.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/tfx.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + endforeach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl) endif(PACKAGE_MODE) ################################### Replay Loader diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 914cebd66f..89f50cf17d 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -46,7 +46,7 @@ GSDeviceOGL::GSDeviceOGL() , m_srv_changed(false) , m_ss_changed(false) { - m_msaa = theApp.GetConfig("msaa", 0); + m_msaa = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_MSAA", 0) : 0; memset(&m_merge_obj, 0, sizeof(m_merge_obj)); memset(&m_interlace, 0, sizeof(m_interlace)); @@ -299,6 +299,19 @@ bool GSDeviceOGL::Create(GSWnd* wnd) for(int i = 0; i < countof(m_interlace.ps); i++) CompileShaderFromSource("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, &m_interlace.ps[i]); + // **************************************************************** + // Shade boost + // **************************************************************** + m_shadeboost.cb = new GSUniformBufferOGL(6, sizeof(ShadeBoostConstantBuffer)); + + int ShadeBoost_Contrast = theApp.GetConfig("ShadeBoost_Contrast", 50); + int ShadeBoost_Brightness = theApp.GetConfig("ShadeBoost_Brightness", 50); + int ShadeBoost_Saturation = theApp.GetConfig("ShadeBoost_Saturation", 50); + std::string macro = format("#define SB_SATURATION %d\n", ShadeBoost_Saturation) + + format("#define SB_BRIGHTNESS %d\n", ShadeBoost_Brightness) + + format("#define SB_CONTRAST %d\n", ShadeBoost_Contrast); + + CompileShaderFromSource("shadeboost.glsl", "ps_main", GL_FRAGMENT_SHADER, &m_shadeboost.ps, macro); // **************************************************************** // rasterization configuration @@ -912,6 +925,24 @@ void GSDeviceOGL::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool lin StretchRect(st, sr, dt, dr, m_interlace.ps[shader], linear); } +void GSDeviceOGL::DoShadeBoost(GSTexture* st, GSTexture* dt) +{ + GSVector2i s = dt->GetSize(); + + GSVector4 sr(0, 0, 1, 1); + GSVector4 dr(0, 0, s.x, s.y); + + ShadeBoostConstantBuffer cb; + + cb.rcpFrame = GSVector4(1.0f / s.x, 1.0f / s.y, 0.0f, 0.0f); + cb.rcpFrameOpt = GSVector4::zero(); + + SetUniformBuffer(m_shadeboost.cb); + m_shadeboost.cb->upload(&cb); + + StretchRect(st, sr, dt, dr, m_shadeboost.ps, m_shadeboost.cb); +} + void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm) { const GSVector2i& size = rt->GetSize(); diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index fcbfd399ec..96eebf4b58 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -552,6 +552,7 @@ class GSDeviceOGL : public GSDevice uint32 fst:1; uint32 logz:1; uint32 rtcopy:1; + uint32 wildhack:2; }; uint32 key; @@ -649,6 +650,7 @@ class GSDeviceOGL : public GSDevice uint32 ltf:1; uint32 colclip:2; uint32 date:2; + uint32 spritehack:1; }; uint32 key; @@ -783,6 +785,14 @@ class GSDeviceOGL : public GSDevice GSBlendStateOGL* bs; } m_date; + struct + { + GLuint ps; + GSUniformBufferOGL *cb; + } m_shadeboost; + + + struct { GSVertexBufferStateOGL* vb; GLuint vs; // program @@ -832,6 +842,7 @@ class GSDeviceOGL : public GSDevice GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c); void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0); + void DoShadeBoost(GSTexture* st, GSTexture* dt); public: GSDeviceOGL(); diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 418aceba61..9aa25b62f9 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -28,7 +28,8 @@ GSRendererOGL::GSRendererOGL() { m_logz = !!theApp.GetConfig("logz", 0); m_fba = !!theApp.GetConfig("fba", 1); - UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0); + UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0) && !!theApp.GetConfig("UserHacks", 0); + UserHacks_WildHack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_WildHack", 0) : 0; m_pixelcenter = GSVector2(-0.5f, -0.5f); } @@ -51,6 +52,15 @@ void GSRendererOGL::SetupIA() if(dev->IAMapVertexBuffer(&ptr, sizeof(GSVertex), m_vertex.next)) { GSVector4i::storent(ptr, m_vertex.buff, sizeof(GSVertex) * m_vertex.next); + + if(UserHacks_WildHack && !isPackedUV_HackFlag) + { + GSVertex* RESTRICT d = (GSVertex*)ptr; + + for(unsigned int i = 0; i < m_vertex.next; i++, d++) + if(PRIM->TME && PRIM->FST) + d->UV &= UserHacks_WildHack == 1 ? 0x3FEF3FEF : 0x3FF73FF7; + } dev->IAUnmapVertexBuffer(); } diff --git a/plugins/GSdx/GSRendererOGL.h b/plugins/GSdx/GSRendererOGL.h index 7cef97af87..4f3ce236b1 100644 --- a/plugins/GSdx/GSRendererOGL.h +++ b/plugins/GSdx/GSRendererOGL.h @@ -38,6 +38,7 @@ class GSRendererOGL : public GSRendererHW bool m_logz; bool m_fba; bool UserHacks_AlphaHack; + int UserHacks_WildHack; protected: void SetupIA(); diff --git a/plugins/GSdx/GSTextureFXOGL.cpp b/plugins/GSdx/GSTextureFXOGL.cpp index ba194377db..e7eb694af3 100644 --- a/plugins/GSdx/GSTextureFXOGL.cpp +++ b/plugins/GSdx/GSTextureFXOGL.cpp @@ -163,7 +163,8 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS + format("#define PS_AOUT %d\n", sel.aout) + format("#define PS_LTF %d\n", sel.ltf) + format("#define PS_COLCLIP %d\n", sel.colclip) - + format("#define PS_DATE %d\n", sel.date); + + format("#define PS_DATE %d\n", sel.date) + + format("#define PS_SPRITEHACK %d\n", sel.spritehack); CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &ps, macro); diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index c45dcd9063..92ce5fb75e 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -37,6 +37,7 @@ #define PS_LTF 1 #define PS_COLCLIP 0 #define PS_DATE 0 +#define PS_SPRITEHACK 0 #endif struct vertex @@ -554,7 +555,16 @@ void atst(vec4 c) { // nothing to do } - else if(PS_ATST == 2 || PS_ATST == 3) // l, le + else if(PS_ATST == 2) + { + } + else if(PS_ATST == 2 ) // l + { + if (PS_SPRITEHACK == 0) + if ((AREF - a) < 0.0f) + discard; + } + else if(PS_ATST == 2 ) // le { if ((AREF - a) < 0.0f) discard; From f8d573770ee109ee54dc390bf288bd96a1ab8a08 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Fri, 27 Apr 2012 06:30:09 +0000 Subject: [PATCH 54/56] gsdx-ogl: forgot to add the glsl file... git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5182 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/res/shadeboost.glsl | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 plugins/GSdx/res/shadeboost.glsl diff --git a/plugins/GSdx/res/shadeboost.glsl b/plugins/GSdx/res/shadeboost.glsl new file mode 100644 index 0000000000..c98222d80a --- /dev/null +++ b/plugins/GSdx/res/shadeboost.glsl @@ -0,0 +1,61 @@ +//#version 420 // Keep it for editor detection + +/* +** Contrast, saturation, brightness +** Code of this function is from TGM's shader pack +** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 +*/ + +struct vertex_basic +{ + vec4 p; + vec2 t; +}; + +#ifdef FRAGMENT_SHADER + +layout(location = 0) in vertex_basic PSin; + +layout(location = 0) out vec4 SV_Target0; + +layout(std140, binding = 6) uniform cb0 +{ + vec4 BGColor; +}; + +layout(binding = 0) uniform sampler2D TextureSampler; + +// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% +vec4 ContrastSaturationBrightness(vec4 color) +{ + const float sat = SB_SATURATION / 50.0; + const float brt = SB_BRIGHTNESS / 50.0; + const float con = SB_CONTRAST / 50.0; + + // Increase or decrease theese values to adjust r, g and b color channels seperately + const float AvgLumR = 0.5; + const float AvgLumG = 0.5; + const float AvgLumB = 0.5; + + const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); + + vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); + vec3 brtColor = color.rgb * brt; + float dot_intensity = dot(brtColor, LumCoeff); + vec3 intensity = vec3(dot_intensity, dot_intensity, dot_intensity); + vec3 satColor = mix(intensity, brtColor, sat); + vec3 conColor = mix(AvgLumin, satColor, con); + + color.rgb = conColor; + return color; +} + + +void ps_main() +{ + vec4 c = texture(TextureSampler, PSin.t); + SV_Target0 = ContrastSaturationBrightness(c); +} + + +#endif From f5ee23aa37af32c63565a4268439cb9489e9b17a Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 28 Apr 2012 09:19:42 +0000 Subject: [PATCH 55/56] gsdx-ogl: Update gui with latest option * put shade boost in HW setting (not sure it is HW only) * Remove logz, useless since openGL support 32bits Z buffer * Update hack section with a table. Note don't put MSAA (not yet implemented) to have a nice square Note: user hack is enabled with "UserHacks" instead of "allowHacks" git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5184 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSLinuxDialog.cpp | 97 +++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/plugins/GSdx/GSLinuxDialog.cpp b/plugins/GSdx/GSLinuxDialog.cpp index 255e3a55e6..8d168c1ccd 100644 --- a/plugins/GSdx/GSLinuxDialog.cpp +++ b/plugins/GSdx/GSLinuxDialog.cpp @@ -25,10 +25,11 @@ #include "GSLinuxLogo.h" GtkWidget *msaa_combo_box, *render_combo_box, *filter_combo_box; -GtkWidget *logz_check, *paltex_check, *fba_check, *aa_check, *native_res_check; +GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check, *native_res_check; +GtkWidget *sb_contrast, *sb_brightness, *sb_saturation; GtkWidget *resx_spin, *resy_spin; -GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skidraw_spin; +GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check; static void SysMessage(const char *fmt, ...) { @@ -161,7 +162,7 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) if (hardware_render) { gtk_widget_set_sensitive(filter_combo_box, true); - gtk_widget_set_sensitive(logz_check, true); + gtk_widget_set_sensitive(shadeboost_check, true); gtk_widget_set_sensitive(paltex_check, true); gtk_widget_set_sensitive(fba_check, true); gtk_widget_set_sensitive(native_res_check, true); @@ -187,11 +188,15 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) gtk_widget_set_sensitive(resy_spin, false); } } + + gtk_widget_set_sensitive(sb_brightness,true); + gtk_widget_set_sensitive(sb_saturation,true); + gtk_widget_set_sensitive(sb_contrast,true); } else { gtk_widget_set_sensitive(filter_combo_box, false); - gtk_widget_set_sensitive(logz_check, false); + gtk_widget_set_sensitive(shadeboost_check, false); gtk_widget_set_sensitive(paltex_check, false); gtk_widget_set_sensitive(fba_check, false); @@ -199,6 +204,10 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data ) gtk_widget_set_sensitive(msaa_combo_box, false); gtk_widget_set_sensitive(resx_spin, false); gtk_widget_set_sensitive(resy_spin, false); + + gtk_widget_set_sensitive(sb_brightness,false); + gtk_widget_set_sensitive(sb_saturation,false); + gtk_widget_set_sensitive(sb_contrast,false); } } @@ -211,7 +220,7 @@ bool RunLinuxDialog() GtkWidget *interlace_combo_box, *threads_spin; GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label, *filter_label; - GtkWidget *hack_skipdraw_label, *hack_box, *hack_frame; + GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame; int return_value; GdkPixbuf* logo_pixmap; @@ -240,7 +249,7 @@ bool RunLinuxDialog() hw_box = gtk_vbox_new(false, 5); hw_frame = gtk_frame_new ("Hardware Mode Settings"); gtk_container_add(GTK_CONTAINER(hw_frame), hw_box); - hw_table = gtk_table_new(2,2, false); + hw_table = gtk_table_new(5,2, false); gtk_container_add(GTK_CONTAINER(hw_box), hw_table); // The software mode frame and container. (It doesn't have enough in it for a table.) @@ -252,6 +261,8 @@ bool RunLinuxDialog() hack_box = gtk_hbox_new(false, 5); hack_frame = gtk_frame_new ("Hacks"); gtk_container_add(GTK_CONTAINER(hack_frame), hack_box); + hack_table = gtk_table_new(3,3, false); + gtk_container_add(GTK_CONTAINER(hack_box), hack_table); // Grab a logo, to make things look nice. logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL); @@ -310,26 +321,35 @@ bool RunLinuxDialog() gtk_box_pack_start(GTK_BOX(resxy_box), rexy_label, false, false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5); gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5); - + // Create our hack settings. hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack"); hack_offset_check = gtk_check_button_new_with_label("Offset Hack"); hack_skipdraw_label = gtk_label_new("Skipdraw:"); - hack_skidraw_spin = gtk_spin_button_new_with_range(0,1000,1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skidraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0)); - gtk_box_pack_start(GTK_BOX(hack_box), hack_alpha_check, false, false, 5); - gtk_box_pack_start(GTK_BOX(hack_box), hack_offset_check, false, false, 5); - gtk_box_pack_start(GTK_BOX(hack_box), hack_skipdraw_label, false, false, 5); - gtk_box_pack_start(GTK_BOX(hack_box), hack_skidraw_spin, false, false, 0); - + hack_skipdraw_spin = gtk_spin_button_new_with_range(0,1000,1); + hack_enble_check = gtk_check_button_new_with_label("Enable User Hacks"); + hack_wild_check = gtk_check_button_new_with_label("Wild arm Hack"); + hack_sprite_check = gtk_check_button_new_with_label("Sprite Hack"); + hack_msaa_check = gtk_check_button_new_with_label("Msaa Hack"); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skipdraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0)); + // Tables are strange. The numbers are for their position: left, right, top, bottom. + gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_alpha_check, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_offset_check, 1, 2, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_sprite_check, 0, 1, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_wild_check, 1, 2, 1, 2); + // Note: MSAA is not implemented yet. I disable it to make the table square + //gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_msaa_check, 2, 3, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_label, 0, 1, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_spin, 1, 2, 2, 3); + // Create our checkboxes. - logz_check = gtk_check_button_new_with_label("Logarithmic Z"); + shadeboost_check = gtk_check_button_new_with_label("Shade boost"); paltex_check = gtk_check_button_new_with_label("Allow 8 bit textures"); fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)"); aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)"); // Set the checkboxes. - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(logz_check), theApp.GetConfig("logz", 1)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0)); @@ -337,6 +357,27 @@ bool RunLinuxDialog() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0)); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_enble_check), theApp.GetConfig("UserHacks", 0)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_msaa_check), theApp.GetConfig("UserHacks_MSAA", 0)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_wild_check), theApp.GetConfig("UserHacks_WildHack", 0)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_sprite_check), theApp.GetConfig("UserHacks_SpriteHack", 0)); + + // Shadeboost scale + sb_brightness = gtk_hscale_new_with_range(0, 200, 10); + GtkWidget* sb_brightness_label = gtk_label_new("Shade Boost Brightness"); + gtk_scale_set_value_pos(GTK_SCALE(sb_brightness), GTK_POS_RIGHT); + gtk_range_set_value(GTK_RANGE(sb_brightness), theApp.GetConfig("ShadeBoost_Brightness", 50)); + + sb_contrast = gtk_hscale_new_with_range(0, 200, 10); + GtkWidget* sb_contrast_label = gtk_label_new("Shade Boost Contrast"); + gtk_scale_set_value_pos(GTK_SCALE(sb_contrast), GTK_POS_RIGHT); + gtk_range_set_value(GTK_RANGE(sb_contrast), theApp.GetConfig("ShadeBoost_Contrast", 50)); + + sb_saturation = gtk_hscale_new_with_range(0, 200, 10); + GtkWidget* sb_saturation_label = gtk_label_new("Shade Boost Saturation"); + gtk_scale_set_value_pos(GTK_SCALE(sb_saturation), GTK_POS_RIGHT); + gtk_range_set_value(GTK_RANGE(sb_saturation), theApp.GetConfig("ShadeBoost_Saturation", 50)); // Populate all those boxes we created earlier with widgets. gtk_container_add(GTK_CONTAINER(res_box), native_box); @@ -348,9 +389,16 @@ bool RunLinuxDialog() // Tables are strange. The numbers are for their position: left, right, top, bottom. gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1); - gtk_table_attach_defaults(GTK_TABLE(hw_table), logz_check, 1, 2, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(hw_table), shadeboost_check, 1, 2, 0, 1); gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_brightness_label, 0, 1, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_brightness, 1, 2, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_contrast_label, 0, 1, 3, 4); + gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_contrast, 1, 2, 3, 4); + gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_saturation_label, 0, 1, 4, 5); + gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_saturation, 1, 2, 4, 5); + // Put everything in the big box. gtk_container_add(GTK_CONTAINER(main_box), renderer_box); @@ -359,7 +407,7 @@ bool RunLinuxDialog() gtk_container_add(GTK_CONTAINER(main_box), hw_frame); gtk_container_add(GTK_CONTAINER(main_box), sw_frame); - if (!!theApp.GetConfig("allowHacks", 0)) + if (!!theApp.GetConfig("UserHacks", 0)) { gtk_container_add(GTK_CONTAINER(main_box), hack_frame); } @@ -403,19 +451,28 @@ bool RunLinuxDialog() theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin))); theApp.SetConfig("filter", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(filter_combo_box))); - theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check))); + theApp.SetConfig("shadeboost", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shadeboost_check))); theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check))); theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check))); theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check))); theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check))); + theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation))); + theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness))); + theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast))); + theApp.SetConfig("msaa", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(msaa_combo_box))); theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin))); theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin))); - theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skidraw_spin))); + theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skipdraw_spin))); theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check))); theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check))); + + theApp.SetConfig("UserHacks_MSAA", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_msaa_check))); + theApp.SetConfig("UserHacks_WildHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_wild_check))); + theApp.SetConfig("UserHacks_SpriteHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_sprite_check))); + theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check))); // Let's just be windowed for the moment. theApp.SetConfig("windowed", 1); From f303da1c45403dceba3b782becb15886ef59ed51 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sat, 28 Apr 2012 09:39:23 +0000 Subject: [PATCH 56/56] gsdx-ogl: fix potential build failure on MS git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5185 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GS.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index e59abc2a55..0b1cad4b7f 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -441,12 +441,14 @@ EXPORT_C GSreadFIFO(uint8* mem) if (theApp.GetConfig("renderer", 0) / 3 == 4) { fprintf(stderr, "Disable FIFO1 on opengl\n"); } -#endif s_gs->m_wnd.AttachContext(); +#endif s_gs->ReadFIFO(mem, 1); +#ifdef _LINUX s_gs->m_wnd.DetachContext(); +#endif } EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) @@ -460,12 +462,14 @@ EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) #endif //return; } -#endif s_gs->m_wnd.AttachContext(); +#endif s_gs->ReadFIFO(mem, size); +#ifdef _LINUX s_gs->m_wnd.DetachContext(); +#endif } EXPORT_C GSgifTransfer(const uint8* mem, uint32 size)