Move most backend functionality to VideoCommon

This commit is contained in:
Stenzek
2019-02-15 11:59:50 +10:00
parent 933f3ba008
commit f039149198
182 changed files with 8334 additions and 15917 deletions

View File

@ -6,6 +6,7 @@
#include <algorithm>
#include <array>
#include "VideoCommon/SamplerCommon.h"
#include "VideoCommon/TextureConfig.h"
void RasterizationState::Generate(const BPMemory& bp, PrimitiveType primitive_type)
{
@ -23,6 +24,12 @@ RasterizationState& RasterizationState::operator=(const RasterizationState& rhs)
return *this;
}
FramebufferState& FramebufferState::operator=(const FramebufferState& rhs)
{
hex = rhs.hex;
return *this;
}
void DepthState::Generate(const BPMemory& bp)
{
testenable = bp.zmode.testenable.Value();
@ -206,10 +213,19 @@ RasterizationState GetInvalidRasterizationState()
return state;
}
RasterizationState GetNoCullRasterizationState()
RasterizationState GetNoCullRasterizationState(PrimitiveType primitive)
{
RasterizationState state = {};
state.cullmode = GenMode::CULL_NONE;
state.primitive = primitive;
return state;
}
RasterizationState GetCullBackFaceRasterizationState(PrimitiveType primitive)
{
RasterizationState state = {};
state.cullmode = GenMode::CULL_BACK;
state.primitive = primitive;
return state;
}
@ -220,7 +236,7 @@ DepthState GetInvalidDepthState()
return state;
}
DepthState GetNoDepthTestingDepthStencilState()
DepthState GetNoDepthTestingDepthState()
{
DepthState state = {};
state.testenable = false;
@ -229,6 +245,15 @@ DepthState GetNoDepthTestingDepthStencilState()
return state;
}
DepthState GetAlwaysWriteDepthState()
{
DepthState state = {};
state.testenable = true;
state.updateenable = true;
state.func = ZMode::ALWAYS;
return state;
}
BlendingState GetInvalidBlendingState()
{
BlendingState state;
@ -251,6 +276,21 @@ BlendingState GetNoBlendingBlendState()
return state;
}
BlendingState GetNoColorWriteBlendState()
{
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 = false;
state.alphaupdate = false;
return state;
}
SamplerState GetInvalidSamplerState()
{
SamplerState state;
@ -287,4 +327,20 @@ SamplerState GetLinearSamplerState()
state.anisotropic_filtering = false;
return state;
}
FramebufferState GetColorFramebufferState(AbstractTextureFormat format)
{
FramebufferState state = {};
state.color_texture_format = format;
state.depth_texture_format = AbstractTextureFormat::Undefined;
state.per_sample_shading = false;
state.samples = 1;
return state;
}
FramebufferState GetRGBA8FramebufferState()
{
return GetColorFramebufferState(AbstractTextureFormat::RGBA8);
}
} // namespace RenderState