mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-20 08:04:15 +00:00
Fix vertex buffer size on the gpu when the draw vertex count is less than the buffer size, added a few more registers (currently not implemented)
This commit is contained in:
parent
af5f059d4e
commit
900a84ae0a
7 changed files with 80 additions and 13 deletions
14
Ryujinx.Graphics/Gal/GalComparisonOp.cs
Normal file
14
Ryujinx.Graphics/Gal/GalComparisonOp.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace Ryujinx.Graphics.Gal
|
||||||
|
{
|
||||||
|
public enum GalComparisonOp
|
||||||
|
{
|
||||||
|
Never = 0x200,
|
||||||
|
Less = 0x201,
|
||||||
|
Equal = 0x202,
|
||||||
|
Lequal = 0x203,
|
||||||
|
Greater = 0x204,
|
||||||
|
NotEqual = 0x205,
|
||||||
|
Gequal = 0x206,
|
||||||
|
Always = 0x207
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,16 @@ namespace Ryujinx.Graphics.Gal
|
||||||
|
|
||||||
bool IsIboCached(long Key, long DataSize);
|
bool IsIboCached(long Key, long DataSize);
|
||||||
|
|
||||||
|
void EnableCullFace();
|
||||||
|
|
||||||
|
void DisableCullFace();
|
||||||
|
|
||||||
|
void EnableDepthTest();
|
||||||
|
|
||||||
|
void DisableDepthTest();
|
||||||
|
|
||||||
|
void SetDepthFunction(GalComparisonOp Func);
|
||||||
|
|
||||||
void CreateVbo(long Key, byte[] Buffer);
|
void CreateVbo(long Key, byte[] Buffer);
|
||||||
|
|
||||||
void CreateIbo(long Key, byte[] Buffer);
|
void CreateIbo(long Key, byte[] Buffer);
|
||||||
|
|
|
@ -5,6 +5,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
static class OGLEnumConverter
|
static class OGLEnumConverter
|
||||||
{
|
{
|
||||||
|
public static DepthFunction GetDepthFunc(GalComparisonOp Func)
|
||||||
|
{
|
||||||
|
if ((int)Func >= (int)DepthFunction.Never &&
|
||||||
|
(int)Func <= (int)DepthFunction.Always)
|
||||||
|
{
|
||||||
|
return (DepthFunction)Func;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException(nameof(Func));
|
||||||
|
}
|
||||||
|
|
||||||
public static DrawElementsType GetDrawElementsType(GalIndexFormat Format)
|
public static DrawElementsType GetDrawElementsType(GalIndexFormat Format)
|
||||||
{
|
{
|
||||||
switch (Format)
|
switch (Format)
|
||||||
|
|
|
@ -106,6 +106,31 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
return IboCache.TryGetSize(Key, out long Size) && Size == DataSize;
|
return IboCache.TryGetSize(Key, out long Size) && Size == DataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnableCullFace()
|
||||||
|
{
|
||||||
|
GL.Enable(EnableCap.CullFace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableCullFace()
|
||||||
|
{
|
||||||
|
GL.Disable(EnableCap.CullFace);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableDepthTest()
|
||||||
|
{
|
||||||
|
GL.Enable(EnableCap.DepthTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableDepthTest()
|
||||||
|
{
|
||||||
|
GL.Disable(EnableCap.DepthTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDepthFunction(GalComparisonOp Func)
|
||||||
|
{
|
||||||
|
GL.DepthFunc(OGLEnumConverter.GetDepthFunc(Func));
|
||||||
|
}
|
||||||
|
|
||||||
public void CreateVbo(long Key, byte[] Buffer)
|
public void CreateVbo(long Key, byte[] Buffer)
|
||||||
{
|
{
|
||||||
int Handle = GL.GenBuffer();
|
int Handle = GL.GenBuffer();
|
||||||
|
|
|
@ -283,7 +283,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
return FreeBinding;
|
return FreeBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
BindUniformBuffersIfNotNull(Current.Vertex);
|
BindUniformBuffersIfNotNull(Current.Vertex);
|
||||||
BindUniformBuffersIfNotNull(Current.TessControl);
|
BindUniformBuffersIfNotNull(Current.TessControl);
|
||||||
BindUniformBuffersIfNotNull(Current.TessEvaluation);
|
BindUniformBuffersIfNotNull(Current.TessEvaluation);
|
||||||
|
|
|
@ -79,6 +79,8 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
|
|
||||||
Gpu.Renderer.Shader.BindProgram();
|
Gpu.Renderer.Shader.BindProgram();
|
||||||
|
|
||||||
|
SetCullFace();
|
||||||
|
SetDepth();
|
||||||
SetAlphaBlending();
|
SetAlphaBlending();
|
||||||
|
|
||||||
UploadTextures(Vmm, Keys);
|
UploadTextures(Vmm, Keys);
|
||||||
|
@ -98,8 +100,7 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
|
|
||||||
SetFrameBuffer(Vmm, 0);
|
SetFrameBuffer(Vmm, 0);
|
||||||
|
|
||||||
//TODO: Enable this once the frame buffer problems are fixed.
|
Gpu.Renderer.Rasterizer.ClearBuffers(Layer, Flags);
|
||||||
//Gpu.Renderer.ClearBuffers(Layer, Flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetFrameBuffer(NvGpuVmm Vmm, int FbIndex)
|
private void SetFrameBuffer(NvGpuVmm Vmm, int FbIndex)
|
||||||
|
@ -177,6 +178,16 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
throw new ArgumentOutOfRangeException(nameof(Program));
|
throw new ArgumentOutOfRangeException(nameof(Program));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetCullFace()
|
||||||
|
{
|
||||||
|
//TODO.
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetDepth()
|
||||||
|
{
|
||||||
|
//TODO.
|
||||||
|
}
|
||||||
|
|
||||||
private void SetAlphaBlending()
|
private void SetAlphaBlending()
|
||||||
{
|
{
|
||||||
//TODO: Support independent blend properly.
|
//TODO: Support independent blend properly.
|
||||||
|
@ -434,16 +445,7 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
|
|
||||||
int Stride = Control & 0xfff;
|
int Stride = Control & 0xfff;
|
||||||
|
|
||||||
long VbSize = 0;
|
long VbSize = (VertexEndPos - VertexPosition) + 1;
|
||||||
|
|
||||||
if (IndexCount != 0)
|
|
||||||
{
|
|
||||||
VbSize = (VertexEndPos - VertexPosition) + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VbSize = VertexCount * Stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VboCached = Gpu.Renderer.Rasterizer.IsVboCached(VertexPosition, VbSize);
|
bool VboCached = Gpu.Renderer.Rasterizer.IsVboCached(VertexPosition, VbSize);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
VertexArrayFirst = 0x35d,
|
VertexArrayFirst = 0x35d,
|
||||||
VertexArrayCount = 0x35e,
|
VertexArrayCount = 0x35e,
|
||||||
VertexAttribNFormat = 0x458,
|
VertexAttribNFormat = 0x458,
|
||||||
|
DepthTestEnable = 0x4b3,
|
||||||
IBlendEnable = 0x4b9,
|
IBlendEnable = 0x4b9,
|
||||||
|
DepthTestFunction = 0x4c3,
|
||||||
BlendSeparateAlpha = 0x4cf,
|
BlendSeparateAlpha = 0x4cf,
|
||||||
BlendEquationRgb = 0x4d0,
|
BlendEquationRgb = 0x4d0,
|
||||||
BlendFuncSrcRgb = 0x4d1,
|
BlendFuncSrcRgb = 0x4d1,
|
||||||
|
@ -35,6 +37,9 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
IndexArrayFormat = 0x5f6,
|
IndexArrayFormat = 0x5f6,
|
||||||
IndexBatchFirst = 0x5f7,
|
IndexBatchFirst = 0x5f7,
|
||||||
IndexBatchCount = 0x5f8,
|
IndexBatchCount = 0x5f8,
|
||||||
|
CullFaceEnable = 0x646,
|
||||||
|
FrontFace = 0x647,
|
||||||
|
CullFace = 0x648,
|
||||||
QueryAddress = 0x6c0,
|
QueryAddress = 0x6c0,
|
||||||
QuerySequence = 0x6c2,
|
QuerySequence = 0x6c2,
|
||||||
QueryControl = 0x6c3,
|
QueryControl = 0x6c3,
|
||||||
|
|
Loading…
Reference in a new issue