mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 21:32:50 +00:00
d3d12: Add Blend Op
This commit is contained in:
parent
a2b8d3a885
commit
25c09c5088
@ -531,27 +531,42 @@ void D3D12GSRender::ExecCMD(u32 cmd)
|
||||
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**) &commandList);
|
||||
}
|
||||
|
||||
static D3D12_BLEND_OP getBlendOp()
|
||||
static D3D12_BLEND_OP getBlendOp(u16 op)
|
||||
{
|
||||
return D3D12_BLEND_OP_ADD;
|
||||
switch (op)
|
||||
{
|
||||
case CELL_GCM_FUNC_ADD: return D3D12_BLEND_OP_ADD;
|
||||
case CELL_GCM_FUNC_SUBTRACT: return D3D12_BLEND_OP_SUBTRACT;
|
||||
case CELL_GCM_FUNC_REVERSE_SUBTRACT: return D3D12_BLEND_OP_REV_SUBTRACT;
|
||||
case CELL_GCM_MIN: return D3D12_BLEND_OP_MIN;
|
||||
case CELL_GCM_MAX: return D3D12_BLEND_OP_MAX;
|
||||
case CELL_GCM_FUNC_ADD_SIGNED:
|
||||
case CELL_GCM_FUNC_REVERSE_ADD_SIGNED:
|
||||
case CELL_GCM_FUNC_REVERSE_SUBTRACT_SIGNED:
|
||||
LOG_WARNING(RSX, "Unsupported Blend Op %d", op);
|
||||
}
|
||||
}
|
||||
|
||||
static D3D12_BLEND getBlendFactor(u16 glFactor)
|
||||
static D3D12_BLEND getBlendFactor(u16 factor)
|
||||
{
|
||||
switch (glFactor)
|
||||
switch (factor)
|
||||
{
|
||||
default: LOG_WARNING(RSX, "Unsupported Blend Op %d", glFactor);
|
||||
case GL_ZERO: return D3D12_BLEND_ZERO;
|
||||
case GL_ONE: return D3D12_BLEND_ONE;
|
||||
case GL_SRC_COLOR: return D3D12_BLEND_SRC_COLOR;
|
||||
case GL_ONE_MINUS_SRC_COLOR: return D3D12_BLEND_INV_SRC_COLOR;
|
||||
case GL_DST_COLOR: return D3D12_BLEND_DEST_COLOR;
|
||||
case GL_ONE_MINUS_DST_COLOR: D3D12_BLEND_INV_DEST_COLOR;
|
||||
case GL_SRC_ALPHA: return D3D12_BLEND_SRC_ALPHA;
|
||||
case GL_ONE_MINUS_SRC_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA;
|
||||
case GL_DST_ALPHA: return D3D12_BLEND_DEST_ALPHA;
|
||||
case GL_ONE_MINUS_DST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA;
|
||||
case GL_SRC_ALPHA_SATURATE: return D3D12_BLEND_SRC_ALPHA_SAT;
|
||||
case CELL_GCM_ZERO: return D3D12_BLEND_ZERO;
|
||||
case CELL_GCM_ONE: return D3D12_BLEND_ONE;
|
||||
case CELL_GCM_SRC_COLOR: return D3D12_BLEND_SRC_COLOR;
|
||||
case CELL_GCM_ONE_MINUS_SRC_COLOR: return D3D12_BLEND_INV_SRC_COLOR;
|
||||
case CELL_GCM_SRC_ALPHA: return D3D12_BLEND_SRC_ALPHA;
|
||||
case CELL_GCM_ONE_MINUS_SRC_ALPHA: return D3D12_BLEND_INV_SRC_ALPHA;
|
||||
case CELL_GCM_DST_ALPHA: return D3D12_BLEND_DEST_ALPHA;
|
||||
case CELL_GCM_ONE_MINUS_DST_ALPHA: return D3D12_BLEND_INV_DEST_ALPHA;
|
||||
case CELL_GCM_DST_COLOR: return D3D12_BLEND_DEST_COLOR;
|
||||
case CELL_GCM_ONE_MINUS_DST_COLOR: return D3D12_BLEND_INV_DEST_COLOR;
|
||||
case CELL_GCM_SRC_ALPHA_SATURATE: return D3D12_BLEND_SRC_ALPHA_SAT;
|
||||
case CELL_GCM_CONSTANT_COLOR:
|
||||
case CELL_GCM_ONE_MINUS_CONSTANT_COLOR:
|
||||
case CELL_GCM_CONSTANT_ALPHA:
|
||||
case CELL_GCM_ONE_MINUS_CONSTANT_ALPHA:
|
||||
LOG_WARNING(RSX, "Unsupported Blend Factor %d", factor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,21 +648,23 @@ bool D3D12GSRender::LoadProgram()
|
||||
};
|
||||
prop.Blend = CD3D12_BLEND_DESC;
|
||||
|
||||
if (m_set_blend)
|
||||
{
|
||||
prop.Blend.RenderTarget[0].BlendEnable = true;
|
||||
}
|
||||
|
||||
if (m_set_blend_equation)
|
||||
{
|
||||
// glBlendEquationSeparate(m_blend_equation_rgb, m_blend_equation_alpha);
|
||||
// checkForGlError("glBlendEquationSeparate");
|
||||
prop.Blend.RenderTarget[0].BlendOp = getBlendOp(m_blend_equation_rgb);
|
||||
prop.Blend.RenderTarget[0].BlendOpAlpha = getBlendOp(m_blend_equation_alpha);
|
||||
}
|
||||
|
||||
if (m_set_blend_sfactor && m_set_blend_dfactor)
|
||||
{
|
||||
prop.Blend.RenderTarget[0].BlendEnable = true;
|
||||
prop.Blend.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD;
|
||||
prop.Blend.RenderTarget[0].SrcBlend = getBlendFactor(m_blend_sfactor_rgb);
|
||||
prop.Blend.RenderTarget[0].DestBlend = getBlendFactor(m_blend_dfactor_rgb);
|
||||
prop.Blend.RenderTarget[0].SrcBlendAlpha = getBlendFactor(m_blend_sfactor_alpha);
|
||||
prop.Blend.RenderTarget[0].DestBlendAlpha = getBlendFactor(m_blend_dfactor_alpha);
|
||||
prop.Blend.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD;
|
||||
}
|
||||
|
||||
if (m_set_logic_op)
|
||||
|
@ -136,21 +136,49 @@ enum
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP = 8,
|
||||
|
||||
// Logic Op
|
||||
CELL_GCM_CLEAR = 1,
|
||||
CELL_GCM_AND = 2,
|
||||
CELL_GCM_AND_REVERSE = 3,
|
||||
CELL_GCM_COPY = 4,
|
||||
CELL_GCM_AND_INVERTED = 5,
|
||||
CELL_GCM_NOOP = 6,
|
||||
CELL_GCM_XOR = 7,
|
||||
CELL_GCM_OR = 8,
|
||||
CELL_GCM_NOR = 9,
|
||||
CELL_GCM_EQUIV = 10,
|
||||
CELL_GCM_INVERT = 11,
|
||||
CELL_GCM_OR_REVERSE = 12,
|
||||
CELL_GCM_COPY_INVERTED = 13,
|
||||
CELL_GCM_OR_INVERTED = 14,
|
||||
CELL_GCM_NAND = 15,
|
||||
CELL_GCM_CLEAR = 0x1500,
|
||||
CELL_GCM_AND = 0x1501,
|
||||
CELL_GCM_AND_REVERSE = 0x1502,
|
||||
CELL_GCM_COPY = 0x1503,
|
||||
CELL_GCM_AND_INVERTED = 0x1504,
|
||||
CELL_GCM_NOOP = 0x1505,
|
||||
CELL_GCM_XOR = 0x1506,
|
||||
CELL_GCM_OR = 0x1507,
|
||||
CELL_GCM_NOR = 0x1508,
|
||||
CELL_GCM_EQUIV = 0x1509,
|
||||
CELL_GCM_INVERT = 0x150A,
|
||||
CELL_GCM_OR_REVERSE = 0x150B,
|
||||
CELL_GCM_COPY_INVERTED = 0x150C,
|
||||
CELL_GCM_OR_INVERTED = 0x150D,
|
||||
CELL_GCM_NAND = 0x150E,
|
||||
CELL_GCM_SET = 0x150F,
|
||||
|
||||
// Blend Op
|
||||
CELL_GCM_FUNC_ADD = 0x8006,
|
||||
CELL_GCM_MIN = 0x8007,
|
||||
CELL_GCM_MAX = 0x8008,
|
||||
CELL_GCM_FUNC_SUBTRACT = 0x800A,
|
||||
CELL_GCM_FUNC_REVERSE_SUBTRACT = 0x800B,
|
||||
CELL_GCM_FUNC_REVERSE_SUBTRACT_SIGNED = 0x0000F005,
|
||||
CELL_GCM_FUNC_ADD_SIGNED = 0x0000F006,
|
||||
CELL_GCM_FUNC_REVERSE_ADD_SIGNED = 0x0000F007,
|
||||
|
||||
// Blend Factor
|
||||
CELL_GCM_ZERO = 0,
|
||||
CELL_GCM_ONE = 1,
|
||||
CELL_GCM_SRC_COLOR = 0x0300,
|
||||
CELL_GCM_ONE_MINUS_SRC_COLOR = 0x0301,
|
||||
CELL_GCM_SRC_ALPHA = 0x0302,
|
||||
CELL_GCM_ONE_MINUS_SRC_ALPHA = 0x0303,
|
||||
CELL_GCM_DST_ALPHA = 0x0304,
|
||||
CELL_GCM_ONE_MINUS_DST_ALPHA = 0x0305,
|
||||
CELL_GCM_DST_COLOR = 0x0306,
|
||||
CELL_GCM_ONE_MINUS_DST_COLOR = 0x0307,
|
||||
CELL_GCM_SRC_ALPHA_SATURATE = 0x0308,
|
||||
CELL_GCM_CONSTANT_COLOR = 0x8001,
|
||||
CELL_GCM_ONE_MINUS_CONSTANT_COLOR = 0x8002,
|
||||
CELL_GCM_CONSTANT_ALPHA = 0x8003,
|
||||
CELL_GCM_ONE_MINUS_CONSTANT_ALPHA = 0x8004,
|
||||
};
|
||||
|
||||
// GCM Surface
|
||||
|
Loading…
x
Reference in New Issue
Block a user