mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 01:25:25 +00:00
Some code cleanup
This commit is contained in:
parent
af8498d679
commit
654e617fe7
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Sampler
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum AddressMode
|
public enum AddressMode
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Blend
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct BlendDescriptor
|
public struct BlendDescriptor
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Blend
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum BlendFactor
|
public enum BlendFactor
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Blend
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum BlendOp
|
public enum BlendOp
|
||||||
{
|
{
|
|
@ -1,18 +0,0 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Color
|
|
||||||
{
|
|
||||||
public struct ColorSI
|
|
||||||
{
|
|
||||||
public int Red { get; }
|
|
||||||
public int Green { get; }
|
|
||||||
public int Blue { get; }
|
|
||||||
public int Alpha { get; }
|
|
||||||
|
|
||||||
public ColorSI(int red, int green, int blue, int alpha)
|
|
||||||
{
|
|
||||||
Red = red;
|
|
||||||
Green = green;
|
|
||||||
Blue = blue;
|
|
||||||
Alpha = alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Color
|
|
||||||
{
|
|
||||||
public struct ColorUI
|
|
||||||
{
|
|
||||||
public uint Red { get; }
|
|
||||||
public uint Green { get; }
|
|
||||||
public uint Blue { get; }
|
|
||||||
public uint Alpha { get; }
|
|
||||||
|
|
||||||
public ColorUI(uint red, uint green, uint blue, uint alpha)
|
|
||||||
{
|
|
||||||
Red = red;
|
|
||||||
Green = green;
|
|
||||||
Blue = blue;
|
|
||||||
Alpha = alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Color
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct ColorF
|
public struct ColorF
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Sampler
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum CompareMode
|
public enum CompareMode
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Texture
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum DepthStencilMode
|
public enum DepthStencilMode
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.DepthStencil
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct DepthStencilState
|
public struct DepthStencilState
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.DepthStencil
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct DepthTestDescriptor
|
public struct DepthTestDescriptor
|
||||||
{
|
{
|
|
@ -1,33 +1,10 @@
|
||||||
using Ryujinx.Graphics.GAL.Blend;
|
|
||||||
using Ryujinx.Graphics.GAL.Color;
|
|
||||||
using Ryujinx.Graphics.GAL.DepthStencil;
|
|
||||||
using Ryujinx.Graphics.GAL.InputAssembler;
|
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public interface IPipeline
|
public interface IPipeline
|
||||||
{
|
{
|
||||||
void BindBlendState(int index, BlendDescriptor blend);
|
|
||||||
|
|
||||||
void BindIndexBuffer(BufferRange buffer, IndexType type);
|
|
||||||
|
|
||||||
void BindImage(int index, ShaderStage stage, ITexture texture);
|
|
||||||
|
|
||||||
void BindProgram(IProgram program);
|
|
||||||
|
|
||||||
void BindSampler(int index, ShaderStage stage, ISampler sampler);
|
|
||||||
void BindTexture(int index, ShaderStage stage, ITexture texture);
|
|
||||||
|
|
||||||
void BindStorageBuffer(int index, ShaderStage stage, BufferRange buffer);
|
|
||||||
void BindUniformBuffer(int index, ShaderStage stage, BufferRange buffer);
|
|
||||||
|
|
||||||
void BindVertexAttribs(VertexAttribDescriptor[] vertexAttribs);
|
|
||||||
void BindVertexBuffers(VertexBufferDescriptor[] vertexBuffers);
|
|
||||||
|
|
||||||
void ClearRenderTargetColor(int index, uint componentMask, ColorF color);
|
void ClearRenderTargetColor(int index, uint componentMask, ColorF color);
|
||||||
void ClearRenderTargetColor(int index, uint componentMask, ColorSI color);
|
|
||||||
void ClearRenderTargetColor(int index, uint componentMask, ColorUI color);
|
|
||||||
|
|
||||||
void ClearRenderTargetDepthStencil(
|
void ClearRenderTargetDepthStencil(
|
||||||
float depthValue,
|
float depthValue,
|
||||||
|
@ -35,7 +12,7 @@ namespace Ryujinx.Graphics.GAL
|
||||||
int stencilValue,
|
int stencilValue,
|
||||||
int stencilMask);
|
int stencilMask);
|
||||||
|
|
||||||
void Dispatch(int groupsX, int groupsY, int groupsZ);
|
void DispatchCompute(int groupsX, int groupsY, int groupsZ);
|
||||||
|
|
||||||
void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance);
|
void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance);
|
||||||
void DrawIndexed(
|
void DrawIndexed(
|
||||||
|
@ -45,6 +22,8 @@ namespace Ryujinx.Graphics.GAL
|
||||||
int firstVertex,
|
int firstVertex,
|
||||||
int firstInstance);
|
int firstInstance);
|
||||||
|
|
||||||
|
void SetBlendState(int index, BlendDescriptor blend);
|
||||||
|
|
||||||
void SetBlendColor(ColorF color);
|
void SetBlendColor(ColorF color);
|
||||||
|
|
||||||
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
||||||
|
@ -57,16 +36,33 @@ namespace Ryujinx.Graphics.GAL
|
||||||
|
|
||||||
void SetFrontFace(FrontFace frontFace);
|
void SetFrontFace(FrontFace frontFace);
|
||||||
|
|
||||||
|
void SetIndexBuffer(BufferRange buffer, IndexType type);
|
||||||
|
|
||||||
|
void SetImage(int index, ShaderStage stage, ITexture texture);
|
||||||
|
|
||||||
void SetPrimitiveRestart(bool enable, int index);
|
void SetPrimitiveRestart(bool enable, int index);
|
||||||
|
|
||||||
void SetPrimitiveTopology(PrimitiveTopology topology);
|
void SetPrimitiveTopology(PrimitiveTopology topology);
|
||||||
|
|
||||||
|
void SetProgram(IProgram program);
|
||||||
|
|
||||||
void SetRenderTargetColorMasks(uint[] componentMask);
|
void SetRenderTargetColorMasks(uint[] componentMask);
|
||||||
|
|
||||||
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
||||||
|
|
||||||
|
void SetSampler(int index, ShaderStage stage, ISampler sampler);
|
||||||
|
|
||||||
void SetStencilTest(StencilTestDescriptor stencilTest);
|
void SetStencilTest(StencilTestDescriptor stencilTest);
|
||||||
|
|
||||||
|
void SetStorageBuffer(int index, ShaderStage stage, BufferRange buffer);
|
||||||
|
|
||||||
|
void SetTexture(int index, ShaderStage stage, ITexture texture);
|
||||||
|
|
||||||
|
void SetUniformBuffer(int index, ShaderStage stage, BufferRange buffer);
|
||||||
|
|
||||||
|
void SetVertexAttribs(VertexAttribDescriptor[] vertexAttribs);
|
||||||
|
void SetVertexBuffers(VertexBufferDescriptor[] vertexBuffers);
|
||||||
|
|
||||||
void SetViewports(int first, Viewport[] viewports);
|
void SetViewports(int first, Viewport[] viewports);
|
||||||
|
|
||||||
void TextureBarrier();
|
void TextureBarrier();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
using Ryujinx.Graphics.GAL.Sampler;
|
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Sampler
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum MagFilter
|
public enum MagFilter
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Sampler
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum MinFilter
|
public enum MinFilter
|
||||||
{
|
{
|
|
@ -1,6 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Color;
|
namespace Ryujinx.Graphics.GAL
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL.Sampler
|
|
||||||
{
|
{
|
||||||
public struct SamplerCreateInfo
|
public struct SamplerCreateInfo
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.DepthStencil
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum StencilOp
|
public enum StencilOp
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.DepthStencil
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct StencilTestDescriptor
|
public struct StencilTestDescriptor
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Texture
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum SwizzleComponent
|
public enum SwizzleComponent
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.Texture
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum Target
|
public enum Target
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL.Texture
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct TextureCreateInfo
|
public struct TextureCreateInfo
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.InputAssembler
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct VertexAttribDescriptor
|
public struct VertexAttribDescriptor
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Ryujinx.Graphics.GAL.InputAssembler
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct VertexBufferDescriptor
|
public struct VertexBufferDescriptor
|
||||||
{
|
{
|
|
@ -1,25 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu
|
|
||||||
{
|
|
||||||
static class Debugging
|
|
||||||
{
|
|
||||||
public static void PrintTexInfo(string prefix, Image.Texture tex)
|
|
||||||
{
|
|
||||||
if (tex == null)
|
|
||||||
{
|
|
||||||
Console.WriteLine(prefix + " null");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string range = $"{tex.Address:X}..{(tex.Address + tex.Size):X}";
|
|
||||||
|
|
||||||
int debugId = tex.HostTexture.GetStorageDebugId();
|
|
||||||
|
|
||||||
string str = $"{prefix} p {debugId:X8} {tex.Info.Target} {tex.Info.FormatInfo.Format} {tex.Info.Width}x{tex.Info.Height}x{tex.Info.DepthOrLayers} mips {tex.Info.Levels} addr {range}";
|
|
||||||
|
|
||||||
Console.WriteLine(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
using Ryujinx.Graphics.Gpu.Shader;
|
using Ryujinx.Graphics.Gpu.Shader;
|
||||||
using Ryujinx.Graphics.Gpu.State;
|
using Ryujinx.Graphics.Gpu.State;
|
||||||
|
@ -30,17 +30,17 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
dispatchParams.UnpackBlockSizeY(),
|
dispatchParams.UnpackBlockSizeY(),
|
||||||
dispatchParams.UnpackBlockSizeZ());
|
dispatchParams.UnpackBlockSizeZ());
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindProgram(cs.HostProgram);
|
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
|
||||||
|
|
||||||
var samplerPool = state.Get<PoolState>(MethodOffset.SamplerPoolState);
|
var samplerPool = state.Get<PoolState>(MethodOffset.SamplerPoolState);
|
||||||
|
|
||||||
_textureManager.SetComputeSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId, dispatchParams.SamplerIndex);
|
TextureManager.SetComputeSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId, dispatchParams.SamplerIndex);
|
||||||
|
|
||||||
var texturePool = state.Get<PoolState>(MethodOffset.TexturePoolState);
|
var texturePool = state.Get<PoolState>(MethodOffset.TexturePoolState);
|
||||||
|
|
||||||
_textureManager.SetComputeTexturePool(texturePool.Address.Pack(), texturePool.MaximumId);
|
TextureManager.SetComputeTexturePool(texturePool.Address.Pack(), texturePool.MaximumId);
|
||||||
|
|
||||||
_textureManager.SetComputeTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex));
|
TextureManager.SetComputeTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex));
|
||||||
|
|
||||||
ShaderProgramInfo info = cs.Shader.Program.Info;
|
ShaderProgramInfo info = cs.Shader.Program.Info;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
ulong gpuVa = dispatchParams.UniformBuffers[index].PackAddress();
|
ulong gpuVa = dispatchParams.UniformBuffers[index].PackAddress();
|
||||||
ulong size = dispatchParams.UniformBuffers[index].UnpackSize();
|
ulong size = dispatchParams.UniformBuffers[index].UnpackSize();
|
||||||
|
|
||||||
_bufferManager.SetComputeUniformBuffer(index, gpuVa, size);
|
BufferManager.SetComputeUniformBuffer(index, gpuVa, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < info.SBuffers.Count; index++)
|
for (int index = 0; index < info.SBuffers.Count; index++)
|
||||||
|
@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
sbEnableMask |= 1u << sb.Slot;
|
sbEnableMask |= 1u << sb.Slot;
|
||||||
|
|
||||||
ulong sbDescAddress = _bufferManager.GetComputeUniformBufferAddress(0);
|
ulong sbDescAddress = BufferManager.GetComputeUniformBufferAddress(0);
|
||||||
|
|
||||||
int sbDescOffset = 0x310 + sb.Slot * 0x10;
|
int sbDescOffset = 0x310 + sb.Slot * 0x10;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
SbDescriptor sbDescriptor = MemoryMarshal.Cast<byte, SbDescriptor>(sbDescriptorData)[0];
|
SbDescriptor sbDescriptor = MemoryMarshal.Cast<byte, SbDescriptor>(sbDescriptorData)[0];
|
||||||
|
|
||||||
_bufferManager.SetComputeStorageBuffer(sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size);
|
BufferManager.SetComputeStorageBuffer(sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ubEnableMask = 0;
|
ubEnableMask = 0;
|
||||||
|
@ -86,8 +86,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
ubEnableMask |= 1u << info.CBuffers[index].Slot;
|
ubEnableMask |= 1u << info.CBuffers[index].Slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
_bufferManager.SetComputeStorageBufferEnableMask(sbEnableMask);
|
BufferManager.SetComputeStorageBufferEnableMask(sbEnableMask);
|
||||||
_bufferManager.SetComputeUniformBufferEnableMask(ubEnableMask);
|
BufferManager.SetComputeUniformBufferEnableMask(ubEnableMask);
|
||||||
|
|
||||||
var textureBindings = new TextureBindingInfo[info.Textures.Count];
|
var textureBindings = new TextureBindingInfo[info.Textures.Count];
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_textureManager.SetComputeTextures(textureBindings);
|
TextureManager.SetComputeTextures(textureBindings);
|
||||||
|
|
||||||
var imageBindings = new TextureBindingInfo[info.Images.Count];
|
var imageBindings = new TextureBindingInfo[info.Images.Count];
|
||||||
|
|
||||||
|
@ -120,12 +120,12 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_textureManager.SetComputeImages(imageBindings);
|
TextureManager.SetComputeImages(imageBindings);
|
||||||
|
|
||||||
_bufferManager.CommitComputeBindings();
|
BufferManager.CommitComputeBindings();
|
||||||
_textureManager.CommitComputeBindings();
|
TextureManager.CommitComputeBindings();
|
||||||
|
|
||||||
_context.Renderer.Pipeline.Dispatch(
|
_context.Renderer.Pipeline.DispatchCompute(
|
||||||
dispatchParams.UnpackGridSizeX(),
|
dispatchParams.UnpackGridSizeX(),
|
||||||
dispatchParams.UnpackGridSizeY(),
|
dispatchParams.UnpackGridSizeY(),
|
||||||
dispatchParams.UnpackGridSizeZ());
|
dispatchParams.UnpackGridSizeZ());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Color;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Gpu.State;
|
using Ryujinx.Graphics.Gpu.State;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Engine
|
namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
UpdateRenderTargetState(state, useControl: false);
|
UpdateRenderTargetState(state, useControl: false);
|
||||||
|
|
||||||
_textureManager.CommitGraphicsBindings();
|
TextureManager.CommitGraphicsBindings();
|
||||||
|
|
||||||
bool clearDepth = (argument & 1) != 0;
|
bool clearDepth = (argument & 1) != 0;
|
||||||
bool clearStencil = (argument & 2) != 0;
|
bool clearStencil = (argument & 2) != 0;
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Buffer to buffer copy.
|
// Buffer to buffer copy.
|
||||||
_bufferManager.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size);
|
BufferManager.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ using Ryujinx.Graphics.Gpu.State;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Engine
|
namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
|
using Texture = Image.Texture;
|
||||||
|
|
||||||
partial class Methods
|
partial class Methods
|
||||||
{
|
{
|
||||||
private void CopyTexture(GpuState state, int argument)
|
private void CopyTexture(GpuState state, int argument)
|
||||||
|
@ -10,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
var dstCopyTexture = state.Get<CopyTexture>(MethodOffset.CopyDstTexture);
|
var dstCopyTexture = state.Get<CopyTexture>(MethodOffset.CopyDstTexture);
|
||||||
var srcCopyTexture = state.Get<CopyTexture>(MethodOffset.CopySrcTexture);
|
var srcCopyTexture = state.Get<CopyTexture>(MethodOffset.CopySrcTexture);
|
||||||
|
|
||||||
Image.Texture srcTexture = _textureManager.FindOrCreateTexture(srcCopyTexture);
|
Texture srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture);
|
||||||
|
|
||||||
if (srcTexture == null)
|
if (srcTexture == null)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
dstCopyTexture.Format = RtFormat.D32Float;
|
dstCopyTexture.Format = RtFormat.D32Float;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image.Texture dstTexture = _textureManager.FindOrCreateTexture(dstCopyTexture);
|
Texture dstTexture = TextureManager.FindOrCreateTexture(dstCopyTexture);
|
||||||
|
|
||||||
if (dstTexture == null)
|
if (dstTexture == null)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +78,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
srcCopyTexture.Height++;
|
srcCopyTexture.Height++;
|
||||||
|
|
||||||
srcTexture = _textureManager.FindOrCreateTexture(srcCopyTexture);
|
srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture);
|
||||||
|
|
||||||
srcRegion = new Extents2D(
|
srcRegion = new Extents2D(
|
||||||
srcRegion.X1 - srcTexture.Info.Width,
|
srcRegion.X1 - srcTexture.Info.Width,
|
||||||
|
|
|
@ -41,11 +41,11 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
ulong address = uniformBuffer.Address.Pack();
|
ulong address = uniformBuffer.Address.Pack();
|
||||||
|
|
||||||
_bufferManager.SetGraphicsUniformBuffer((int)type, index, address, (uint)uniformBuffer.Size);
|
BufferManager.SetGraphicsUniformBuffer((int)type, index, address, (uint)uniformBuffer.Size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_bufferManager.SetGraphicsUniformBuffer((int)type, index, 0, 0);
|
BufferManager.SetGraphicsUniformBuffer((int)type, index, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Blend;
|
|
||||||
using Ryujinx.Graphics.GAL.DepthStencil;
|
|
||||||
using Ryujinx.Graphics.GAL.InputAssembler;
|
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
using Ryujinx.Graphics.Gpu.Shader;
|
using Ryujinx.Graphics.Gpu.Shader;
|
||||||
|
@ -13,19 +10,18 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Engine
|
namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
|
using Texture = Image.Texture;
|
||||||
|
|
||||||
partial class Methods
|
partial class Methods
|
||||||
{
|
{
|
||||||
private GpuContext _context;
|
private readonly GpuContext _context;
|
||||||
|
|
||||||
private ShaderCache _shaderCache;
|
private readonly ShaderCache _shaderCache;
|
||||||
|
|
||||||
private ShaderProgramInfo[] _currentProgramInfo;
|
private readonly ShaderProgramInfo[] _currentProgramInfo;
|
||||||
|
|
||||||
private BufferManager _bufferManager;
|
public BufferManager BufferManager { get; }
|
||||||
private TextureManager _textureManager;
|
public TextureManager TextureManager { get; }
|
||||||
|
|
||||||
public BufferManager BufferManager => _bufferManager;
|
|
||||||
public TextureManager TextureManager => _textureManager;
|
|
||||||
|
|
||||||
private bool _isAnyVbInstanced;
|
private bool _isAnyVbInstanced;
|
||||||
private bool _vsUsesInstanceId;
|
private bool _vsUsesInstanceId;
|
||||||
|
@ -38,8 +34,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
_currentProgramInfo = new ShaderProgramInfo[Constants.TotalShaderStages];
|
_currentProgramInfo = new ShaderProgramInfo[Constants.TotalShaderStages];
|
||||||
|
|
||||||
_bufferManager = new BufferManager(context);
|
BufferManager = new BufferManager(context);
|
||||||
_textureManager = new TextureManager(context);
|
TextureManager = new TextureManager(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterCallbacks(GpuState state)
|
public void RegisterCallbacks(GpuState state)
|
||||||
|
@ -183,8 +179,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
UpdateStorageBuffers();
|
UpdateStorageBuffers();
|
||||||
|
|
||||||
_bufferManager.CommitBindings();
|
BufferManager.CommitBindings();
|
||||||
_textureManager.CommitGraphicsBindings();
|
TextureManager.CommitGraphicsBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStorageBuffers()
|
private void UpdateStorageBuffers()
|
||||||
|
@ -202,7 +198,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
BufferDescriptor sb = info.SBuffers[index];
|
BufferDescriptor sb = info.SBuffers[index];
|
||||||
|
|
||||||
ulong sbDescAddress = _bufferManager.GetGraphicsUniformBufferAddress(stage, 0);
|
ulong sbDescAddress = BufferManager.GetGraphicsUniformBufferAddress(stage, 0);
|
||||||
|
|
||||||
int sbDescOffset = 0x110 + stage * 0x100 + sb.Slot * 0x10;
|
int sbDescOffset = 0x110 + stage * 0x100 + sb.Slot * 0x10;
|
||||||
|
|
||||||
|
@ -212,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
SbDescriptor sbDescriptor = MemoryMarshal.Cast<byte, SbDescriptor>(sbDescriptorData)[0];
|
SbDescriptor sbDescriptor = MemoryMarshal.Cast<byte, SbDescriptor>(sbDescriptorData)[0];
|
||||||
|
|
||||||
_bufferManager.SetGraphicsStorageBuffer(stage, sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size);
|
BufferManager.SetGraphicsStorageBuffer(stage, sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,17 +232,14 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
if (index >= count || !IsRtEnabled(colorState))
|
if (index >= count || !IsRtEnabled(colorState))
|
||||||
{
|
{
|
||||||
_textureManager.SetRenderTargetColor(index, null);
|
TextureManager.SetRenderTargetColor(index, null);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image.Texture color = _textureManager.FindOrCreateTexture(
|
Texture color = TextureManager.FindOrCreateTexture(colorState, samplesInX, samplesInY);
|
||||||
colorState,
|
|
||||||
samplesInX,
|
|
||||||
samplesInY);
|
|
||||||
|
|
||||||
_textureManager.SetRenderTargetColor(index, color);
|
TextureManager.SetRenderTargetColor(index, color);
|
||||||
|
|
||||||
if (color != null)
|
if (color != null)
|
||||||
{
|
{
|
||||||
|
@ -256,21 +249,17 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
bool dsEnable = state.Get<Boolean32>(MethodOffset.RtDepthStencilEnable);
|
bool dsEnable = state.Get<Boolean32>(MethodOffset.RtDepthStencilEnable);
|
||||||
|
|
||||||
Image.Texture depthStencil = null;
|
Texture depthStencil = null;
|
||||||
|
|
||||||
if (dsEnable)
|
if (dsEnable)
|
||||||
{
|
{
|
||||||
var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState);
|
var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState);
|
||||||
var dsSize = state.Get<Size3D> (MethodOffset.RtDepthStencilSize);
|
var dsSize = state.Get<Size3D> (MethodOffset.RtDepthStencilSize);
|
||||||
|
|
||||||
depthStencil = _textureManager.FindOrCreateTexture(
|
depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY);
|
||||||
dsState,
|
|
||||||
dsSize,
|
|
||||||
samplesInX,
|
|
||||||
samplesInY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_textureManager.SetRenderTargetDepthStencil(depthStencil);
|
TextureManager.SetRenderTargetDepthStencil(depthStencil);
|
||||||
|
|
||||||
if (depthStencil != null)
|
if (depthStencil != null)
|
||||||
{
|
{
|
||||||
|
@ -335,8 +324,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
// the maximum supported viewport dimensions.
|
// the maximum supported viewport dimensions.
|
||||||
// This must be compensated on the shader, by dividing the vertex position
|
// This must be compensated on the shader, by dividing the vertex position
|
||||||
// by the maximum viewport dimensions.
|
// by the maximum viewport dimensions.
|
||||||
float maxSize = (float)_context.Capabilities.MaximumViewportDimensions;
|
float maxSize = _context.Capabilities.MaximumViewportDimensions;
|
||||||
float halfMaxSize = (float)_context.Capabilities.MaximumViewportDimensions * 0.5f;
|
float halfMaxSize = _context.Capabilities.MaximumViewportDimensions * 0.5f;
|
||||||
|
|
||||||
region = new RectangleF(-halfMaxSize, -halfMaxSize, maxSize, maxSize * yFlip);
|
region = new RectangleF(-halfMaxSize, -halfMaxSize, maxSize, maxSize * yFlip);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +351,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
float units = state.Get<float>(MethodOffset.DepthBiasUnits);
|
float units = state.Get<float>(MethodOffset.DepthBiasUnits);
|
||||||
float clamp = state.Get<float>(MethodOffset.DepthBiasClamp);
|
float clamp = state.Get<float>(MethodOffset.DepthBiasClamp);
|
||||||
|
|
||||||
PolygonModeMask enables = 0;
|
PolygonModeMask enables;
|
||||||
|
|
||||||
enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0);
|
enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0);
|
||||||
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0);
|
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0);
|
||||||
|
@ -435,16 +424,16 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
? texturePool.MaximumId
|
? texturePool.MaximumId
|
||||||
: samplerPool.MaximumId;
|
: samplerPool.MaximumId;
|
||||||
|
|
||||||
_textureManager.SetGraphicsSamplerPool(samplerPool.Address.Pack(), maximumId, samplerIndex);
|
TextureManager.SetGraphicsSamplerPool(samplerPool.Address.Pack(), maximumId, samplerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTexturePoolState(GpuState state)
|
private void UpdateTexturePoolState(GpuState state)
|
||||||
{
|
{
|
||||||
var texturePool = state.Get<PoolState>(MethodOffset.TexturePoolState);
|
var texturePool = state.Get<PoolState>(MethodOffset.TexturePoolState);
|
||||||
|
|
||||||
_textureManager.SetGraphicsTexturePool(texturePool.Address.Pack(), texturePool.MaximumId);
|
TextureManager.SetGraphicsTexturePool(texturePool.Address.Pack(), texturePool.MaximumId);
|
||||||
|
|
||||||
_textureManager.SetGraphicsTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex));
|
TextureManager.SetGraphicsTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVertexAttribState(GpuState state)
|
private void UpdateVertexAttribState(GpuState state)
|
||||||
|
@ -457,7 +446,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
if (!FormatTable.TryGetAttribFormat(vertexAttrib.UnpackFormat(), out Format format))
|
if (!FormatTable.TryGetAttribFormat(vertexAttrib.UnpackFormat(), out Format format))
|
||||||
{
|
{
|
||||||
// TODO: warning.
|
Logger.PrintError(LogClass.Gpu, $"Invalid attribute format 0x{vertexAttrib.UnpackFormat():X}.");
|
||||||
|
|
||||||
format = Format.R32G32B32A32Float;
|
format = Format.R32G32B32A32Float;
|
||||||
}
|
}
|
||||||
|
@ -468,7 +457,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
format);
|
format);
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindVertexAttribs(vertexAttribs);
|
_context.Renderer.Pipeline.SetVertexAttribs(vertexAttribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdatePrimitiveRestartState(GpuState state)
|
private void UpdatePrimitiveRestartState(GpuState state)
|
||||||
|
@ -504,7 +493,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
case IndexType.UInt: size *= 4; break;
|
case IndexType.UInt: size *= 4; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_bufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type);
|
BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type);
|
||||||
|
|
||||||
// The index buffer affects the vertex buffer size calculation, we
|
// The index buffer affects the vertex buffer size calculation, we
|
||||||
// need to ensure that they are updated.
|
// need to ensure that they are updated.
|
||||||
|
@ -521,7 +510,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
if (!vertexBuffer.UnpackEnable())
|
if (!vertexBuffer.UnpackEnable())
|
||||||
{
|
{
|
||||||
_bufferManager.SetVertexBuffer(index, 0, 0, 0, 0);
|
BufferManager.SetVertexBuffer(index, 0, 0, 0, 0);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -557,7 +546,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
size = (ulong)((firstInstance + drawState.First + drawState.Count) * stride);
|
size = (ulong)((firstInstance + drawState.First + drawState.Count) * stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
_bufferManager.SetVertexBuffer(index, address, size, stride, divisor);
|
BufferManager.SetVertexBuffer(index, address, size, stride, divisor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +569,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
var colorMask = state.Get<RtColorMask>(MethodOffset.RtColorMask, rtColorMaskShared ? 0 : index);
|
var colorMask = state.Get<RtColorMask>(MethodOffset.RtColorMask, rtColorMaskShared ? 0 : index);
|
||||||
|
|
||||||
uint componentMask = 0;
|
uint componentMask;
|
||||||
|
|
||||||
componentMask = (colorMask.UnpackRed() ? 1u : 0u);
|
componentMask = (colorMask.UnpackRed() ? 1u : 0u);
|
||||||
componentMask |= (colorMask.UnpackGreen() ? 2u : 0u);
|
componentMask |= (colorMask.UnpackGreen() ? 2u : 0u);
|
||||||
|
@ -597,8 +586,6 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
bool blendIndependent = state.Get<Boolean32>(MethodOffset.BlendIndependent);
|
bool blendIndependent = state.Get<Boolean32>(MethodOffset.BlendIndependent);
|
||||||
|
|
||||||
BlendState[] blends = new BlendState[8];
|
|
||||||
|
|
||||||
for (int index = 0; index < 8; index++)
|
for (int index = 0; index < 8; index++)
|
||||||
{
|
{
|
||||||
BlendDescriptor descriptor;
|
BlendDescriptor descriptor;
|
||||||
|
@ -632,7 +619,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
blend.AlphaDstFactor);
|
blend.AlphaDstFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindBlendState(index, descriptor);
|
_context.Renderer.Pipeline.SetBlendState(index, descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,7 +691,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_textureManager.SetGraphicsTextures(stage, textureBindings);
|
TextureManager.SetGraphicsTextures(stage, textureBindings);
|
||||||
|
|
||||||
var imageBindings = new TextureBindingInfo[info.Images.Count];
|
var imageBindings = new TextureBindingInfo[info.Images.Count];
|
||||||
|
|
||||||
|
@ -717,7 +704,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_textureManager.SetGraphicsImages(stage, imageBindings);
|
TextureManager.SetGraphicsImages(stage, imageBindings);
|
||||||
|
|
||||||
uint sbEnableMask = 0;
|
uint sbEnableMask = 0;
|
||||||
uint ubEnableMask = 0;
|
uint ubEnableMask = 0;
|
||||||
|
@ -732,11 +719,11 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
ubEnableMask |= 1u << info.CBuffers[index].Slot;
|
ubEnableMask |= 1u << info.CBuffers[index].Slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
_bufferManager.SetGraphicsStorageBufferEnableMask(stage, sbEnableMask);
|
BufferManager.SetGraphicsStorageBufferEnableMask(stage, sbEnableMask);
|
||||||
_bufferManager.SetGraphicsUniformBufferEnableMask(stage, ubEnableMask);
|
BufferManager.SetGraphicsUniformBufferEnableMask(stage, ubEnableMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindProgram(gs.HostProgram);
|
_context.Renderer.Pipeline.SetProgram(gs.HostProgram);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetViewportTransformEnable(GpuState state)
|
public bool GetViewportTransformEnable(GpuState state)
|
||||||
|
@ -796,7 +783,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
private void InvalidateTextures(GpuState state, int argument)
|
private void InvalidateTextures(GpuState state, int argument)
|
||||||
{
|
{
|
||||||
_textureManager.Flush();
|
TextureManager.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TextureBarrierTiled(GpuState state, int argument)
|
private void TextureBarrierTiled(GpuState state, int argument)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Color;
|
|
||||||
using Ryujinx.Graphics.GAL.Sampler;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Sampler;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
using Ryujinx.Graphics.Texture;
|
using Ryujinx.Graphics.Texture;
|
||||||
using Ryujinx.Graphics.Texture.Astc;
|
using Ryujinx.Graphics.Texture.Astc;
|
||||||
|
@ -15,18 +14,16 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
private GpuContext _context;
|
private GpuContext _context;
|
||||||
|
|
||||||
private TextureInfo _info;
|
|
||||||
|
|
||||||
private SizeInfo _sizeInfo;
|
private SizeInfo _sizeInfo;
|
||||||
|
|
||||||
public Format Format => _info.FormatInfo.Format;
|
public Format Format => Info.FormatInfo.Format;
|
||||||
|
|
||||||
public TextureInfo Info => _info;
|
public TextureInfo Info { get; private set; }
|
||||||
|
|
||||||
private int _depth;
|
private int _depth;
|
||||||
private int _layers;
|
private int _layers;
|
||||||
private int _firstLayer;
|
private readonly int _firstLayer;
|
||||||
private int _firstLevel;
|
private readonly int _firstLevel;
|
||||||
|
|
||||||
private bool _hasData;
|
private bool _hasData;
|
||||||
|
|
||||||
|
@ -43,8 +40,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
public bool Modified { get; set; }
|
public bool Modified { get; set; }
|
||||||
|
|
||||||
public ulong Address => _info.Address;
|
public ulong Address => Info.Address;
|
||||||
public ulong EndAddress => _info.Address + Size;
|
public ulong EndAddress => Info.Address + Size;
|
||||||
|
|
||||||
public ulong Size => (ulong)_sizeInfo.TotalSize;
|
public ulong Size => (ulong)_sizeInfo.TotalSize;
|
||||||
|
|
||||||
|
@ -127,13 +124,13 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
width <<= _firstLevel;
|
width <<= _firstLevel;
|
||||||
height <<= _firstLevel;
|
height <<= _firstLevel;
|
||||||
|
|
||||||
if (_info.Target == Target.Texture3D)
|
if (Info.Target == Target.Texture3D)
|
||||||
{
|
{
|
||||||
depthOrLayers <<= _firstLevel;
|
depthOrLayers <<= _firstLevel;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
depthOrLayers = _viewStorage._info.DepthOrLayers;
|
depthOrLayers = _viewStorage.Info.DepthOrLayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
_viewStorage.RecreateStorageOrView(width, height, depthOrLayers);
|
_viewStorage.RecreateStorageOrView(width, height, depthOrLayers);
|
||||||
|
@ -145,13 +142,13 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
int viewDepthOrLayers;
|
int viewDepthOrLayers;
|
||||||
|
|
||||||
if (view._info.Target == Target.Texture3D)
|
if (view.Info.Target == Target.Texture3D)
|
||||||
{
|
{
|
||||||
viewDepthOrLayers = Math.Max(1, depthOrLayers >> view._firstLevel);
|
viewDepthOrLayers = Math.Max(1, depthOrLayers >> view._firstLevel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
viewDepthOrLayers = view._info.DepthOrLayers;
|
viewDepthOrLayers = view.Info.DepthOrLayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.RecreateStorageOrView(viewWidth, viewHeight, viewDepthOrLayers);
|
view.RecreateStorageOrView(viewWidth, viewHeight, viewDepthOrLayers);
|
||||||
|
@ -161,27 +158,27 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
private void RecreateStorageOrView(int width, int height, int depthOrLayers)
|
private void RecreateStorageOrView(int width, int height, int depthOrLayers)
|
||||||
{
|
{
|
||||||
SetInfo(new TextureInfo(
|
SetInfo(new TextureInfo(
|
||||||
_info.Address,
|
Info.Address,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
depthOrLayers,
|
depthOrLayers,
|
||||||
_info.Levels,
|
Info.Levels,
|
||||||
_info.SamplesInX,
|
Info.SamplesInX,
|
||||||
_info.SamplesInY,
|
Info.SamplesInY,
|
||||||
_info.Stride,
|
Info.Stride,
|
||||||
_info.IsLinear,
|
Info.IsLinear,
|
||||||
_info.GobBlocksInY,
|
Info.GobBlocksInY,
|
||||||
_info.GobBlocksInZ,
|
Info.GobBlocksInZ,
|
||||||
_info.GobBlocksInTileX,
|
Info.GobBlocksInTileX,
|
||||||
_info.Target,
|
Info.Target,
|
||||||
_info.FormatInfo,
|
Info.FormatInfo,
|
||||||
_info.DepthStencilMode,
|
Info.DepthStencilMode,
|
||||||
_info.SwizzleR,
|
Info.SwizzleR,
|
||||||
_info.SwizzleG,
|
Info.SwizzleG,
|
||||||
_info.SwizzleB,
|
Info.SwizzleB,
|
||||||
_info.SwizzleA));
|
Info.SwizzleA));
|
||||||
|
|
||||||
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(_info, _context.Capabilities);
|
TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities);
|
||||||
|
|
||||||
if (_viewStorage != this)
|
if (_viewStorage != this)
|
||||||
{
|
{
|
||||||
|
@ -215,50 +212,50 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
Span<byte> data = _context.PhysicalMemory.Read(Address, Size);
|
Span<byte> data = _context.PhysicalMemory.Read(Address, Size);
|
||||||
|
|
||||||
if (_info.IsLinear)
|
if (Info.IsLinear)
|
||||||
{
|
{
|
||||||
data = LayoutConverter.ConvertLinearStridedToLinear(
|
data = LayoutConverter.ConvertLinearStridedToLinear(
|
||||||
_info.Width,
|
Info.Width,
|
||||||
_info.Height,
|
Info.Height,
|
||||||
_info.FormatInfo.BlockWidth,
|
Info.FormatInfo.BlockWidth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.Stride,
|
Info.Stride,
|
||||||
_info.FormatInfo.BytesPerPixel,
|
Info.FormatInfo.BytesPerPixel,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = LayoutConverter.ConvertBlockLinearToLinear(
|
data = LayoutConverter.ConvertBlockLinearToLinear(
|
||||||
_info.Width,
|
Info.Width,
|
||||||
_info.Height,
|
Info.Height,
|
||||||
_depth,
|
_depth,
|
||||||
_info.Levels,
|
Info.Levels,
|
||||||
_layers,
|
_layers,
|
||||||
_info.FormatInfo.BlockWidth,
|
Info.FormatInfo.BlockWidth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.FormatInfo.BytesPerPixel,
|
Info.FormatInfo.BytesPerPixel,
|
||||||
_info.GobBlocksInY,
|
Info.GobBlocksInY,
|
||||||
_info.GobBlocksInZ,
|
Info.GobBlocksInZ,
|
||||||
_info.GobBlocksInTileX,
|
Info.GobBlocksInTileX,
|
||||||
_sizeInfo,
|
_sizeInfo,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_context.Capabilities.SupportsAstcCompression && _info.FormatInfo.Format.IsAstc())
|
if (!_context.Capabilities.SupportsAstcCompression && Info.FormatInfo.Format.IsAstc())
|
||||||
{
|
{
|
||||||
if (!AstcDecoder.TryDecodeToRgba8(
|
if (!AstcDecoder.TryDecodeToRgba8(
|
||||||
data.ToArray(),
|
data.ToArray(),
|
||||||
_info.FormatInfo.BlockWidth,
|
Info.FormatInfo.BlockWidth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.Width,
|
Info.Width,
|
||||||
_info.Height,
|
Info.Height,
|
||||||
_depth,
|
_depth,
|
||||||
_info.Levels,
|
Info.Levels,
|
||||||
out Span<byte> decoded))
|
out Span<byte> decoded))
|
||||||
{
|
{
|
||||||
string texInfo = $"{_info.Target} {_info.FormatInfo.Format} {_info.Width}x{_info.Height}x{_info.DepthOrLayers} levels {_info.Levels}";
|
string texInfo = $"{Info.Target} {Info.FormatInfo.Format} {Info.Width}x{Info.Height}x{Info.DepthOrLayers} levels {Info.Levels}";
|
||||||
|
|
||||||
Logger.PrintError(LogClass.Gpu, $"Invalid ASTC texture at 0x{_info.Address:X} ({texInfo}).");
|
Logger.PrintError(LogClass.Gpu, $"Invalid ASTC texture at 0x{Info.Address:X} ({texInfo}).");
|
||||||
}
|
}
|
||||||
|
|
||||||
data = decoded;
|
data = decoded;
|
||||||
|
@ -273,31 +270,31 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
Span<byte> data = HostTexture.GetData();
|
Span<byte> data = HostTexture.GetData();
|
||||||
|
|
||||||
if (_info.IsLinear)
|
if (Info.IsLinear)
|
||||||
{
|
{
|
||||||
data = LayoutConverter.ConvertLinearToLinearStrided(
|
data = LayoutConverter.ConvertLinearToLinearStrided(
|
||||||
_info.Width,
|
Info.Width,
|
||||||
_info.Height,
|
Info.Height,
|
||||||
_info.FormatInfo.BlockWidth,
|
Info.FormatInfo.BlockWidth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.Stride,
|
Info.Stride,
|
||||||
_info.FormatInfo.BytesPerPixel,
|
Info.FormatInfo.BytesPerPixel,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = LayoutConverter.ConvertLinearToBlockLinear(
|
data = LayoutConverter.ConvertLinearToBlockLinear(
|
||||||
_info.Width,
|
Info.Width,
|
||||||
_info.Height,
|
Info.Height,
|
||||||
_depth,
|
_depth,
|
||||||
_info.Levels,
|
Info.Levels,
|
||||||
_layers,
|
_layers,
|
||||||
_info.FormatInfo.BlockWidth,
|
Info.FormatInfo.BlockWidth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.FormatInfo.BytesPerPixel,
|
Info.FormatInfo.BytesPerPixel,
|
||||||
_info.GobBlocksInY,
|
Info.GobBlocksInY,
|
||||||
_info.GobBlocksInZ,
|
Info.GobBlocksInZ,
|
||||||
_info.GobBlocksInTileX,
|
Info.GobBlocksInTileX,
|
||||||
_sizeInfo,
|
_sizeInfo,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
|
@ -332,8 +329,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
if ((flags & TextureSearchFlags.IgnoreMs) != 0)
|
if ((flags & TextureSearchFlags.IgnoreMs) != 0)
|
||||||
{
|
{
|
||||||
bool msTargetCompatible = _info.Target == Target.Texture2DMultisample &&
|
bool msTargetCompatible = Info.Target == Target.Texture2DMultisample && info.Target == Target.Texture2D;
|
||||||
info.Target == Target.Texture2D;
|
|
||||||
|
|
||||||
if (!msTargetCompatible && !TargetAndSamplesCompatible(info))
|
if (!msTargetCompatible && !TargetAndSamplesCompatible(info))
|
||||||
{
|
{
|
||||||
|
@ -345,25 +341,24 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _info.Address == info.Address && _info.Levels == info.Levels;
|
return Info.Address == info.Address && Info.Levels == info.Levels;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FormatMatches(TextureInfo info, bool strict)
|
private bool FormatMatches(TextureInfo info, bool strict)
|
||||||
{
|
{
|
||||||
// D32F and R32F texture have the same representation internally,
|
// D32F and R32F texture have the same representation internally,
|
||||||
// however the R32F format is used to sample from depth textures.
|
// however the R32F format is used to sample from depth textures.
|
||||||
if (_info.FormatInfo.Format == Format.D32Float &&
|
if (Info.FormatInfo.Format == Format.D32Float && info.FormatInfo.Format == Format.R32Float && !strict)
|
||||||
info.FormatInfo.Format == Format.R32Float && !strict)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _info.FormatInfo.Format == info.FormatInfo.Format;
|
return Info.FormatInfo.Format == info.FormatInfo.Format;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LayoutMatches(TextureInfo info)
|
private bool LayoutMatches(TextureInfo info)
|
||||||
{
|
{
|
||||||
if (_info.IsLinear != info.IsLinear)
|
if (Info.IsLinear != info.IsLinear)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -372,12 +367,12 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
// For block linear textures, the stride is ignored.
|
// For block linear textures, the stride is ignored.
|
||||||
if (info.IsLinear)
|
if (info.IsLinear)
|
||||||
{
|
{
|
||||||
return _info.Stride == info.Stride;
|
return Info.Stride == info.Stride;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return _info.GobBlocksInY == info.GobBlocksInY &&
|
return Info.GobBlocksInY == info.GobBlocksInY &&
|
||||||
_info.GobBlocksInZ == info.GobBlocksInZ;
|
Info.GobBlocksInZ == info.GobBlocksInZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,21 +383,21 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
public bool SizeMatches(TextureInfo info, int level)
|
public bool SizeMatches(TextureInfo info, int level)
|
||||||
{
|
{
|
||||||
return Math.Max(1, _info.Width >> level) == info.Width &&
|
return Math.Max(1, Info.Width >> level) == info.Width &&
|
||||||
Math.Max(1, _info.Height >> level) == info.Height &&
|
Math.Max(1, Info.Height >> level) == info.Height &&
|
||||||
Math.Max(1, _info.GetDepth() >> level) == info.GetDepth();
|
Math.Max(1, Info.GetDepth() >> level) == info.GetDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SizeMatches(TextureInfo info, bool alignSizes)
|
private bool SizeMatches(TextureInfo info, bool alignSizes)
|
||||||
{
|
{
|
||||||
if (_info.GetLayers() != info.GetLayers())
|
if (Info.GetLayers() != info.GetLayers())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alignSizes)
|
if (alignSizes)
|
||||||
{
|
{
|
||||||
Size size0 = GetAlignedSize(_info);
|
Size size0 = GetAlignedSize(Info);
|
||||||
Size size1 = GetAlignedSize(info);
|
Size size1 = GetAlignedSize(info);
|
||||||
|
|
||||||
return size0.Width == size1.Width &&
|
return size0.Width == size1.Width &&
|
||||||
|
@ -411,26 +406,26 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return _info.Width == info.Width &&
|
return Info.Width == info.Width &&
|
||||||
_info.Height == info.Height &&
|
Info.Height == info.Height &&
|
||||||
_info.GetDepth() == info.GetDepth();
|
Info.GetDepth() == info.GetDepth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SamplerParamsMatches(TextureInfo info)
|
private bool SamplerParamsMatches(TextureInfo info)
|
||||||
{
|
{
|
||||||
return _info.DepthStencilMode == info.DepthStencilMode &&
|
return Info.DepthStencilMode == info.DepthStencilMode &&
|
||||||
_info.SwizzleR == info.SwizzleR &&
|
Info.SwizzleR == info.SwizzleR &&
|
||||||
_info.SwizzleG == info.SwizzleG &&
|
Info.SwizzleG == info.SwizzleG &&
|
||||||
_info.SwizzleB == info.SwizzleB &&
|
Info.SwizzleB == info.SwizzleB &&
|
||||||
_info.SwizzleA == info.SwizzleA;
|
Info.SwizzleA == info.SwizzleA;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TargetAndSamplesCompatible(TextureInfo info)
|
private bool TargetAndSamplesCompatible(TextureInfo info)
|
||||||
{
|
{
|
||||||
return _info.Target == info.Target &&
|
return Info.Target == info.Target &&
|
||||||
_info.SamplesInX == info.SamplesInX &&
|
Info.SamplesInX == info.SamplesInX &&
|
||||||
_info.SamplesInY == info.SamplesInY;
|
Info.SamplesInY == info.SamplesInY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsViewCompatible(
|
public bool IsViewCompatible(
|
||||||
|
@ -485,13 +480,13 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _info.SamplesInX == info.SamplesInX &&
|
return Info.SamplesInX == info.SamplesInX &&
|
||||||
_info.SamplesInY == info.SamplesInY;
|
Info.SamplesInY == info.SamplesInY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ViewLayoutCompatible(TextureInfo info, int level)
|
private bool ViewLayoutCompatible(TextureInfo info, int level)
|
||||||
{
|
{
|
||||||
if (_info.IsLinear != info.IsLinear)
|
if (Info.IsLinear != info.IsLinear)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -500,9 +495,9 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
// For block linear textures, the stride is ignored.
|
// For block linear textures, the stride is ignored.
|
||||||
if (info.IsLinear)
|
if (info.IsLinear)
|
||||||
{
|
{
|
||||||
int width = Math.Max(1, _info.Width >> level);
|
int width = Math.Max(1, Info.Width >> level);
|
||||||
|
|
||||||
int stride = width * _info.FormatInfo.BytesPerPixel;
|
int stride = width * Info.FormatInfo.BytesPerPixel;
|
||||||
|
|
||||||
stride = BitUtils.AlignUp(stride, 32);
|
stride = BitUtils.AlignUp(stride, 32);
|
||||||
|
|
||||||
|
@ -510,15 +505,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int height = Math.Max(1, _info.Height >> level);
|
int height = Math.Max(1, Info.Height >> level);
|
||||||
int depth = Math.Max(1, _info.GetDepth() >> level);
|
int depth = Math.Max(1, Info.GetDepth() >> level);
|
||||||
|
|
||||||
(int gobBlocksInY, int gobBlocksInZ) = SizeCalculator.GetMipGobBlockSizes(
|
(int gobBlocksInY, int gobBlocksInZ) = SizeCalculator.GetMipGobBlockSizes(
|
||||||
height,
|
height,
|
||||||
depth,
|
depth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.GobBlocksInY,
|
Info.GobBlocksInY,
|
||||||
_info.GobBlocksInZ);
|
Info.GobBlocksInZ);
|
||||||
|
|
||||||
return gobBlocksInY == info.GobBlocksInY &&
|
return gobBlocksInY == info.GobBlocksInY &&
|
||||||
gobBlocksInZ == info.GobBlocksInZ;
|
gobBlocksInZ == info.GobBlocksInZ;
|
||||||
|
@ -527,12 +522,12 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
private bool ViewFormatCompatible(TextureInfo info)
|
private bool ViewFormatCompatible(TextureInfo info)
|
||||||
{
|
{
|
||||||
return TextureCompatibility.FormatCompatible(_info.FormatInfo, info.FormatInfo);
|
return TextureCompatibility.FormatCompatible(Info.FormatInfo, info.FormatInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ViewSizeMatches(TextureInfo info, int level, bool isCopy)
|
private bool ViewSizeMatches(TextureInfo info, int level, bool isCopy)
|
||||||
{
|
{
|
||||||
Size size = GetAlignedSize(_info, level);
|
Size size = GetAlignedSize(Info, level);
|
||||||
|
|
||||||
Size otherSize = GetAlignedSize(info);
|
Size otherSize = GetAlignedSize(info);
|
||||||
|
|
||||||
|
@ -549,7 +544,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
private bool ViewTargetCompatible(TextureInfo info, bool isCopy)
|
private bool ViewTargetCompatible(TextureInfo info, bool isCopy)
|
||||||
{
|
{
|
||||||
switch (_info.Target)
|
switch (Info.Target)
|
||||||
{
|
{
|
||||||
case Target.Texture1D:
|
case Target.Texture1D:
|
||||||
case Target.Texture1DArray:
|
case Target.Texture1DArray:
|
||||||
|
@ -621,7 +616,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
public ITexture GetTargetTexture(Target target)
|
public ITexture GetTargetTexture(Target target)
|
||||||
{
|
{
|
||||||
if (target == _info.Target)
|
if (target == Info.Target)
|
||||||
{
|
{
|
||||||
return HostTexture;
|
return HostTexture;
|
||||||
}
|
}
|
||||||
|
@ -629,21 +624,21 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
if (_arrayViewTexture == null && IsSameDimensionsTarget(target))
|
if (_arrayViewTexture == null && IsSameDimensionsTarget(target))
|
||||||
{
|
{
|
||||||
TextureCreateInfo createInfo = new TextureCreateInfo(
|
TextureCreateInfo createInfo = new TextureCreateInfo(
|
||||||
_info.Width,
|
Info.Width,
|
||||||
_info.Height,
|
Info.Height,
|
||||||
target == Target.CubemapArray ? 6 : 1,
|
target == Target.CubemapArray ? 6 : 1,
|
||||||
_info.Levels,
|
Info.Levels,
|
||||||
_info.Samples,
|
Info.Samples,
|
||||||
_info.FormatInfo.BlockWidth,
|
Info.FormatInfo.BlockWidth,
|
||||||
_info.FormatInfo.BlockHeight,
|
Info.FormatInfo.BlockHeight,
|
||||||
_info.FormatInfo.BytesPerPixel,
|
Info.FormatInfo.BytesPerPixel,
|
||||||
_info.FormatInfo.Format,
|
Info.FormatInfo.Format,
|
||||||
_info.DepthStencilMode,
|
Info.DepthStencilMode,
|
||||||
target,
|
target,
|
||||||
_info.SwizzleR,
|
Info.SwizzleR,
|
||||||
_info.SwizzleG,
|
Info.SwizzleG,
|
||||||
_info.SwizzleB,
|
Info.SwizzleB,
|
||||||
_info.SwizzleA);
|
Info.SwizzleA);
|
||||||
|
|
||||||
ITexture viewTexture = HostTexture.CreateView(createInfo, 0, 0);
|
ITexture viewTexture = HostTexture.CreateView(createInfo, 0, 0);
|
||||||
|
|
||||||
|
@ -662,7 +657,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
private bool IsSameDimensionsTarget(Target target)
|
private bool IsSameDimensionsTarget(Target target)
|
||||||
{
|
{
|
||||||
switch (_info.Target)
|
switch (Info.Target)
|
||||||
{
|
{
|
||||||
case Target.Texture1D:
|
case Target.Texture1D:
|
||||||
case Target.Texture1DArray:
|
case Target.Texture1DArray:
|
||||||
|
@ -702,7 +697,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
private void SetInfo(TextureInfo info)
|
private void SetInfo(TextureInfo info)
|
||||||
{
|
{
|
||||||
_info = info;
|
Info = info;
|
||||||
|
|
||||||
_depth = info.GetDepth();
|
_depth = info.GetDepth();
|
||||||
_layers = info.GetLayers();
|
_layers = info.GetLayers();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
|
|
|
@ -178,7 +178,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
_textureState[stageIndex][index].Texture = hostTexture;
|
_textureState[stageIndex][index].Texture = hostTexture;
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindTexture(index, stage, hostTexture);
|
_context.Renderer.Pipeline.SetTexture(index, stage, hostTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler sampler = _samplerPool.Get(samplerId);
|
Sampler sampler = _samplerPool.Get(samplerId);
|
||||||
|
@ -189,7 +189,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
_textureState[stageIndex][index].Sampler = hostSampler;
|
_textureState[stageIndex][index].Sampler = hostSampler;
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindSampler(index, stage, hostSampler);
|
_context.Renderer.Pipeline.SetSampler(index, stage, hostSampler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
_imageState[stageIndex][index].Texture = hostTexture;
|
_imageState[stageIndex][index].Texture = hostTexture;
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindImage(index, stage, hostTexture);
|
_context.Renderer.Pipeline.SetImage(index, stage, hostTexture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
using Ryujinx.Graphics.Gpu.State;
|
using Ryujinx.Graphics.Gpu.State;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
if (!FormatTable.TryGetTextureFormat(format, srgb, out FormatInfo formatInfo))
|
if (!FormatTable.TryGetTextureFormat(format, srgb, out FormatInfo formatInfo))
|
||||||
{
|
{
|
||||||
// TODO: Warning.
|
Logger.PrintError(LogClass.Gpu, $"Invalid texture format 0x{format:X} (sRGB: {srgb}).");
|
||||||
|
|
||||||
formatInfo = FormatInfo.Default;
|
formatInfo = FormatInfo.Default;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.InputAssembler;
|
|
||||||
using Ryujinx.Graphics.Gpu.State;
|
using Ryujinx.Graphics.Gpu.State;
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
using System;
|
using System;
|
||||||
|
@ -305,7 +304,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
|
|
||||||
BufferRange buffer = GetBufferRange(bounds.Address, bounds.Size);
|
BufferRange buffer = GetBufferRange(bounds.Address, bounds.Size);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindStorageBuffer(index, ShaderStage.Compute, buffer);
|
_context.Renderer.Pipeline.SetStorageBuffer(index, ShaderStage.Compute, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
enableMask = _cpUniformBuffers.EnableMask;
|
enableMask = _cpUniformBuffers.EnableMask;
|
||||||
|
@ -326,7 +325,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
|
|
||||||
BufferRange buffer = GetBufferRange(bounds.Address, bounds.Size);
|
BufferRange buffer = GetBufferRange(bounds.Address, bounds.Size);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindUniformBuffer(index, ShaderStage.Compute, buffer);
|
_context.Renderer.Pipeline.SetUniformBuffer(index, ShaderStage.Compute, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force rebind after doing compute work.
|
// Force rebind after doing compute work.
|
||||||
|
@ -343,7 +342,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
{
|
{
|
||||||
BufferRange buffer = GetBufferRange(_indexBuffer.Address, _indexBuffer.Size);
|
BufferRange buffer = GetBufferRange(_indexBuffer.Address, _indexBuffer.Size);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindIndexBuffer(buffer, _indexBuffer.Type);
|
_context.Renderer.Pipeline.SetIndexBuffer(buffer, _indexBuffer.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_indexBuffer.Address != 0)
|
else if (_indexBuffer.Address != 0)
|
||||||
|
@ -373,7 +372,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
vertexBuffers[index] = new VertexBufferDescriptor(buffer, vb.Stride, vb.Divisor);
|
vertexBuffers[index] = new VertexBufferDescriptor(buffer, vb.Stride, vb.Divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Renderer.Pipeline.BindVertexBuffers(vertexBuffers);
|
_context.Renderer.Pipeline.SetVertexBuffers(vertexBuffers);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -468,11 +467,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
|
|
||||||
if (isStorage)
|
if (isStorage)
|
||||||
{
|
{
|
||||||
_context.Renderer.Pipeline.BindStorageBuffer(index, stage, buffer);
|
_context.Renderer.Pipeline.SetStorageBuffer(index, stage, buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_context.Renderer.Pipeline.BindUniformBuffer(index, stage, buffer);
|
_context.Renderer.Pipeline.SetUniformBuffer(index, stage, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Shader
|
namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
{
|
{
|
||||||
|
using TextureDescriptor = Image.TextureDescriptor;
|
||||||
|
|
||||||
class ShaderCache
|
class ShaderCache
|
||||||
{
|
{
|
||||||
private const int MaxProgramSize = 0x100000;
|
private const int MaxProgramSize = 0x100000;
|
||||||
|
@ -374,7 +376,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
return !descriptor.UnpackTextureCoordNormalized() && is2DTexture;
|
return !descriptor.UnpackTextureCoordNormalized() && is2DTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image.TextureDescriptor GetTextureDescriptor(GpuState state, int stageIndex, int index)
|
private TextureDescriptor GetTextureDescriptor(GpuState state, int stageIndex, int index)
|
||||||
{
|
{
|
||||||
return _context.Methods.TextureManager.GetGraphicsTextureDescriptor(state, stageIndex, index);
|
return _context.Methods.TextureManager.GetGraphicsTextureDescriptor(state, stageIndex, index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Blend;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.State
|
namespace Ryujinx.Graphics.Gpu.State
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL.Blend;
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.State
|
namespace Ryujinx.Graphics.Gpu.State
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.DepthStencil;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.State
|
namespace Ryujinx.Graphics.Gpu.State
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.DepthStencil;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.State
|
namespace Ryujinx.Graphics.Gpu.State
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu
|
namespace Ryujinx.Graphics.Gpu
|
||||||
{
|
{
|
||||||
|
using Texture = Image.Texture;
|
||||||
|
|
||||||
public class Window
|
public class Window
|
||||||
{
|
{
|
||||||
private GpuContext _context;
|
private readonly GpuContext _context;
|
||||||
|
|
||||||
private struct PresentationTexture
|
private struct PresentationTexture
|
||||||
{
|
{
|
||||||
|
@ -30,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentQueue<PresentationTexture> _frameQueue;
|
private readonly ConcurrentQueue<PresentationTexture> _frameQueue;
|
||||||
|
|
||||||
public Window(GpuContext context)
|
public Window(GpuContext context)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +80,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
|
|
||||||
if (_frameQueue.TryDequeue(out PresentationTexture pt))
|
if (_frameQueue.TryDequeue(out PresentationTexture pt))
|
||||||
{
|
{
|
||||||
Image.Texture texture = _context.Methods.TextureManager.FindOrCreateTexture(pt.Info);
|
Texture texture = _context.Methods.TextureManager.FindOrCreateTexture(pt.Info);
|
||||||
|
|
||||||
texture.SynchronizeMemory();
|
texture.SynchronizeMemory();
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Blend;
|
|
||||||
using Ryujinx.Graphics.GAL.Sampler;
|
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
|
@ -334,31 +331,31 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
return PrimitiveType.Points;
|
return PrimitiveType.Points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StencilOp Convert(this GAL.DepthStencil.StencilOp op)
|
public static OpenTK.Graphics.OpenGL.StencilOp Convert(this GAL.StencilOp op)
|
||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case GAL.DepthStencil.StencilOp.Keep:
|
case GAL.StencilOp.Keep:
|
||||||
return StencilOp.Keep;
|
return OpenTK.Graphics.OpenGL.StencilOp.Keep;
|
||||||
case GAL.DepthStencil.StencilOp.Zero:
|
case GAL.StencilOp.Zero:
|
||||||
return StencilOp.Zero;
|
return OpenTK.Graphics.OpenGL.StencilOp.Zero;
|
||||||
case GAL.DepthStencil.StencilOp.Replace:
|
case GAL.StencilOp.Replace:
|
||||||
return StencilOp.Replace;
|
return OpenTK.Graphics.OpenGL.StencilOp.Replace;
|
||||||
case GAL.DepthStencil.StencilOp.IncrementAndClamp:
|
case GAL.StencilOp.IncrementAndClamp:
|
||||||
return StencilOp.Incr;
|
return OpenTK.Graphics.OpenGL.StencilOp.Incr;
|
||||||
case GAL.DepthStencil.StencilOp.DecrementAndClamp:
|
case GAL.StencilOp.DecrementAndClamp:
|
||||||
return StencilOp.Decr;
|
return OpenTK.Graphics.OpenGL.StencilOp.Decr;
|
||||||
case GAL.DepthStencil.StencilOp.Invert:
|
case GAL.StencilOp.Invert:
|
||||||
return StencilOp.Invert;
|
return OpenTK.Graphics.OpenGL.StencilOp.Invert;
|
||||||
case GAL.DepthStencil.StencilOp.IncrementAndWrap:
|
case GAL.StencilOp.IncrementAndWrap:
|
||||||
return StencilOp.IncrWrap;
|
return OpenTK.Graphics.OpenGL.StencilOp.IncrWrap;
|
||||||
case GAL.DepthStencil.StencilOp.DecrementAndWrap:
|
case GAL.StencilOp.DecrementAndWrap:
|
||||||
return StencilOp.DecrWrap;
|
return OpenTK.Graphics.OpenGL.StencilOp.DecrWrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.PrintError(LogClass.Gpu, $"Invalid {nameof(GAL.DepthStencil.StencilOp)} enum value: {op}.");
|
Logger.PrintError(LogClass.Gpu, $"Invalid {nameof(GAL.StencilOp)} enum value: {op}.");
|
||||||
|
|
||||||
return StencilOp.Keep;
|
return OpenTK.Graphics.OpenGL.StencilOp.Keep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static All Convert(this SwizzleComponent swizzleComponent)
|
public static All Convert(this SwizzleComponent swizzleComponent)
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Blend;
|
|
||||||
using Ryujinx.Graphics.GAL.Color;
|
|
||||||
using Ryujinx.Graphics.GAL.DepthStencil;
|
|
||||||
using Ryujinx.Graphics.GAL.InputAssembler;
|
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -41,166 +37,6 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_clipDepthMode = ClipDepthMode.NegativeOneToOne;
|
_clipDepthMode = ClipDepthMode.NegativeOneToOne;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindBlendState(int index, BlendDescriptor blend)
|
|
||||||
{
|
|
||||||
if (!blend.Enable)
|
|
||||||
{
|
|
||||||
GL.Disable(IndexedEnableCap.Blend, index);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL.BlendEquationSeparate(
|
|
||||||
index,
|
|
||||||
blend.ColorOp.Convert(),
|
|
||||||
blend.AlphaOp.Convert());
|
|
||||||
|
|
||||||
GL.BlendFuncSeparate(
|
|
||||||
index,
|
|
||||||
(BlendingFactorSrc) blend.ColorSrcFactor.Convert(),
|
|
||||||
(BlendingFactorDest)blend.ColorDstFactor.Convert(),
|
|
||||||
(BlendingFactorSrc) blend.AlphaSrcFactor.Convert(),
|
|
||||||
(BlendingFactorDest)blend.AlphaDstFactor.Convert());
|
|
||||||
|
|
||||||
GL.Enable(IndexedEnableCap.Blend, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindImage(int index, ShaderStage stage, ITexture texture)
|
|
||||||
{
|
|
||||||
int unit = _program.GetImageUnit(stage, index);
|
|
||||||
|
|
||||||
if (unit != -1 && texture != null)
|
|
||||||
{
|
|
||||||
TextureView view = (TextureView)texture;
|
|
||||||
|
|
||||||
FormatInfo formatInfo = FormatTable.GetFormatInfo(view.Format);
|
|
||||||
|
|
||||||
SizedInternalFormat format = (SizedInternalFormat)formatInfo.PixelInternalFormat;
|
|
||||||
|
|
||||||
GL.BindImageTexture(
|
|
||||||
unit,
|
|
||||||
view.Handle,
|
|
||||||
0,
|
|
||||||
true,
|
|
||||||
0,
|
|
||||||
TextureAccess.ReadWrite,
|
|
||||||
format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindIndexBuffer(BufferRange buffer, IndexType type)
|
|
||||||
{
|
|
||||||
_elementsType = type.Convert();
|
|
||||||
|
|
||||||
_indexBaseOffset = (IntPtr)buffer.Offset;
|
|
||||||
|
|
||||||
EnsureVertexArray();
|
|
||||||
|
|
||||||
_vertexArray.SetIndexBuffer((Buffer)buffer.Buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindProgram(IProgram program)
|
|
||||||
{
|
|
||||||
_program = (Program)program;
|
|
||||||
|
|
||||||
_program.Bind();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindSampler(int index, ShaderStage stage, ISampler sampler)
|
|
||||||
{
|
|
||||||
int unit = _program.GetTextureUnit(stage, index);
|
|
||||||
|
|
||||||
if (unit != -1 && sampler != null)
|
|
||||||
{
|
|
||||||
((Sampler)sampler).Bind(unit);
|
|
||||||
}
|
|
||||||
else if (unit == -1)
|
|
||||||
{
|
|
||||||
Logger.PrintError(LogClass.Gpu, $"Invalid binding point: {stage} {index}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindTexture(int index, ShaderStage stage, ITexture texture)
|
|
||||||
{
|
|
||||||
int unit = _program.GetTextureUnit(stage, index);
|
|
||||||
|
|
||||||
if (unit != -1 && texture != null)
|
|
||||||
{
|
|
||||||
if (unit == 0)
|
|
||||||
{
|
|
||||||
_unit0Texture = ((TextureView)texture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
((TextureView)texture).Bind(unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (unit == -1)
|
|
||||||
{
|
|
||||||
Logger.PrintError(LogClass.Gpu, $"Invalid binding point: {stage} {index}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindStorageBuffer(int index, ShaderStage stage, BufferRange buffer)
|
|
||||||
{
|
|
||||||
BindBuffer(index, stage, buffer, isStorage: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindUniformBuffer(int index, ShaderStage stage, BufferRange buffer)
|
|
||||||
{
|
|
||||||
BindBuffer(index, stage, buffer, isStorage: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BindBuffer(int index, ShaderStage stage, BufferRange buffer, bool isStorage)
|
|
||||||
{
|
|
||||||
int bindingPoint = isStorage
|
|
||||||
? _program.GetStorageBufferBindingPoint(stage, index)
|
|
||||||
: _program.GetUniformBufferBindingPoint(stage, index);
|
|
||||||
|
|
||||||
if (bindingPoint == -1)
|
|
||||||
{
|
|
||||||
Logger.PrintError(LogClass.Gpu, $"Invalid binding point: {stage} {index}.");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferRangeTarget target = isStorage
|
|
||||||
? BufferRangeTarget.ShaderStorageBuffer
|
|
||||||
: BufferRangeTarget.UniformBuffer;
|
|
||||||
|
|
||||||
if (buffer.Buffer == null)
|
|
||||||
{
|
|
||||||
GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bufferHandle = ((Buffer)buffer.Buffer).Handle;
|
|
||||||
|
|
||||||
IntPtr bufferOffset = (IntPtr)buffer.Offset;
|
|
||||||
|
|
||||||
GL.BindBufferRange(
|
|
||||||
target,
|
|
||||||
bindingPoint,
|
|
||||||
bufferHandle,
|
|
||||||
bufferOffset,
|
|
||||||
buffer.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindVertexAttribs(VertexAttribDescriptor[] vertexAttribs)
|
|
||||||
{
|
|
||||||
EnsureVertexArray();
|
|
||||||
|
|
||||||
_vertexArray.SetVertexAttributes(vertexAttribs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindVertexBuffers(VertexBufferDescriptor[] vertexBuffers)
|
|
||||||
{
|
|
||||||
EnsureVertexArray();
|
|
||||||
|
|
||||||
_vertexArray.SetVertexBuffers(vertexBuffers);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearRenderTargetColor(int index, uint componentMask, ColorF color)
|
public void ClearRenderTargetColor(int index, uint componentMask, ColorF color)
|
||||||
{
|
{
|
||||||
GL.ColorMask(
|
GL.ColorMask(
|
||||||
|
@ -217,43 +53,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
RestoreComponentMask(index);
|
RestoreComponentMask(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearRenderTargetColor(int index, uint componentMask, ColorSI color)
|
public void ClearRenderTargetDepthStencil(float depthValue, bool depthMask, int stencilValue, int stencilMask)
|
||||||
{
|
|
||||||
GL.ColorMask(
|
|
||||||
index,
|
|
||||||
(componentMask & 1u) != 0,
|
|
||||||
(componentMask & 2u) != 0,
|
|
||||||
(componentMask & 4u) != 0,
|
|
||||||
(componentMask & 8u) != 0);
|
|
||||||
|
|
||||||
int[] colors = new int[] { color.Red, color.Green, color.Blue, color.Alpha };
|
|
||||||
|
|
||||||
GL.ClearBuffer(ClearBuffer.Color, index, colors);
|
|
||||||
|
|
||||||
RestoreComponentMask(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearRenderTargetColor(int index, uint componentMask, ColorUI color)
|
|
||||||
{
|
|
||||||
GL.ColorMask(
|
|
||||||
index,
|
|
||||||
(componentMask & 1u) != 0,
|
|
||||||
(componentMask & 2u) != 0,
|
|
||||||
(componentMask & 4u) != 0,
|
|
||||||
(componentMask & 8u) != 0);
|
|
||||||
|
|
||||||
uint[] colors = new uint[] { color.Red, color.Green, color.Blue, color.Alpha };
|
|
||||||
|
|
||||||
GL.ClearBuffer(ClearBuffer.Color, index, colors);
|
|
||||||
|
|
||||||
RestoreComponentMask(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearRenderTargetDepthStencil(
|
|
||||||
float depthValue,
|
|
||||||
bool depthMask,
|
|
||||||
int stencilValue,
|
|
||||||
int stencilMask)
|
|
||||||
{
|
{
|
||||||
bool stencilMaskChanged =
|
bool stencilMaskChanged =
|
||||||
stencilMask != 0 &&
|
stencilMask != 0 &&
|
||||||
|
@ -295,7 +95,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispatch(int groupsX, int groupsY, int groupsZ)
|
public void DispatchCompute(int groupsX, int groupsY, int groupsZ)
|
||||||
{
|
{
|
||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
|
@ -607,21 +407,35 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirect(BufferRange buffer, ulong offset, int drawCount, int stride)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DrawIndexedIndirect(BufferRange buffer, ulong offset, int drawCount, int stride)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetBlendColor(ColorF color)
|
public void SetBlendColor(ColorF color)
|
||||||
{
|
{
|
||||||
GL.BlendColor(color.Red, color.Green, color.Blue, color.Alpha);
|
GL.BlendColor(color.Red, color.Green, color.Blue, color.Alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetBlendState(int index, BlendDescriptor blend)
|
||||||
|
{
|
||||||
|
if (!blend.Enable)
|
||||||
|
{
|
||||||
|
GL.Disable(IndexedEnableCap.Blend, index);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL.BlendEquationSeparate(
|
||||||
|
index,
|
||||||
|
blend.ColorOp.Convert(),
|
||||||
|
blend.AlphaOp.Convert());
|
||||||
|
|
||||||
|
GL.BlendFuncSeparate(
|
||||||
|
index,
|
||||||
|
(BlendingFactorSrc)blend.ColorSrcFactor.Convert(),
|
||||||
|
(BlendingFactorDest)blend.ColorDstFactor.Convert(),
|
||||||
|
(BlendingFactorSrc)blend.AlphaSrcFactor.Convert(),
|
||||||
|
(BlendingFactorDest)blend.AlphaDstFactor.Convert());
|
||||||
|
|
||||||
|
GL.Enable(IndexedEnableCap.Blend, index);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
||||||
{
|
{
|
||||||
if ((enables & PolygonModeMask.Point) != 0)
|
if ((enables & PolygonModeMask.Point) != 0)
|
||||||
|
@ -701,6 +515,33 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
GL.FrontFace(frontFace.Convert());
|
GL.FrontFace(frontFace.Convert());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetImage(int index, ShaderStage stage, ITexture texture)
|
||||||
|
{
|
||||||
|
int unit = _program.GetImageUnit(stage, index);
|
||||||
|
|
||||||
|
if (unit != -1 && texture != null)
|
||||||
|
{
|
||||||
|
TextureView view = (TextureView)texture;
|
||||||
|
|
||||||
|
FormatInfo formatInfo = FormatTable.GetFormatInfo(view.Format);
|
||||||
|
|
||||||
|
SizedInternalFormat format = (SizedInternalFormat)formatInfo.PixelInternalFormat;
|
||||||
|
|
||||||
|
GL.BindImageTexture(unit, view.Handle, 0, true, 0, TextureAccess.ReadWrite, format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIndexBuffer(BufferRange buffer, IndexType type)
|
||||||
|
{
|
||||||
|
_elementsType = type.Convert();
|
||||||
|
|
||||||
|
_indexBaseOffset = (IntPtr)buffer.Offset;
|
||||||
|
|
||||||
|
EnsureVertexArray();
|
||||||
|
|
||||||
|
_vertexArray.SetIndexBuffer((Buffer)buffer.Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetPrimitiveRestart(bool enable, int index)
|
public void SetPrimitiveRestart(bool enable, int index)
|
||||||
{
|
{
|
||||||
if (!enable)
|
if (!enable)
|
||||||
|
@ -720,6 +561,13 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_primitiveType = topology.Convert();
|
_primitiveType = topology.Convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetProgram(IProgram program)
|
||||||
|
{
|
||||||
|
_program = (Program)program;
|
||||||
|
|
||||||
|
_program.Bind();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetRenderTargetColorMasks(uint[] componentMasks)
|
public void SetRenderTargetColorMasks(uint[] componentMasks)
|
||||||
{
|
{
|
||||||
_componentMasks = (uint[])componentMasks.Clone();
|
_componentMasks = (uint[])componentMasks.Clone();
|
||||||
|
@ -752,6 +600,20 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
UpdateDepthTest();
|
UpdateDepthTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetSampler(int index, ShaderStage stage, ISampler sampler)
|
||||||
|
{
|
||||||
|
int unit = _program.GetTextureUnit(stage, index);
|
||||||
|
|
||||||
|
if (unit != -1 && sampler != null)
|
||||||
|
{
|
||||||
|
((Sampler)sampler).Bind(unit);
|
||||||
|
}
|
||||||
|
else if (unit == -1)
|
||||||
|
{
|
||||||
|
Logger.PrintError(LogClass.Gpu, $"Invalid binding point: {stage} {index}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetStencilTest(StencilTestDescriptor stencilTest)
|
public void SetStencilTest(StencilTestDescriptor stencilTest)
|
||||||
{
|
{
|
||||||
if (!stencilTest.TestEnable)
|
if (!stencilTest.TestEnable)
|
||||||
|
@ -794,6 +656,51 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_stencilFrontMask = stencilTest.FrontMask;
|
_stencilFrontMask = stencilTest.FrontMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetStorageBuffer(int index, ShaderStage stage, BufferRange buffer)
|
||||||
|
{
|
||||||
|
SetBuffer(index, stage, buffer, isStorage: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTexture(int index, ShaderStage stage, ITexture texture)
|
||||||
|
{
|
||||||
|
int unit = _program.GetTextureUnit(stage, index);
|
||||||
|
|
||||||
|
if (unit != -1 && texture != null)
|
||||||
|
{
|
||||||
|
if (unit == 0)
|
||||||
|
{
|
||||||
|
_unit0Texture = ((TextureView)texture);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((TextureView)texture).Bind(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (unit == -1)
|
||||||
|
{
|
||||||
|
Logger.PrintError(LogClass.Gpu, $"Invalid binding point: {stage} {index}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetUniformBuffer(int index, ShaderStage stage, BufferRange buffer)
|
||||||
|
{
|
||||||
|
SetBuffer(index, stage, buffer, isStorage: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetVertexAttribs(VertexAttribDescriptor[] vertexAttribs)
|
||||||
|
{
|
||||||
|
EnsureVertexArray();
|
||||||
|
|
||||||
|
_vertexArray.SetVertexAttributes(vertexAttribs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetVertexBuffers(VertexBufferDescriptor[] vertexBuffers)
|
||||||
|
{
|
||||||
|
EnsureVertexArray();
|
||||||
|
|
||||||
|
_vertexArray.SetVertexBuffers(vertexBuffers);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetViewports(int first, Viewport[] viewports)
|
public void SetViewports(int first, Viewport[] viewports)
|
||||||
{
|
{
|
||||||
bool flipY = false;
|
bool flipY = false;
|
||||||
|
@ -848,6 +755,37 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
GL.MemoryBarrier(MemoryBarrierFlags.TextureFetchBarrierBit);
|
GL.MemoryBarrier(MemoryBarrierFlags.TextureFetchBarrierBit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetBuffer(int index, ShaderStage stage, BufferRange buffer, bool isStorage)
|
||||||
|
{
|
||||||
|
int bindingPoint = isStorage
|
||||||
|
? _program.GetStorageBufferBindingPoint(stage, index)
|
||||||
|
: _program.GetUniformBufferBindingPoint(stage, index);
|
||||||
|
|
||||||
|
if (bindingPoint == -1)
|
||||||
|
{
|
||||||
|
Logger.PrintError(LogClass.Gpu, $"Invalid binding point: {stage} {index}.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferRangeTarget target = isStorage
|
||||||
|
? BufferRangeTarget.ShaderStorageBuffer
|
||||||
|
: BufferRangeTarget.UniformBuffer;
|
||||||
|
|
||||||
|
if (buffer.Buffer == null)
|
||||||
|
{
|
||||||
|
GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bufferHandle = ((Buffer)buffer.Buffer).Handle;
|
||||||
|
|
||||||
|
IntPtr bufferOffset = (IntPtr)buffer.Offset;
|
||||||
|
|
||||||
|
GL.BindBufferRange(target, bindingPoint, bufferHandle, bufferOffset, buffer.Size);
|
||||||
|
}
|
||||||
|
|
||||||
private void SetOrigin(ClipOrigin origin)
|
private void SetOrigin(ClipOrigin origin)
|
||||||
{
|
{
|
||||||
if (_clipOrigin != origin)
|
if (_clipOrigin != origin)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Sampler;
|
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
|
@ -10,9 +8,9 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
public IPipeline Pipeline { get; }
|
public IPipeline Pipeline { get; }
|
||||||
|
|
||||||
private Counters _counters;
|
private readonly Counters _counters;
|
||||||
|
|
||||||
private Window _window;
|
private readonly Window _window;
|
||||||
|
|
||||||
public IWindow Window => _window;
|
public IWindow Window => _window;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
|
||||||
using Ryujinx.Graphics.GAL.Sampler;
|
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
using Ryujinx.Graphics.GAL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using Ryujinx.Common;
|
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
using Ryujinx.Common;
|
||||||
|
using Ryujinx.Graphics.GAL;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
|
@ -9,9 +8,9 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
public int Handle { get; private set; }
|
public int Handle { get; private set; }
|
||||||
|
|
||||||
private Renderer _renderer;
|
private readonly Renderer _renderer;
|
||||||
|
|
||||||
private TextureCreateInfo _info;
|
private readonly TextureCreateInfo _info;
|
||||||
|
|
||||||
public Target Target => _info.Target;
|
public Target Target => _info.Target;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Texture;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
|
@ -9,13 +8,13 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
public int Handle { get; private set; }
|
public int Handle { get; private set; }
|
||||||
|
|
||||||
private Renderer _renderer;
|
private readonly Renderer _renderer;
|
||||||
|
|
||||||
private TextureStorage _parent;
|
private readonly TextureStorage _parent;
|
||||||
|
|
||||||
private TextureView _emulatedViewParent;
|
private TextureView _emulatedViewParent;
|
||||||
|
|
||||||
private TextureCreateInfo _info;
|
private readonly TextureCreateInfo _info;
|
||||||
|
|
||||||
private int _firstLayer;
|
private int _firstLayer;
|
||||||
private int _firstLevel;
|
private int _firstLevel;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using Ryujinx.Graphics.GAL.InputAssembler;
|
using Ryujinx.Graphics.GAL;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Ryujinx.Graphics.Shader.Translation;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions;
|
using Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions;
|
||||||
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||||
|
using Ryujinx.Graphics.Shader.Translation;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using static Ryujinx.Graphics.Shader.CodeGen.Glsl.TypeConversion;
|
using static Ryujinx.Graphics.Shader.CodeGen.Glsl.TypeConversion;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using Ryujinx.Graphics.Shader.Translation;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader
|
namespace Ryujinx.Graphics.Shader.Translation
|
||||||
{
|
{
|
||||||
struct ShaderConfig
|
struct ShaderConfig
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@ using Ryujinx.Graphics.Shader.Decoders;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader
|
namespace Ryujinx.Graphics.Shader.Translation
|
||||||
{
|
{
|
||||||
struct OutputMapTarget
|
struct OutputMapTarget
|
||||||
{
|
{
|
Loading…
Reference in a new issue