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 "GSDevice11.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "GSTables.h"
|
|
|
|
|
|
|
|
bool GSDevice11::CreateTextureFX()
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
D3D11_BUFFER_DESC bd;
|
|
|
|
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
|
|
|
|
bd.ByteWidth = sizeof(VSConstantBuffer);
|
|
|
|
bd.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
|
|
|
|
|
|
hr = m_dev->CreateBuffer(&bd, NULL, &m_vs_cb);
|
|
|
|
|
|
|
|
if(FAILED(hr)) return false;
|
|
|
|
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
|
2017-03-03 21:18:49 +00:00
|
|
|
bd.ByteWidth = sizeof(GSConstantBuffer);
|
|
|
|
bd.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
|
|
|
|
|
|
hr = m_dev->CreateBuffer(&bd, NULL, &m_gs_cb);
|
|
|
|
|
|
|
|
if (FAILED(hr)) return false;
|
|
|
|
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
bd.ByteWidth = sizeof(PSConstantBuffer);
|
|
|
|
bd.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
|
|
|
|
|
|
hr = m_dev->CreateBuffer(&bd, NULL, &m_ps_cb);
|
|
|
|
|
|
|
|
if(FAILED(hr)) return false;
|
|
|
|
|
|
|
|
D3D11_SAMPLER_DESC sd;
|
|
|
|
|
|
|
|
memset(&sd, 0, sizeof(sd));
|
|
|
|
|
2020-01-18 20:25:08 +00:00
|
|
|
sd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
2010-04-24 21:37:39 +00:00
|
|
|
sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
2014-02-04 21:42:43 +00:00
|
|
|
sd.MinLOD = -FLT_MAX;
|
2010-04-24 21:37:39 +00:00
|
|
|
sd.MaxLOD = FLT_MAX;
|
2020-01-18 20:25:08 +00:00
|
|
|
sd.MaxAnisotropy = D3D11_MIN_MAXANISOTROPY;
|
2010-04-24 21:37:39 +00:00
|
|
|
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
|
|
|
|
|
|
|
hr = m_dev->CreateSamplerState(&sd, &m_palette_ss);
|
2010-05-14 14:05:39 +00:00
|
|
|
|
|
|
|
if(FAILED(hr)) return false;
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
// create layout
|
|
|
|
|
|
|
|
VSSelector sel;
|
|
|
|
VSConstantBuffer cb;
|
|
|
|
|
|
|
|
SetupVS(sel, &cb);
|
|
|
|
|
2017-03-03 21:18:49 +00:00
|
|
|
GSConstantBuffer gcb;
|
|
|
|
|
|
|
|
SetupGS(GSSelector(1), &gcb);
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|
|
|
{
|
2017-05-26 15:41:52 +00:00
|
|
|
auto i = std::as_const(m_vs).find(sel);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
if(i == m_vs.end())
|
|
|
|
{
|
2019-06-14 18:24:37 +00:00
|
|
|
ShaderMacro sm(m_shader.model);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-06-14 18:24:37 +00:00
|
|
|
sm.AddMacro("VS_TME", sel.tme);
|
|
|
|
sm.AddMacro("VS_FST", sel.fst);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
D3D11_INPUT_ELEMENT_DESC layout[] =
|
|
|
|
{
|
|
|
|
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2019-08-25 18:14:50 +00:00
|
|
|
{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2010-04-24 21:37:39 +00:00
|
|
|
{"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"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},
|
2012-01-19 04:53:36 +00:00
|
|
|
{"TEXCOORD", 2, DXGI_FORMAT_R16G16_UINT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2010-04-24 21:37:39 +00:00
|
|
|
{"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
GSVertexShader11 vs;
|
|
|
|
|
2017-04-08 15:54:27 +00:00
|
|
|
std::vector<char> shader;
|
2015-08-29 15:53:29 +00:00
|
|
|
theApp.LoadResource(IDR_TFX_FX, shader);
|
2019-06-14 18:24:37 +00:00
|
|
|
CreateShader(shader, "tfx.fx", nullptr, "vs_main", sm.GetPtr(), &vs.vs, layout, countof(layout), &vs.il);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
m_vs[sel] = vs;
|
|
|
|
|
|
|
|
i = m_vs.find(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_vs_cb_cache.Update(cb))
|
|
|
|
{
|
|
|
|
ID3D11DeviceContext* ctx = m_ctx;
|
|
|
|
|
|
|
|
ctx->UpdateSubresource(m_vs_cb, 0, NULL, cb, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
VSSetShader(i->second.vs, m_vs_cb);
|
2011-02-07 01:59:05 +00:00
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
IASetInputLayout(i->second.il);
|
|
|
|
}
|
|
|
|
|
2017-03-03 21:18:49 +00:00
|
|
|
void GSDevice11::SetupGS(GSSelector sel, const GSConstantBuffer* cb)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2010-06-07 18:41:37 +00:00
|
|
|
CComPtr<ID3D11GeometryShader> gs;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2020-06-29 07:10:37 +00:00
|
|
|
const bool unscale_pt_ln = (sel.point == 1 || sel.line == 1);
|
|
|
|
// Geometry shader is disabled if sprite conversion is done on the cpu (sel.cpu_sprite).
|
|
|
|
if ((sel.prim > 0 && sel.cpu_sprite == 0 && (sel.iip == 0 || sel.prim == 3)) || unscale_pt_ln)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2020-06-29 07:10:37 +00:00
|
|
|
const auto i = std::as_const(m_gs).find(sel);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2020-06-29 07:10:37 +00:00
|
|
|
if (i != m_gs.end())
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
|
|
|
gs = i->second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-06-14 18:24:37 +00:00
|
|
|
ShaderMacro sm(m_shader.model);
|
|
|
|
|
|
|
|
sm.AddMacro("GS_IIP", sel.iip);
|
|
|
|
sm.AddMacro("GS_PRIM", sel.prim);
|
|
|
|
sm.AddMacro("GS_POINT", sel.point);
|
|
|
|
sm.AddMacro("GS_LINE", sel.line);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2017-04-08 15:54:27 +00:00
|
|
|
std::vector<char> shader;
|
2015-08-29 15:53:29 +00:00
|
|
|
theApp.LoadResource(IDR_TFX_FX, shader);
|
2019-06-14 18:24:37 +00:00
|
|
|
CreateShader(shader, "tfx.fx", nullptr, "gs_main", sm.GetPtr(), &gs);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
m_gs[sel] = gs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-03 21:18:49 +00:00
|
|
|
|
|
|
|
if (m_gs_cb_cache.Update(cb))
|
|
|
|
{
|
|
|
|
ID3D11DeviceContext* ctx = m_ctx;
|
|
|
|
|
|
|
|
ctx->UpdateSubresource(m_gs_cb, 0, NULL, cb, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GSSetShader(gs, m_gs_cb);
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
|
|
|
{
|
2017-05-26 15:41:52 +00:00
|
|
|
auto i = std::as_const(m_ps).find(sel);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
if(i == m_ps.end())
|
|
|
|
{
|
2019-06-14 18:24:37 +00:00
|
|
|
ShaderMacro sm(m_shader.model);
|
|
|
|
|
|
|
|
sm.AddMacro("PS_SCALE_FACTOR", std::max(1, m_upscale_multiplier));
|
|
|
|
sm.AddMacro("PS_FST", sel.fst);
|
|
|
|
sm.AddMacro("PS_WMS", sel.wms);
|
|
|
|
sm.AddMacro("PS_WMT", sel.wmt);
|
|
|
|
sm.AddMacro("PS_FMT", sel.fmt);
|
|
|
|
sm.AddMacro("PS_AEM", sel.aem);
|
|
|
|
sm.AddMacro("PS_TFX", sel.tfx);
|
|
|
|
sm.AddMacro("PS_TCC", sel.tcc);
|
|
|
|
sm.AddMacro("PS_ATST", sel.atst);
|
|
|
|
sm.AddMacro("PS_FOG", sel.fog);
|
|
|
|
sm.AddMacro("PS_CLR1", sel.clr1);
|
|
|
|
sm.AddMacro("PS_FBA", sel.fba);
|
|
|
|
sm.AddMacro("PS_FBMASK", sel.fbmask);
|
|
|
|
sm.AddMacro("PS_LTF", sel.ltf);
|
|
|
|
sm.AddMacro("PS_TCOFFSETHACK", sel.tcoffsethack);
|
|
|
|
sm.AddMacro("PS_POINT_SAMPLER", sel.point_sampler);
|
|
|
|
sm.AddMacro("PS_SHUFFLE", sel.shuffle);
|
|
|
|
sm.AddMacro("PS_READ_BA", sel.read_ba);
|
|
|
|
sm.AddMacro("PS_CHANNEL_FETCH", sel.channel);
|
|
|
|
sm.AddMacro("PS_TALES_OF_ABYSS_HLE", sel.tales_of_abyss_hle);
|
|
|
|
sm.AddMacro("PS_URBAN_CHAOS_HLE", sel.urban_chaos_hle);
|
|
|
|
sm.AddMacro("PS_DFMT", sel.dfmt);
|
|
|
|
sm.AddMacro("PS_DEPTH_FMT", sel.depth_fmt);
|
|
|
|
sm.AddMacro("PS_PAL_FMT", sel.fmt >> 2);
|
|
|
|
sm.AddMacro("PS_INVALID_TEX0", sel.invalid_tex0);
|
|
|
|
sm.AddMacro("PS_HDR", sel.hdr);
|
2019-06-26 14:07:03 +00:00
|
|
|
sm.AddMacro("PS_COLCLIP", sel.colclip);
|
2019-06-14 18:24:37 +00:00
|
|
|
sm.AddMacro("PS_BLEND_A", sel.blend_a);
|
|
|
|
sm.AddMacro("PS_BLEND_B", sel.blend_b);
|
|
|
|
sm.AddMacro("PS_BLEND_C", sel.blend_c);
|
|
|
|
sm.AddMacro("PS_BLEND_D", sel.blend_d);
|
2021-02-04 01:39:20 +00:00
|
|
|
sm.AddMacro("PS_PABE", sel.pabe);
|
2019-09-15 18:49:34 +00:00
|
|
|
sm.AddMacro("PS_DITHER", sel.dither);
|
2020-06-06 15:21:03 +00:00
|
|
|
sm.AddMacro("PS_ZCLAMP", sel.zclamp);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
CComPtr<ID3D11PixelShader> ps;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2017-04-08 15:54:27 +00:00
|
|
|
std::vector<char> shader;
|
2015-08-29 15:53:29 +00:00
|
|
|
theApp.LoadResource(IDR_TFX_FX, shader);
|
2019-06-14 18:24:37 +00:00
|
|
|
CreateShader(shader, "tfx.fx", nullptr, "ps_main", sm.GetPtr(), &ps);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
m_ps[sel] = ps;
|
|
|
|
|
|
|
|
i = m_ps.find(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_ps_cb_cache.Update(cb))
|
|
|
|
{
|
|
|
|
ID3D11DeviceContext* ctx = m_ctx;
|
|
|
|
|
|
|
|
ctx->UpdateSubresource(m_ps_cb, 0, NULL, cb, 0, 0);
|
|
|
|
}
|
|
|
|
|
2010-06-07 18:41:37 +00:00
|
|
|
CComPtr<ID3D11SamplerState> ss0, ss1;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
if(sel.tfx != 4)
|
|
|
|
{
|
|
|
|
if(!(sel.fmt < 3 && sel.wms < 3 && sel.wmt < 3))
|
|
|
|
{
|
|
|
|
ssel.ltf = 0;
|
|
|
|
}
|
|
|
|
|
2017-05-26 15:41:52 +00:00
|
|
|
auto i = std::as_const(m_ps_ss).find(ssel);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
if(i != m_ps_ss.end())
|
|
|
|
{
|
|
|
|
ss0 = i->second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-03 16:58:11 +00:00
|
|
|
D3D11_SAMPLER_DESC sd, af;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
memset(&sd, 0, sizeof(sd));
|
|
|
|
|
2020-01-18 20:25:08 +00:00
|
|
|
af.Filter = m_aniso_filter ? D3D11_FILTER_ANISOTROPIC : D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
2014-02-03 16:58:11 +00:00
|
|
|
sd.Filter = ssel.ltf ? af.Filter : D3D11_FILTER_MIN_MAG_MIP_POINT;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
sd.AddressU = ssel.tau ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.AddressV = ssel.tav ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
2014-02-04 21:42:43 +00:00
|
|
|
sd.MinLOD = -FLT_MAX;
|
2010-04-24 21:37:39 +00:00
|
|
|
sd.MaxLOD = FLT_MAX;
|
2020-01-18 20:25:08 +00:00
|
|
|
sd.MaxAnisotropy = m_aniso_filter;
|
2010-04-24 21:37:39 +00:00
|
|
|
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
|
|
|
|
|
|
|
m_dev->CreateSamplerState(&sd, &ss0);
|
|
|
|
|
|
|
|
m_ps_ss[ssel] = ss0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sel.fmt >= 3)
|
|
|
|
{
|
|
|
|
ss1 = m_palette_ss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-20 00:19:36 +00:00
|
|
|
PSSetSamplerState(ss0, ss1);
|
2010-05-14 14:05:39 +00:00
|
|
|
|
|
|
|
PSSetShader(i->second, m_ps_cb);
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
|
|
|
{
|
2017-05-26 15:41:52 +00:00
|
|
|
auto i = std::as_const(m_om_dss).find(dssel);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
if(i == m_om_dss.end())
|
|
|
|
{
|
|
|
|
D3D11_DEPTH_STENCIL_DESC dsd;
|
|
|
|
|
|
|
|
memset(&dsd, 0, sizeof(dsd));
|
|
|
|
|
|
|
|
if(dssel.date)
|
|
|
|
{
|
|
|
|
dsd.StencilEnable = true;
|
|
|
|
dsd.StencilReadMask = 1;
|
|
|
|
dsd.StencilWriteMask = 1;
|
|
|
|
dsd.FrontFace.StencilFunc = D3D11_COMPARISON_EQUAL;
|
2018-11-28 19:33:15 +00:00
|
|
|
dsd.FrontFace.StencilPassOp = dssel.date_one ? D3D11_STENCIL_OP_ZERO : D3D11_STENCIL_OP_KEEP;
|
2010-04-24 21:37:39 +00:00
|
|
|
dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.BackFace.StencilFunc = D3D11_COMPARISON_EQUAL;
|
2018-11-28 19:33:15 +00:00
|
|
|
dsd.BackFace.StencilPassOp = dssel.date_one ? D3D11_STENCIL_OP_ZERO : D3D11_STENCIL_OP_KEEP;
|
2010-04-24 21:37:39 +00:00
|
|
|
dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dssel.ztst != ZTST_ALWAYS || dssel.zwe)
|
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
static const D3D11_COMPARISON_FUNC ztst[] =
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
D3D11_COMPARISON_NEVER,
|
|
|
|
D3D11_COMPARISON_ALWAYS,
|
|
|
|
D3D11_COMPARISON_GREATER_EQUAL,
|
2010-04-24 21:37:39 +00:00
|
|
|
D3D11_COMPARISON_GREATER
|
|
|
|
};
|
|
|
|
|
|
|
|
dsd.DepthEnable = true;
|
|
|
|
dsd.DepthWriteMask = dssel.zwe ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
|
|
|
|
dsd.DepthFunc = ztst[dssel.ztst];
|
|
|
|
}
|
|
|
|
|
|
|
|
CComPtr<ID3D11DepthStencilState> dss;
|
|
|
|
|
|
|
|
m_dev->CreateDepthStencilState(&dsd, &dss);
|
|
|
|
|
|
|
|
m_om_dss[dssel] = dss;
|
|
|
|
|
|
|
|
i = m_om_dss.find(dssel);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMSetDepthStencilState(i->second, 1);
|
|
|
|
|
2017-05-26 15:41:52 +00:00
|
|
|
auto j = std::as_const(m_om_bs).find(bsel);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
if(j == m_om_bs.end())
|
|
|
|
{
|
|
|
|
D3D11_BLEND_DESC bd;
|
|
|
|
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
|
|
|
|
bd.RenderTarget[0].BlendEnable = bsel.abe;
|
|
|
|
|
|
|
|
if(bsel.abe)
|
|
|
|
{
|
2020-10-29 22:08:05 +00:00
|
|
|
HWBlend blend = GetBlend(bsel.blend_index);
|
2019-06-06 14:21:32 +00:00
|
|
|
bd.RenderTarget[0].BlendOp = (D3D11_BLEND_OP)blend.op;
|
|
|
|
bd.RenderTarget[0].SrcBlend = (D3D11_BLEND)blend.src;
|
|
|
|
bd.RenderTarget[0].DestBlend = (D3D11_BLEND)blend.dst;
|
2010-04-24 21:37:39 +00:00
|
|
|
bd.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
|
|
|
bd.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
|
|
|
bd.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
2019-06-09 16:38:11 +00:00
|
|
|
|
|
|
|
if (bsel.accu_blend)
|
|
|
|
{
|
|
|
|
bd.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
|
|
|
bd.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
|
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(bsel.wr) bd.RenderTarget[0].RenderTargetWriteMask |= D3D11_COLOR_WRITE_ENABLE_RED;
|
|
|
|
if(bsel.wg) bd.RenderTarget[0].RenderTargetWriteMask |= D3D11_COLOR_WRITE_ENABLE_GREEN;
|
|
|
|
if(bsel.wb) bd.RenderTarget[0].RenderTargetWriteMask |= D3D11_COLOR_WRITE_ENABLE_BLUE;
|
|
|
|
if(bsel.wa) bd.RenderTarget[0].RenderTargetWriteMask |= D3D11_COLOR_WRITE_ENABLE_ALPHA;
|
|
|
|
|
|
|
|
CComPtr<ID3D11BlendState> bs;
|
|
|
|
|
|
|
|
m_dev->CreateBlendState(&bd, &bs);
|
|
|
|
|
|
|
|
m_om_bs[bsel] = bs;
|
|
|
|
|
|
|
|
j = m_om_bs.find(bsel);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMSetBlendState(j->second, (float)(int)afix / 0x80);
|
|
|
|
}
|