Renderer: Change SetBlendState to accept a BlendingState

This decouples the state generation (from the emulated GPU) from the
management of internal backend state.
This commit is contained in:
Stenzek 2017-04-30 01:00:45 +10:00
parent 22b8cbae35
commit 3dd675e613
8 changed files with 14 additions and 18 deletions

View File

@ -640,11 +640,9 @@ void Renderer::ReinterpretPixelData(unsigned int convtype)
FramebufferManager::GetEFBDepthTexture()->GetDSV()); FramebufferManager::GetEFBDepthTexture()->GetDSV());
} }
void Renderer::SetBlendMode(bool forceUpdate) void Renderer::SetBlendingState(const BlendingState& state)
{ {
BlendingState state; s_gx_state.blend.hex = state.hex;
state.Generate(bpmem);
gx_state.blend.hex = state.hex;
} }
// This function has the final picture. We adjust the aspect ratio here. // This function has the final picture. We adjust the aspect ratio here.

View File

@ -19,7 +19,7 @@ public:
Renderer(); Renderer();
~Renderer() override; ~Renderer() override;
void SetBlendMode(bool forceUpdate) 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 SetDepthMode() override;

View File

@ -1264,11 +1264,8 @@ void Renderer::ReinterpretPixelData(unsigned int convtype)
} }
} }
void Renderer::SetBlendMode(bool forceUpdate) void Renderer::SetBlendingState(const BlendingState& state)
{ {
BlendingState state;
state.Generate(bpmem);
bool useDualSource = bool useDualSource =
state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend && state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) || state.dstalpha); (!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) || state.dstalpha);
@ -1791,7 +1788,7 @@ void Renderer::RestoreAPIState()
SetGenerationMode(); SetGenerationMode();
BPFunctions::SetScissor(); BPFunctions::SetScissor();
SetDepthMode(); SetDepthMode();
SetBlendMode(true); BPFunctions::SetBlendMode();
SetViewport(); SetViewport();
ProgramShaderCache::BindLastVertexFormat(); ProgramShaderCache::BindLastVertexFormat();

View File

@ -77,7 +77,7 @@ public:
void Init(); void Init();
void Shutdown(); void Shutdown();
void SetBlendMode(bool forceUpdate) 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 SetDepthMode() override;

View File

@ -1340,11 +1340,8 @@ void Renderer::SetDepthMode()
StateTracker::GetInstance()->SetDepthStencilState(new_ds_state); StateTracker::GetInstance()->SetDepthStencilState(new_ds_state);
} }
void Renderer::SetBlendMode(bool force_update) void Renderer::SetBlendingState(const BlendingState& state)
{ {
BlendingState state;
state.Generate(bpmem);
StateTracker::GetInstance()->SetBlendState(state); StateTracker::GetInstance()->SetBlendState(state);
} }

View File

@ -56,7 +56,7 @@ public:
void ResetAPIState() override; void ResetAPIState() override;
void RestoreAPIState() override; void RestoreAPIState() override;
void SetBlendMode(bool force_update) 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 SetDepthMode() override;

View File

@ -8,6 +8,7 @@
#include "VideoCommon/BPFunctions.h" #include "VideoCommon/BPFunctions.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/RenderState.h"
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
@ -72,7 +73,9 @@ void SetDepthMode()
void SetBlendMode() void SetBlendMode()
{ {
g_renderer->SetBlendMode(false); BlendingState state;
state.Generate(bpmem);
g_renderer->SetBlendingState(state);
} }
/* Explanation of the magic behind ClearScreen: /* Explanation of the magic behind ClearScreen:

View File

@ -29,6 +29,7 @@
#include "VideoCommon/AVIDump.h" #include "VideoCommon/AVIDump.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/FPSCounter.h" #include "VideoCommon/FPSCounter.h"
#include "VideoCommon/RenderState.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
class PostProcessingShaderImplementation; class PostProcessingShaderImplementation;
@ -63,7 +64,7 @@ public:
PP_EFB_COPY_CLOCKS PP_EFB_COPY_CLOCKS
}; };
virtual void SetBlendMode(bool forceUpdate) {} 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 SetDepthMode() {}