2009-06-19 20:31:36 +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.
|
|
|
|
*
|
|
|
|
* 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"
|
2009-09-18 00:16:52 +00:00
|
|
|
#include "GSDevice11.h"
|
2009-06-19 20:31:36 +00:00
|
|
|
#include "resource.h"
|
2010-03-11 18:41:31 +00:00
|
|
|
#include "GSTables.h"
|
2009-06-19 20:31:36 +00:00
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
bool GSDevice11::CreateTextureFX()
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
hr = m_dev->CreateBuffer(&bd, NULL, &m_vs_cb);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
if(FAILED(hr)) return false;
|
|
|
|
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
|
|
|
|
bd.ByteWidth = sizeof(PSConstantBuffer);
|
|
|
|
bd.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
hr = m_dev->CreateBuffer(&bd, NULL, &m_ps_cb);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
if(FAILED(hr)) return false;
|
|
|
|
|
|
|
|
D3D11_SAMPLER_DESC sd;
|
|
|
|
|
|
|
|
memset(&sd, 0, sizeof(sd));
|
|
|
|
|
|
|
|
sd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
|
|
|
sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
|
|
sd.MaxLOD = FLT_MAX;
|
|
|
|
sd.MaxAnisotropy = 16;
|
|
|
|
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
hr = m_dev->CreateSamplerState(&sd, &m_palette_ss);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
if(FAILED(hr)) return false;
|
|
|
|
|
2009-07-16 21:36:07 +00:00
|
|
|
// create layout
|
|
|
|
|
|
|
|
VSSelector sel;
|
|
|
|
VSConstantBuffer cb;
|
|
|
|
|
|
|
|
SetupVS(sel, &cb);
|
|
|
|
|
2009-06-19 20:31:36 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
void GSDevice11::SetupIA(const void* vertices, int count, int prim)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
2009-09-18 00:16:52 +00:00
|
|
|
IASetVertexBuffer(vertices, sizeof(GSVertexHW11), count);
|
|
|
|
IASetInputLayout(m_il);
|
|
|
|
IASetPrimitiveTopology((D3D11_PRIMITIVE_TOPOLOGY)prim);
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
hash_map<uint32, CComPtr<ID3D11VertexShader> >::const_iterator i = m_vs.find(sel);
|
|
|
|
|
|
|
|
if(i == m_vs.end())
|
|
|
|
{
|
2009-07-16 21:36:07 +00:00
|
|
|
string str[3];
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
str[0] = format("%d", sel.bppz);
|
|
|
|
str[1] = format("%d", sel.tme);
|
|
|
|
str[2] = format("%d", sel.fst);
|
|
|
|
|
|
|
|
D3D11_SHADER_MACRO macro[] =
|
|
|
|
{
|
|
|
|
{"VS_BPPZ", str[0].c_str()},
|
|
|
|
{"VS_TME", str[1].c_str()},
|
|
|
|
{"VS_FST", str[2].c_str()},
|
|
|
|
{NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
D3D11_INPUT_ELEMENT_DESC layout[] =
|
|
|
|
{
|
|
|
|
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2009-06-23 04:12:32 +00:00
|
|
|
{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"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},
|
2009-06-19 20:31:36 +00:00
|
|
|
{"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
CComPtr<ID3D11InputLayout> il;
|
|
|
|
CComPtr<ID3D11VertexShader> vs;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
if(m_il == NULL)
|
|
|
|
{
|
|
|
|
m_il = il;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_vs[sel] = vs;
|
|
|
|
|
|
|
|
i = m_vs.find(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_vs_cb_cache.Update(cb))
|
|
|
|
{
|
2009-09-18 00:16:52 +00:00
|
|
|
ID3D11DeviceContext* ctx = m_ctx;
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
ctx->UpdateSubresource(m_vs_cb, 0, NULL, cb, 0, 0);
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
VSSetShader(i->second, m_vs_cb);
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
void GSDevice11::SetupGS(GSSelector sel)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
ID3D11GeometryShader* gs = NULL;
|
|
|
|
|
|
|
|
if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) // geometry shader works in every case, but not needed
|
|
|
|
{
|
|
|
|
hash_map<uint32, CComPtr<ID3D11GeometryShader> >::const_iterator i = m_gs.find(sel);
|
|
|
|
|
|
|
|
if(i != m_gs.end())
|
|
|
|
{
|
2009-06-27 03:32:33 +00:00
|
|
|
gs = i->second;
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
string str[2];
|
|
|
|
|
|
|
|
str[0] = format("%d", sel.iip);
|
|
|
|
str[1] = format("%d", sel.prim);
|
|
|
|
|
|
|
|
D3D11_SHADER_MACRO macro[] =
|
|
|
|
{
|
2009-06-19 20:43:08 +00:00
|
|
|
{"GS_IIP", str[0].c_str()},
|
|
|
|
{"GS_PRIM", str[1].c_str()},
|
2009-06-19 20:31:36 +00:00
|
|
|
{NULL, NULL},
|
|
|
|
};
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
CompileShader(IDR_TFX_FX, "gs_main", macro, &gs);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
m_gs[sel] = gs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
GSSetShader(gs);
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
hash_map<uint32, CComPtr<ID3D11PixelShader> >::const_iterator i = m_ps.find(sel);
|
|
|
|
|
|
|
|
if(i == m_ps.end())
|
|
|
|
{
|
2010-03-12 19:01:05 +00:00
|
|
|
string str[14];
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
str[0] = format("%d", sel.fst);
|
|
|
|
str[1] = format("%d", sel.wms);
|
|
|
|
str[2] = format("%d", sel.wmt);
|
2009-07-06 16:35:06 +00:00
|
|
|
str[3] = format("%d", sel.fmt);
|
2009-06-19 20:31:36 +00:00
|
|
|
str[4] = format("%d", sel.aem);
|
|
|
|
str[5] = format("%d", sel.tfx);
|
|
|
|
str[6] = format("%d", sel.tcc);
|
2009-07-26 15:30:25 +00:00
|
|
|
str[7] = format("%d", sel.atst);
|
|
|
|
str[8] = format("%d", sel.fog);
|
|
|
|
str[9] = format("%d", sel.clr1);
|
|
|
|
str[10] = format("%d", sel.fba);
|
|
|
|
str[11] = format("%d", sel.aout);
|
|
|
|
str[12] = format("%d", sel.ltf);
|
2010-03-12 19:01:05 +00:00
|
|
|
str[13] = format("%d", sel.colclip);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
D3D11_SHADER_MACRO macro[] =
|
|
|
|
{
|
2009-06-19 20:43:08 +00:00
|
|
|
{"PS_FST", str[0].c_str()},
|
|
|
|
{"PS_WMS", str[1].c_str()},
|
|
|
|
{"PS_WMT", str[2].c_str()},
|
2009-07-06 16:35:06 +00:00
|
|
|
{"PS_FMT", str[3].c_str()},
|
2009-06-19 20:43:08 +00:00
|
|
|
{"PS_AEM", str[4].c_str()},
|
|
|
|
{"PS_TFX", str[5].c_str()},
|
|
|
|
{"PS_TCC", str[6].c_str()},
|
2009-07-26 15:30:25 +00:00
|
|
|
{"PS_ATST", str[7].c_str()},
|
|
|
|
{"PS_FOG", str[8].c_str()},
|
|
|
|
{"PS_CLR1", str[9].c_str()},
|
|
|
|
{"PS_FBA", str[10].c_str()},
|
|
|
|
{"PS_AOUT", str[11].c_str()},
|
|
|
|
{"PS_LTF", str[12].c_str()},
|
2010-03-12 19:01:05 +00:00
|
|
|
{"PS_COLCLIP", str[13].c_str()},
|
2009-06-19 20:31:36 +00:00
|
|
|
{NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
CComPtr<ID3D11PixelShader> ps;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
m_ps[sel] = ps;
|
|
|
|
|
|
|
|
i = m_ps.find(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_ps_cb_cache.Update(cb))
|
|
|
|
{
|
2009-09-18 00:16:52 +00:00
|
|
|
ID3D11DeviceContext* ctx = m_ctx;
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
ctx->UpdateSubresource(m_ps_cb, 0, NULL, cb, 0, 0);
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
PSSetShader(i->second, m_ps_cb);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
ID3D11SamplerState* ss0 = NULL;
|
|
|
|
ID3D11SamplerState* ss1 = NULL;
|
|
|
|
|
|
|
|
if(sel.tfx != 4)
|
|
|
|
{
|
2009-07-06 16:35:06 +00:00
|
|
|
if(!(sel.fmt < 3 && sel.wms < 3 && sel.wmt < 3))
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
ssel.ltf = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
hash_map<uint32, CComPtr<ID3D11SamplerState> >::const_iterator i = m_ps_ss.find(ssel);
|
|
|
|
|
|
|
|
if(i != m_ps_ss.end())
|
|
|
|
{
|
2009-06-27 03:32:33 +00:00
|
|
|
ss0 = i->second;
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D3D11_SAMPLER_DESC sd;
|
|
|
|
|
|
|
|
memset(&sd, 0, sizeof(sd));
|
|
|
|
|
|
|
|
sd.Filter = ssel.ltf ? D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_POINT;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
sd.MaxLOD = FLT_MAX;
|
|
|
|
sd.MaxAnisotropy = 16;
|
|
|
|
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
m_dev->CreateSamplerState(&sd, &ss0);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
m_ps_ss[ssel] = ss0;
|
|
|
|
}
|
|
|
|
|
2009-07-06 16:35:06 +00:00
|
|
|
if(sel.fmt >= 3)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
ss1 = m_palette_ss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
PSSetSamplerState(ss0, ss1);
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
hash_map<uint32, CComPtr<ID3D11DepthStencilState> >::const_iterator i = m_om_dss.find(dssel);
|
|
|
|
|
|
|
|
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;
|
|
|
|
dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.BackFace.StencilFunc = D3D11_COMPARISON_EQUAL;
|
|
|
|
dsd.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
}
|
|
|
|
|
2009-07-16 21:36:07 +00:00
|
|
|
if(dssel.ztst != ZTST_ALWAYS || dssel.zwe)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
static const D3D11_COMPARISON_FUNC ztst[] =
|
|
|
|
{
|
|
|
|
D3D11_COMPARISON_NEVER,
|
|
|
|
D3D11_COMPARISON_ALWAYS,
|
|
|
|
D3D11_COMPARISON_GREATER_EQUAL,
|
|
|
|
D3D11_COMPARISON_GREATER
|
|
|
|
};
|
|
|
|
|
2009-07-16 21:36:07 +00:00
|
|
|
dsd.DepthEnable = true;
|
2009-06-19 20:31:36 +00:00
|
|
|
dsd.DepthWriteMask = dssel.zwe ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
|
|
|
|
dsd.DepthFunc = ztst[dssel.ztst];
|
|
|
|
}
|
|
|
|
|
|
|
|
CComPtr<ID3D11DepthStencilState> dss;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
m_dev->CreateDepthStencilState(&dsd, &dss);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
m_om_dss[dssel] = dss;
|
|
|
|
|
|
|
|
i = m_om_dss.find(dssel);
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
OMSetDepthStencilState(i->second, 1);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
hash_map<uint32, CComPtr<ID3D11BlendState> >::const_iterator j = m_om_bs.find(bsel);
|
|
|
|
|
|
|
|
if(j == m_om_bs.end())
|
|
|
|
{
|
|
|
|
D3D11_BLEND_DESC bd;
|
|
|
|
|
|
|
|
memset(&bd, 0, sizeof(bd));
|
|
|
|
|
|
|
|
bd.RenderTarget[0].BlendEnable = bsel.abe;
|
|
|
|
|
|
|
|
if(bsel.abe)
|
|
|
|
{
|
|
|
|
int i = ((bsel.a * 3 + bsel.b) * 3 + bsel.c) * 3 + bsel.d;
|
|
|
|
|
2010-03-11 18:41:31 +00:00
|
|
|
bd.RenderTarget[0].BlendOp = (D3D11_BLEND_OP)blendMapD3D9[i].op;
|
|
|
|
bd.RenderTarget[0].SrcBlend = (D3D11_BLEND)blendMapD3D9[i].src;
|
|
|
|
bd.RenderTarget[0].DestBlend = (D3D11_BLEND)blendMapD3D9[i].dst;
|
2009-06-19 20:31:36 +00:00
|
|
|
bd.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
|
|
|
bd.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
|
|
|
bd.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
|
|
|
|
2010-03-11 18:41:31 +00:00
|
|
|
// SRC* -> SRC1*
|
|
|
|
// Yes, this casting mess really is needed. I want to go back to C
|
|
|
|
if (bd.RenderTarget[0].SrcBlend >= 3 && bd.RenderTarget[0].SrcBlend <= 6)
|
|
|
|
bd.RenderTarget[0].SrcBlend = (D3D11_BLEND)((int)bd.RenderTarget[0].SrcBlend + 13);
|
|
|
|
if (bd.RenderTarget[0].DestBlend >= 3 && bd.RenderTarget[0].DestBlend <= 6)
|
|
|
|
bd.RenderTarget[0].DestBlend = (D3D11_BLEND)((int)bd.RenderTarget[0].DestBlend + 13);
|
|
|
|
|
2010-03-12 19:01:05 +00:00
|
|
|
// Not very good but I don't wanna write another 81 row table
|
|
|
|
if (bsel.negative) {
|
|
|
|
if (bd.RenderTarget[0].BlendOp == D3D11_BLEND_OP_ADD)
|
|
|
|
bd.RenderTarget[0].BlendOp = D3D11_BLEND_OP_REV_SUBTRACT;
|
|
|
|
else if (bd.RenderTarget[0].BlendOp == D3D11_BLEND_OP_REV_SUBTRACT)
|
|
|
|
bd.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
|
|
|
else
|
|
|
|
; // god knows, best just not to mess with it for now
|
|
|
|
}
|
|
|
|
|
2010-03-11 18:41:31 +00:00
|
|
|
if(blendMapD3D9[i].bogus == 1)
|
2009-06-19 20:31:36 +00:00
|
|
|
{
|
|
|
|
(bsel.a == 0 ? bd.RenderTarget[0].SrcBlend : bd.RenderTarget[0].DestBlend) = D3D11_BLEND_ONE;
|
2010-03-15 21:07:58 +00:00
|
|
|
|
|
|
|
const string afixstr = format("%d >> 7", afix);
|
|
|
|
const char *col[3] = {"Cs", "Cd", "0"};
|
|
|
|
const char *alpha[3] = {"As", "Ad", afixstr.c_str()};
|
|
|
|
printf("Impossible blend for D3D: (%s - %s) * %s + %s\n",
|
|
|
|
col[bsel.a], col[bsel.b], alpha[bsel.c], col[bsel.d]);
|
2009-06-19 20:31:36 +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;
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
m_dev->CreateBlendState(&bd, &bs);
|
2009-06-19 20:31:36 +00:00
|
|
|
|
|
|
|
m_om_bs[bsel] = bs;
|
|
|
|
|
|
|
|
j = m_om_bs.find(bsel);
|
|
|
|
}
|
|
|
|
|
2009-09-18 00:16:52 +00:00
|
|
|
OMSetBlendState(j->second, (float)(int)afix / 0x80);
|
2009-06-19 20:31:36 +00:00
|
|
|
}
|