mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
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:
@@ -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())];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -184,8 +184,8 @@ void ClearScreen(const MathUtil::Rectangle<int>& rc)
|
||||
auto pixel_format = bpmem.zcontrol.pixel_format;
|
||||
|
||||
// (1): Disable unused color channels
|
||||
if (pixel_format == PEControl::RGB8_Z24 || pixel_format == PEControl::RGB565_Z16 ||
|
||||
pixel_format == PEControl::Z24)
|
||||
if (pixel_format == PixelFormat::RGB8_Z24 || pixel_format == PixelFormat::RGB565_Z16 ||
|
||||
pixel_format == PixelFormat::Z24)
|
||||
{
|
||||
alphaEnable = false;
|
||||
}
|
||||
@@ -196,11 +196,11 @@ void ClearScreen(const MathUtil::Rectangle<int>& rc)
|
||||
u32 z = bpmem.clearZValue;
|
||||
|
||||
// (2) drop additional accuracy
|
||||
if (pixel_format == PEControl::RGBA6_Z24)
|
||||
if (pixel_format == PixelFormat::RGBA6_Z24)
|
||||
{
|
||||
color = RGBA8ToRGBA6ToRGBA8(color);
|
||||
}
|
||||
else if (pixel_format == PEControl::RGB565_Z16)
|
||||
else if (pixel_format == PixelFormat::RGB565_Z16)
|
||||
{
|
||||
color = RGBA8ToRGB565ToRGBA8(color);
|
||||
z = Z24ToZ16ToZ24(z);
|
||||
@@ -228,29 +228,28 @@ void OnPixelFormatChange()
|
||||
const auto new_format = bpmem.zcontrol.pixel_format;
|
||||
g_renderer->StorePixelFormat(new_format);
|
||||
|
||||
DEBUG_LOG_FMT(VIDEO, "pixelfmt: pixel={}, zc={}", static_cast<int>(new_format),
|
||||
static_cast<int>(bpmem.zcontrol.zformat));
|
||||
DEBUG_LOG_FMT(VIDEO, "pixelfmt: pixel={}, zc={}", new_format, bpmem.zcontrol.zformat);
|
||||
|
||||
// no need to reinterpret pixel data in these cases
|
||||
if (new_format == old_format || old_format == PEControl::INVALID_FMT)
|
||||
if (new_format == old_format || old_format == PixelFormat::INVALID_FMT)
|
||||
return;
|
||||
|
||||
// Check for pixel format changes
|
||||
switch (old_format)
|
||||
{
|
||||
case PEControl::RGB8_Z24:
|
||||
case PEControl::Z24:
|
||||
case PixelFormat::RGB8_Z24:
|
||||
case PixelFormat::Z24:
|
||||
{
|
||||
// Z24 and RGB8_Z24 are treated equal, so just return in this case
|
||||
if (new_format == PEControl::RGB8_Z24 || new_format == PEControl::Z24)
|
||||
if (new_format == PixelFormat::RGB8_Z24 || new_format == PixelFormat::Z24)
|
||||
return;
|
||||
|
||||
if (new_format == PEControl::RGBA6_Z24)
|
||||
if (new_format == PixelFormat::RGBA6_Z24)
|
||||
{
|
||||
g_renderer->ReinterpretPixelData(EFBReinterpretType::RGB8ToRGBA6);
|
||||
return;
|
||||
}
|
||||
else if (new_format == PEControl::RGB565_Z16)
|
||||
else if (new_format == PixelFormat::RGB565_Z16)
|
||||
{
|
||||
g_renderer->ReinterpretPixelData(EFBReinterpretType::RGB8ToRGB565);
|
||||
return;
|
||||
@@ -258,14 +257,14 @@ void OnPixelFormatChange()
|
||||
}
|
||||
break;
|
||||
|
||||
case PEControl::RGBA6_Z24:
|
||||
case PixelFormat::RGBA6_Z24:
|
||||
{
|
||||
if (new_format == PEControl::RGB8_Z24 || new_format == PEControl::Z24)
|
||||
if (new_format == PixelFormat::RGB8_Z24 || new_format == PixelFormat::Z24)
|
||||
{
|
||||
g_renderer->ReinterpretPixelData(EFBReinterpretType::RGBA6ToRGB8);
|
||||
return;
|
||||
}
|
||||
else if (new_format == PEControl::RGB565_Z16)
|
||||
else if (new_format == PixelFormat::RGB565_Z16)
|
||||
{
|
||||
g_renderer->ReinterpretPixelData(EFBReinterpretType::RGBA6ToRGB565);
|
||||
return;
|
||||
@@ -273,14 +272,14 @@ void OnPixelFormatChange()
|
||||
}
|
||||
break;
|
||||
|
||||
case PEControl::RGB565_Z16:
|
||||
case PixelFormat::RGB565_Z16:
|
||||
{
|
||||
if (new_format == PEControl::RGB8_Z24 || new_format == PEControl::Z24)
|
||||
if (new_format == PixelFormat::RGB8_Z24 || new_format == PixelFormat::Z24)
|
||||
{
|
||||
g_renderer->ReinterpretPixelData(EFBReinterpretType::RGB565ToRGB8);
|
||||
return;
|
||||
}
|
||||
else if (new_format == PEControl::RGBA6_Z24)
|
||||
else if (new_format == PixelFormat::RGBA6_Z24)
|
||||
{
|
||||
g_renderer->ReinterpretPixelData(EFBReinterpretType::RGB565ToRGBA6);
|
||||
return;
|
||||
@@ -292,8 +291,7 @@ void OnPixelFormatChange()
|
||||
break;
|
||||
}
|
||||
|
||||
ERROR_LOG_FMT(VIDEO, "Unhandled EFB format change: {} to {}", static_cast<int>(old_format),
|
||||
static_cast<int>(new_format));
|
||||
ERROR_LOG_FMT(VIDEO, "Unhandled EFB format change: {} to {}", old_format, new_format);
|
||||
}
|
||||
|
||||
void SetInterlacingMode(const BPCmd& bp)
|
||||
@@ -305,17 +303,15 @@ void SetInterlacingMode(const BPCmd& bp)
|
||||
{
|
||||
// SDK always sets bpmem.lineptwidth.lineaspect via BPMEM_LINEPTWIDTH
|
||||
// just before this cmd
|
||||
static constexpr std::string_view action[] = {"don't adjust", "adjust"};
|
||||
DEBUG_LOG_FMT(VIDEO, "BPMEM_FIELDMODE texLOD:{} lineaspect:{}", action[bpmem.fieldmode.texLOD],
|
||||
action[bpmem.lineptwidth.lineaspect]);
|
||||
DEBUG_LOG_FMT(VIDEO, "BPMEM_FIELDMODE texLOD:{} lineaspect:{}", bpmem.fieldmode.texLOD,
|
||||
bpmem.lineptwidth.adjust_for_aspect_ratio);
|
||||
}
|
||||
break;
|
||||
case BPMEM_FIELDMASK:
|
||||
{
|
||||
// Determines if fields will be written to EFB (always computed)
|
||||
static constexpr std::string_view action[] = {"skip", "write"};
|
||||
DEBUG_LOG_FMT(VIDEO, "BPMEM_FIELDMASK even:{} odd:{}", action[bpmem.fieldmask.even],
|
||||
action[bpmem.fieldmask.odd]);
|
||||
DEBUG_LOG_FMT(VIDEO, "BPMEM_FIELDMASK even:{} odd:{}", bpmem.fieldmask.even,
|
||||
bpmem.fieldmask.odd);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -17,7 +17,7 @@ bool BlendMode::UseLogicOp() const
|
||||
return false;
|
||||
|
||||
// Fast path for Kirby's Return to Dreamland, they use it with dstAlpha.
|
||||
if (logicmode == BlendMode::NOOP)
|
||||
if (logicmode == LogicOp::NoOp)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
+767
-454
File diff suppressed because it is too large
Load Diff
@@ -91,10 +91,9 @@ static void BPWritten(const BPCmd& bp)
|
||||
{
|
||||
case BPMEM_GENMODE: // Set the Generation Mode
|
||||
PRIM_LOG("genmode: texgen={}, col={}, multisampling={}, tev={}, cullmode={}, ind={}, zfeeze={}",
|
||||
bpmem.genMode.numtexgens.Value(), bpmem.genMode.numcolchans.Value(),
|
||||
bpmem.genMode.multisampling.Value(), bpmem.genMode.numtevstages.Value() + 1,
|
||||
static_cast<u32>(bpmem.genMode.cullmode), bpmem.genMode.numindstages.Value(),
|
||||
bpmem.genMode.zfreeze.Value());
|
||||
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.multisampling,
|
||||
bpmem.genMode.numtevstages + 1, bpmem.genMode.cullmode, bpmem.genMode.numindstages,
|
||||
bpmem.genMode.zfreeze);
|
||||
|
||||
if (bp.changes)
|
||||
PixelShaderManager::SetGenModeChanged();
|
||||
@@ -138,8 +137,8 @@ static void BPWritten(const BPCmd& bp)
|
||||
GeometryShaderManager::SetLinePtWidthChanged();
|
||||
return;
|
||||
case BPMEM_ZMODE: // Depth Control
|
||||
PRIM_LOG("zmode: test={}, func={}, upd={}", bpmem.zmode.testenable.Value(),
|
||||
bpmem.zmode.func.Value(), bpmem.zmode.updateenable.Value());
|
||||
PRIM_LOG("zmode: test={}, func={}, upd={}", bpmem.zmode.testenable, bpmem.zmode.func,
|
||||
bpmem.zmode.updateenable);
|
||||
SetDepthMode();
|
||||
PixelShaderManager::SetZModeControl();
|
||||
return;
|
||||
@@ -147,10 +146,9 @@ static void BPWritten(const BPCmd& bp)
|
||||
if (bp.changes & 0xFFFF)
|
||||
{
|
||||
PRIM_LOG("blendmode: en={}, open={}, colupd={}, alphaupd={}, dst={}, src={}, sub={}, mode={}",
|
||||
bpmem.blendmode.blendenable.Value(), bpmem.blendmode.logicopenable.Value(),
|
||||
bpmem.blendmode.colorupdate.Value(), bpmem.blendmode.alphaupdate.Value(),
|
||||
bpmem.blendmode.dstfactor.Value(), bpmem.blendmode.srcfactor.Value(),
|
||||
bpmem.blendmode.subtract.Value(), bpmem.blendmode.logicmode.Value());
|
||||
bpmem.blendmode.blendenable, bpmem.blendmode.logicopenable,
|
||||
bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate, bpmem.blendmode.dstfactor,
|
||||
bpmem.blendmode.srcfactor, bpmem.blendmode.subtract, bpmem.blendmode.logicmode);
|
||||
|
||||
SetBlendMode();
|
||||
|
||||
@@ -158,8 +156,7 @@ static void BPWritten(const BPCmd& bp)
|
||||
}
|
||||
return;
|
||||
case BPMEM_CONSTANTALPHA: // Set Destination Alpha
|
||||
PRIM_LOG("constalpha: alp={}, en={}", bpmem.dstalpha.alpha.Value(),
|
||||
bpmem.dstalpha.enable.Value());
|
||||
PRIM_LOG("constalpha: alp={}, en={}", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
|
||||
if (bp.changes)
|
||||
{
|
||||
PixelShaderManager::SetAlpha();
|
||||
@@ -264,14 +261,14 @@ static void BPWritten(const BPCmd& bp)
|
||||
const UPE_Copy PE_copy = bpmem.triggerEFBCopy;
|
||||
if (PE_copy.copy_to_xfb == 0)
|
||||
{
|
||||
// bpmem.zcontrol.pixel_format to PEControl::Z24 is when the game wants to copy from ZBuffer
|
||||
// bpmem.zcontrol.pixel_format to PixelFormat::Z24 is when the game wants to copy from ZBuffer
|
||||
// (Zbuffer uses 24-bit Format)
|
||||
static constexpr CopyFilterCoefficients::Values filter_coefficients = {
|
||||
{0, 0, 21, 22, 21, 0, 0}};
|
||||
bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24;
|
||||
bool is_depth_copy = bpmem.zcontrol.pixel_format == PixelFormat::Z24;
|
||||
g_texture_cache->CopyRenderTargetToTexture(
|
||||
destAddr, PE_copy.tp_realFormat(), copy_width, copy_height, destStride, is_depth_copy,
|
||||
srcRect, !!PE_copy.intensity_fmt, !!PE_copy.half_scale, 1.0f, 1.0f,
|
||||
srcRect, PE_copy.intensity_fmt, PE_copy.half_scale, 1.0f, 1.0f,
|
||||
bpmem.triggerEFBCopy.clamp_top, bpmem.triggerEFBCopy.clamp_bottom, filter_coefficients);
|
||||
}
|
||||
else
|
||||
@@ -297,7 +294,7 @@ static void BPWritten(const BPCmd& bp)
|
||||
destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom,
|
||||
bpmem.copyTexSrcWH.x + 1, destStride, height, yScale);
|
||||
|
||||
bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24;
|
||||
bool is_depth_copy = bpmem.zcontrol.pixel_format == PixelFormat::Z24;
|
||||
g_texture_cache->CopyRenderTargetToTexture(
|
||||
destAddr, EFBCopyFormat::XFB, copy_width, height, destStride, is_depth_copy, srcRect,
|
||||
false, false, yScale, s_gammaLUT[PE_copy.gamma], bpmem.triggerEFBCopy.clamp_top,
|
||||
@@ -370,10 +367,9 @@ static void BPWritten(const BPCmd& bp)
|
||||
PixelShaderManager::SetFogColorChanged();
|
||||
return;
|
||||
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
|
||||
PRIM_LOG("alphacmp: ref0={}, ref1={}, comp0={}, comp1={}, logic={}",
|
||||
bpmem.alpha_test.ref0.Value(), bpmem.alpha_test.ref1.Value(),
|
||||
static_cast<int>(bpmem.alpha_test.comp0), static_cast<int>(bpmem.alpha_test.comp1),
|
||||
static_cast<int>(bpmem.alpha_test.logic));
|
||||
PRIM_LOG("alphacmp: ref0={}, ref1={}, comp0={}, comp1={}, logic={}", bpmem.alpha_test.ref0,
|
||||
bpmem.alpha_test.ref1, bpmem.alpha_test.comp0, bpmem.alpha_test.comp1,
|
||||
bpmem.alpha_test.logic);
|
||||
if (bp.changes & 0xFFFF)
|
||||
PixelShaderManager::SetAlpha();
|
||||
if (bp.changes)
|
||||
@@ -383,7 +379,7 @@ static void BPWritten(const BPCmd& bp)
|
||||
}
|
||||
return;
|
||||
case BPMEM_BIAS: // BIAS
|
||||
PRIM_LOG("ztex bias={:#x}", bpmem.ztex1.bias.Value());
|
||||
PRIM_LOG("ztex bias={:#x}", bpmem.ztex1.bias);
|
||||
if (bp.changes)
|
||||
PixelShaderManager::SetZTextureBias();
|
||||
return;
|
||||
@@ -393,11 +389,7 @@ static void BPWritten(const BPCmd& bp)
|
||||
PixelShaderManager::SetZTextureTypeChanged();
|
||||
if (bp.changes & 12)
|
||||
PixelShaderManager::SetZTextureOpChanged();
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
static constexpr std::string_view pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
|
||||
static constexpr std::string_view pztype[] = {"Z8", "Z16", "Z24", "?"};
|
||||
PRIM_LOG("ztex op={}, type={}", pzop[bpmem.ztex2.op], pztype[bpmem.ztex2.type]);
|
||||
#endif
|
||||
PRIM_LOG("ztex op={}, type={}", bpmem.ztex2.op, bpmem.ztex2.type);
|
||||
}
|
||||
return;
|
||||
// ----------------------------------
|
||||
@@ -588,15 +580,15 @@ static void BPWritten(const BPCmd& bp)
|
||||
case BPMEM_TEV_COLOR_RA + 6:
|
||||
{
|
||||
int num = (bp.address >> 1) & 0x3;
|
||||
if (bpmem.tevregs[num].type_ra)
|
||||
if (bpmem.tevregs[num].ra.type == TevRegType::Constant)
|
||||
{
|
||||
PixelShaderManager::SetTevKonstColor(num, 0, (s32)bpmem.tevregs[num].red);
|
||||
PixelShaderManager::SetTevKonstColor(num, 3, (s32)bpmem.tevregs[num].alpha);
|
||||
PixelShaderManager::SetTevKonstColor(num, 0, bpmem.tevregs[num].ra.red);
|
||||
PixelShaderManager::SetTevKonstColor(num, 3, bpmem.tevregs[num].ra.alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
PixelShaderManager::SetTevColor(num, 0, (s32)bpmem.tevregs[num].red);
|
||||
PixelShaderManager::SetTevColor(num, 3, (s32)bpmem.tevregs[num].alpha);
|
||||
PixelShaderManager::SetTevColor(num, 0, bpmem.tevregs[num].ra.red);
|
||||
PixelShaderManager::SetTevColor(num, 3, bpmem.tevregs[num].ra.alpha);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -607,15 +599,15 @@ static void BPWritten(const BPCmd& bp)
|
||||
case BPMEM_TEV_COLOR_BG + 6:
|
||||
{
|
||||
int num = (bp.address >> 1) & 0x3;
|
||||
if (bpmem.tevregs[num].type_bg)
|
||||
if (bpmem.tevregs[num].bg.type == TevRegType::Constant)
|
||||
{
|
||||
PixelShaderManager::SetTevKonstColor(num, 1, (s32)bpmem.tevregs[num].green);
|
||||
PixelShaderManager::SetTevKonstColor(num, 2, (s32)bpmem.tevregs[num].blue);
|
||||
PixelShaderManager::SetTevKonstColor(num, 1, bpmem.tevregs[num].bg.green);
|
||||
PixelShaderManager::SetTevKonstColor(num, 2, bpmem.tevregs[num].bg.blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
PixelShaderManager::SetTevColor(num, 1, (s32)bpmem.tevregs[num].green);
|
||||
PixelShaderManager::SetTevColor(num, 2, (s32)bpmem.tevregs[num].blue);
|
||||
PixelShaderManager::SetTevColor(num, 1, bpmem.tevregs[num].bg.green);
|
||||
PixelShaderManager::SetTevColor(num, 2, bpmem.tevregs[num].bg.blue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -915,26 +907,18 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
SetRegName(BPMEM_BLENDMODE);
|
||||
BlendMode mode;
|
||||
mode.hex = cmddata;
|
||||
const char* dstfactors[] = {"0", "1", "src_color", "1-src_color",
|
||||
"src_alpha", "1-src_alpha", "dst_alpha", "1-dst_alpha"};
|
||||
const char* srcfactors[] = {"0", "1", "dst_color", "1-dst_color",
|
||||
"src_alpha", "1-src_alpha", "dst_alpha", "1-dst_alpha"};
|
||||
const char* logicmodes[] = {"0", "s & d", "s & ~d", "s", "~s & d", "d",
|
||||
"s ^ d", "s | d", "~(s | d)", "~(s ^ d)", "~d", "s | ~d",
|
||||
"~s", "~s | d", "~(s & d)", "1"};
|
||||
*desc =
|
||||
fmt::format("Enable: {}\n"
|
||||
"Logic ops: {}\n"
|
||||
"Dither: {}\n"
|
||||
"Color write: {}\n"
|
||||
"Alpha write: {}\n"
|
||||
"Dest factor: {}\n"
|
||||
"Source factor: {}\n"
|
||||
"Subtract: {}\n"
|
||||
"Logic mode: {}\n",
|
||||
no_yes[mode.blendenable], no_yes[mode.logicopenable], no_yes[mode.dither],
|
||||
no_yes[mode.colorupdate], no_yes[mode.alphaupdate], dstfactors[mode.dstfactor],
|
||||
srcfactors[mode.srcfactor], no_yes[mode.subtract], logicmodes[mode.logicmode]);
|
||||
*desc = fmt::format("Enable: {}\n"
|
||||
"Logic ops: {}\n"
|
||||
"Dither: {}\n"
|
||||
"Color write: {}\n"
|
||||
"Alpha write: {}\n"
|
||||
"Dest factor: {}\n"
|
||||
"Source factor: {}\n"
|
||||
"Subtract: {}\n"
|
||||
"Logic mode: {}\n",
|
||||
no_yes[mode.blendenable], no_yes[mode.logicopenable], no_yes[mode.dither],
|
||||
no_yes[mode.colorupdate], no_yes[mode.alphaupdate], mode.dstfactor,
|
||||
mode.srcfactor, no_yes[mode.subtract], mode.logicmode);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -948,16 +932,10 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
SetRegName(BPMEM_ZCOMPARE);
|
||||
PEControl config;
|
||||
config.hex = cmddata;
|
||||
const char* pixel_formats[] = {"RGB8_Z24", "RGBA6_Z24", "RGB565_Z16", "Z24",
|
||||
"Y8", "U8", "V8", "YUV420"};
|
||||
const char* zformats[] = {
|
||||
"linear", "compressed (near)", "compressed (mid)", "compressed (far)",
|
||||
"inv linear", "compressed (inv near)", "compressed (inv mid)", "compressed (inv far)"};
|
||||
*desc = fmt::format("EFB pixel format: {}\n"
|
||||
"Depth format: {}\n"
|
||||
"Early depth test: {}\n",
|
||||
pixel_formats[config.pixel_format], zformats[config.zformat],
|
||||
no_yes[config.early_ztest]);
|
||||
config.pixel_format, config.zformat, no_yes[config.early_ztest]);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1048,7 +1026,7 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
"Mipmap filter: {}\n"
|
||||
"Vertical scaling: {}\n"
|
||||
"Clear: {}\n"
|
||||
"Frame to field: 0x{:01X}\n"
|
||||
"Frame to field: {}\n"
|
||||
"Copy to XFB: {}\n"
|
||||
"Intensity format: {}\n"
|
||||
"Automatic color conversion: {}",
|
||||
@@ -1059,9 +1037,8 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
(copy.gamma == 0) ?
|
||||
"1.0" :
|
||||
(copy.gamma == 1) ? "1.7" : (copy.gamma == 2) ? "2.2" : "Invalid value 0x3?",
|
||||
no_yes[copy.half_scale], no_yes[copy.scale_invert], no_yes[copy.clear],
|
||||
static_cast<u32>(copy.frame_to_field), no_yes[copy.copy_to_xfb], no_yes[copy.intensity_fmt],
|
||||
no_yes[copy.auto_conv]);
|
||||
no_yes[copy.half_scale], no_yes[copy.scale_invert], no_yes[copy.clear], copy.frame_to_field,
|
||||
no_yes[copy.copy_to_xfb], no_yes[copy.intensity_fmt], no_yes[copy.auto_conv]);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1183,8 +1160,8 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
*desc = fmt::format("Texture Unit: {}\n"
|
||||
"Width: {}\n"
|
||||
"Height: {}\n"
|
||||
"Format: {:x}\n",
|
||||
texnum, u32(teximg.width) + 1, u32(teximg.height) + 1, u32(teximg.format));
|
||||
"Format: {}\n",
|
||||
texnum, u32(teximg.width) + 1, u32(teximg.height) + 1, teximg.format);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1208,7 +1185,7 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
"Even TMEM Height: {}\n"
|
||||
"Cache is manually managed: {}\n",
|
||||
texnum, u32(teximg.tmem_even), u32(teximg.cache_width),
|
||||
u32(teximg.cache_height), no_yes[teximg.image_type]);
|
||||
u32(teximg.cache_height), no_yes[teximg.cache_manually_managed]);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1285,14 +1262,6 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
SetRegName(BPMEM_TEV_COLOR_ENV);
|
||||
TevStageCombiner::ColorCombiner cc;
|
||||
cc.hex = cmddata;
|
||||
const char* tevin[] = {
|
||||
"prev.rgb", "prev.aaa", "c0.rgb", "c0.aaa", "c1.rgb", "c1.aaa", "c2.rgb", "c2.aaa",
|
||||
"tex.rgb", "tex.aaa", "ras.rgb", "ras.aaa", "ONE", "HALF", "konst.rgb", "ZERO",
|
||||
};
|
||||
const char* tevbias[] = {"0", "+0.5", "-0.5", "compare"};
|
||||
const char* tevop[] = {"add", "sub"};
|
||||
const char* tevscale[] = {"1", "2", "4", "0.5"};
|
||||
const char* tevout[] = {"prev.rgb", "c0.rgb", "c1.rgb", "c2.rgb"};
|
||||
*desc = fmt::format("Tev stage: {}\n"
|
||||
"a: {}\n"
|
||||
"b: {}\n"
|
||||
@@ -1303,9 +1272,8 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
"Clamp: {}\n"
|
||||
"Scale factor: {}\n"
|
||||
"Dest: {}\n",
|
||||
(data[0] - BPMEM_TEV_COLOR_ENV) / 2, tevin[cc.a], tevin[cc.b], tevin[cc.c],
|
||||
tevin[cc.d], tevbias[cc.bias], tevop[cc.op], no_yes[cc.clamp],
|
||||
tevscale[cc.shift], tevout[cc.dest]);
|
||||
(data[0] - BPMEM_TEV_COLOR_ENV) / 2, cc.a, cc.b, cc.c, cc.d, cc.bias, cc.op,
|
||||
no_yes[cc.clamp], cc.scale, cc.dest);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1329,13 +1297,6 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
SetRegName(BPMEM_TEV_ALPHA_ENV);
|
||||
TevStageCombiner::AlphaCombiner ac;
|
||||
ac.hex = cmddata;
|
||||
const char* tevin[] = {
|
||||
"prev", "c0", "c1", "c2", "tex", "ras", "konst", "ZERO",
|
||||
};
|
||||
const char* tevbias[] = {"0", "+0.5", "-0.5", "compare"};
|
||||
const char* tevop[] = {"add", "sub"};
|
||||
const char* tevscale[] = {"1", "2", "4", "0.5"};
|
||||
const char* tevout[] = {"prev", "c0", "c1", "c2"};
|
||||
*desc = fmt::format("Tev stage: {}\n"
|
||||
"a: {}\n"
|
||||
"b: {}\n"
|
||||
@@ -1348,9 +1309,8 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
"Dest: {}\n"
|
||||
"Ras sel: {}\n"
|
||||
"Tex sel: {}\n",
|
||||
(data[0] - BPMEM_TEV_ALPHA_ENV) / 2, tevin[ac.a], tevin[ac.b], tevin[ac.c],
|
||||
tevin[ac.d], tevbias[ac.bias], tevop[ac.op], no_yes[ac.clamp],
|
||||
tevscale[ac.shift], tevout[ac.dest], ac.rswap.Value(), ac.tswap.Value());
|
||||
(data[0] - BPMEM_TEV_ALPHA_ENV) / 2, ac.a, ac.b, ac.c, ac.d, ac.bias, ac.op,
|
||||
no_yes[ac.clamp], ac.scale, ac.dest, ac.rswap.Value(), ac.tswap.Value());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1410,14 +1370,10 @@ void GetBPRegInfo(const u8* data, std::string* name, std::string* desc)
|
||||
SetRegName(BPMEM_ALPHACOMPARE);
|
||||
AlphaTest test;
|
||||
test.hex = cmddata;
|
||||
const char* functions[] = {"NEVER", "LESS", "EQUAL", "LEQUAL",
|
||||
"GREATER", "NEQUAL", "GEQUAL", "ALWAYS"};
|
||||
const char* logic[] = {"AND", "OR", "XOR", "XNOR"};
|
||||
*desc = fmt::format("Test 1: {} (ref: 0x{:02x})\n"
|
||||
"Test 2: {} (ref: 0x{:02x})\n"
|
||||
"Logic: {}\n",
|
||||
functions[test.comp0], test.ref0.Value(), functions[test.comp1],
|
||||
test.ref1.Value(), logic[test.logic]);
|
||||
test.comp0, test.ref0.Value(), test.comp1, test.ref1.Value(), test.logic);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ using float4 = std::array<float, 4>;
|
||||
using uint4 = std::array<u32, 4>;
|
||||
using int4 = std::array<s32, 4>;
|
||||
|
||||
enum class SrcBlendFactor : u32;
|
||||
enum class DstBlendFactor : u32;
|
||||
|
||||
struct PixelShaderConstants
|
||||
{
|
||||
std::array<int4, 4> colors;
|
||||
@@ -45,10 +48,10 @@ struct PixelShaderConstants
|
||||
std::array<int4, 32> konst; // .rgba
|
||||
// The following are used in ubershaders when using shader_framebuffer_fetch blending
|
||||
u32 blend_enable;
|
||||
u32 blend_src_factor;
|
||||
u32 blend_src_factor_alpha;
|
||||
u32 blend_dst_factor;
|
||||
u32 blend_dst_factor_alpha;
|
||||
SrcBlendFactor blend_src_factor;
|
||||
SrcBlendFactor blend_src_factor_alpha;
|
||||
DstBlendFactor blend_dst_factor;
|
||||
DstBlendFactor blend_dst_factor_alpha;
|
||||
u32 blend_subtract;
|
||||
u32 blend_subtract_alpha;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,15 @@
|
||||
#include "VideoCommon/ShaderGenCommon.h"
|
||||
|
||||
enum class APIType;
|
||||
enum class AlphaTestResult;
|
||||
enum class SrcBlendFactor : u32;
|
||||
enum class DstBlendFactor : u32;
|
||||
enum class CompareMode : u32;
|
||||
enum class AlphaTestOp : u32;
|
||||
enum class RasColorChan : u32;
|
||||
enum class KonstSel : u32;
|
||||
enum class FogProjection : u32;
|
||||
enum class FogType : u32;
|
||||
|
||||
#pragma pack(1)
|
||||
struct pixel_shader_uid_data
|
||||
@@ -19,18 +28,18 @@ struct pixel_shader_uid_data
|
||||
u32 NumValues() const { return num_values; }
|
||||
u32 pad0 : 4;
|
||||
u32 useDstAlpha : 1;
|
||||
u32 Pretest : 2;
|
||||
AlphaTestResult Pretest : 2;
|
||||
u32 nIndirectStagesUsed : 4;
|
||||
u32 genMode_numtexgens : 4;
|
||||
u32 genMode_numtevstages : 4;
|
||||
u32 genMode_numindstages : 3;
|
||||
u32 alpha_test_comp0 : 3;
|
||||
u32 alpha_test_comp1 : 3;
|
||||
u32 alpha_test_logic : 2;
|
||||
CompareMode alpha_test_comp0 : 3;
|
||||
CompareMode alpha_test_comp1 : 3;
|
||||
AlphaTestOp alpha_test_logic : 2;
|
||||
u32 alpha_test_use_zcomploc_hack : 1;
|
||||
u32 fog_proj : 1;
|
||||
FogProjection fog_proj : 1;
|
||||
|
||||
u32 fog_fsel : 3;
|
||||
FogType fog_fsel : 3;
|
||||
u32 fog_RangeBaseEnabled : 1;
|
||||
u32 ztex_op : 2;
|
||||
u32 per_pixel_depth : 1;
|
||||
@@ -43,13 +52,13 @@ struct pixel_shader_uid_data
|
||||
u32 rgba6_format : 1;
|
||||
u32 dither : 1;
|
||||
u32 uint_output : 1;
|
||||
u32 blend_enable : 1; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_src_factor : 3; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_src_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_dst_factor : 3; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_dst_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_subtract : 1; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_subtract_alpha : 1; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_enable : 1; // Only used with shader_framebuffer_fetch blend
|
||||
SrcBlendFactor blend_src_factor : 3; // Only used with shader_framebuffer_fetch blend
|
||||
SrcBlendFactor blend_src_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend
|
||||
DstBlendFactor blend_dst_factor : 3; // Only used with shader_framebuffer_fetch blend
|
||||
DstBlendFactor blend_dst_factor_alpha : 3; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_subtract : 1; // Only used with shader_framebuffer_fetch blend
|
||||
u32 blend_subtract_alpha : 1; // Only used with shader_framebuffer_fetch blend
|
||||
|
||||
u32 texMtxInfo_n_projection : 8; // 8x1 bit
|
||||
u32 tevindref_bi0 : 3;
|
||||
@@ -136,7 +145,7 @@ struct pixel_shader_uid_data
|
||||
u32 tevorders_texmap : 3;
|
||||
u32 tevorders_texcoord : 3;
|
||||
u32 tevorders_enable : 1;
|
||||
u32 tevorders_colorchan : 3;
|
||||
RasColorChan tevorders_colorchan : 3;
|
||||
u32 pad1 : 6;
|
||||
|
||||
// TODO: Clean up the swapXY mess
|
||||
@@ -152,8 +161,8 @@ struct pixel_shader_uid_data
|
||||
u32 tevksel_swap2c : 2;
|
||||
u32 tevksel_swap1d : 2;
|
||||
u32 tevksel_swap2d : 2;
|
||||
u32 tevksel_kc : 5;
|
||||
u32 tevksel_ka : 5;
|
||||
KonstSel tevksel_kc : 5;
|
||||
KonstSel tevksel_ka : 5;
|
||||
u32 pad3 : 14;
|
||||
} stagehash[16];
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ void PixelShaderManager::SetConstants()
|
||||
// Destination alpha is only enabled if alpha writes are enabled. Force entire uniform to zero
|
||||
// when disabled.
|
||||
u32 dstalpha = bpmem.blendmode.alphaupdate && bpmem.dstalpha.enable &&
|
||||
bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24 ?
|
||||
bpmem.zcontrol.pixel_format == PixelFormat::RGBA6_Z24 ?
|
||||
bpmem.dstalpha.hex :
|
||||
0;
|
||||
|
||||
@@ -270,7 +270,7 @@ void PixelShaderManager::SetAlphaTestChanged()
|
||||
// TODO: we could optimize this further and check the actual constants,
|
||||
// i.e. "a <= 0" and "a >= 255" will always pass.
|
||||
u32 alpha_test =
|
||||
bpmem.alpha_test.TestResult() != AlphaTest::PASS ? bpmem.alpha_test.hex | 1 << 31 : 0;
|
||||
bpmem.alpha_test.TestResult() != AlphaTestResult::Pass ? bpmem.alpha_test.hex | 1 << 31 : 0;
|
||||
if (constants.alphaTest != alpha_test)
|
||||
{
|
||||
constants.alphaTest = alpha_test;
|
||||
@@ -362,25 +362,26 @@ void PixelShaderManager::SetZTextureTypeChanged()
|
||||
{
|
||||
switch (bpmem.ztex2.type)
|
||||
{
|
||||
case TEV_ZTEX_TYPE_U8:
|
||||
case ZTexFormat::U8:
|
||||
constants.zbias[0][0] = 0;
|
||||
constants.zbias[0][1] = 0;
|
||||
constants.zbias[0][2] = 0;
|
||||
constants.zbias[0][3] = 1;
|
||||
break;
|
||||
case TEV_ZTEX_TYPE_U16:
|
||||
case ZTexFormat::U16:
|
||||
constants.zbias[0][0] = 1;
|
||||
constants.zbias[0][1] = 0;
|
||||
constants.zbias[0][2] = 0;
|
||||
constants.zbias[0][3] = 256;
|
||||
break;
|
||||
case TEV_ZTEX_TYPE_U24:
|
||||
case ZTexFormat::U24:
|
||||
constants.zbias[0][0] = 65536;
|
||||
constants.zbias[0][1] = 256;
|
||||
constants.zbias[0][2] = 1;
|
||||
constants.zbias[0][3] = 0;
|
||||
break;
|
||||
default:
|
||||
PanicAlertFmt("Invalid ztex format {}", bpmem.ztex2.type);
|
||||
break;
|
||||
}
|
||||
dirty = true;
|
||||
@@ -457,8 +458,9 @@ void PixelShaderManager::SetZModeControl()
|
||||
{
|
||||
u32 late_ztest = bpmem.UseLateDepthTest();
|
||||
u32 rgba6_format =
|
||||
(bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24 && !g_ActiveConfig.bForceTrueColor) ? 1 :
|
||||
0;
|
||||
(bpmem.zcontrol.pixel_format == PixelFormat::RGBA6_Z24 && !g_ActiveConfig.bForceTrueColor) ?
|
||||
1 :
|
||||
0;
|
||||
u32 dither = rgba6_format && bpmem.blendmode.dither;
|
||||
if (constants.late_ztest != late_ztest || constants.rgba6_format != rgba6_format ||
|
||||
constants.dither != dither)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user