From 8df23211f6196dbb8ee28f6cce51aadaf35e7679 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 9 May 2024 19:21:01 -0400 Subject: [PATCH] Effects --- .../Effects/FsrScalingFilter.cs | 10 ++++---- .../Effects/FxaaPostProcessingEffect.cs | 14 +++++------ .../Effects/SmaaPostProcessingEffect.cs | 24 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs b/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs index 4e4a1f849..d9821a241 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs @@ -123,13 +123,13 @@ namespace Ryujinx.Graphics.OpenGL.Effects uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram); int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture); _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 dispatchX = (width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; - int dispatchY = (height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + uint dispatchX = (uint)((width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim); + uint dispatchY = (uint)((height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim); // Scaling pass float srcWidth = Math.Abs(source.X2 - source.X1); @@ -156,7 +156,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects // Sharpening Pass _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); _gd.Api.Uniform1(_inputUniform, 0); _gd.Api.Uniform1(_outputUniform, 0); diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs index 24a72a23a..ed772b874 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs @@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects 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"); _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; - int previousProgram = _gd.Api.GetInteger(GetPName.CurrentProgram); + uint previousProgram = (uint)_gd.Api.GetInteger(GetPName.CurrentProgram); int previousUnit = _gd.Api.GetInteger(GetPName.ActiveTexture); _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); - var dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize); - var dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize); + uint dispatchX = (uint)BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize); + uint dispatchY = (uint)BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize); view.Bind(0); _gd.Api.Uniform1(_inputUniform, 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.UseProgram(previousProgram); _gd.Api.MemoryBarrier(MemoryBarrierMask.ShaderImageAccessBarrierBit); diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs index 4b9d4983d..dfb7073fe 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs @@ -93,13 +93,13 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa var neighbourShaderData = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa_neighbour.glsl"); 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; - var blendProgram = ShaderHelper.CompileProgram(shaders, ShaderType.ComputeShader); + var blendProgram = ShaderHelper.CompileProgram(_gd.Api, shaders, ShaderType.ComputeShader); shaders[1] = neighbourShaderData; - var neighbourProgram = ShaderHelper.CompileProgram(shaders, ShaderType.ComputeShader); + var neighbourProgram = ShaderHelper.CompileProgram(_gd.Api, shaders, ShaderType.ComputeShader); _edgeShaderPrograms[i] = edgeProgram; _blendShaderPrograms[i] = blendProgram; @@ -184,14 +184,14 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa var areaTexture = _areaTexture.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); _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); - int previousTextureBinding1 = _gd.Api.GetInteger(GetPName.TextureBinding2D); + uint previousTextureBinding1 = (uint)_gd.Api.GetInteger(GetPName.TextureBinding2D); _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); framebuffer.Bind(); @@ -206,11 +206,11 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa framebuffer.Dispose(); - var dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize); - var dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize); + uint dispatchX = (uint)BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize); + uint dispatchY = (uint)BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize); 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]); view.Bind(0); _gd.Api.Uniform1(_inputUniform, 0); @@ -219,7 +219,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa _gd.Api.DispatchCompute(dispatchX, dispatchY, 1); _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]); edgeOutput.Bind(0); areaTexture.Bind(1); @@ -232,7 +232,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa _gd.Api.DispatchCompute(dispatchX, dispatchY, 1); _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]); view.Bind(0); blendOutput.Bind(1);