mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
VideoCommon: Make dst_alpha state implicit.
This commit is contained in:
@ -1218,7 +1218,7 @@ void Renderer::ResizeSwapChain()
|
||||
OnSwapChainResized();
|
||||
}
|
||||
|
||||
void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
void Renderer::ApplyState()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
|
||||
void ReinterpretPixelData(unsigned int convtype) override;
|
||||
|
||||
void ApplyState(bool bUseDstAlpha) override;
|
||||
void ApplyState() override;
|
||||
|
||||
void ResetAPIState() override;
|
||||
void RestoreAPIState() override;
|
||||
|
@ -304,10 +304,10 @@ void StateTracker::SetBlendState(const BlendState& state)
|
||||
m_dirty_flags |= DIRTY_FLAG_PIPELINE;
|
||||
}
|
||||
|
||||
bool StateTracker::CheckForShaderChanges(u32 gx_primitive_type, DSTALPHA_MODE dstalpha_mode)
|
||||
bool StateTracker::CheckForShaderChanges(u32 gx_primitive_type)
|
||||
{
|
||||
VertexShaderUid vs_uid = GetVertexShaderUid();
|
||||
PixelShaderUid ps_uid = GetPixelShaderUid(dstalpha_mode);
|
||||
PixelShaderUid ps_uid = GetPixelShaderUid();
|
||||
|
||||
bool changed = false;
|
||||
|
||||
@ -340,16 +340,6 @@ bool StateTracker::CheckForShaderChanges(u32 gx_primitive_type, DSTALPHA_MODE ds
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (m_dstalpha_mode != dstalpha_mode)
|
||||
{
|
||||
// Switching to/from alpha pass requires a pipeline change, since the blend state
|
||||
// is overridden in the destination alpha pass.
|
||||
if (m_dstalpha_mode == DSTALPHA_ALPHA_PASS || dstalpha_mode == DSTALPHA_ALPHA_PASS)
|
||||
changed = true;
|
||||
|
||||
m_dstalpha_mode = dstalpha_mode;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
m_dirty_flags |= DIRTY_FLAG_PIPELINE;
|
||||
|
||||
@ -881,22 +871,6 @@ void StateTracker::EndClearRenderPass()
|
||||
EndRenderPass();
|
||||
}
|
||||
|
||||
PipelineInfo StateTracker::GetAlphaPassPipelineConfig(const PipelineInfo& info) const
|
||||
{
|
||||
PipelineInfo temp_info = info;
|
||||
|
||||
// Skip depth writes for this pass. The results will be the same, so no
|
||||
// point in overwriting depth values with the same value.
|
||||
temp_info.depth_stencil_state.write_enable = VK_FALSE;
|
||||
|
||||
// Only allow alpha writes, and disable blending.
|
||||
temp_info.blend_state.blend_enable = VK_FALSE;
|
||||
temp_info.blend_state.logic_op_enable = VK_FALSE;
|
||||
temp_info.blend_state.write_mask = VK_COLOR_COMPONENT_A_BIT;
|
||||
|
||||
return temp_info;
|
||||
}
|
||||
|
||||
VkPipeline StateTracker::GetPipelineAndCacheUID(const PipelineInfo& info)
|
||||
{
|
||||
auto result = g_object_cache->GetPipelineWithCacheResult(info);
|
||||
@ -915,17 +889,7 @@ bool StateTracker::UpdatePipeline()
|
||||
return false;
|
||||
|
||||
// Grab a new pipeline object, this can fail.
|
||||
// We have to use a different blend state for the alpha pass of the dstalpha fallback.
|
||||
if (m_dstalpha_mode == DSTALPHA_ALPHA_PASS)
|
||||
{
|
||||
// We need to retain the existing state, since we don't want to break the next draw.
|
||||
PipelineInfo temp_info = GetAlphaPassPipelineConfig(m_pipeline_state);
|
||||
m_pipeline_object = GetPipelineAndCacheUID(temp_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pipeline_object = GetPipelineAndCacheUID(m_pipeline_state);
|
||||
}
|
||||
m_pipeline_object = GetPipelineAndCacheUID(m_pipeline_state);
|
||||
|
||||
m_dirty_flags |= DIRTY_FLAG_PIPELINE_BINDING;
|
||||
return m_pipeline_object != VK_NULL_HANDLE;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
void SetDepthStencilState(const DepthStencilState& state);
|
||||
void SetBlendState(const BlendState& state);
|
||||
|
||||
bool CheckForShaderChanges(u32 gx_primitive_type, DSTALPHA_MODE dstalpha_mode);
|
||||
bool CheckForShaderChanges(u32 gx_primitive_type);
|
||||
|
||||
void UpdateVertexShaderConstants();
|
||||
void UpdateGeometryShaderConstants();
|
||||
@ -172,9 +172,6 @@ private:
|
||||
// If not, ends the render pass if it is a clear render pass.
|
||||
bool IsViewportWithinRenderArea() const;
|
||||
|
||||
// Gets a pipeline state that can be used to draw the alpha pass with constant alpha enabled.
|
||||
PipelineInfo GetAlphaPassPipelineConfig(const PipelineInfo& info) const;
|
||||
|
||||
// Obtains a Vulkan pipeline object for the specified pipeline configuration.
|
||||
// Also adds this pipeline configuration to the UID cache if it is not present already.
|
||||
VkPipeline GetPipelineAndCacheUID(const PipelineInfo& info);
|
||||
@ -205,7 +202,6 @@ private:
|
||||
|
||||
// pipeline state
|
||||
PipelineInfo m_pipeline_state = {};
|
||||
DSTALPHA_MODE m_dstalpha_mode = DSTALPHA_NONE;
|
||||
VkPipeline m_pipeline_object = VK_NULL_HANDLE;
|
||||
|
||||
// shader bindings
|
||||
|
@ -124,7 +124,7 @@ void VertexManager::ResetBuffer(u32 stride)
|
||||
static_cast<u32>(m_index_stream_buffer->GetCurrentOffset() / sizeof(u16));
|
||||
}
|
||||
|
||||
void VertexManager::vFlush(bool use_dst_alpha)
|
||||
void VertexManager::vFlush()
|
||||
{
|
||||
const VertexFormat* vertex_format =
|
||||
static_cast<VertexFormat*>(VertexLoaderManager::GetCurrentVertexFormat());
|
||||
@ -153,13 +153,8 @@ void VertexManager::vFlush(bool use_dst_alpha)
|
||||
break;
|
||||
}
|
||||
|
||||
// Can we do single-pass dst alpha?
|
||||
DSTALPHA_MODE dstalpha_mode = DSTALPHA_NONE;
|
||||
if (use_dst_alpha && g_vulkan_context->SupportsDualSourceBlend())
|
||||
dstalpha_mode = DSTALPHA_DUAL_SOURCE_BLEND;
|
||||
|
||||
// Check for any shader stage changes
|
||||
StateTracker::GetInstance()->CheckForShaderChanges(m_current_primitive_type, dstalpha_mode);
|
||||
StateTracker::GetInstance()->CheckForShaderChanges(m_current_primitive_type);
|
||||
|
||||
// Update any changed constants
|
||||
StateTracker::GetInstance()->UpdateVertexShaderConstants();
|
||||
|
@ -31,7 +31,7 @@ protected:
|
||||
void ResetBuffer(u32 stride) override;
|
||||
|
||||
private:
|
||||
void vFlush(bool use_dst_alpha) override;
|
||||
void vFlush() override;
|
||||
|
||||
std::vector<u8> m_cpu_vertex_buffer;
|
||||
std::vector<u16> m_cpu_index_buffer;
|
||||
|
Reference in New Issue
Block a user