Only try uploading const buffers that are really used
This commit is contained in:
parent
008f652c36
commit
f9d44b4218
5 changed files with 38 additions and 21 deletions
|
@ -9,6 +9,7 @@ namespace Ryujinx.Graphics.Gal
|
||||||
|
|
||||||
void Create(IGalMemory Memory, long VpAPos, long Key, GalShaderType Type);
|
void Create(IGalMemory Memory, long VpAPos, long Key, GalShaderType Type);
|
||||||
|
|
||||||
|
IEnumerable<ShaderDeclInfo> GetConstBufferUsage(long Key);
|
||||||
IEnumerable<ShaderDeclInfo> GetTextureUsage(long Key);
|
IEnumerable<ShaderDeclInfo> GetTextureUsage(long Key);
|
||||||
|
|
||||||
void EnsureTextureBinding(string UniformName, int Value);
|
void EnsureTextureBinding(string UniformName, int Value);
|
||||||
|
|
|
@ -279,7 +279,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
if (Stage != null)
|
if (Stage != null)
|
||||||
{
|
{
|
||||||
foreach (ShaderDeclInfo DeclInfo in Stage.UniformUsage)
|
foreach (ShaderDeclInfo DeclInfo in Stage.ConstBufferUsage)
|
||||||
{
|
{
|
||||||
long Key = New.ConstBufferKeys[(int)Stage.Type][DeclInfo.Cbuf];
|
long Key = New.ConstBufferKeys[(int)Stage.Type][DeclInfo.Cbuf];
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
return new OGLShaderStage(
|
return new OGLShaderStage(
|
||||||
Type,
|
Type,
|
||||||
Program.Code,
|
Program.Code,
|
||||||
Program.Textures,
|
Program.Uniforms,
|
||||||
Program.Uniforms);
|
Program.Textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<ShaderDeclInfo> GetConstBufferUsage(long Key)
|
||||||
|
{
|
||||||
|
if (Stages.TryGetValue(Key, out OGLShaderStage Stage))
|
||||||
|
{
|
||||||
|
return Stage.ConstBufferUsage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enumerable.Empty<ShaderDeclInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<ShaderDeclInfo> GetTextureUsage(long Key)
|
public IEnumerable<ShaderDeclInfo> GetTextureUsage(long Key)
|
||||||
|
@ -224,7 +234,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
if (Stage != null)
|
if (Stage != null)
|
||||||
{
|
{
|
||||||
foreach (ShaderDeclInfo DeclInfo in Stage.UniformUsage)
|
foreach (ShaderDeclInfo DeclInfo in Stage.ConstBufferUsage)
|
||||||
{
|
{
|
||||||
int BlockIndex = GL.GetUniformBlockIndex(ProgramHandle, DeclInfo.Name);
|
int BlockIndex = GL.GetUniformBlockIndex(ProgramHandle, DeclInfo.Name);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
|
@ -23,19 +24,19 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public string Code { get; private set; }
|
public string Code { get; private set; }
|
||||||
|
|
||||||
|
public IEnumerable<ShaderDeclInfo> ConstBufferUsage { get; private set; }
|
||||||
public IEnumerable<ShaderDeclInfo> TextureUsage { get; private set; }
|
public IEnumerable<ShaderDeclInfo> TextureUsage { get; private set; }
|
||||||
public IEnumerable<ShaderDeclInfo> UniformUsage { get; private set; }
|
|
||||||
|
|
||||||
public OGLShaderStage(
|
public OGLShaderStage(
|
||||||
GalShaderType Type,
|
GalShaderType Type,
|
||||||
string Code,
|
string Code,
|
||||||
IEnumerable<ShaderDeclInfo> TextureUsage,
|
IEnumerable<ShaderDeclInfo> ConstBufferUsage,
|
||||||
IEnumerable<ShaderDeclInfo> UniformUsage)
|
IEnumerable<ShaderDeclInfo> TextureUsage)
|
||||||
{
|
{
|
||||||
this.Type = Type;
|
this.Type = Type;
|
||||||
this.Code = Code;
|
this.Code = Code;
|
||||||
|
this.ConstBufferUsage = ConstBufferUsage;
|
||||||
this.TextureUsage = TextureUsage;
|
this.TextureUsage = TextureUsage;
|
||||||
this.UniformUsage = UniformUsage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Compile()
|
public void Compile()
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
Gpu.Renderer.Shader.BindProgram();
|
Gpu.Renderer.Shader.BindProgram();
|
||||||
|
|
||||||
UploadTextures(Vmm, State, Keys);
|
UploadTextures(Vmm, State, Keys);
|
||||||
UploadConstBuffers(Vmm, State);
|
UploadConstBuffers(Vmm, State, Keys);
|
||||||
UploadVertexArrays(Vmm, State);
|
UploadVertexArrays(Vmm, State);
|
||||||
|
|
||||||
DispatchRender(Vmm, State);
|
DispatchRender(Vmm, State);
|
||||||
|
@ -463,24 +463,29 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
Gpu.Renderer.Texture.SetSampler(Sampler);
|
Gpu.Renderer.Texture.SetSampler(Sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UploadConstBuffers(NvGpuVmm Vmm, GalPipelineState State)
|
private void UploadConstBuffers(NvGpuVmm Vmm, GalPipelineState State, long[] Keys)
|
||||||
{
|
{
|
||||||
for (int Stage = 0; Stage < State.ConstBufferKeys.Length; Stage++)
|
for (int Stage = 0; Stage < Keys.Length; Stage++)
|
||||||
{
|
{
|
||||||
for (int Index = 0; Index < State.ConstBufferKeys[Stage].Length; Index++)
|
foreach (ShaderDeclInfo DeclInfo in Gpu.Renderer.Shader.GetConstBufferUsage(Keys[Stage]))
|
||||||
{
|
{
|
||||||
ConstBuffer Cb = ConstBuffers[Stage][Index];
|
ConstBuffer Cb = ConstBuffers[Stage][DeclInfo.Cbuf];
|
||||||
|
|
||||||
|
if (!Cb.Enabled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
long Key = Vmm.GetPhysicalAddress(Cb.Position);
|
long Key = Vmm.GetPhysicalAddress(Cb.Position);
|
||||||
|
|
||||||
if (Cb.Enabled && QueryKeyUpload(Vmm, Key, Cb.Size, NvGpuBufferType.ConstBuffer))
|
if (QueryKeyUpload(Vmm, Key, Cb.Size, NvGpuBufferType.ConstBuffer))
|
||||||
{
|
{
|
||||||
IntPtr Source = Vmm.GetHostAddress(Cb.Position, Cb.Size);
|
IntPtr Source = Vmm.GetHostAddress(Cb.Position, Cb.Size);
|
||||||
|
|
||||||
Gpu.Renderer.Buffer.SetData(Key, Cb.Size, Source);
|
Gpu.Renderer.Buffer.SetData(Key, Cb.Size, Source);
|
||||||
}
|
}
|
||||||
|
|
||||||
State.ConstBufferKeys[Stage][Index] = Key;
|
State.ConstBufferKeys[Stage][DeclInfo.Cbuf] = Key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue