mirror of https://github.com/RPCS3/rpcs3.git
d3d12: Implement blend decoding
This commit is contained in:
parent
312ff7e8f5
commit
4a89432d39
|
@ -4,6 +4,9 @@
|
||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
#include <dxgi1_4.h>
|
#include <dxgi1_4.h>
|
||||||
|
|
||||||
|
// Some constants are the same between RSX and GL
|
||||||
|
#include <GL\GL.h>
|
||||||
|
|
||||||
GetGSFrameCb2 GetGSFrame = nullptr;
|
GetGSFrameCb2 GetGSFrame = nullptr;
|
||||||
|
|
||||||
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
|
void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
|
||||||
|
@ -589,6 +592,32 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
|
||||||
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
|
m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
D3D12_BLEND_OP getBlendOp()
|
||||||
|
{
|
||||||
|
return D3D12_BLEND_OP_ADD;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
D3D12_BLEND getBlendFactor(u16 glFactor)
|
||||||
|
{
|
||||||
|
switch (glFactor)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
||||||
{
|
{
|
||||||
// Get constant from fragment program
|
// Get constant from fragment program
|
||||||
|
@ -691,7 +720,47 @@ bool D3D12GSRender::LoadProgram()
|
||||||
prop.Topology = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
prop.Topology = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static D3D12_BLEND_DESC CD3D12_BLEND_DESC =
|
||||||
|
{
|
||||||
|
FALSE,
|
||||||
|
FALSE,
|
||||||
|
{
|
||||||
|
FALSE,FALSE,
|
||||||
|
D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
|
||||||
|
D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
|
||||||
|
D3D12_LOGIC_OP_NOOP,
|
||||||
|
D3D12_COLOR_WRITE_ENABLE_ALL,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
prop.Blend = CD3D12_BLEND_DESC;
|
||||||
|
|
||||||
|
if (m_set_blend_equation)
|
||||||
|
{
|
||||||
|
// glBlendEquationSeparate(m_blend_equation_rgb, m_blend_equation_alpha);
|
||||||
|
// checkForGlError("glBlendEquationSeparate");
|
||||||
|
}
|
||||||
|
|
||||||
|
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_blend_color)
|
||||||
|
{
|
||||||
|
// glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a);
|
||||||
|
// checkForGlError("glBlendColor");
|
||||||
|
}
|
||||||
|
|
||||||
prop.IASet = m_IASet;
|
prop.IASet = m_IASet;
|
||||||
|
|
||||||
|
|
||||||
m_PSO = m_cachePSO.getGraphicPipelineState(m_cur_vertex_prog, m_cur_fragment_prog, prop, std::make_pair(m_device, m_rootSignature));
|
m_PSO = m_cachePSO.getGraphicPipelineState(m_cur_vertex_prog, m_cur_fragment_prog, prop, std::make_pair(m_device, m_rootSignature));
|
||||||
return m_PSO != nullptr;
|
return m_PSO != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -803,19 +872,6 @@ void D3D12GSRender::ExecCMD()
|
||||||
};
|
};
|
||||||
commandList->RSSetScissorRects(1, &box);
|
commandList->RSSetScissorRects(1, &box);
|
||||||
|
|
||||||
/*
|
|
||||||
#define GL_POINTS 0x0000
|
|
||||||
#define GL_LINES 0x0001
|
|
||||||
#define GL_LINE_LOOP 0x0002
|
|
||||||
#define GL_LINE_STRIP 0x0003
|
|
||||||
#define GL_TRIANGLES 0x0004
|
|
||||||
#define GL_TRIANGLE_STRIP 0x0005
|
|
||||||
#define GL_TRIANGLE_FAN 0x0006
|
|
||||||
#define GL_QUADS 0x0007
|
|
||||||
#define GL_QUAD_STRIP 0x0008
|
|
||||||
#define GL_POLYGON 0x0009
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool requireIndexBuffer = false;
|
bool requireIndexBuffer = false;
|
||||||
switch (m_draw_mode - 1)
|
switch (m_draw_mode - 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,9 +14,11 @@ struct D3D12PipelineProperties
|
||||||
{
|
{
|
||||||
D3D12_PRIMITIVE_TOPOLOGY_TYPE Topology;
|
D3D12_PRIMITIVE_TOPOLOGY_TYPE Topology;
|
||||||
std::vector<D3D12_INPUT_ELEMENT_DESC> IASet;
|
std::vector<D3D12_INPUT_ELEMENT_DESC> IASet;
|
||||||
|
D3D12_BLEND_DESC Blend;
|
||||||
|
|
||||||
bool operator==(const D3D12PipelineProperties &in) const
|
bool operator==(const D3D12PipelineProperties &in) const
|
||||||
{
|
{
|
||||||
|
// TODO: blend and IASet equality
|
||||||
return Topology == in.Topology;
|
return Topology == in.Topology;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -136,20 +138,7 @@ struct D3D12Traits
|
||||||
D3D12_DEFAULT_STENCIL_WRITE_MASK,
|
D3D12_DEFAULT_STENCIL_WRITE_MASK,
|
||||||
};
|
};
|
||||||
|
|
||||||
static D3D12_BLEND_DESC CD3D12_BLEND_DESC =
|
graphicPipelineStateDesc.BlendState = pipelineProperties.Blend;
|
||||||
{
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
{
|
|
||||||
FALSE,FALSE,
|
|
||||||
D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
|
|
||||||
D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
|
|
||||||
D3D12_LOGIC_OP_NOOP,
|
|
||||||
D3D12_COLOR_WRITE_ENABLE_ALL,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
graphicPipelineStateDesc.BlendState = CD3D12_BLEND_DESC;
|
|
||||||
graphicPipelineStateDesc.DepthStencilState = CD3D12_DEPTH_STENCIL_DESC;
|
graphicPipelineStateDesc.DepthStencilState = CD3D12_DEPTH_STENCIL_DESC;
|
||||||
graphicPipelineStateDesc.RasterizerState = CD3D12_RASTERIZER_DESC;
|
graphicPipelineStateDesc.RasterizerState = CD3D12_RASTERIZER_DESC;
|
||||||
graphicPipelineStateDesc.PrimitiveTopologyType = pipelineProperties.Topology;
|
graphicPipelineStateDesc.PrimitiveTopologyType = pipelineProperties.Topology;
|
||||||
|
|
Loading…
Reference in New Issue