2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2010-04-24 21:37:39 +00:00
|
|
|
* 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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2010-04-24 21:37:39 +00:00
|
|
|
* 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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2010-04-24 21:37:39 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2010-04-24 21:37:39 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "GSRendererDX11.h"
|
|
|
|
|
|
|
|
GSRendererDX11::GSRendererDX11()
|
2016-10-13 09:25:48 +00:00
|
|
|
: GSRendererDX(new GSTextureCache11(this), GSVector2(-0.5f))
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GSRendererDX11::CreateDevice(GSDevice* dev)
|
|
|
|
{
|
2018-10-08 05:19:07 +00:00
|
|
|
if (!__super::CreateDevice(dev))
|
2010-04-24 21:37:39 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
void GSRendererDX11::EmulateTextureShuffleAndFbmask()
|
|
|
|
{
|
|
|
|
size_t count = m_vertex.next;
|
|
|
|
GSVertex* v = &m_vertex.buff[0];
|
|
|
|
|
|
|
|
// Note: D3D1011 is limited and can't read the current framebuffer so we can't have PS_FBMASK and PS_WRITE_RG shaders ported and working.
|
2018-10-08 05:19:07 +00:00
|
|
|
if (m_texture_shuffle)
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
m_ps_sel.shuffle = 1;
|
2018-09-13 07:35:42 +00:00
|
|
|
m_ps_sel.dfmt = 0;
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
|
|
|
|
const GIFRegXYOFFSET& o = m_context->XYOFFSET;
|
|
|
|
|
|
|
|
// vertex position is 8 to 16 pixels, therefore it is the 16-31 bits of the colors
|
|
|
|
int pos = (v[0].XYZ.X - o.OFX) & 0xFF;
|
|
|
|
bool write_ba = (pos > 112 && pos < 136);
|
|
|
|
// Read texture is 8 to 16 pixels (same as above)
|
|
|
|
float tw = (float)(1u << m_context->TEX0.TW);
|
|
|
|
int tex_pos = (PRIM->FST) ? v[0].U : (int)(tw * v[0].ST.S);
|
|
|
|
tex_pos &= 0xFF;
|
|
|
|
m_ps_sel.read_ba = (tex_pos > 112 && tex_pos < 144);
|
|
|
|
|
|
|
|
// Convert the vertex info to a 32 bits color format equivalent
|
2018-10-08 05:19:07 +00:00
|
|
|
if (PRIM->FST)
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
|
2018-10-08 05:19:07 +00:00
|
|
|
for(size_t i = 0; i < count; i += 2)
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
if (write_ba)
|
|
|
|
v[i].XYZ.X -= 128u;
|
|
|
|
else
|
|
|
|
v[i+1].XYZ.X += 128u;
|
|
|
|
|
|
|
|
if (m_ps_sel.read_ba)
|
|
|
|
v[i].U -= 128u;
|
|
|
|
else
|
|
|
|
v[i+1].U += 128u;
|
|
|
|
|
|
|
|
// Height is too big (2x).
|
|
|
|
int tex_offset = v[i].V & 0xF;
|
|
|
|
GSVector4i offset(o.OFY, tex_offset, o.OFY, tex_offset);
|
|
|
|
|
|
|
|
GSVector4i tmp(v[i].XYZ.Y, v[i].V, v[i+1].XYZ.Y, v[i+1].V);
|
|
|
|
tmp = GSVector4i(tmp - offset).srl32(1) + offset;
|
|
|
|
|
|
|
|
v[i].XYZ.Y = (uint16)tmp.x;
|
|
|
|
v[i].V = (uint16)tmp.y;
|
|
|
|
v[i+1].XYZ.Y = (uint16)tmp.z;
|
|
|
|
v[i+1].V = (uint16)tmp.w;
|
|
|
|
}
|
2018-10-08 05:19:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
const float offset_8pix = 8.0f / tw;
|
|
|
|
|
2018-10-08 05:19:07 +00:00
|
|
|
for(size_t i = 0; i < count; i += 2)
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
if (write_ba)
|
|
|
|
v[i].XYZ.X -= 128u;
|
|
|
|
else
|
|
|
|
v[i+1].XYZ.X += 128u;
|
|
|
|
|
|
|
|
if (m_ps_sel.read_ba)
|
|
|
|
v[i].ST.S -= offset_8pix;
|
|
|
|
else
|
|
|
|
v[i+1].ST.S += offset_8pix;
|
|
|
|
|
|
|
|
// Height is too big (2x).
|
|
|
|
GSVector4i offset(o.OFY, o.OFY);
|
|
|
|
|
|
|
|
GSVector4i tmp(v[i].XYZ.Y, v[i+1].XYZ.Y);
|
|
|
|
tmp = GSVector4i(tmp - offset).srl32(1) + offset;
|
|
|
|
|
|
|
|
//fprintf(stderr, "Before %d, After %d\n", v[i+1].XYZ.Y, tmp.y);
|
|
|
|
v[i].XYZ.Y = (uint16)tmp.x;
|
|
|
|
v[i].ST.T /= 2.0f;
|
|
|
|
v[i+1].XYZ.Y = (uint16)tmp.y;
|
|
|
|
v[i+1].ST.T /= 2.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Please bang my head against the wall!
|
|
|
|
// 1/ Reduce the frame mask to a 16 bit format
|
|
|
|
const uint32& m = m_context->FRAME.FBMSK;
|
|
|
|
uint32 fbmask = ((m >> 3) & 0x1F) | ((m >> 6) & 0x3E0) | ((m >> 9) & 0x7C00) | ((m >> 16) & 0x8000);
|
2018-04-23 18:09:49 +00:00
|
|
|
// FIXME GSVector will be nice here
|
|
|
|
uint8 rg_mask = fbmask & 0xFF;
|
|
|
|
uint8 ba_mask = (fbmask >> 8) & 0xFF;
|
2018-11-13 00:56:11 +00:00
|
|
|
m_om_bsel.wrgba = 0;
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
|
|
|
|
// 2 Select the new mask (Please someone put SSE here)
|
2018-10-08 05:19:07 +00:00
|
|
|
if (rg_mask != 0xFF)
|
|
|
|
{
|
|
|
|
if (write_ba)
|
|
|
|
{
|
2018-11-13 00:56:11 +00:00
|
|
|
m_om_bsel.wb = 1;
|
2018-10-08 05:19:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-13 00:56:11 +00:00
|
|
|
m_om_bsel.wr = 1;
|
2018-04-23 18:09:49 +00:00
|
|
|
}
|
2018-10-08 05:19:07 +00:00
|
|
|
}
|
|
|
|
else if ((fbmask & 0xFF) != 0xFF)
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
#ifdef _DEBUG
|
2018-11-13 00:56:11 +00:00
|
|
|
fprintf(stderr, "Please fix me! wb %u wr %u\n", m_om_bsel.wb, m_om_bsel.wr);
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
#endif
|
|
|
|
//ASSERT(0);
|
|
|
|
}
|
|
|
|
|
2018-10-08 05:19:07 +00:00
|
|
|
if (ba_mask != 0xFF)
|
|
|
|
{
|
|
|
|
if (write_ba)
|
|
|
|
{
|
2018-11-13 00:56:11 +00:00
|
|
|
m_om_bsel.wa = 1;
|
2018-10-08 05:19:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-13 00:56:11 +00:00
|
|
|
m_om_bsel.wg = 1;
|
2018-04-23 18:09:49 +00:00
|
|
|
}
|
2018-10-08 05:19:07 +00:00
|
|
|
}
|
|
|
|
else if ((fbmask & 0xFF) != 0xFF)
|
|
|
|
{
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
#ifdef _DEBUG
|
2018-11-13 00:56:11 +00:00
|
|
|
fprintf(stderr, "Please fix me! wa %u wg %u\n", m_om_bsel.wa, m_om_bsel.wg);
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
#endif
|
|
|
|
//ASSERT(0);
|
|
|
|
}
|
2018-10-08 05:19:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-13 07:35:42 +00:00
|
|
|
m_ps_sel.dfmt = GSLocalMemory::m_psm[m_context->FRAME.PSM].fmt;
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
|
2018-11-13 00:56:11 +00:00
|
|
|
m_om_bsel.wrgba = ~GSVector4i::load((int)m_context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask();
|
GSdx-D3D: Texture and channel shuffle improvements.
Texture Shuffle changes:
Always Enable Texture shuffle on D3D10/11.
Previously Texture shuffle was enabled if CRC hack
level was below Full, this was kinda not good since
D3D also relies on CRC hacks on Full so you could either
stick with texture shuffle or crc hacks.
Texture shuffle is not supported on D3D9, however we can do a partial
port where instead of vertical lines with the effect we get the effect
on the entire screen. Better than nothing I suppose.
Ported some of the code from OpenGL to D3D
( just a copy - paste job :) ),
part of the code misses a dedicated shader but we can still
use it to fix various issues on many games.
List of affected games tested so far:
The Godfather, Final Fight Streetwise, The Suffering Ties that Bind,
Urban Chaos have their vertical lines issues fixed
(highly possible for other games as well), MGS and Stolen see an improvement
but they are still broken without crc hacks. Other games that suffered
similar issues are probably affected as well.
Channel Shuffle changes:
Update Channel Shuffle detection. A lot of games should see an improvement,
MGS, Urban Chaos, Stolen have their top left corner issues resolved.
Other games should be affected as well that use similar logic.
They still miss a shader so some effects are still broken/show glitches
but it's a nice improvement for D3D users.
Shared changes:
Texture Shuffle and Channel shuffle have been moved to their
own dedicated functions. Should make things a bit cleaner.
Move part of the code for Texture Shuffle to GSRendererHW to be shared
across all HW renderers, should aboid copy paste/duplicate code.
2018-03-18 09:08:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-11 15:18:40 +00:00
|
|
|
void GSRendererDX11::EmulateChannelShuffle(GSTexture** rt, const GSTextureCache::Source* tex)
|
|
|
|
{
|
|
|
|
// Uncomment to disable HLE emulation (allow to trace the draw call)
|
|
|
|
// m_channel_shuffle = false;
|
|
|
|
|
|
|
|
// First let's check we really have a channel shuffle effect
|
|
|
|
if (m_channel_shuffle)
|
|
|
|
{
|
2018-12-17 10:50:16 +00:00
|
|
|
if (m_game.title == CRC::GT4 || m_game.title == CRC::GT3 || m_game.title == CRC::GTConcept || m_game.title == CRC::TouristTrophy)
|
|
|
|
{
|
|
|
|
// fprintf(stderr, "Gran Turismo RGB Channel\n");
|
|
|
|
m_ps_sel.channel = ChannelFetch_RGB;
|
|
|
|
m_context->TEX0.TFX = TFX_DECAL;
|
|
|
|
*rt = tex->m_from_target;
|
|
|
|
}
|
|
|
|
else if (m_game.title == CRC::Tekken5)
|
2018-12-11 15:18:40 +00:00
|
|
|
{
|
|
|
|
if (m_context->FRAME.FBW == 1)
|
|
|
|
{
|
|
|
|
// Used in stages: Secret Garden, Acid Rain, Moonlit Wilderness
|
|
|
|
// fprintf(stderr, "Tekken5 RGB Channel\n");
|
2018-12-17 10:50:16 +00:00
|
|
|
m_ps_sel.channel = ChannelFetch_RGB;
|
|
|
|
m_context->FRAME.FBMSK = 0xFF000000;
|
2018-12-11 15:18:40 +00:00
|
|
|
// 12 pages: 2 calls by channel, 3 channels, 1 blit
|
|
|
|
// Minus current draw call
|
|
|
|
m_skip = 12 * (3 + 3 + 1) - 1;
|
2018-12-17 10:50:16 +00:00
|
|
|
*rt = tex->m_from_target;
|
2018-12-11 15:18:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Could skip model drawing if wrongly detected
|
|
|
|
m_channel_shuffle = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((tex->m_texture->GetType() == GSTexture::DepthStencil) && !(tex->m_32_bits_fmt))
|
|
|
|
{
|
2018-12-13 01:55:10 +00:00
|
|
|
// So far 2 games hit this code path. Urban Chaos and Tales of Abyss
|
|
|
|
// UC: will copy depth to green channel
|
|
|
|
// ToA: will copy depth to alpha channel
|
|
|
|
if ((m_context->FRAME.FBMSK & 0xFF0000) == 0xFF0000)
|
|
|
|
{
|
|
|
|
// Green channel is masked
|
|
|
|
// fprintf(stderr, "Tales Of Abyss Crazyness (MSB 16b depth to Alpha)\n");
|
|
|
|
m_ps_sel.tales_of_abyss_hle = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fprintf(stderr, "Urban Chaos Crazyness (Green extraction)\n");
|
|
|
|
m_ps_sel.urban_chaos_hle = 1;
|
|
|
|
}
|
2018-12-11 15:18:40 +00:00
|
|
|
}
|
|
|
|
else if (m_index.tail <= 64 && m_context->CLAMP.WMT == 3)
|
|
|
|
{
|
|
|
|
// Blood will tell. I think it is channel effect too but again
|
|
|
|
// implemented in a different way. I don't want to add more CRC stuff. So
|
|
|
|
// let's disable channel when the signature is different.
|
|
|
|
//
|
|
|
|
// Note: Tales Of Abyss and Tekken5 could hit this path too. Those games are
|
|
|
|
// handled above.
|
|
|
|
// fprintf(stderr, "Maybe not a channel!\n");
|
|
|
|
m_channel_shuffle = false;
|
|
|
|
}
|
|
|
|
else if (m_context->CLAMP.WMS == 3 && ((m_context->CLAMP.MAXU & 0x8) == 8))
|
|
|
|
{
|
|
|
|
// Read either blue or Alpha. Let's go for Blue ;)
|
|
|
|
// MGS3/Kill Zone
|
|
|
|
// fprintf(stderr, "Blue channel\n");
|
|
|
|
m_ps_sel.channel = ChannelFetch_BLUE;
|
|
|
|
}
|
|
|
|
else if (m_context->CLAMP.WMS == 3 && ((m_context->CLAMP.MINU & 0x8) == 0))
|
|
|
|
{
|
|
|
|
// Read either Red or Green. Let's check the V coordinate. 0-1 is likely top so
|
|
|
|
// red. 2-3 is likely bottom so green (actually depends on texture base pointer offset)
|
|
|
|
bool green = PRIM->FST && (m_vertex.buff[0].V & 32);
|
|
|
|
if (green && (m_context->FRAME.FBMSK & 0x00FFFFFF) == 0x00FFFFFF)
|
|
|
|
{
|
|
|
|
// Typically used in Terminator 3
|
|
|
|
int blue_mask = m_context->FRAME.FBMSK >> 24;
|
|
|
|
int green_mask = ~blue_mask & 0xFF;
|
|
|
|
int blue_shift = -1;
|
|
|
|
|
|
|
|
// Note: potentially we could also check the value of the clut
|
|
|
|
switch (m_context->FRAME.FBMSK >> 24)
|
|
|
|
{
|
|
|
|
case 0xFF: ASSERT(0); break;
|
|
|
|
case 0xFE: blue_shift = 1; break;
|
|
|
|
case 0xFC: blue_shift = 2; break;
|
|
|
|
case 0xF8: blue_shift = 3; break;
|
|
|
|
case 0xF0: blue_shift = 4; break;
|
|
|
|
case 0xE0: blue_shift = 5; break;
|
|
|
|
case 0xC0: blue_shift = 6; break;
|
|
|
|
case 0x80: blue_shift = 7; break;
|
|
|
|
default: ASSERT(0); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int green_shift = 8 - blue_shift;
|
|
|
|
ps_cb.ChannelShuffle = GSVector4i(blue_mask, blue_shift, green_mask, green_shift);
|
|
|
|
|
|
|
|
if (blue_shift >= 0)
|
|
|
|
{
|
|
|
|
// fprintf(stderr, "Green/Blue channel (%d, %d)\n", blue_shift, green_shift);
|
|
|
|
m_ps_sel.channel = ChannelFetch_GXBY;
|
|
|
|
m_context->FRAME.FBMSK = 0x00FFFFFF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fprintf(stderr, "Green channel (wrong mask) (fbmask %x)\n", m_context->FRAME.FBMSK >> 24);
|
|
|
|
m_ps_sel.channel = ChannelFetch_GREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (green)
|
|
|
|
{
|
|
|
|
// fprintf(stderr, "Green channel\n");
|
|
|
|
m_ps_sel.channel = ChannelFetch_GREEN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Pop
|
|
|
|
// fprintf(stderr, "Red channel\n");
|
|
|
|
m_ps_sel.channel = ChannelFetch_RED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fprintf(stderr, "Channel not supported\n");
|
|
|
|
m_channel_shuffle = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Effect is really a channel shuffle effect so let's cheat a little
|
|
|
|
if (m_channel_shuffle)
|
|
|
|
{
|
2018-12-12 18:12:36 +00:00
|
|
|
// FIXME: Slot 4 - unbind texture when it isn't used.
|
2018-12-11 15:18:40 +00:00
|
|
|
dev->PSSetShaderResource(4, tex->m_from_target);
|
|
|
|
// Replace current draw with a fullscreen sprite
|
|
|
|
//
|
|
|
|
// Performance GPU note: it could be wise to reduce the size to
|
|
|
|
// the rendered size of the framebuffer
|
|
|
|
|
|
|
|
GSVertex* s = &m_vertex.buff[0];
|
|
|
|
s[0].XYZ.X = (uint16)(m_context->XYOFFSET.OFX + 0);
|
|
|
|
s[1].XYZ.X = (uint16)(m_context->XYOFFSET.OFX + 16384);
|
|
|
|
s[0].XYZ.Y = (uint16)(m_context->XYOFFSET.OFY + 0);
|
|
|
|
s[1].XYZ.Y = (uint16)(m_context->XYOFFSET.OFY + 16384);
|
|
|
|
|
|
|
|
m_vertex.head = m_vertex.tail = m_vertex.next = 2;
|
|
|
|
m_index.tail = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
|
|
dev->PSSetShaderResource(4, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-03 21:18:49 +00:00
|
|
|
void GSRendererDX11::SetupIA(const float& sx, const float& sy)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2012-01-19 04:53:36 +00:00
|
|
|
GSDevice11* dev = (GSDevice11*)m_dev;
|
2012-01-06 00:17:52 +00:00
|
|
|
|
2017-03-03 21:18:49 +00:00
|
|
|
D3D11_PRIMITIVE_TOPOLOGY t;
|
|
|
|
|
2018-11-25 06:10:36 +00:00
|
|
|
bool unscale_pt_ln = (GetUpscaleMultiplier() != 1);
|
2017-03-03 21:18:49 +00:00
|
|
|
|
|
|
|
switch (m_vt.m_primclass)
|
|
|
|
{
|
|
|
|
case GS_POINT_CLASS:
|
2018-11-25 06:10:36 +00:00
|
|
|
if (unscale_pt_ln)
|
2018-10-08 05:19:07 +00:00
|
|
|
{
|
2017-03-03 21:18:49 +00:00
|
|
|
m_gs_sel.point = 1;
|
|
|
|
gs_cb.PointSize = GSVector2(16.0f * sx, 16.0f * sy);
|
|
|
|
}
|
|
|
|
|
|
|
|
t = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
|
|
|
|
break;
|
|
|
|
case GS_LINE_CLASS:
|
2018-11-25 06:10:36 +00:00
|
|
|
if (unscale_pt_ln)
|
2018-10-08 05:19:07 +00:00
|
|
|
{
|
2017-03-03 21:18:49 +00:00
|
|
|
m_gs_sel.line = 1;
|
|
|
|
gs_cb.PointSize = GSVector2(16.0f * sx, 16.0f * sy);
|
|
|
|
}
|
|
|
|
|
|
|
|
t = D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case GS_SPRITE_CLASS:
|
2017-06-13 00:11:45 +00:00
|
|
|
t = D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
|
2017-03-03 21:18:49 +00:00
|
|
|
break;
|
|
|
|
case GS_TRIANGLE_CLASS:
|
|
|
|
|
|
|
|
t = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
__assume(0);
|
|
|
|
}
|
|
|
|
|
2012-01-19 04:53:36 +00:00
|
|
|
void* ptr = NULL;
|
2011-02-07 01:59:05 +00:00
|
|
|
|
2018-10-08 05:19:07 +00:00
|
|
|
if (dev->IAMapVertexBuffer(&ptr, sizeof(GSVertex), m_vertex.next))
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2013-02-12 10:57:48 +00:00
|
|
|
GSVector4i::storent(ptr, m_vertex.buff, sizeof(GSVertex) * m_vertex.next);
|
|
|
|
|
2018-10-08 05:19:07 +00:00
|
|
|
if (UserHacks_WildHack && !isPackedUV_HackFlag)
|
2013-02-12 10:57:48 +00:00
|
|
|
{
|
|
|
|
GSVertex* RESTRICT d = (GSVertex*)ptr;
|
|
|
|
|
GSdx:
- changed the KH2 fix in GetTextureMinMax to my taste, should give the same results, when the used texture rect is to the left/above the clamped area, it returns [min, min+1], and [max-1, max] for right/below
- m_mem.m_clut.Read32 was returned to its original place from GetAlphaMinMax
- UserHacks_WildHack was moved up to GSState, special UV handlers are only used when this setting is active
- updated xbyak to the latest available (avx2 seems incomplete, the 256-bit promoted old instructions are missing)
- changed vtune's include path to the 2013 edition
Some other not yet commited changes from a year ago:
- WriteImageX overflow crash-fix
- moved colclamp after dithering (sw mode), it makes more sense, no visible changes noticed
- Gif_Tag::analyzeTag(), there was a conditional I didn't like, split the loop into two parts
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5649 96395faa-99c1-11dd-bbfe-3dabce05a288
2013-06-06 11:36:01 +00:00
|
|
|
for(unsigned int i = 0; i < m_vertex.next; i++)
|
|
|
|
{
|
2018-10-08 05:19:07 +00:00
|
|
|
if (PRIM->TME && PRIM->FST) d[i].UV &= 0x3FEF3FEF;
|
GSdx:
- changed the KH2 fix in GetTextureMinMax to my taste, should give the same results, when the used texture rect is to the left/above the clamped area, it returns [min, min+1], and [max-1, max] for right/below
- m_mem.m_clut.Read32 was returned to its original place from GetAlphaMinMax
- UserHacks_WildHack was moved up to GSState, special UV handlers are only used when this setting is active
- updated xbyak to the latest available (avx2 seems incomplete, the 256-bit promoted old instructions are missing)
- changed vtune's include path to the 2013 edition
Some other not yet commited changes from a year ago:
- WriteImageX overflow crash-fix
- moved colclamp after dithering (sw mode), it makes more sense, no visible changes noticed
- Gif_Tag::analyzeTag(), there was a conditional I didn't like, split the loop into two parts
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5649 96395faa-99c1-11dd-bbfe-3dabce05a288
2013-06-06 11:36:01 +00:00
|
|
|
}
|
2013-02-12 10:57:48 +00:00
|
|
|
}
|
|
|
|
|
2012-01-19 04:53:36 +00:00
|
|
|
dev->IAUnmapVertexBuffer();
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
2010-08-17 04:38:49 +00:00
|
|
|
|
2012-01-19 04:53:36 +00:00
|
|
|
dev->IASetIndexBuffer(m_index.buff, m_index.tail);
|
|
|
|
dev->IASetPrimitiveTopology(t);
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|