Renderer: Move depth state to VideoCommon and seperate from bpmem
This commit is contained in:
parent
4d36f0cc87
commit
2869c570f1
|
@ -456,10 +456,9 @@ ID3D11RasterizerState* StateCache::Get(RasterizerState state)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11DepthStencilState* StateCache::Get(ZMode state)
|
ID3D11DepthStencilState* StateCache::Get(DepthState state)
|
||||||
{
|
{
|
||||||
auto it = m_depth.find(state.hex);
|
auto it = m_depth.find(state.hex);
|
||||||
|
|
||||||
if (it != m_depth.end())
|
if (it != m_depth.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
|
@ -472,6 +471,7 @@ ID3D11DepthStencilState* StateCache::Get(ZMode state)
|
||||||
depthdc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
|
depthdc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
|
||||||
depthdc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
|
depthdc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
|
||||||
|
|
||||||
|
// Less/greater are swapped due to inverted depth.
|
||||||
const D3D11_COMPARISON_FUNC d3dCmpFuncs[8] = {
|
const D3D11_COMPARISON_FUNC d3dCmpFuncs[8] = {
|
||||||
D3D11_COMPARISON_NEVER, D3D11_COMPARISON_GREATER, D3D11_COMPARISON_EQUAL,
|
D3D11_COMPARISON_NEVER, D3D11_COMPARISON_GREATER, D3D11_COMPARISON_EQUAL,
|
||||||
D3D11_COMPARISON_GREATER_EQUAL, D3D11_COMPARISON_LESS, D3D11_COMPARISON_NOT_EQUAL,
|
D3D11_COMPARISON_GREATER_EQUAL, D3D11_COMPARISON_LESS, D3D11_COMPARISON_NOT_EQUAL,
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
ID3D11SamplerState* Get(SamplerState state);
|
ID3D11SamplerState* Get(SamplerState state);
|
||||||
ID3D11BlendState* Get(BlendingState state);
|
ID3D11BlendState* Get(BlendingState state);
|
||||||
ID3D11RasterizerState* Get(RasterizerState state);
|
ID3D11RasterizerState* Get(RasterizerState state);
|
||||||
ID3D11DepthStencilState* Get(ZMode state);
|
ID3D11DepthStencilState* Get(DepthState state);
|
||||||
|
|
||||||
// Release all cached states and clear hash tables.
|
// Release all cached states and clear hash tables.
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct GXPipelineState
|
||||||
{
|
{
|
||||||
std::array<SamplerState, 8> samplers;
|
std::array<SamplerState, 8> samplers;
|
||||||
BlendingState blend;
|
BlendingState blend;
|
||||||
ZMode zmode;
|
DepthState zmode;
|
||||||
RasterizerState raster;
|
RasterizerState raster;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -916,9 +916,9 @@ void Renderer::SetGenerationMode()
|
||||||
s_gx_state.raster.cull_mode = d3d_cull_modes[bpmem.genMode.cullmode];
|
s_gx_state.raster.cull_mode = d3d_cull_modes[bpmem.genMode.cullmode];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetDepthMode()
|
void Renderer::SetDepthState(const DepthState& state)
|
||||||
{
|
{
|
||||||
s_gx_state.zmode.hex = bpmem.zmode.hex;
|
s_gx_state.zmode.hex = state.hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetSamplerState(int stage, int texindex, bool custom_tex)
|
void Renderer::SetSamplerState(int stage, int texindex, bool custom_tex)
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
void SetBlendingState(const BlendingState& state) override;
|
void SetBlendingState(const BlendingState& state) override;
|
||||||
void SetScissorRect(const EFBRectangle& rc) override;
|
void SetScissorRect(const EFBRectangle& rc) override;
|
||||||
void SetGenerationMode() override;
|
void SetGenerationMode() override;
|
||||||
void SetDepthMode() override;
|
void SetDepthState(const DepthState& state) override;
|
||||||
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
||||||
void SetInterlacingMode() override;
|
void SetInterlacingMode() override;
|
||||||
void SetViewport() override;
|
void SetViewport() override;
|
||||||
|
|
|
@ -1787,7 +1787,7 @@ void Renderer::RestoreAPIState()
|
||||||
}
|
}
|
||||||
SetGenerationMode();
|
SetGenerationMode();
|
||||||
BPFunctions::SetScissor();
|
BPFunctions::SetScissor();
|
||||||
SetDepthMode();
|
BPFunctions::SetDepthMode();
|
||||||
BPFunctions::SetBlendMode();
|
BPFunctions::SetBlendMode();
|
||||||
SetViewport();
|
SetViewport();
|
||||||
|
|
||||||
|
@ -1813,16 +1813,16 @@ void Renderer::SetGenerationMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetDepthMode()
|
void Renderer::SetDepthState(const DepthState& state)
|
||||||
{
|
{
|
||||||
const GLenum glCmpFuncs[8] = {GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,
|
const GLenum glCmpFuncs[8] = {GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,
|
||||||
GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS};
|
GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS};
|
||||||
|
|
||||||
if (bpmem.zmode.testenable)
|
if (state.testenable)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthMask(bpmem.zmode.updateenable ? GL_TRUE : GL_FALSE);
|
glDepthMask(state.updateenable ? GL_TRUE : GL_FALSE);
|
||||||
glDepthFunc(glCmpFuncs[bpmem.zmode.func]);
|
glDepthFunc(glCmpFuncs[state.func]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
void SetBlendingState(const BlendingState& state) override;
|
void SetBlendingState(const BlendingState& state) override;
|
||||||
void SetScissorRect(const EFBRectangle& rc) override;
|
void SetScissorRect(const EFBRectangle& rc) override;
|
||||||
void SetGenerationMode() override;
|
void SetGenerationMode() override;
|
||||||
void SetDepthMode() override;
|
void SetDepthState(const DepthState& state) override;
|
||||||
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
||||||
void SetInterlacingMode() override;
|
void SetInterlacingMode() override;
|
||||||
void SetViewport() override;
|
void SetViewport() override;
|
||||||
|
|
|
@ -135,16 +135,6 @@ union RasterizationState
|
||||||
u32 bits;
|
u32 bits;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Depth state info
|
|
||||||
union DepthStencilState
|
|
||||||
{
|
|
||||||
BitField<0, 1, VkBool32> test_enable;
|
|
||||||
BitField<1, 1, VkBool32> write_enable;
|
|
||||||
BitField<2, 3, VkCompareOp> compare_op;
|
|
||||||
|
|
||||||
u32 bits;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Sampler info
|
// Sampler info
|
||||||
union SamplerState
|
union SamplerState
|
||||||
{
|
{
|
||||||
|
|
|
@ -1164,16 +1164,16 @@ void FramebufferManager::DrawPokeVertices(const EFBPokeVertex* vertices, size_t
|
||||||
pipeline_info.render_pass = m_efb_load_render_pass;
|
pipeline_info.render_pass = m_efb_load_render_pass;
|
||||||
pipeline_info.rasterization_state.bits = Util::GetNoCullRasterizationState().bits;
|
pipeline_info.rasterization_state.bits = Util::GetNoCullRasterizationState().bits;
|
||||||
pipeline_info.rasterization_state.samples = m_efb_samples;
|
pipeline_info.rasterization_state.samples = m_efb_samples;
|
||||||
pipeline_info.depth_stencil_state.bits = Util::GetNoDepthTestingDepthStencilState().bits;
|
pipeline_info.depth_state.hex = Util::GetNoDepthTestingDepthStencilState().hex;
|
||||||
pipeline_info.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
pipeline_info.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
||||||
pipeline_info.blend_state.colorupdate = write_color;
|
pipeline_info.blend_state.colorupdate = write_color;
|
||||||
pipeline_info.blend_state.alphaupdate = write_color;
|
pipeline_info.blend_state.alphaupdate = write_color;
|
||||||
pipeline_info.primitive_topology = m_poke_primitive_topology;
|
pipeline_info.primitive_topology = m_poke_primitive_topology;
|
||||||
if (write_depth)
|
if (write_depth)
|
||||||
{
|
{
|
||||||
pipeline_info.depth_stencil_state.test_enable = VK_TRUE;
|
pipeline_info.depth_state.testenable = true;
|
||||||
pipeline_info.depth_stencil_state.write_enable = VK_TRUE;
|
pipeline_info.depth_state.updateenable = true;
|
||||||
pipeline_info.depth_stencil_state.compare_op = VK_COMPARE_OP_ALWAYS;
|
pipeline_info.depth_state.func = ZMode::ALWAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline pipeline = g_shader_cache->GetPipeline(pipeline_info);
|
VkPipeline pipeline = g_shader_cache->GetPipeline(pipeline_info);
|
||||||
|
|
|
@ -459,10 +459,10 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha
|
||||||
blend_state.colorupdate = color_enable;
|
blend_state.colorupdate = color_enable;
|
||||||
blend_state.alphaupdate = alpha_enable;
|
blend_state.alphaupdate = alpha_enable;
|
||||||
|
|
||||||
DepthStencilState depth_state = Util::GetNoDepthTestingDepthStencilState();
|
DepthState depth_state = Util::GetNoDepthTestingDepthStencilState();
|
||||||
depth_state.test_enable = z_enable ? VK_TRUE : VK_FALSE;
|
depth_state.testenable = z_enable;
|
||||||
depth_state.write_enable = z_enable ? VK_TRUE : VK_FALSE;
|
depth_state.updateenable = z_enable;
|
||||||
depth_state.compare_op = VK_COMPARE_OP_ALWAYS;
|
depth_state.func = ZMode::ALWAYS;
|
||||||
|
|
||||||
RasterizationState rs_state = Util::GetNoCullRasterizationState();
|
RasterizationState rs_state = Util::GetNoCullRasterizationState();
|
||||||
rs_state.per_sample_shading = g_ActiveConfig.bSSAA ? VK_TRUE : VK_FALSE;
|
rs_state.per_sample_shading = g_ActiveConfig.bSSAA ? VK_TRUE : VK_FALSE;
|
||||||
|
@ -476,7 +476,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha
|
||||||
g_shader_cache->GetPassthroughGeometryShader(), m_clear_fragment_shader);
|
g_shader_cache->GetPassthroughGeometryShader(), m_clear_fragment_shader);
|
||||||
|
|
||||||
draw.SetRasterizationState(rs_state);
|
draw.SetRasterizationState(rs_state);
|
||||||
draw.SetDepthStencilState(depth_state);
|
draw.SetDepthState(depth_state);
|
||||||
draw.SetBlendState(blend_state);
|
draw.SetBlendState(blend_state);
|
||||||
|
|
||||||
draw.DrawColoredQuad(target_rc.left, target_rc.top, target_rc.GetWidth(), target_rc.GetHeight(),
|
draw.DrawColoredQuad(target_rc.left, target_rc.top, target_rc.GetWidth(), target_rc.GetHeight(),
|
||||||
|
@ -1303,45 +1303,9 @@ void Renderer::SetGenerationMode()
|
||||||
StateTracker::GetInstance()->SetRasterizationState(new_rs_state);
|
StateTracker::GetInstance()->SetRasterizationState(new_rs_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetDepthMode()
|
void Renderer::SetDepthState(const DepthState& state)
|
||||||
{
|
{
|
||||||
DepthStencilState new_ds_state = {};
|
StateTracker::GetInstance()->SetDepthState(state);
|
||||||
new_ds_state.test_enable = bpmem.zmode.testenable ? VK_TRUE : VK_FALSE;
|
|
||||||
new_ds_state.write_enable = bpmem.zmode.updateenable ? VK_TRUE : VK_FALSE;
|
|
||||||
|
|
||||||
// Inverted depth, hence these are swapped
|
|
||||||
switch (bpmem.zmode.func)
|
|
||||||
{
|
|
||||||
case ZMode::NEVER:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_NEVER;
|
|
||||||
break;
|
|
||||||
case ZMode::LESS:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_GREATER;
|
|
||||||
break;
|
|
||||||
case ZMode::EQUAL:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_EQUAL;
|
|
||||||
break;
|
|
||||||
case ZMode::LEQUAL:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_GREATER_OR_EQUAL;
|
|
||||||
break;
|
|
||||||
case ZMode::GREATER:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_LESS;
|
|
||||||
break;
|
|
||||||
case ZMode::NEQUAL:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_NOT_EQUAL;
|
|
||||||
break;
|
|
||||||
case ZMode::GEQUAL:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_LESS_OR_EQUAL;
|
|
||||||
break;
|
|
||||||
case ZMode::ALWAYS:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_ALWAYS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
new_ds_state.compare_op = VK_COMPARE_OP_ALWAYS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
StateTracker::GetInstance()->SetDepthStencilState(new_ds_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetBlendingState(const BlendingState& state)
|
void Renderer::SetBlendingState(const BlendingState& state)
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
void SetBlendingState(const BlendingState& state) override;
|
void SetBlendingState(const BlendingState& state) override;
|
||||||
void SetScissorRect(const EFBRectangle& rc) override;
|
void SetScissorRect(const EFBRectangle& rc) override;
|
||||||
void SetGenerationMode() override;
|
void SetGenerationMode() override;
|
||||||
void SetDepthMode() override;
|
void SetDepthState(const DepthState& state) override;
|
||||||
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
void SetSamplerState(int stage, int texindex, bool custom_tex) override;
|
||||||
void SetInterlacingMode() override;
|
void SetInterlacingMode() override;
|
||||||
void SetViewport() override;
|
void SetViewport() override;
|
||||||
|
|
|
@ -122,16 +122,21 @@ GetVulkanMultisampleState(const RasterizationState& rs_state)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkPipelineDepthStencilStateCreateInfo
|
static VkPipelineDepthStencilStateCreateInfo GetVulkanDepthStencilState(const DepthState& state)
|
||||||
GetVulkanDepthStencilState(const DepthStencilState& state)
|
|
||||||
{
|
{
|
||||||
|
// Less/greater are swapped due to inverted depth.
|
||||||
|
static constexpr std::array<VkCompareOp, 8> funcs = {
|
||||||
|
{VK_COMPARE_OP_NEVER, VK_COMPARE_OP_GREATER, VK_COMPARE_OP_EQUAL,
|
||||||
|
VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_LESS, VK_COMPARE_OP_NOT_EQUAL,
|
||||||
|
VK_COMPARE_OP_LESS_OR_EQUAL, VK_COMPARE_OP_ALWAYS}};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType
|
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType
|
||||||
nullptr, // const void* pNext
|
nullptr, // const void* pNext
|
||||||
0, // VkPipelineDepthStencilStateCreateFlags flags
|
0, // VkPipelineDepthStencilStateCreateFlags flags
|
||||||
state.test_enable, // VkBool32 depthTestEnable
|
state.testenable, // VkBool32 depthTestEnable
|
||||||
state.write_enable, // VkBool32 depthWriteEnable
|
state.updateenable, // VkBool32 depthWriteEnable
|
||||||
state.compare_op, // VkCompareOp depthCompareOp
|
funcs[state.func], // VkCompareOp depthCompareOp
|
||||||
VK_FALSE, // VkBool32 depthBoundsTestEnable
|
VK_FALSE, // VkBool32 depthBoundsTestEnable
|
||||||
VK_FALSE, // VkBool32 stencilTestEnable
|
VK_FALSE, // VkBool32 stencilTestEnable
|
||||||
{}, // VkStencilOpState front
|
{}, // VkStencilOpState front
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct PipelineInfo
|
||||||
VkRenderPass render_pass;
|
VkRenderPass render_pass;
|
||||||
BlendingState blend_state;
|
BlendingState blend_state;
|
||||||
RasterizationState rasterization_state;
|
RasterizationState rasterization_state;
|
||||||
DepthStencilState depth_stencil_state;
|
DepthState depth_state;
|
||||||
VkPrimitiveTopology primitive_topology;
|
VkPrimitiveTopology primitive_topology;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ bool StateTracker::Initialize()
|
||||||
m_pipeline_state.rasterization_state.cull_mode = VK_CULL_MODE_NONE;
|
m_pipeline_state.rasterization_state.cull_mode = VK_CULL_MODE_NONE;
|
||||||
m_pipeline_state.rasterization_state.per_sample_shading = VK_FALSE;
|
m_pipeline_state.rasterization_state.per_sample_shading = VK_FALSE;
|
||||||
m_pipeline_state.rasterization_state.depth_clamp = VK_FALSE;
|
m_pipeline_state.rasterization_state.depth_clamp = VK_FALSE;
|
||||||
m_pipeline_state.depth_stencil_state.test_enable = VK_TRUE;
|
m_pipeline_state.depth_state.testenable = true;
|
||||||
m_pipeline_state.depth_stencil_state.write_enable = VK_TRUE;
|
m_pipeline_state.depth_state.updateenable = true;
|
||||||
m_pipeline_state.depth_stencil_state.compare_op = VK_COMPARE_OP_LESS;
|
m_pipeline_state.depth_state.func = ZMode::ALWAYS;
|
||||||
m_pipeline_state.blend_state.hex = 0;
|
m_pipeline_state.blend_state.hex = 0;
|
||||||
m_pipeline_state.blend_state.blendenable = false;
|
m_pipeline_state.blend_state.blendenable = false;
|
||||||
m_pipeline_state.blend_state.srcfactor = BlendMode::ONE;
|
m_pipeline_state.blend_state.srcfactor = BlendMode::ONE;
|
||||||
|
@ -167,7 +167,7 @@ void StateTracker::AppendToPipelineUIDCache(const PipelineInfo& info)
|
||||||
SerializedPipelineUID sinfo;
|
SerializedPipelineUID sinfo;
|
||||||
sinfo.blend_state_bits = info.blend_state.hex;
|
sinfo.blend_state_bits = info.blend_state.hex;
|
||||||
sinfo.rasterizer_state_bits = info.rasterization_state.bits;
|
sinfo.rasterizer_state_bits = info.rasterization_state.bits;
|
||||||
sinfo.depth_stencil_state_bits = info.depth_stencil_state.bits;
|
sinfo.depth_state_bits = info.depth_state.hex;
|
||||||
sinfo.vertex_decl = m_pipeline_state.vertex_format->GetVertexDeclaration();
|
sinfo.vertex_decl = m_pipeline_state.vertex_format->GetVertexDeclaration();
|
||||||
sinfo.vs_uid = m_vs_uid;
|
sinfo.vs_uid = m_vs_uid;
|
||||||
sinfo.gs_uid = m_gs_uid;
|
sinfo.gs_uid = m_gs_uid;
|
||||||
|
@ -212,7 +212,7 @@ bool StateTracker::PrecachePipelineUID(const SerializedPipelineUID& uid)
|
||||||
}
|
}
|
||||||
pinfo.render_pass = m_load_render_pass;
|
pinfo.render_pass = m_load_render_pass;
|
||||||
pinfo.rasterization_state.bits = uid.rasterizer_state_bits;
|
pinfo.rasterization_state.bits = uid.rasterizer_state_bits;
|
||||||
pinfo.depth_stencil_state.bits = uid.depth_stencil_state_bits;
|
pinfo.depth_state.hex = uid.depth_state_bits;
|
||||||
pinfo.blend_state.hex = uid.blend_state_bits;
|
pinfo.blend_state.hex = uid.blend_state_bits;
|
||||||
pinfo.primitive_topology = uid.primitive_topology;
|
pinfo.primitive_topology = uid.primitive_topology;
|
||||||
|
|
||||||
|
@ -316,12 +316,12 @@ void StateTracker::SetRasterizationState(const RasterizationState& state)
|
||||||
m_dirty_flags |= DIRTY_FLAG_PIPELINE;
|
m_dirty_flags |= DIRTY_FLAG_PIPELINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StateTracker::SetDepthStencilState(const DepthStencilState& state)
|
void StateTracker::SetDepthState(const DepthState& state)
|
||||||
{
|
{
|
||||||
if (m_pipeline_state.depth_stencil_state.bits == state.bits)
|
if (m_pipeline_state.depth_state.hex == state.hex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_pipeline_state.depth_stencil_state.bits = state.bits;
|
m_pipeline_state.depth_state.hex = state.hex;
|
||||||
m_dirty_flags |= DIRTY_FLAG_PIPELINE;
|
m_dirty_flags |= DIRTY_FLAG_PIPELINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,7 @@ public:
|
||||||
{
|
{
|
||||||
return m_pipeline_state.rasterization_state;
|
return m_pipeline_state.rasterization_state;
|
||||||
}
|
}
|
||||||
const DepthStencilState& GetDepthStencilState() const
|
const DepthState& GetDepthStencilState() const { return m_pipeline_state.depth_state; }
|
||||||
{
|
|
||||||
return m_pipeline_state.depth_stencil_state;
|
|
||||||
}
|
|
||||||
const BlendingState& GetBlendState() const { return m_pipeline_state.blend_state; }
|
const BlendingState& GetBlendState() const { return m_pipeline_state.blend_state; }
|
||||||
void SetVertexBuffer(VkBuffer buffer, VkDeviceSize offset);
|
void SetVertexBuffer(VkBuffer buffer, VkDeviceSize offset);
|
||||||
void SetIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType type);
|
void SetIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType type);
|
||||||
|
@ -58,7 +55,7 @@ public:
|
||||||
void DisableBackFaceCulling();
|
void DisableBackFaceCulling();
|
||||||
|
|
||||||
void SetRasterizationState(const RasterizationState& state);
|
void SetRasterizationState(const RasterizationState& state);
|
||||||
void SetDepthStencilState(const DepthStencilState& state);
|
void SetDepthState(const DepthState& state);
|
||||||
void SetBlendState(const BlendingState& state);
|
void SetBlendState(const BlendingState& state);
|
||||||
|
|
||||||
bool CheckForShaderChanges(u32 gx_primitive_type);
|
bool CheckForShaderChanges(u32 gx_primitive_type);
|
||||||
|
@ -130,7 +127,7 @@ private:
|
||||||
struct SerializedPipelineUID
|
struct SerializedPipelineUID
|
||||||
{
|
{
|
||||||
u32 rasterizer_state_bits;
|
u32 rasterizer_state_bits;
|
||||||
u32 depth_stencil_state_bits;
|
u32 depth_state_bits;
|
||||||
u32 blend_state_bits;
|
u32 blend_state_bits;
|
||||||
PortableVertexDeclaration vertex_decl;
|
PortableVertexDeclaration vertex_decl;
|
||||||
VertexShaderUid vs_uid;
|
VertexShaderUid vs_uid;
|
||||||
|
|
|
@ -195,12 +195,12 @@ RasterizationState GetNoCullRasterizationState()
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthStencilState GetNoDepthTestingDepthStencilState()
|
DepthState GetNoDepthTestingDepthStencilState()
|
||||||
{
|
{
|
||||||
DepthStencilState state = {};
|
DepthState state = {};
|
||||||
state.test_enable = VK_FALSE;
|
state.testenable = false;
|
||||||
state.write_enable = VK_FALSE;
|
state.updateenable = false;
|
||||||
state.compare_op = VK_COMPARE_OP_ALWAYS;
|
state.func = ZMode::ALWAYS;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ UtilityShaderDraw::UtilityShaderDraw(VkCommandBuffer command_buffer,
|
||||||
m_pipeline_info.gs = geometry_shader;
|
m_pipeline_info.gs = geometry_shader;
|
||||||
m_pipeline_info.ps = pixel_shader;
|
m_pipeline_info.ps = pixel_shader;
|
||||||
m_pipeline_info.rasterization_state.bits = Util::GetNoCullRasterizationState().bits;
|
m_pipeline_info.rasterization_state.bits = Util::GetNoCullRasterizationState().bits;
|
||||||
m_pipeline_info.depth_stencil_state.bits = Util::GetNoDepthTestingDepthStencilState().bits;
|
m_pipeline_info.depth_state.hex = Util::GetNoDepthTestingDepthStencilState().hex;
|
||||||
m_pipeline_info.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
m_pipeline_info.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
||||||
m_pipeline_info.primitive_topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
m_pipeline_info.primitive_topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
}
|
}
|
||||||
|
@ -450,9 +450,9 @@ void UtilityShaderDraw::SetRasterizationState(const RasterizationState& state)
|
||||||
m_pipeline_info.rasterization_state.bits = state.bits;
|
m_pipeline_info.rasterization_state.bits = state.bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilityShaderDraw::SetDepthStencilState(const DepthStencilState& state)
|
void UtilityShaderDraw::SetDepthState(const DepthState& state)
|
||||||
{
|
{
|
||||||
m_pipeline_info.depth_stencil_state.bits = state.bits;
|
m_pipeline_info.depth_state.hex = state.hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilityShaderDraw::SetBlendState(const BlendingState& state)
|
void UtilityShaderDraw::SetBlendState(const BlendingState& state)
|
||||||
|
|
|
@ -39,7 +39,7 @@ VkRect2D ClampRect2D(const VkRect2D& rect, u32 width, u32 height);
|
||||||
VkBlendFactor GetAlphaBlendFactor(VkBlendFactor factor);
|
VkBlendFactor GetAlphaBlendFactor(VkBlendFactor factor);
|
||||||
|
|
||||||
RasterizationState GetNoCullRasterizationState();
|
RasterizationState GetNoCullRasterizationState();
|
||||||
DepthStencilState GetNoDepthTestingDepthStencilState();
|
DepthState GetNoDepthTestingDepthStencilState();
|
||||||
BlendingState GetNoBlendingBlendState();
|
BlendingState GetNoBlendingBlendState();
|
||||||
|
|
||||||
// Combines viewport and scissor updates
|
// Combines viewport and scissor updates
|
||||||
|
@ -151,7 +151,7 @@ public:
|
||||||
void SetPSTexelBuffer(VkBufferView view);
|
void SetPSTexelBuffer(VkBufferView view);
|
||||||
|
|
||||||
void SetRasterizationState(const RasterizationState& state);
|
void SetRasterizationState(const RasterizationState& state);
|
||||||
void SetDepthStencilState(const DepthStencilState& state);
|
void SetDepthState(const DepthState& state);
|
||||||
void SetBlendState(const BlendingState& state);
|
void SetBlendState(const BlendingState& state);
|
||||||
|
|
||||||
void BeginRenderPass(VkFramebuffer framebuffer, const VkRect2D& region,
|
void BeginRenderPass(VkFramebuffer framebuffer, const VkRect2D& region,
|
||||||
|
|
|
@ -68,12 +68,14 @@ void SetScissor()
|
||||||
|
|
||||||
void SetDepthMode()
|
void SetDepthMode()
|
||||||
{
|
{
|
||||||
g_renderer->SetDepthMode();
|
DepthState state = {};
|
||||||
|
state.Generate(bpmem);
|
||||||
|
g_renderer->SetDepthState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBlendMode()
|
void SetBlendMode()
|
||||||
{
|
{
|
||||||
BlendingState state;
|
BlendingState state = {};
|
||||||
state.Generate(bpmem);
|
state.Generate(bpmem);
|
||||||
g_renderer->SetBlendingState(state);
|
g_renderer->SetBlendingState(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
virtual void SetBlendingState(const BlendingState& state) {}
|
virtual void SetBlendingState(const BlendingState& state) {}
|
||||||
virtual void SetScissorRect(const EFBRectangle& rc) {}
|
virtual void SetScissorRect(const EFBRectangle& rc) {}
|
||||||
virtual void SetGenerationMode() {}
|
virtual void SetGenerationMode() {}
|
||||||
virtual void SetDepthMode() {}
|
virtual void SetDepthState(const DepthState& state) {}
|
||||||
virtual void SetSamplerState(int stage, int texindex, bool custom_tex) {}
|
virtual void SetSamplerState(int stage, int texindex, bool custom_tex) {}
|
||||||
virtual void SetInterlacingMode() {}
|
virtual void SetInterlacingMode() {}
|
||||||
virtual void SetViewport() {}
|
virtual void SetViewport() {}
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
|
|
||||||
#include "VideoCommon/RenderState.h"
|
#include "VideoCommon/RenderState.h"
|
||||||
|
|
||||||
|
void DepthState::Generate(const BPMemory& bp)
|
||||||
|
{
|
||||||
|
testenable = bp.zmode.testenable.Value();
|
||||||
|
updateenable = bp.zmode.updateenable.Value();
|
||||||
|
func = bp.zmode.func.Value();
|
||||||
|
}
|
||||||
|
|
||||||
// If the framebuffer format has no alpha channel, it is assumed to
|
// If the framebuffer format has no alpha channel, it is assumed to
|
||||||
// ONE on blending. As the backends may emulate this framebuffer
|
// ONE on blending. As the backends may emulate this framebuffer
|
||||||
// configuration with an alpha channel, we just drop all references
|
// configuration with an alpha channel, we just drop all references
|
||||||
|
|
|
@ -9,6 +9,17 @@
|
||||||
#include "VideoCommon/BPMemory.h"
|
#include "VideoCommon/BPMemory.h"
|
||||||
#include "VideoCommon/BPStructs.h"
|
#include "VideoCommon/BPStructs.h"
|
||||||
|
|
||||||
|
union DepthState
|
||||||
|
{
|
||||||
|
void Generate(const BPMemory& bp);
|
||||||
|
|
||||||
|
BitField<0, 1, u32> testenable;
|
||||||
|
BitField<1, 1, u32> updateenable;
|
||||||
|
BitField<2, 3, ZMode::CompareMode> func;
|
||||||
|
|
||||||
|
u32 hex;
|
||||||
|
};
|
||||||
|
|
||||||
union BlendingState
|
union BlendingState
|
||||||
{
|
{
|
||||||
void Generate(const BPMemory& bp);
|
void Generate(const BPMemory& bp);
|
||||||
|
|
Loading…
Reference in New Issue