Add TEX texture types and 1D and 3D textures support. Stub depth
This commit is contained in:
parent
56fde4c02d
commit
3bc53382c8
6 changed files with 75 additions and 50 deletions
|
@ -91,38 +91,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
const int Level = 0;
|
||||
const int Border = 0;
|
||||
|
||||
switch (Target)
|
||||
{
|
||||
case TextureTarget.Texture2D:
|
||||
GL.TexImage2D(
|
||||
Target,
|
||||
Level,
|
||||
InternalFormat,
|
||||
Image.Width,
|
||||
Image.Height,
|
||||
Border,
|
||||
PixelFormat,
|
||||
PixelType,
|
||||
IntPtr.Zero);
|
||||
break;
|
||||
|
||||
case TextureTarget.Texture2DArray:
|
||||
GL.TexImage3D(
|
||||
Target,
|
||||
Level,
|
||||
InternalFormat,
|
||||
Image.Width,
|
||||
Image.Height,
|
||||
Image.Depth,
|
||||
Border,
|
||||
PixelFormat,
|
||||
PixelType,
|
||||
IntPtr.Zero);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException(Target.ToString());
|
||||
}
|
||||
OGLHelper.TexImage(
|
||||
Target,
|
||||
Level,
|
||||
InternalFormat,
|
||||
Image.Width,
|
||||
Image.Height,
|
||||
Image.Depth,
|
||||
Border,
|
||||
PixelFormat,
|
||||
PixelType,
|
||||
null);
|
||||
|
||||
if (Initialized)
|
||||
{
|
||||
|
|
|
@ -304,8 +304,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
switch (Target)
|
||||
{
|
||||
case GalImageTarget._1d: return TextureTarget.Texture1D;
|
||||
case GalImageTarget._2d: return TextureTarget.Texture2D;
|
||||
case GalImageTarget._2dArray: return TextureTarget.Texture2DArray;
|
||||
case GalImageTarget._3d: return TextureTarget.Texture3D;
|
||||
case GalImageTarget.CubeMap: return TextureTarget.TextureCubeMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
switch (Target)
|
||||
{
|
||||
case TextureTarget.Texture1D:
|
||||
GL.TexImage1D(
|
||||
Target,
|
||||
Level,
|
||||
InternalFormat,
|
||||
Width,
|
||||
Border,
|
||||
PixelFormat,
|
||||
PixelType,
|
||||
Data);
|
||||
break;
|
||||
|
||||
case TextureTarget.Texture2D:
|
||||
GL.TexImage2D(
|
||||
Target,
|
||||
|
@ -33,6 +45,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
break;
|
||||
|
||||
case TextureTarget.Texture2DArray:
|
||||
case TextureTarget.Texture3D:
|
||||
//FIXME: Unstub depth when swizzle is fixed
|
||||
Depth = 1;
|
||||
GL.TexImage3D(
|
||||
Target,
|
||||
Level,
|
||||
|
@ -110,6 +125,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
break;
|
||||
|
||||
case TextureTarget.Texture2DArray:
|
||||
case TextureTarget.Texture3D:
|
||||
//FIXME: Unstub depth when swizzle is fixed
|
||||
Depth = 1;
|
||||
GL.CompressedTexImage3D(
|
||||
Target,
|
||||
Level,
|
||||
|
|
|
@ -145,8 +145,6 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
{
|
||||
SB = new StringBuilder();
|
||||
|
||||
SB.AppendLine("#version 410 core");
|
||||
|
||||
PrintDeclHeader();
|
||||
PrintDeclTextures();
|
||||
PrintDeclUniforms();
|
||||
|
@ -185,6 +183,8 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
|
||||
private void PrintDeclHeader()
|
||||
{
|
||||
SB.AppendLine("#version 410 core");
|
||||
|
||||
if (Decl.ShaderType == GalShaderType.Geometry)
|
||||
{
|
||||
int MaxVertices = Header.MaxOutputVertexCount;
|
||||
|
@ -209,9 +209,9 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
SB.AppendLine("layout(triangles) in;" + Environment.NewLine);
|
||||
|
||||
SB.AppendLine($"layout({OutputTopology}, max_vertices = {MaxVertices}) out;");
|
||||
|
||||
SB.AppendLine();
|
||||
}
|
||||
|
||||
SB.AppendLine();
|
||||
}
|
||||
|
||||
private void PrintDeclTextures()
|
||||
|
@ -259,11 +259,9 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
|
||||
SB.AppendLine(IdentationStr + "int " + GlslDecl.InstanceUniformName + ";");
|
||||
|
||||
SB.AppendLine("};");
|
||||
SB.AppendLine("};" + Environment.NewLine);
|
||||
}
|
||||
|
||||
SB.AppendLine();
|
||||
|
||||
foreach (ShaderDeclInfo DeclInfo in Decl.Uniforms.Values.OrderBy(DeclKeySelector))
|
||||
{
|
||||
SB.AppendLine($"layout (std140) uniform {DeclInfo.Name} {{");
|
||||
|
@ -1217,11 +1215,15 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
GetOperExpr(Op, Op.OperandB) + ", " +
|
||||
GetOperExpr(Op, Op.OperandC) + ")";
|
||||
}
|
||||
else
|
||||
else if (Op.OperandB != null)
|
||||
{
|
||||
return "vec2(" + GetOperExpr(Op, Op.OperandA) + ", " +
|
||||
GetOperExpr(Op, Op.OperandB) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetOperExpr(Op, Op.OperandA);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetITexSamplerCoords(ShaderIrOp Op)
|
||||
|
@ -1232,11 +1234,15 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
GetOperExpr(Op, Op.OperandB) + ", " +
|
||||
GetOperExpr(Op, Op.OperandC) + ")";
|
||||
}
|
||||
else
|
||||
else if (Op.OperandB != null)
|
||||
{
|
||||
return "ivec2(" + GetOperExpr(Op, Op.OperandA) + ", " +
|
||||
GetOperExpr(Op, Op.OperandB) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetOperExpr(Op, Op.OperandA);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetOperExpr(ShaderIrOp Op, ShaderIrNode Oper)
|
||||
|
@ -1383,8 +1389,10 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
{
|
||||
switch (Type)
|
||||
{
|
||||
case ShaderTextureType._1d: return "sampler1D";
|
||||
case ShaderTextureType._2d: return "sampler2D";
|
||||
case ShaderTextureType._2dArray: return "sampler2DArray";
|
||||
case ShaderTextureType._3d: return "sampler3D";
|
||||
case ShaderTextureType.Cube: return "samplerCube";
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,16 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
{ RGB_, RG_A, R_BA, _GBA, RGBA, ____, ____, ____ }
|
||||
};
|
||||
|
||||
private static ShaderTextureType[] TexTypes = new ShaderTextureType[]
|
||||
{
|
||||
ShaderTextureType._1d,
|
||||
ShaderTextureType._2d,
|
||||
ShaderTextureType._3d,
|
||||
ShaderTextureType.Cube,
|
||||
};
|
||||
|
||||
private static int[] TexTypeCoords = new int[] { 1, 2, 3, 3 };
|
||||
|
||||
private static ShaderTextureType[] TexsTypes = new ShaderTextureType[]
|
||||
{
|
||||
ShaderTextureType._1d,
|
||||
|
@ -159,14 +169,15 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
|
||||
private static void EmitTex(ShaderIrBlock Block, long OpCode, bool GprHandle)
|
||||
{
|
||||
//TODO: Support other formats.
|
||||
ShaderIrOperGpr[] Coords = new ShaderIrOperGpr[2];
|
||||
int TypeId = (int)((OpCode >> 29) & 3);
|
||||
|
||||
for (int Index = 0; Index < Coords.Length; Index++)
|
||||
ShaderIrOperGpr[] Coords = new ShaderIrOperGpr[3];
|
||||
|
||||
ShaderTextureType Type = TexTypes[TypeId];
|
||||
|
||||
for (int Index = 0; Index < TexTypeCoords[TypeId]; Index++)
|
||||
{
|
||||
Coords[Index] = GetOperGpr8(OpCode);
|
||||
|
||||
Coords[Index].Index += Index;
|
||||
Coords[Index] = GetOperGpr8(OpCode) + Index;
|
||||
|
||||
if (Coords[Index].Index > ShaderIrOperGpr.ZRIndex)
|
||||
{
|
||||
|
@ -186,9 +197,9 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
{
|
||||
ShaderIrOperGpr Dst = new ShaderIrOperGpr(TempRegStart + Ch);
|
||||
|
||||
ShaderIrMetaTex Meta = new ShaderIrMetaTex(ShaderTextureType._2d, TextureIndex, Ch);
|
||||
ShaderIrMetaTex Meta = new ShaderIrMetaTex(Type, TextureIndex, Ch);
|
||||
|
||||
ShaderIrOp Op = new ShaderIrOp(Inst, Coords[0], Coords[1], null, Meta);
|
||||
ShaderIrOp Op = new ShaderIrOp(Inst, Coords[0], Coords[1], Coords[2], Meta);
|
||||
|
||||
Block.AddNode(GetPredNode(new ShaderIrAsg(Dst, Op), OpCode));
|
||||
}
|
||||
|
@ -266,6 +277,13 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
OperC = GetOperGpr8 (OpCode);
|
||||
break;
|
||||
|
||||
//This layout is copy-pasted, complitely untested
|
||||
case ShaderTextureType._3d:
|
||||
OperA = GetOperGpr8(OpCode) + 1;
|
||||
OperB = GetOperGpr20(OpCode);
|
||||
OperC = GetOperGpr8(OpCode);
|
||||
break;
|
||||
|
||||
//Unsure about this layout
|
||||
case ShaderTextureType.Cube:
|
||||
OperA = GetOperGpr8 (OpCode);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Enable_Memory_Checks = false
|
||||
|
||||
#Dump shaders in local directory (e.g. `C:\ShaderDumps`)
|
||||
Graphics_Shaders_Dump_Path =
|
||||
Graphics_Shaders_Dump_Path = D:\Shaders
|
||||
|
||||
#Enable print debug logs
|
||||
Logging_Enable_Debug = false
|
||||
|
|
Loading…
Reference in a new issue