Scissor test implementation. Partially stubbed until geometry shaders… (#556)
* Scissor test implementation. Partially stubbed until geometry shaders are fixed * Apply to all viewports when geometry shaders are disabled. * Also apply enable cap to all viewports when geometry shaders are disabled * Added fixme as per suggestion Co-Authored-By: BaronKiko <BaronKiko@users.noreply.github.com> * Apparently no alignment needed here. * Comment on new line * Correct height calculation
This commit is contained in:
parent
8406ec6272
commit
0cd5ba03fe
4 changed files with 103 additions and 0 deletions
|
@ -24,6 +24,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
|
||||
private ConstBuffer[][] ConstBuffers;
|
||||
|
||||
// Height kept for flipping y axis
|
||||
private int ViewportHeight = 0;
|
||||
|
||||
private int CurrentInstance = 0;
|
||||
|
||||
public NvGpuEngine3d(NvGpu Gpu)
|
||||
|
@ -97,6 +100,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
SetCullFace(State);
|
||||
SetDepth(State);
|
||||
SetStencil(State);
|
||||
SetScissor(State);
|
||||
SetBlending(State);
|
||||
SetColorMask(State);
|
||||
SetPrimitiveRestart(State);
|
||||
|
@ -208,6 +212,8 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
|
||||
Gpu.ResourceManager.SendColorBuffer(Vmm, Key, FbIndex, Image);
|
||||
|
||||
ViewportHeight = VpH;
|
||||
|
||||
Gpu.Renderer.RenderTarget.SetViewport(FbIndex, VpX, VpY, VpW, VpH);
|
||||
}
|
||||
|
||||
|
@ -407,6 +413,36 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
}
|
||||
}
|
||||
|
||||
private void SetScissor(GalPipelineState State)
|
||||
{
|
||||
// FIXME: Stubbed, only the first scissor test is valid without a geometry shader loaded. At time of writing geometry shaders are also stubbed.
|
||||
// Once geometry shaders are fixed it should be equal to GalPipelineState.RenderTargetCount when shader loaded, otherwise equal to 1
|
||||
State.ScissorTestCount = 1;
|
||||
|
||||
for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
|
||||
{
|
||||
State.ScissorTestEnabled[Index] = ReadRegisterBool(NvGpuEngine3dReg.ScissorEnable + Index * 4);
|
||||
|
||||
if (State.ScissorTestEnabled[Index])
|
||||
{
|
||||
uint ScissorHorizontal = (uint)ReadRegister(NvGpuEngine3dReg.ScissorHorizontal + Index * 4);
|
||||
uint ScissorVertical = (uint)ReadRegister(NvGpuEngine3dReg.ScissorVertical + Index * 4);
|
||||
|
||||
State.ScissorTestX[Index] = (int)((ScissorHorizontal & 0xFFFF) * State.FlipX); // X, lower 16 bits
|
||||
State.ScissorTestWidth[Index] = (int)((ScissorHorizontal >> 16) * State.FlipX) - State.ScissorTestX[Index]; // Width, right side is upper 16 bits
|
||||
|
||||
State.ScissorTestY[Index] = (int)((ScissorVertical & 0xFFFF)); // Y, lower 16 bits
|
||||
State.ScissorTestHeight[Index] = (int)((ScissorVertical >> 16)) - State.ScissorTestY[Index]; // Height, top side is upper 16 bits
|
||||
|
||||
// Y coordinates may have to be flipped
|
||||
if ((int)State.FlipY == -1)
|
||||
{
|
||||
State.ScissorTestY[Index] = ViewportHeight - State.ScissorTestY[Index] - State.ScissorTestHeight[Index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBlending(GalPipelineState State)
|
||||
{
|
||||
bool BlendIndependent = ReadRegisterBool(NvGpuEngine3dReg.BlendIndependent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue