Implement HLE macros for render target clears (#3528)
* Implement HLE macros for render target clears * Add constants for the offsets
This commit is contained in:
parent
c48a75979f
commit
1080f64df9
16 changed files with 149 additions and 43 deletions
|
@ -12,6 +12,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
/// </summary>
|
||||
class MacroHLE : IMacroEE
|
||||
{
|
||||
private const int ColorLayerCountOffset = 0x818;
|
||||
private const int ColorStructSize = 0x40;
|
||||
private const int ZetaLayerCountOffset = 0x1230;
|
||||
|
||||
private readonly GPFifoProcessor _processor;
|
||||
private readonly MacroHLEFunctionName _functionName;
|
||||
|
||||
|
@ -45,6 +49,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
{
|
||||
switch (_functionName)
|
||||
{
|
||||
case MacroHLEFunctionName.ClearColor:
|
||||
ClearColor(state, arg0);
|
||||
break;
|
||||
case MacroHLEFunctionName.ClearDepthStencil:
|
||||
ClearDepthStencil(state, arg0);
|
||||
break;
|
||||
case MacroHLEFunctionName.MultiDrawElementsIndirectCount:
|
||||
MultiDrawElementsIndirectCount(state, arg0);
|
||||
break;
|
||||
|
@ -53,6 +63,31 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears one bound color target.
|
||||
/// </summary>
|
||||
/// <param name="state">GPU state at the time of the call</param>
|
||||
/// <param name="arg0">First argument of the call</param>
|
||||
private void ClearColor(IDeviceState state, int arg0)
|
||||
{
|
||||
int index = (arg0 >> 6) & 0xf;
|
||||
int layerCount = state.Read(ColorLayerCountOffset + index * ColorStructSize);
|
||||
|
||||
_processor.ThreedClass.Clear(arg0, layerCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current depth-stencil target.
|
||||
/// </summary>
|
||||
/// <param name="state">GPU state at the time of the call</param>
|
||||
/// <param name="arg0">First argument of the call</param>
|
||||
private void ClearDepthStencil(IDeviceState state, int arg0)
|
||||
{
|
||||
int layerCount = state.Read(ZetaLayerCountOffset);
|
||||
|
||||
_processor.ThreedClass.Clear(arg0, layerCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a indirect multi-draw, with parameters from a GPU buffer.
|
||||
/// </summary>
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
enum MacroHLEFunctionName
|
||||
{
|
||||
None,
|
||||
ClearColor,
|
||||
ClearDepthStencil,
|
||||
MultiDrawElementsIndirectCount
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,12 +46,19 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
|
||||
private static readonly TableEntry[] Table = new TableEntry[]
|
||||
{
|
||||
new TableEntry(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28),
|
||||
new TableEntry(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24),
|
||||
new TableEntry(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C)
|
||||
};
|
||||
|
||||
private static bool IsMacroHLESupported(Capabilities caps, MacroHLEFunctionName name)
|
||||
{
|
||||
if (name == MacroHLEFunctionName.MultiDrawElementsIndirectCount)
|
||||
if (name == MacroHLEFunctionName.ClearColor ||
|
||||
name == MacroHLEFunctionName.ClearDepthStencil)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (name == MacroHLEFunctionName.MultiDrawElementsIndirectCount)
|
||||
{
|
||||
return caps.SupportsIndirectParameters;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue