Convert BPMemory to BitField and enum class

Additional changes:
- For TevStageCombiner's ColorCombiner and AlphaCombiner, op/comparison and scale/compare_mode have been split as there are different meanings and enums if bias is set to compare.  (Shift has also been renamed to scale)
- In TexMode0, min_filter has been split into min_mip and min_filter.
- In TexImage1, image_type is now cache_manually_managed.
- The unused bit in GenMode is now exposed.
- LPSize's lineaspect is now named adjust_for_aspect_ratio.
This commit is contained in:
Pokechu22
2021-03-06 19:27:19 -08:00
parent db8ced7e4e
commit 70f9fc4e75
33 changed files with 1553 additions and 1236 deletions
+7 -7
View File
@@ -378,7 +378,7 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
D3D11_LOGIC_OP_COPY_INVERTED, D3D11_LOGIC_OP_OR_INVERTED, D3D11_LOGIC_OP_NAND,
D3D11_LOGIC_OP_SET}};
tdesc.LogicOpEnable = TRUE;
tdesc.LogicOp = logic_ops[state.logicmode];
tdesc.LogicOp = logic_ops[u32(state.logicmode.Value())];
ComPtr<ID3D11BlendState1> res;
HRESULT hr = D3D::device1->CreateBlendState1(&desc, res.GetAddressOf());
@@ -416,10 +416,10 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
use_dual_source ? D3D11_BLEND_INV_SRC1_ALPHA : D3D11_BLEND_INV_SRC_ALPHA,
D3D11_BLEND_DEST_ALPHA, D3D11_BLEND_INV_DEST_ALPHA}};
tdesc.SrcBlend = src_factors[state.srcfactor];
tdesc.SrcBlendAlpha = src_factors[state.srcfactoralpha];
tdesc.DestBlend = dst_factors[state.dstfactor];
tdesc.DestBlendAlpha = dst_factors[state.dstfactoralpha];
tdesc.SrcBlend = src_factors[u32(state.srcfactor.Value())];
tdesc.SrcBlendAlpha = src_factors[u32(state.srcfactoralpha.Value())];
tdesc.DestBlend = dst_factors[u32(state.dstfactor.Value())];
tdesc.DestBlendAlpha = dst_factors[u32(state.dstfactoralpha.Value())];
tdesc.BlendOp = state.subtract ? D3D11_BLEND_OP_REV_SUBTRACT : D3D11_BLEND_OP_ADD;
tdesc.BlendOpAlpha = state.subtractAlpha ? D3D11_BLEND_OP_REV_SUBTRACT : D3D11_BLEND_OP_ADD;
@@ -441,7 +441,7 @@ ID3D11RasterizerState* StateCache::Get(RasterizationState state)
D3D11_RASTERIZER_DESC desc = {};
desc.FillMode = D3D11_FILL_SOLID;
desc.CullMode = cull_modes[state.cullmode];
desc.CullMode = cull_modes[u32(state.cullmode.Value())];
desc.ScissorEnable = TRUE;
ComPtr<ID3D11RasterizerState> res;
@@ -477,7 +477,7 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state)
depthdc.DepthEnable = TRUE;
depthdc.DepthWriteMask =
state.updateenable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
depthdc.DepthFunc = d3dCmpFuncs[state.func];
depthdc.DepthFunc = d3dCmpFuncs[u32(state.func.Value())];
}
else
{
@@ -66,7 +66,7 @@ static void GetD3DRasterizerDesc(D3D12_RASTERIZER_DESC* desc, const Rasterizatio
{D3D12_CULL_MODE_NONE, D3D12_CULL_MODE_BACK, D3D12_CULL_MODE_FRONT, D3D12_CULL_MODE_FRONT}};
desc->FillMode = D3D12_FILL_MODE_SOLID;
desc->CullMode = cull_modes[rs_state.cullmode];
desc->CullMode = cull_modes[u32(rs_state.cullmode.Value())];
desc->MultisampleEnable = fb_state.samples > 1;
}
@@ -80,7 +80,7 @@ static void GetD3DDepthDesc(D3D12_DEPTH_STENCIL_DESC* desc, const DepthState& st
D3D12_COMPARISON_FUNC_ALWAYS}};
desc->DepthEnable = state.testenable;
desc->DepthFunc = compare_funcs[state.func];
desc->DepthFunc = compare_funcs[u32(state.func.Value())];
desc->DepthWriteMask =
state.updateenable ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO;
}
@@ -135,24 +135,24 @@ static void GetD3DBlendDesc(D3D12_BLEND_DESC* desc, const BlendingState& state)
rtblend->BlendOpAlpha = state.subtractAlpha ? D3D12_BLEND_OP_REV_SUBTRACT : D3D12_BLEND_OP_ADD;
if (state.usedualsrc)
{
rtblend->SrcBlend = src_dual_src_factors[state.srcfactor];
rtblend->SrcBlendAlpha = src_dual_src_factors[state.srcfactoralpha];
rtblend->DestBlend = dst_dual_src_factors[state.dstfactor];
rtblend->DestBlendAlpha = dst_dual_src_factors[state.dstfactoralpha];
rtblend->SrcBlend = src_dual_src_factors[u32(state.srcfactor.Value())];
rtblend->SrcBlendAlpha = src_dual_src_factors[u32(state.srcfactoralpha.Value())];
rtblend->DestBlend = dst_dual_src_factors[u32(state.dstfactor.Value())];
rtblend->DestBlendAlpha = dst_dual_src_factors[u32(state.dstfactoralpha.Value())];
}
else
{
rtblend->SrcBlend = src_factors[state.srcfactor];
rtblend->SrcBlendAlpha = src_factors[state.srcfactoralpha];
rtblend->DestBlend = dst_factors[state.dstfactor];
rtblend->DestBlendAlpha = dst_factors[state.dstfactoralpha];
rtblend->SrcBlend = src_factors[u32(state.srcfactor.Value())];
rtblend->SrcBlendAlpha = src_factors[u32(state.srcfactoralpha.Value())];
rtblend->DestBlend = dst_factors[u32(state.dstfactor.Value())];
rtblend->DestBlendAlpha = dst_factors[u32(state.dstfactoralpha.Value())];
}
}
else
{
rtblend->LogicOpEnable = state.logicopenable;
if (state.logicopenable)
rtblend->LogicOp = logic_ops[state.logicmode];
rtblend->LogicOp = logic_ops[u32(state.logicmode.Value())];
}
}
+8 -6
View File
@@ -1140,11 +1140,11 @@ void Renderer::ApplyRasterizationState(const RasterizationState state)
return;
// none, ccw, cw, ccw
if (state.cullmode != GenMode::CULL_NONE)
if (state.cullmode != CullMode::None)
{
// TODO: GX_CULL_ALL not supported, yet!
glEnable(GL_CULL_FACE);
glFrontFace(state.cullmode == GenMode::CULL_FRONT ? GL_CCW : GL_CW);
glFrontFace(state.cullmode == CullMode::Front ? GL_CCW : GL_CW);
}
else
{
@@ -1166,7 +1166,7 @@ void Renderer::ApplyDepthState(const DepthState state)
{
glEnable(GL_DEPTH_TEST);
glDepthMask(state.updateenable ? GL_TRUE : GL_FALSE);
glDepthFunc(glCmpFuncs[state.func]);
glDepthFunc(glCmpFuncs[u32(state.func.Value())]);
}
else
{
@@ -1229,8 +1229,10 @@ void Renderer::ApplyBlendingState(const BlendingState state)
GLenum equation = state.subtract ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
GLenum equationAlpha = state.subtractAlpha ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
glBlendEquationSeparate(equation, equationAlpha);
glBlendFuncSeparate(src_factors[state.srcfactor], dst_factors[state.dstfactor],
src_factors[state.srcfactoralpha], dst_factors[state.dstfactoralpha]);
glBlendFuncSeparate(src_factors[u32(state.srcfactor.Value())],
dst_factors[u32(state.dstfactor.Value())],
src_factors[u32(state.srcfactoralpha.Value())],
dst_factors[u32(state.dstfactoralpha.Value())]);
}
const GLenum logic_op_codes[16] = {
@@ -1244,7 +1246,7 @@ void Renderer::ApplyBlendingState(const BlendingState state)
if (state.logicopenable)
{
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(logic_op_codes[state.logicmode]);
glLogicOp(logic_op_codes[u32(state.logicmode.Value())]);
}
else
{
@@ -489,13 +489,16 @@ bool CullTest(const OutputVertexData* v0, const OutputVertexData* v1, const Outp
backface = normalZDir <= 0.0f;
if ((bpmem.genMode.cullmode & 1) && !backface) // cull frontfacing
// TODO: Are these tests / the definition of backface above backwards?
if ((bpmem.genMode.cullmode == CullMode::Back || bpmem.genMode.cullmode == CullMode::All) &&
!backface) // cull frontfacing
{
INCSTAT(g_stats.this_frame.num_triangles_culled)
return false;
}
if ((bpmem.genMode.cullmode & 2) && backface) // cull backfacing
if ((bpmem.genMode.cullmode == CullMode::Front || bpmem.genMode.cullmode == CullMode::All) &&
backface) // cull backfacing
{
INCSTAT(g_stats.this_frame.num_triangles_culled)
return false;
@@ -41,12 +41,12 @@ static void SetPixelAlphaOnly(u32 offset, u8 a)
{
switch (bpmem.zcontrol.pixel_format)
{
case PEControl::RGB8_Z24:
case PEControl::Z24:
case PEControl::RGB565_Z16:
case PixelFormat::RGB8_Z24:
case PixelFormat::Z24:
case PixelFormat::RGB565_Z16:
// do nothing
break;
case PEControl::RGBA6_Z24:
case PixelFormat::RGBA6_Z24:
{
u32 a32 = a;
u32* dst = (u32*)&efb[offset];
@@ -56,8 +56,7 @@ static void SetPixelAlphaOnly(u32 offset, u8 a)
}
break;
default:
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}",
static_cast<int>(bpmem.zcontrol.pixel_format));
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}", bpmem.zcontrol.pixel_format);
break;
}
}
@@ -66,8 +65,8 @@ static void SetPixelColorOnly(u32 offset, u8* rgb)
{
switch (bpmem.zcontrol.pixel_format)
{
case PEControl::RGB8_Z24:
case PEControl::Z24:
case PixelFormat::RGB8_Z24:
case PixelFormat::Z24:
{
u32 src = *(u32*)rgb;
u32* dst = (u32*)&efb[offset];
@@ -76,7 +75,7 @@ static void SetPixelColorOnly(u32 offset, u8* rgb)
*dst = val;
}
break;
case PEControl::RGBA6_Z24:
case PixelFormat::RGBA6_Z24:
{
u32 src = *(u32*)rgb;
u32* dst = (u32*)&efb[offset];
@@ -87,7 +86,7 @@ static void SetPixelColorOnly(u32 offset, u8* rgb)
*dst = val;
}
break;
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
{
INFO_LOG_FMT(VIDEO, "RGB565_Z16 is not supported correctly yet");
u32 src = *(u32*)rgb;
@@ -98,8 +97,7 @@ static void SetPixelColorOnly(u32 offset, u8* rgb)
}
break;
default:
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}",
static_cast<int>(bpmem.zcontrol.pixel_format));
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}", bpmem.zcontrol.pixel_format);
break;
}
}
@@ -108,8 +106,8 @@ static void SetPixelAlphaColor(u32 offset, u8* color)
{
switch (bpmem.zcontrol.pixel_format)
{
case PEControl::RGB8_Z24:
case PEControl::Z24:
case PixelFormat::RGB8_Z24:
case PixelFormat::Z24:
{
u32 src = *(u32*)color;
u32* dst = (u32*)&efb[offset];
@@ -118,7 +116,7 @@ static void SetPixelAlphaColor(u32 offset, u8* color)
*dst = val;
}
break;
case PEControl::RGBA6_Z24:
case PixelFormat::RGBA6_Z24:
{
u32 src = *(u32*)color;
u32* dst = (u32*)&efb[offset];
@@ -130,7 +128,7 @@ static void SetPixelAlphaColor(u32 offset, u8* color)
*dst = val;
}
break;
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
{
INFO_LOG_FMT(VIDEO, "RGB565_Z16 is not supported correctly yet");
u32 src = *(u32*)color;
@@ -141,8 +139,7 @@ static void SetPixelAlphaColor(u32 offset, u8* color)
}
break;
default:
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}",
static_cast<int>(bpmem.zcontrol.pixel_format));
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}", bpmem.zcontrol.pixel_format);
break;
}
}
@@ -154,23 +151,22 @@ static u32 GetPixelColor(u32 offset)
switch (bpmem.zcontrol.pixel_format)
{
case PEControl::RGB8_Z24:
case PEControl::Z24:
case PixelFormat::RGB8_Z24:
case PixelFormat::Z24:
return 0xff | ((src & 0x00ffffff) << 8);
case PEControl::RGBA6_Z24:
case PixelFormat::RGBA6_Z24:
return Convert6To8(src & 0x3f) | // Alpha
Convert6To8((src >> 6) & 0x3f) << 8 | // Blue
Convert6To8((src >> 12) & 0x3f) << 16 | // Green
Convert6To8((src >> 18) & 0x3f) << 24; // Red
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
INFO_LOG_FMT(VIDEO, "RGB565_Z16 is not supported correctly yet");
return 0xff | ((src & 0x00ffffff) << 8);
default:
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}",
static_cast<int>(bpmem.zcontrol.pixel_format));
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}", bpmem.zcontrol.pixel_format);
return 0;
}
}
@@ -179,9 +175,9 @@ static void SetPixelDepth(u32 offset, u32 depth)
{
switch (bpmem.zcontrol.pixel_format)
{
case PEControl::RGB8_Z24:
case PEControl::RGBA6_Z24:
case PEControl::Z24:
case PixelFormat::RGB8_Z24:
case PixelFormat::RGBA6_Z24:
case PixelFormat::Z24:
{
u32* dst = (u32*)&efb[offset];
u32 val = *dst & 0xff000000;
@@ -189,7 +185,7 @@ static void SetPixelDepth(u32 offset, u32 depth)
*dst = val;
}
break;
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
{
INFO_LOG_FMT(VIDEO, "RGB565_Z16 is not supported correctly yet");
u32* dst = (u32*)&efb[offset];
@@ -199,8 +195,7 @@ static void SetPixelDepth(u32 offset, u32 depth)
}
break;
default:
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}",
static_cast<int>(bpmem.zcontrol.pixel_format));
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}", bpmem.zcontrol.pixel_format);
break;
}
}
@@ -211,59 +206,58 @@ static u32 GetPixelDepth(u32 offset)
switch (bpmem.zcontrol.pixel_format)
{
case PEControl::RGB8_Z24:
case PEControl::RGBA6_Z24:
case PEControl::Z24:
case PixelFormat::RGB8_Z24:
case PixelFormat::RGBA6_Z24:
case PixelFormat::Z24:
{
depth = (*(u32*)&efb[offset]) & 0x00ffffff;
}
break;
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
{
INFO_LOG_FMT(VIDEO, "RGB565_Z16 is not supported correctly yet");
depth = (*(u32*)&efb[offset]) & 0x00ffffff;
}
break;
default:
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}",
static_cast<int>(bpmem.zcontrol.pixel_format));
ERROR_LOG_FMT(VIDEO, "Unsupported pixel format: {}", bpmem.zcontrol.pixel_format);
break;
}
return depth;
}
static u32 GetSourceFactor(u8* srcClr, u8* dstClr, BlendMode::BlendFactor mode)
static u32 GetSourceFactor(u8* srcClr, u8* dstClr, SrcBlendFactor mode)
{
switch (mode)
{
case BlendMode::ZERO:
case SrcBlendFactor::Zero:
return 0;
case BlendMode::ONE:
case SrcBlendFactor::One:
return 0xffffffff;
case BlendMode::DSTCLR:
case SrcBlendFactor::DstClr:
return *(u32*)dstClr;
case BlendMode::INVDSTCLR:
case SrcBlendFactor::InvDstClr:
return 0xffffffff - *(u32*)dstClr;
case BlendMode::SRCALPHA:
case SrcBlendFactor::SrcAlpha:
{
u8 alpha = srcClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
return factor;
}
case BlendMode::INVSRCALPHA:
case SrcBlendFactor::InvSrcAlpha:
{
u8 alpha = 0xff - srcClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
return factor;
}
case BlendMode::DSTALPHA:
case SrcBlendFactor::DstAlpha:
{
u8 alpha = dstClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
return factor;
}
case BlendMode::INVDSTALPHA:
case SrcBlendFactor::InvDstAlpha:
{
u8 alpha = 0xff - dstClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
@@ -274,37 +268,37 @@ static u32 GetSourceFactor(u8* srcClr, u8* dstClr, BlendMode::BlendFactor mode)
return 0;
}
static u32 GetDestinationFactor(u8* srcClr, u8* dstClr, BlendMode::BlendFactor mode)
static u32 GetDestinationFactor(u8* srcClr, u8* dstClr, DstBlendFactor mode)
{
switch (mode)
{
case BlendMode::ZERO:
case DstBlendFactor::Zero:
return 0;
case BlendMode::ONE:
case DstBlendFactor::One:
return 0xffffffff;
case BlendMode::SRCCLR:
case DstBlendFactor::SrcClr:
return *(u32*)srcClr;
case BlendMode::INVSRCCLR:
case DstBlendFactor::InvSrcClr:
return 0xffffffff - *(u32*)srcClr;
case BlendMode::SRCALPHA:
case DstBlendFactor::SrcAlpha:
{
u8 alpha = srcClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
return factor;
}
case BlendMode::INVSRCALPHA:
case DstBlendFactor::InvSrcAlpha:
{
u8 alpha = 0xff - srcClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
return factor;
}
case BlendMode::DSTALPHA:
case DstBlendFactor::DstAlpha:
{
u8 alpha = dstClr[ALP_C] & 0xff;
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
return factor;
}
case BlendMode::INVDSTALPHA:
case DstBlendFactor::InvDstAlpha:
{
u8 alpha = 0xff - dstClr[ALP_C];
u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha;
@@ -337,56 +331,56 @@ static void BlendColor(u8* srcClr, u8* dstClr)
}
}
static void LogicBlend(u32 srcClr, u32* dstClr, BlendMode::LogicOp op)
static void LogicBlend(u32 srcClr, u32* dstClr, LogicOp op)
{
switch (op)
{
case BlendMode::CLEAR:
case LogicOp::Clear:
*dstClr = 0;
break;
case BlendMode::AND:
case LogicOp::And:
*dstClr = srcClr & *dstClr;
break;
case BlendMode::AND_REVERSE:
case LogicOp::AndReverse:
*dstClr = srcClr & (~*dstClr);
break;
case BlendMode::COPY:
case LogicOp::Copy:
*dstClr = srcClr;
break;
case BlendMode::AND_INVERTED:
case LogicOp::AndInverted:
*dstClr = (~srcClr) & *dstClr;
break;
case BlendMode::NOOP:
case LogicOp::NoOp:
// Do nothing
break;
case BlendMode::XOR:
case LogicOp::Xor:
*dstClr = srcClr ^ *dstClr;
break;
case BlendMode::OR:
case LogicOp::Or:
*dstClr = srcClr | *dstClr;
break;
case BlendMode::NOR:
case LogicOp::Nor:
*dstClr = ~(srcClr | *dstClr);
break;
case BlendMode::EQUIV:
case LogicOp::Equiv:
*dstClr = ~(srcClr ^ *dstClr);
break;
case BlendMode::INVERT:
case LogicOp::Invert:
*dstClr = ~*dstClr;
break;
case BlendMode::OR_REVERSE:
case LogicOp::OrReverse:
*dstClr = srcClr | (~*dstClr);
break;
case BlendMode::COPY_INVERTED:
case LogicOp::CopyInverted:
*dstClr = ~srcClr;
break;
case BlendMode::OR_INVERTED:
case LogicOp::OrInverted:
*dstClr = (~srcClr) | *dstClr;
break;
case BlendMode::NAND:
case LogicOp::Nand:
*dstClr = ~(srcClr & *dstClr);
break;
case BlendMode::SET:
case LogicOp::Set:
*dstClr = 0xffffffff;
break;
}
@@ -404,7 +398,7 @@ static void SubtractBlend(u8* srcClr, u8* dstClr)
static void Dither(u16 x, u16 y, u8* color)
{
// No blending for RGB8 mode
if (!bpmem.blendmode.dither || bpmem.zcontrol.pixel_format != PEControl::PixelFormat::RGBA6_Z24)
if (!bpmem.blendmode.dither || bpmem.zcontrol.pixel_format != PixelFormat::RGBA6_Z24)
return;
// Flipper uses a standard 2x2 Bayer Matrix for 6 bit dithering
@@ -662,33 +656,33 @@ bool ZCompare(u16 x, u16 y, u32 z)
switch (bpmem.zmode.func)
{
case ZMode::NEVER:
case CompareMode::Never:
pass = false;
break;
case ZMode::LESS:
case CompareMode::Less:
pass = z < depth;
break;
case ZMode::EQUAL:
case CompareMode::Equal:
pass = z == depth;
break;
case ZMode::LEQUAL:
case CompareMode::LEqual:
pass = z <= depth;
break;
case ZMode::GREATER:
case CompareMode::Greater:
pass = z > depth;
break;
case ZMode::NEQUAL:
case CompareMode::NEqual:
pass = z != depth;
break;
case ZMode::GEQUAL:
case CompareMode::GEqual:
pass = z >= depth;
break;
case ZMode::ALWAYS:
case CompareMode::Always:
pass = true;
break;
default:
pass = false;
ERROR_LOG_FMT(VIDEO, "Bad Z compare mode {}", static_cast<int>(bpmem.zmode.func));
ERROR_LOG_FMT(VIDEO, "Bad Z compare mode {}", bpmem.zmode.func);
break;
}
@@ -173,7 +173,7 @@ static inline void CalculateLOD(s32* lodp, bool* linear, u32 texmap, u32 texcoor
const TexMode1& tm1 = texUnit.texMode1[subTexmap];
float sDelta, tDelta;
if (tm0.diag_lod)
if (tm0.diag_lod == LODType::Diagonal)
{
float* uv0 = rasterBlock.Pixel[0][0].Uv[texcoord];
float* uv1 = rasterBlock.Pixel[1][1].Uv[texcoord];
@@ -199,7 +199,8 @@ static inline void CalculateLOD(s32* lodp, bool* linear, u32 texmap, u32 texcoor
bias >>= 1;
lod += bias;
*linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter));
*linear = ((lod > 0 && tm0.min_filter == FilterMode::Linear) ||
(lod <= 0 && tm0.mag_filter == FilterMode::Linear));
// NOTE: The order of comparisons for this clamp check matters.
if (lod > static_cast<s32>(tm1.max_lod))
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -57,7 +57,7 @@ class Tev
INDIRECT = 32
};
void SetRasColor(int colorChan, int swaptable);
void SetRasColor(RasColorChan colorChan, int swaptable);
void DrawColorRegular(const TevStageCombiner::ColorCombiner& cc, const InputRegType inputs[4]);
void DrawColorCompare(const TevStageCombiner::ColorCombiner& cc, const InputRegType inputs[4]);
@@ -504,7 +504,7 @@ static void EncodeRGBA6(u8* dst, const u8* src, EFBCopyFormat format, bool yuv)
break;
default:
PanicAlertFmt("Unknown texture copy format: {:#x}\n", format);
PanicAlertFmt("Unknown texture copy format: {}\n", format);
break;
}
}
@@ -743,7 +743,7 @@ static void EncodeRGBA6halfscale(u8* dst, const u8* src, EFBCopyFormat format, b
break;
default:
PanicAlertFmt("Unknown texture copy format: {:#x}\n", format);
PanicAlertFmt("Unknown texture copy format: {}\n", format);
break;
}
}
@@ -960,7 +960,7 @@ static void EncodeRGB8(u8* dst, const u8* src, EFBCopyFormat format, bool yuv)
break;
default:
PanicAlertFmt("Unknown texture copy format: {:#x}\n", format);
PanicAlertFmt("Unknown texture copy format: {}\n", format);
break;
}
}
@@ -1192,7 +1192,7 @@ static void EncodeRGB8halfscale(u8* dst, const u8* src, EFBCopyFormat format, bo
break;
default:
PanicAlertFmt("Unknown texture copy format: {:#x}\n", format);
PanicAlertFmt("Unknown texture copy format: {}\n", format);
break;
}
}
@@ -1300,7 +1300,7 @@ static void EncodeZ24(u8* dst, const u8* src, EFBCopyFormat format)
break;
default:
PanicAlertFmt("Unknown texture copy format: {:#x}\n", format);
PanicAlertFmt("Unknown texture copy format: {}\n", format);
break;
}
}
@@ -1414,7 +1414,7 @@ static void EncodeZ24halfscale(u8* dst, const u8* src, EFBCopyFormat format)
break;
default:
PanicAlertFmt("Unknown texture copy format: {:#x}\n", format);
PanicAlertFmt("Unknown texture copy format: {}\n", format);
break;
}
}
@@ -1431,16 +1431,16 @@ void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 b
{
switch (params.efb_format)
{
case PEControl::RGBA6_Z24:
case PixelFormat::RGBA6_Z24:
EncodeRGBA6halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB8_Z24:
case PixelFormat::RGB8_Z24:
EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
EncodeRGB8halfscale(dst, src, params.copy_format, params.yuv);
break;
case PEControl::Z24:
case PixelFormat::Z24:
EncodeZ24halfscale(dst, src, params.copy_format);
break;
default:
@@ -1451,16 +1451,16 @@ void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 b
{
switch (params.efb_format)
{
case PEControl::RGBA6_Z24:
case PixelFormat::RGBA6_Z24:
EncodeRGBA6(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB8_Z24:
case PixelFormat::RGB8_Z24:
EncodeRGB8(dst, src, params.copy_format, params.yuv);
break;
case PEControl::RGB565_Z16:
case PixelFormat::RGB565_Z16:
EncodeRGB8(dst, src, params.copy_format, params.yuv);
break;
case PEControl::Z24:
case PixelFormat::Z24:
EncodeZ24(dst, src, params.copy_format);
break;
default:
@@ -8,6 +8,7 @@
#include <cmath>
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "Core/HW/Memmap.h"
#include "VideoCommon/BPMemory.h"
@@ -18,27 +19,29 @@
namespace TextureSampler
{
static inline void WrapCoord(int* coordp, int wrapMode, int imageSize)
static inline void WrapCoord(int* coordp, WrapMode wrapMode, int imageSize)
{
int coord = *coordp;
switch (wrapMode)
{
case 0: // clamp
case WrapMode::Clamp:
coord = (coord > imageSize) ? imageSize : (coord < 0) ? 0 : coord;
break;
case 1: // wrap
case WrapMode::Repeat:
coord = coord % (imageSize + 1);
coord = (coord < 0) ? imageSize + coord : coord;
break;
case 2: // mirror
case WrapMode::Mirror:
{
const int sizePlus1 = imageSize + 1;
const int div = coord / sizePlus1;
coord = coord - (div * sizePlus1);
coord = (coord < 0) ? -coord : coord;
coord = (div & 1) ? imageSize - coord : coord;
break;
}
break;
default:
PanicAlertFmt("Invalid wrap mode: {}", wrapMode);
}
*coordp = coord;
}
@@ -74,10 +77,11 @@ void Sample(s32 s, s32 t, s32 lod, bool linear, u8 texmap, u8* sample)
{
// use mipmap
baseMip = lod >> 4;
mipLinear = (lodFract && tm0.min_filter & TexMode0::TEXF_LINEAR);
mipLinear = (lodFract && tm0.mipmap_filter == MipMode::Linear);
// if using nearest mip filter and lodFract >= 0.5 round up to next mip
baseMip += (lodFract >> 3) & (tm0.min_filter & TexMode0::TEXF_POINT);
if (tm0.mipmap_filter == MipMode::Point && lodFract >= 8)
baseMip++;
}
if (mipLinear)
@@ -111,12 +115,12 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8* sample)
const TexMode0& tm0 = texUnit.texMode0[subTexmap];
const TexImage0& ti0 = texUnit.texImage0[subTexmap];
const TexTLUT& texTlut = texUnit.texTlut[subTexmap];
const TextureFormat texfmt = static_cast<TextureFormat>(ti0.format);
const TLUTFormat tlutfmt = static_cast<TLUTFormat>(texTlut.tlut_format);
const TextureFormat texfmt = ti0.format;
const TLUTFormat tlutfmt = texTlut.tlut_format;
const u8* imageSrc;
const u8* imageSrcOdd = nullptr;
if (texUnit.texImage1[subTexmap].image_type)
if (texUnit.texImage1[subTexmap].cache_manually_managed)
{
imageSrc = &texMem[texUnit.texImage1[subTexmap].tmem_even * TMEM_LINE_SIZE];
if (texfmt == TextureFormat::RGBA8)
@@ -188,7 +192,7 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8* sample)
WrapCoord(&imageSPlus1, tm0.wrap_s, imageWidth);
WrapCoord(&imageTPlus1, tm0.wrap_t, imageHeight);
if (!(texfmt == TextureFormat::RGBA8 && texUnit.texImage1[subTexmap].image_type))
if (!(texfmt == TextureFormat::RGBA8 && texUnit.texImage1[subTexmap].cache_manually_managed))
{
TexDecoder_DecodeTexel(sampledTex, imageSrc, imageS, imageT, imageWidth, texfmt, tlut,
tlutfmt);
@@ -240,7 +244,7 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8* sample)
WrapCoord(&imageS, tm0.wrap_s, imageWidth);
WrapCoord(&imageT, tm0.wrap_t, imageHeight);
if (!(texfmt == TextureFormat::RGBA8 && texUnit.texImage1[subTexmap].image_type))
if (!(texfmt == TextureFormat::RGBA8 && texUnit.texImage1[subTexmap].cache_manually_managed))
TexDecoder_DecodeTexel(sample, imageSrc, imageS, imageT, imageWidth, texfmt, tlut, tlutfmt);
else
TexDecoder_DecodeTexelRGBA8FromTmem(sample, imageSrc, imageSrcOdd, imageS, imageT,
+26 -24
View File
@@ -52,13 +52,13 @@ GetVulkanRasterizationState(const RasterizationState& state)
depth_clamp, // VkBool32 depthClampEnable
VK_FALSE, // VkBool32 rasterizerDiscardEnable
VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode
cull_modes[state.cullmode], // VkCullModeFlags cullMode
VK_FRONT_FACE_CLOCKWISE, // VkFrontFace frontFace
VK_FALSE, // VkBool32 depthBiasEnable
0.0f, // float depthBiasConstantFactor
0.0f, // float depthBiasClamp
0.0f, // float depthBiasSlopeFactor
1.0f // float lineWidth
cull_modes[u32(state.cullmode.Value())], // VkCullModeFlags cullMode
VK_FRONT_FACE_CLOCKWISE, // VkFrontFace frontFace
VK_FALSE, // VkBool32 depthBiasEnable
0.0f, // float depthBiasConstantFactor
0.0f, // float depthBiasClamp
0.0f, // float depthBiasSlopeFactor
1.0f // float lineWidth
};
}
@@ -85,31 +85,32 @@ static VkPipelineDepthStencilStateCreateInfo GetVulkanDepthStencilState(const De
bool inverted_depth = !g_ActiveConfig.backend_info.bSupportsReversedDepthRange;
switch (state.func)
{
case ZMode::NEVER:
case CompareMode::Never:
compare_op = VK_COMPARE_OP_NEVER;
break;
case ZMode::LESS:
case CompareMode::Less:
compare_op = inverted_depth ? VK_COMPARE_OP_GREATER : VK_COMPARE_OP_LESS;
break;
case ZMode::EQUAL:
case CompareMode::Equal:
compare_op = VK_COMPARE_OP_EQUAL;
break;
case ZMode::LEQUAL:
case CompareMode::LEqual:
compare_op = inverted_depth ? VK_COMPARE_OP_GREATER_OR_EQUAL : VK_COMPARE_OP_LESS_OR_EQUAL;
break;
case ZMode::GREATER:
case CompareMode::Greater:
compare_op = inverted_depth ? VK_COMPARE_OP_LESS : VK_COMPARE_OP_GREATER;
break;
case ZMode::NEQUAL:
case CompareMode::NEqual:
compare_op = VK_COMPARE_OP_NOT_EQUAL;
break;
case ZMode::GEQUAL:
case CompareMode::GEqual:
compare_op = inverted_depth ? VK_COMPARE_OP_LESS_OR_EQUAL : VK_COMPARE_OP_GREATER_OR_EQUAL;
break;
case ZMode::ALWAYS:
case CompareMode::Always:
compare_op = VK_COMPARE_OP_ALWAYS;
break;
default:
PanicAlertFmt("Invalid compare mode {}", state.func);
compare_op = VK_COMPARE_OP_ALWAYS;
break;
}
@@ -150,10 +151,10 @@ static VkPipelineColorBlendAttachmentState GetVulkanAttachmentBlendState(const B
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
vk_state.srcColorBlendFactor = src_factors[state.srcfactor];
vk_state.srcAlphaBlendFactor = src_factors[state.srcfactoralpha];
vk_state.dstColorBlendFactor = dst_factors[state.dstfactor];
vk_state.dstAlphaBlendFactor = dst_factors[state.dstfactoralpha];
vk_state.srcColorBlendFactor = src_factors[u32(state.srcfactor.Value())];
vk_state.srcAlphaBlendFactor = src_factors[u32(state.srcfactoralpha.Value())];
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
}
else
{
@@ -169,10 +170,10 @@ static VkPipelineColorBlendAttachmentState GetVulkanAttachmentBlendState(const B
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_FACTOR_DST_ALPHA,
VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA}};
vk_state.srcColorBlendFactor = src_factors[state.srcfactor];
vk_state.srcAlphaBlendFactor = src_factors[state.srcfactoralpha];
vk_state.dstColorBlendFactor = dst_factors[state.dstfactor];
vk_state.dstAlphaBlendFactor = dst_factors[state.dstfactoralpha];
vk_state.srcColorBlendFactor = src_factors[u32(state.srcfactor.Value())];
vk_state.srcAlphaBlendFactor = src_factors[u32(state.srcfactoralpha.Value())];
vk_state.dstColorBlendFactor = dst_factors[u32(state.dstfactor.Value())];
vk_state.dstAlphaBlendFactor = dst_factors[u32(state.dstfactoralpha.Value())];
}
if (state.colorupdate)
@@ -211,7 +212,8 @@ GetVulkanColorBlendState(const BlendingState& state,
vk_logic_op_enable = VK_FALSE;
}
VkLogicOp vk_logic_op = vk_logic_op_enable ? vk_logic_ops[state.logicmode] : VK_LOGIC_OP_CLEAR;
VkLogicOp vk_logic_op =
vk_logic_op_enable ? vk_logic_ops[u32(state.logicmode.Value())] : VK_LOGIC_OP_CLEAR;
VkPipelineColorBlendStateCreateInfo vk_state = {
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType
@@ -166,9 +166,9 @@ void Renderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool color_enable
// Determine whether the EFB has an alpha channel. If it doesn't, we can clear the alpha
// channel to 0xFF. This hopefully allows us to use the fast path in most cases.
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16 ||
bpmem.zcontrol.pixel_format == PEControl::RGB8_Z24 ||
bpmem.zcontrol.pixel_format == PEControl::Z24)
if (bpmem.zcontrol.pixel_format == PixelFormat::RGB565_Z16 ||
bpmem.zcontrol.pixel_format == PixelFormat::RGB8_Z24 ||
bpmem.zcontrol.pixel_format == PixelFormat::Z24)
{
// Force alpha writes, and clear the alpha channel. This is different to the other backends,
// where the existing values of the alpha channel are preserved.