VideoCommon: Make dst_alpha state implicit.

This commit is contained in:
degasus
2016-12-28 01:37:41 +01:00
parent b7d8bd13a6
commit 41b0c74e30
33 changed files with 79 additions and 149 deletions

View File

@ -551,9 +551,9 @@ void PixelShaderCache::Shutdown()
g_ps_disk_cache.Close();
}
bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode)
bool PixelShaderCache::SetShader()
{
PixelShaderUid uid = GetPixelShaderUid(dstAlphaMode);
PixelShaderUid uid = GetPixelShaderUid();
// Check if the shader is already set
if (last_entry)

View File

@ -9,8 +9,6 @@
#include "VideoCommon/PixelShaderGen.h"
enum DSTALPHA_MODE;
namespace DX11
{
class PixelShaderCache
@ -19,7 +17,7 @@ public:
static void Init();
static void Clear();
static void Shutdown();
static bool SetShader(DSTALPHA_MODE dstAlphaMode); // TODO: Should be renamed to LoadShader
static bool SetShader(); // TODO: Should be renamed to LoadShader
static bool InsertByteCode(const PixelShaderUid& uid, const void* bytecode,
unsigned int bytecodelen);

View File

@ -940,8 +940,12 @@ void Renderer::RestoreAPIState()
BPFunctions::SetScissor();
}
void Renderer::ApplyState(bool bUseDstAlpha)
void Renderer::ApplyState()
{
// TODO: Refactor this logic here.
bool bUseDstAlpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate &&
bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
gx_state.blend.use_dst_alpha = bUseDstAlpha;
D3D::stateman->PushBlendState(gx_state_cache.Get(gx_state.blend));
D3D::stateman->PushDepthState(gx_state_cache.Get(gx_state.zmode));

View File

@ -29,7 +29,7 @@ public:
bool IsFullscreen() const override;
// TODO: Fix confusing names (see ResetAPIState and RestoreAPIState)
void ApplyState(bool bUseDstAlpha) override;
void ApplyState() override;
void RestoreState() override;
void ApplyCullDisable();

View File

@ -147,9 +147,9 @@ void VertexManager::Draw(u32 stride)
static_cast<Renderer*>(g_renderer.get())->RestoreCull();
}
void VertexManager::vFlush(bool useDstAlpha)
void VertexManager::vFlush()
{
if (!PixelShaderCache::SetShader(useDstAlpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE))
if (!PixelShaderCache::SetShader())
{
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR, true, { printf("Fail to set pixel shader\n"); });
return;
@ -179,7 +179,7 @@ void VertexManager::vFlush(bool useDstAlpha)
PrepareDrawBuffers(stride);
VertexLoaderManager::GetCurrentVertexFormat()->SetupVertexPointers();
g_renderer->ApplyState(useDstAlpha);
g_renderer->ApplyState();
Draw(stride);

View File

@ -25,7 +25,7 @@ private:
void PrepareDrawBuffers(u32 stride);
void Draw(u32 stride);
// temp
void vFlush(bool useDstAlpha) override;
void vFlush() override;
u32 m_vertexDrawOffset;
u32 m_indexDrawOffset;