Send data to OpenGL host without client-side copies (#285)
* Directly send host address to buffer data * Cleanup OGLShader * Directly copy vertex and index data too * Revert shader bind "cache" * Address feedback
This commit is contained in:
parent
45bb24dbae
commit
5fe0bc584b
8 changed files with 55 additions and 110 deletions
|
@ -5,6 +5,8 @@ using System.Collections.Concurrent;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Buffer = System.Buffer;
|
||||
|
||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
{
|
||||
public class OGLShader : IGalShader
|
||||
|
@ -151,7 +153,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
return Enumerable.Empty<ShaderDeclInfo>();
|
||||
}
|
||||
|
||||
public void SetConstBuffer(long Key, int Cbuf, byte[] Data)
|
||||
public void SetConstBuffer(long Key, int Cbuf, int DataSize, IntPtr HostAddress)
|
||||
{
|
||||
if (Stages.TryGetValue(Key, out ShaderStage Stage))
|
||||
{
|
||||
|
@ -159,13 +161,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
OGLStreamBuffer Buffer = GetConstBuffer(Stage.Type, Cbuf);
|
||||
|
||||
int Size = Math.Min(Data.Length, Buffer.Size);
|
||||
int Size = Math.Min(DataSize, Buffer.Size);
|
||||
|
||||
byte[] Destiny = Buffer.Map(Size);
|
||||
|
||||
Array.Copy(Data, Destiny, Size);
|
||||
|
||||
Buffer.Unmap(Size);
|
||||
Buffer.SetData(Size, HostAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +276,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
int FreeBinding = 0;
|
||||
|
||||
int BindUniformBlocksIfNotNull(ShaderStage Stage)
|
||||
void BindUniformBlocksIfNotNull(ShaderStage Stage)
|
||||
{
|
||||
if (Stage != null)
|
||||
{
|
||||
|
@ -297,8 +295,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
FreeBinding++;
|
||||
}
|
||||
}
|
||||
|
||||
return FreeBinding;
|
||||
}
|
||||
|
||||
BindUniformBlocksIfNotNull(Current.Vertex);
|
||||
|
@ -312,7 +308,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
int FreeBinding = 0;
|
||||
|
||||
int BindUniformBuffersIfNotNull(ShaderStage Stage)
|
||||
void BindUniformBuffersIfNotNull(ShaderStage Stage)
|
||||
{
|
||||
if (Stage != null)
|
||||
{
|
||||
|
@ -325,8 +321,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
FreeBinding++;
|
||||
}
|
||||
}
|
||||
|
||||
return FreeBinding;
|
||||
}
|
||||
|
||||
BindUniformBuffersIfNotNull(Current.Vertex);
|
||||
|
@ -347,7 +341,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
//Allocate a maximum of 64 KiB
|
||||
int Size = Math.Min(GL.GetInteger(GetPName.MaxUniformBlockSize), 64 * 1024);
|
||||
|
||||
Buffer = OGLStreamBuffer.Create(BufferTarget.UniformBuffer, Size);
|
||||
Buffer = new OGLStreamBuffer(BufferTarget.UniformBuffer, Size);
|
||||
|
||||
ConstBuffers[StageIndex][Cbuf] = Buffer;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue