This commit is contained in:
Isaac Marovitz 2024-05-09 19:21:01 -04:00
parent e46b671875
commit 8df23211f6
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
3 changed files with 24 additions and 24 deletions

View file

@ -123,13 +123,13 @@ namespace Ryujinx.Graphics.OpenGL.Effects
uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram); uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram);
int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture); int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture);
_gd.Api.ActiveTexture(TextureUnit.Texture0); _gd.Api.ActiveTexture(TextureUnit.Texture0);
int previousTextureBinding = _gd.Api.GetInteger(GetPName.TextureBinding2D); uint previousTextureBinding = (uint)_gd.Api.GetInteger(GetPName.TextureBinding2D);
_gd.Api.BindImageTexture(0, textureView.Handle, 0, false, 0, BufferAccessARB.ReadWrite, SizedInternalFormat.Rgba8); _gd.Api.BindImageTexture(0, textureView.Handle, 0, false, 0, BufferAccessARB.ReadWrite, InternalFormat.Rgba8);
int threadGroupWorkRegionDim = 16; int threadGroupWorkRegionDim = 16;
int dispatchX = (width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; uint dispatchX = (uint)((width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim);
int dispatchY = (height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; uint dispatchY = (uint)((height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim);
// Scaling pass // Scaling pass
float srcWidth = Math.Abs(source.X2 - source.X1); float srcWidth = Math.Abs(source.X2 - source.X1);
@ -156,7 +156,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects
// Sharpening Pass // Sharpening Pass
_gd.Api.UseProgram(_sharpeningShaderProgram); _gd.Api.UseProgram(_sharpeningShaderProgram);
_gd.Api.BindImageTexture(0, destinationTexture.Handle, 0, false, 0, BufferAccessARB.ReadWrite, SizedInternalFormat.Rgba8); _gd.Api.BindImageTexture(0, destinationTexture.Handle, 0, false, 0, BufferAccessARB.ReadWrite, InternalFormat.Rgba8);
textureView.Bind(0); textureView.Bind(0);
_gd.Api.Uniform1(_inputUniform, 0); _gd.Api.Uniform1(_inputUniform, 0);
_gd.Api.Uniform1(_outputUniform, 0); _gd.Api.Uniform1(_outputUniform, 0);

View file

@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects
private void Initialize() private void Initialize()
{ {
_shaderProgram = ShaderHelper.CompileProgram(EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/fxaa.glsl"), ShaderType.ComputeShader); _shaderProgram = ShaderHelper.CompileProgram(_gd.Api, EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/fxaa.glsl"), ShaderType.ComputeShader);
_resolutionUniform = _gd.Api.GetUniformLocation(_shaderProgram, "invResolution"); _resolutionUniform = _gd.Api.GetUniformLocation(_shaderProgram, "invResolution");
_inputUniform = _gd.Api.GetUniformLocation(_shaderProgram, "inputTexture"); _inputUniform = _gd.Api.GetUniformLocation(_shaderProgram, "inputTexture");
@ -49,21 +49,21 @@ namespace Ryujinx.Graphics.OpenGL.Effects
var textureView = _textureStorage.CreateView(view.Info, 0, 0) as TextureView; var textureView = _textureStorage.CreateView(view.Info, 0, 0) as TextureView;
int previousProgram = _gd.Api.GetInteger(GetPName.CurrentProgram); uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram);
int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture); int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture);
_gd.Api.ActiveTexture(TextureUnit.Texture0); _gd.Api.ActiveTexture(TextureUnit.Texture0);
int previousTextureBinding = _gd.Api.GetInteger(GetPName.TextureBinding2D); uint previousTextureBinding = (uint)_gd.Api.GetInteger(GetPName.TextureBinding2D);
_gd.Api.BindImageTexture(0, textureView.Handle, 0, false, 0, BufferAccessARB.ReadWrite, SizedInternalFormat.Rgba8); _gd.Api.BindImageTexture(0, textureView.Handle, 0, false, 0, BufferAccessARB.ReadWrite, InternalFormat.Rgba8);
_gd.Api.UseProgram(_shaderProgram); _gd.Api.UseProgram(_shaderProgram);
var dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize); uint dispatchX = (uint)BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize);
var dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize); uint dispatchY = (uint)BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize);
view.Bind(0); view.Bind(0);
_gd.Api.Uniform1(_inputUniform, 0); _gd.Api.Uniform1(_inputUniform, 0);
_gd.Api.Uniform1(_outputUniform, 0); _gd.Api.Uniform1(_outputUniform, 0);
_gd.Api.Uniform2(_resolutionUniform, (float)view.Width, (float)view.Height); _gd.Api.Uniform2(_resolutionUniform, view.Width, view.Height);
_gd.Api.DispatchCompute(dispatchX, dispatchY, 1); _gd.Api.DispatchCompute(dispatchX, dispatchY, 1);
_gd.Api.UseProgram(previousProgram); _gd.Api.UseProgram(previousProgram);
_gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit); _gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit);

View file

@ -93,13 +93,13 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
var neighbourShaderData = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa_neighbour.glsl"); var neighbourShaderData = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa_neighbour.glsl");
var shaders = new string[] { presets, edgeShaderData }; var shaders = new string[] { presets, edgeShaderData };
var edgeProgram = ShaderHelper.CompileProgram(shaders, ShaderType.ComputeShader); var edgeProgram = ShaderHelper.CompileProgram(_gd.Api, shaders, ShaderType.ComputeShader);
shaders[1] = blendShaderData; shaders[1] = blendShaderData;
var blendProgram = ShaderHelper.CompileProgram(shaders, ShaderType.ComputeShader); var blendProgram = ShaderHelper.CompileProgram(_gd.Api, shaders, ShaderType.ComputeShader);
shaders[1] = neighbourShaderData; shaders[1] = neighbourShaderData;
var neighbourProgram = ShaderHelper.CompileProgram(shaders, ShaderType.ComputeShader); var neighbourProgram = ShaderHelper.CompileProgram(_gd.Api, shaders, ShaderType.ComputeShader);
_edgeShaderPrograms[i] = edgeProgram; _edgeShaderPrograms[i] = edgeProgram;
_blendShaderPrograms[i] = blendProgram; _blendShaderPrograms[i] = blendProgram;
@ -184,14 +184,14 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
var areaTexture = _areaTexture.DefaultView as TextureView; var areaTexture = _areaTexture.DefaultView as TextureView;
var searchTexture = _searchTexture.DefaultView as TextureView; var searchTexture = _searchTexture.DefaultView as TextureView;
var previousFramebuffer = _gd.Api.GetInteger(GetPName.DrawFramebufferBinding); uint previousFramebuffer = (uint)_gd.Api.GetInteger(GetPName.DrawFramebufferBinding);
int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture); int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture);
_gd.Api.ActiveTexture(TextureUnit.Texture0); _gd.Api.ActiveTexture(TextureUnit.Texture0);
int previousTextureBinding0 = _gd.Api.GetInteger(GetPName.TextureBinding2D); uint previousTextureBinding0 = (uint)_gd.Api.GetInteger(GetPName.TextureBinding2D);
_gd.Api.ActiveTexture(TextureUnit.Texture1); _gd.Api.ActiveTexture(TextureUnit.Texture1);
int previousTextureBinding1 = _gd.Api.GetInteger(GetPName.TextureBinding2D); uint previousTextureBinding1 = (uint)_gd.Api.GetInteger(GetPName.TextureBinding2D);
_gd.Api.ActiveTexture(TextureUnit.Texture2); _gd.Api.ActiveTexture(TextureUnit.Texture2);
int previousTextureBinding2 = _gd.Api.GetInteger(GetPName.TextureBinding2D); uint previousTextureBinding2 = (uint)_gd.Api.GetInteger(GetPName.TextureBinding2D);
var framebuffer = new Framebuffer(_gd.Api); var framebuffer = new Framebuffer(_gd.Api);
framebuffer.Bind(); framebuffer.Bind();
@ -206,11 +206,11 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
framebuffer.Dispose(); framebuffer.Dispose();
var dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize); uint dispatchX = (uint)BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize);
var dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize); uint dispatchY = (uint)BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize);
uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram); uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram);
_gd.Api.BindImageTexture(0, edgeOutput.Handle, 0, false, 0, BufferAccessARB.ReadWrite, SizedInternalFormat.Rgba8); _gd.Api.BindImageTexture(0, edgeOutput.Handle, 0, false, 0, BufferAccessARB.ReadWrite, InternalFormat.Rgba8);
_gd.Api.UseProgram(_edgeShaderPrograms[Quality]); _gd.Api.UseProgram(_edgeShaderPrograms[Quality]);
view.Bind(0); view.Bind(0);
_gd.Api.Uniform1(_inputUniform, 0); _gd.Api.Uniform1(_inputUniform, 0);
@ -219,7 +219,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
_gd.Api.DispatchCompute(dispatchX, dispatchY, 1); _gd.Api.DispatchCompute(dispatchX, dispatchY, 1);
_gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit); _gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit);
_gd.Api.BindImageTexture(0, blendOutput.Handle, 0, false, 0, BufferAccessARB.ReadWrite, SizedInternalFormat.Rgba8); _gd.Api.BindImageTexture(0, blendOutput.Handle, 0, false, 0, BufferAccessARB.ReadWrite,InternalFormat.Rgba8);
_gd.Api.UseProgram(_blendShaderPrograms[Quality]); _gd.Api.UseProgram(_blendShaderPrograms[Quality]);
edgeOutput.Bind(0); edgeOutput.Bind(0);
areaTexture.Bind(1); areaTexture.Bind(1);
@ -232,7 +232,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
_gd.Api.DispatchCompute(dispatchX, dispatchY, 1); _gd.Api.DispatchCompute(dispatchX, dispatchY, 1);
_gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit); _gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit);
_gd.Api.BindImageTexture(0, textureView.Handle, 0, false, 0, BufferAccessARB.ReadWrite, SizedInternalFormat.Rgba8); _gd.Api.BindImageTexture(0, textureView.Handle, 0, false, 0, BufferAccessARB.ReadWrite, InternalFormat.Rgba8);
_gd.Api.UseProgram(_neighbourShaderPrograms[Quality]); _gd.Api.UseProgram(_neighbourShaderPrograms[Quality]);
view.Bind(0); view.Bind(0);
blendOutput.Bind(1); blendOutput.Bind(1);