VideoCommon: Add helpers for generating common render states
This commit is contained in:
parent
b7a099814a
commit
340aabbb06
|
@ -1192,11 +1192,11 @@ void FramebufferManager::DrawPokeVertices(const EFBPokeVertex* vertices, size_t
|
||||||
pipeline_info.gs = (GetEFBLayers() > 1) ? m_poke_geometry_shader : VK_NULL_HANDLE;
|
pipeline_info.gs = (GetEFBLayers() > 1) ? m_poke_geometry_shader : VK_NULL_HANDLE;
|
||||||
pipeline_info.ps = m_poke_fragment_shader;
|
pipeline_info.ps = m_poke_fragment_shader;
|
||||||
pipeline_info.render_pass = m_efb_load_render_pass;
|
pipeline_info.render_pass = m_efb_load_render_pass;
|
||||||
pipeline_info.rasterization_state.hex = Util::GetNoCullRasterizationState().hex;
|
pipeline_info.rasterization_state.hex = RenderState::GetNoCullRasterizationState().hex;
|
||||||
pipeline_info.rasterization_state.primitive = m_poke_primitive;
|
pipeline_info.rasterization_state.primitive = m_poke_primitive;
|
||||||
pipeline_info.multisampling_state.hex = GetEFBMultisamplingState().hex;
|
pipeline_info.multisampling_state.hex = GetEFBMultisamplingState().hex;
|
||||||
pipeline_info.depth_state.hex = Util::GetNoDepthTestingDepthStencilState().hex;
|
pipeline_info.depth_state.hex = RenderState::GetNoDepthTestingDepthStencilState().hex;
|
||||||
pipeline_info.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
pipeline_info.blend_state.hex = RenderState::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;
|
||||||
if (write_depth)
|
if (write_depth)
|
||||||
|
|
|
@ -400,7 +400,7 @@ void RasterFont::PrintMultiLineText(VkRenderPass render_pass, const std::string&
|
||||||
draw.SetPSSampler(0, m_texture->GetView(), g_object_cache->GetLinearSampler());
|
draw.SetPSSampler(0, m_texture->GetView(), g_object_cache->GetLinearSampler());
|
||||||
|
|
||||||
// Setup alpha blending
|
// Setup alpha blending
|
||||||
BlendingState blend_state = Util::GetNoBlendingBlendState();
|
BlendingState blend_state = RenderState::GetNoBlendingBlendState();
|
||||||
blend_state.blendenable = true;
|
blend_state.blendenable = true;
|
||||||
blend_state.srcfactor = BlendMode::SRCALPHA;
|
blend_state.srcfactor = BlendMode::SRCALPHA;
|
||||||
blend_state.dstfactor = BlendMode::INVSRCALPHA;
|
blend_state.dstfactor = BlendMode::INVSRCALPHA;
|
||||||
|
|
|
@ -455,11 +455,11 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha
|
||||||
StateTracker::GetInstance()->SetPendingRebind();
|
StateTracker::GetInstance()->SetPendingRebind();
|
||||||
|
|
||||||
// Mask away the appropriate colors and use a shader
|
// Mask away the appropriate colors and use a shader
|
||||||
BlendingState blend_state = Util::GetNoBlendingBlendState();
|
BlendingState blend_state = RenderState::GetNoBlendingBlendState();
|
||||||
blend_state.colorupdate = color_enable;
|
blend_state.colorupdate = color_enable;
|
||||||
blend_state.alphaupdate = alpha_enable;
|
blend_state.alphaupdate = alpha_enable;
|
||||||
|
|
||||||
DepthState depth_state = Util::GetNoDepthTestingDepthStencilState();
|
DepthState depth_state = RenderState::GetNoDepthTestingDepthStencilState();
|
||||||
depth_state.testenable = z_enable;
|
depth_state.testenable = z_enable;
|
||||||
depth_state.updateenable = z_enable;
|
depth_state.updateenable = z_enable;
|
||||||
depth_state.func = ZMode::ALWAYS;
|
depth_state.func = ZMode::ALWAYS;
|
||||||
|
|
|
@ -1210,9 +1210,9 @@ void ShaderCache::CreateDummyPipeline(const UberShader::VertexShaderUid& vuid,
|
||||||
VK_NULL_HANDLE;
|
VK_NULL_HANDLE;
|
||||||
pinfo.ps = GetPixelUberShaderForUid(puid);
|
pinfo.ps = GetPixelUberShaderForUid(puid);
|
||||||
pinfo.render_pass = FramebufferManager::GetInstance()->GetEFBLoadRenderPass();
|
pinfo.render_pass = FramebufferManager::GetInstance()->GetEFBLoadRenderPass();
|
||||||
pinfo.rasterization_state.hex = Util::GetNoCullRasterizationState().hex;
|
pinfo.rasterization_state.hex = RenderState::GetNoCullRasterizationState().hex;
|
||||||
pinfo.depth_state.hex = Util::GetNoDepthTestingDepthStencilState().hex;
|
pinfo.depth_state.hex = RenderState::GetNoDepthTestingDepthStencilState().hex;
|
||||||
pinfo.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
pinfo.blend_state.hex = RenderState::GetNoBlendingBlendState().hex;
|
||||||
pinfo.multisampling_state.hex = FramebufferManager::GetInstance()->GetEFBMultisamplingState().hex;
|
pinfo.multisampling_state.hex = FramebufferManager::GetInstance()->GetEFBMultisamplingState().hex;
|
||||||
pinfo.rasterization_state.primitive = guid.GetUidData()->primitive_type;
|
pinfo.rasterization_state.primitive = guid.GetUidData()->primitive_type;
|
||||||
GetPipelineWithCacheResultAsync(pinfo);
|
GetPipelineWithCacheResultAsync(pinfo);
|
||||||
|
|
|
@ -185,36 +185,6 @@ VkBlendFactor GetAlphaBlendFactor(VkBlendFactor factor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterizationState GetNoCullRasterizationState()
|
|
||||||
{
|
|
||||||
RasterizationState state = {};
|
|
||||||
state.cullmode = GenMode::CULL_NONE;
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
DepthState GetNoDepthTestingDepthStencilState()
|
|
||||||
{
|
|
||||||
DepthState state = {};
|
|
||||||
state.testenable = false;
|
|
||||||
state.updateenable = false;
|
|
||||||
state.func = ZMode::ALWAYS;
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlendingState GetNoBlendingBlendState()
|
|
||||||
{
|
|
||||||
BlendingState state = {};
|
|
||||||
state.blendenable = false;
|
|
||||||
state.srcfactor = BlendMode::ONE;
|
|
||||||
state.srcfactoralpha = BlendMode::ZERO;
|
|
||||||
state.dstfactor = BlendMode::ONE;
|
|
||||||
state.dstfactoralpha = BlendMode::ZERO;
|
|
||||||
state.logicopenable = false;
|
|
||||||
state.colorupdate = true;
|
|
||||||
state.alphaupdate = true;
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetViewportAndScissor(VkCommandBuffer command_buffer, int x, int y, int width, int height,
|
void SetViewportAndScissor(VkCommandBuffer command_buffer, int x, int y, int width, int height,
|
||||||
float min_depth /*= 0.0f*/, float max_depth /*= 1.0f*/)
|
float min_depth /*= 0.0f*/, float max_depth /*= 1.0f*/)
|
||||||
{
|
{
|
||||||
|
@ -342,10 +312,10 @@ UtilityShaderDraw::UtilityShaderDraw(VkCommandBuffer command_buffer,
|
||||||
m_pipeline_info.vs = vertex_shader;
|
m_pipeline_info.vs = vertex_shader;
|
||||||
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.hex = Util::GetNoCullRasterizationState().hex;
|
m_pipeline_info.rasterization_state.hex = RenderState::GetNoCullRasterizationState().hex;
|
||||||
m_pipeline_info.rasterization_state.primitive = primitive;
|
m_pipeline_info.rasterization_state.primitive = primitive;
|
||||||
m_pipeline_info.depth_state.hex = Util::GetNoDepthTestingDepthStencilState().hex;
|
m_pipeline_info.depth_state.hex = RenderState::GetNoDepthTestingDepthStencilState().hex;
|
||||||
m_pipeline_info.blend_state.hex = Util::GetNoBlendingBlendState().hex;
|
m_pipeline_info.blend_state.hex = RenderState::GetNoBlendingBlendState().hex;
|
||||||
m_pipeline_info.multisampling_state.per_sample_shading = false;
|
m_pipeline_info.multisampling_state.per_sample_shading = false;
|
||||||
m_pipeline_info.multisampling_state.samples = 1;
|
m_pipeline_info.multisampling_state.samples = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,6 @@ VkRect2D ClampRect2D(const VkRect2D& rect, u32 width, u32 height);
|
||||||
// Map {SRC,DST}_COLOR to {SRC,DST}_ALPHA
|
// Map {SRC,DST}_COLOR to {SRC,DST}_ALPHA
|
||||||
VkBlendFactor GetAlphaBlendFactor(VkBlendFactor factor);
|
VkBlendFactor GetAlphaBlendFactor(VkBlendFactor factor);
|
||||||
|
|
||||||
RasterizationState GetNoCullRasterizationState();
|
|
||||||
DepthState GetNoDepthTestingDepthStencilState();
|
|
||||||
BlendingState GetNoBlendingBlendState();
|
|
||||||
|
|
||||||
// Combines viewport and scissor updates
|
// Combines viewport and scissor updates
|
||||||
void SetViewportAndScissor(VkCommandBuffer command_buffer, int x, int y, int width, int height,
|
void SetViewportAndScissor(VkCommandBuffer command_buffer, int x, int y, int width, int height,
|
||||||
float min_depth = 0.0f, float max_depth = 1.0f);
|
float min_depth = 0.0f, float max_depth = 1.0f);
|
||||||
|
|
|
@ -144,3 +144,37 @@ void BlendingState::Generate(const BPMemory& bp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace RenderState
|
||||||
|
{
|
||||||
|
RasterizationState GetNoCullRasterizationState()
|
||||||
|
{
|
||||||
|
RasterizationState state = {};
|
||||||
|
state.cullmode = GenMode::CULL_NONE;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthState GetNoDepthTestingDepthStencilState()
|
||||||
|
{
|
||||||
|
DepthState state = {};
|
||||||
|
state.testenable = false;
|
||||||
|
state.updateenable = false;
|
||||||
|
state.func = ZMode::ALWAYS;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlendingState GetNoBlendingBlendState()
|
||||||
|
{
|
||||||
|
BlendingState state = {};
|
||||||
|
state.usedualsrc = false;
|
||||||
|
state.blendenable = false;
|
||||||
|
state.srcfactor = BlendMode::ONE;
|
||||||
|
state.srcfactoralpha = BlendMode::ONE;
|
||||||
|
state.dstfactor = BlendMode::ZERO;
|
||||||
|
state.dstfactoralpha = BlendMode::ZERO;
|
||||||
|
state.logicopenable = false;
|
||||||
|
state.colorupdate = true;
|
||||||
|
state.alphaupdate = true;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -58,3 +58,10 @@ union BlendingState
|
||||||
|
|
||||||
u32 hex;
|
u32 hex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace RenderState
|
||||||
|
{
|
||||||
|
RasterizationState GetNoCullRasterizationState();
|
||||||
|
DepthState GetNoDepthTestingDepthStencilState();
|
||||||
|
BlendingState GetNoBlendingBlendState();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue