mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-11-27 16:42:22 -05:00
DepthStencil Blits
This commit is contained in:
committed by
Evan Husted
parent
4373610790
commit
40ea153616
@@ -7,35 +7,11 @@ struct CopyVertexOut {
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
struct TexCoords {
|
||||
float data[4];
|
||||
};
|
||||
|
||||
struct ConstantBuffers {
|
||||
constant TexCoords* tex_coord;
|
||||
};
|
||||
|
||||
struct Textures
|
||||
{
|
||||
texture2d_ms<float, access::read> texture;
|
||||
};
|
||||
|
||||
vertex CopyVertexOut vertexMain(uint vid [[vertex_id]],
|
||||
constant ConstantBuffers &constant_buffers [[buffer(20)]]) {
|
||||
CopyVertexOut out;
|
||||
|
||||
int low = vid & 1;
|
||||
int high = vid >> 1;
|
||||
out.uv.x = constant_buffers.tex_coord->data[low];
|
||||
out.uv.y = constant_buffers.tex_coord->data[2 + high];
|
||||
out.position.x = (float(low) - 0.5f) * 2.0f;
|
||||
out.position.y = (float(high) - 0.5f) * 2.0f;
|
||||
out.position.z = 0.0f;
|
||||
out.position.w = 1.0f;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentMain(CopyVertexOut in [[stage_in]],
|
||||
constant Textures &textures [[buffer(22)]],
|
||||
uint sample_id [[sample_id]]) {
|
||||
|
||||
27
src/Ryujinx.Graphics.Metal/Shaders/DepthBlit.metal
Normal file
27
src/Ryujinx.Graphics.Metal/Shaders/DepthBlit.metal
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct CopyVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
struct Textures
|
||||
{
|
||||
texture2d<float, access::sample> texture;
|
||||
sampler sampler;
|
||||
};
|
||||
|
||||
struct FragmentOut {
|
||||
float depth [[depth(any)]];
|
||||
};
|
||||
|
||||
fragment FragmentOut fragmentMain(CopyVertexOut in [[stage_in]],
|
||||
constant Textures &textures [[buffer(22)]]) {
|
||||
FragmentOut out;
|
||||
|
||||
out.depth = textures.texture.sample(textures.sampler, in.uv).r;
|
||||
|
||||
return out;
|
||||
}
|
||||
29
src/Ryujinx.Graphics.Metal/Shaders/DepthBlitMs.metal
Normal file
29
src/Ryujinx.Graphics.Metal/Shaders/DepthBlitMs.metal
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct CopyVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
struct Textures
|
||||
{
|
||||
texture2d_ms<float, access::read> texture;
|
||||
};
|
||||
|
||||
struct FragmentOut {
|
||||
float depth [[depth(any)]];
|
||||
};
|
||||
|
||||
fragment FragmentOut fragmentMain(CopyVertexOut in [[stage_in]],
|
||||
constant Textures &textures [[buffer(22)]],
|
||||
uint sample_id [[sample_id]]) {
|
||||
FragmentOut out;
|
||||
|
||||
uint2 tex_size = uint2(textures.texture.get_width(), textures.texture.get_height());
|
||||
uint2 tex_coord = uint2(in.uv * float2(tex_size));
|
||||
out.depth = textures.texture.read(tex_coord, sample_id).r;
|
||||
|
||||
return out;
|
||||
}
|
||||
27
src/Ryujinx.Graphics.Metal/Shaders/StencilBlit.metal
Normal file
27
src/Ryujinx.Graphics.Metal/Shaders/StencilBlit.metal
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct CopyVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
struct Textures
|
||||
{
|
||||
texture2d<uint, access::sample> texture;
|
||||
sampler sampler;
|
||||
};
|
||||
|
||||
struct FragmentOut {
|
||||
uint stencil [[stencil]];
|
||||
};
|
||||
|
||||
fragment FragmentOut fragmentMain(CopyVertexOut in [[stage_in]],
|
||||
constant Textures &textures [[buffer(22)]]) {
|
||||
FragmentOut out;
|
||||
|
||||
out.stencil = textures.texture.sample(textures.sampler, in.uv).r;
|
||||
|
||||
return out;
|
||||
}
|
||||
29
src/Ryujinx.Graphics.Metal/Shaders/StencilBlitMs.metal
Normal file
29
src/Ryujinx.Graphics.Metal/Shaders/StencilBlitMs.metal
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct CopyVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
struct Textures
|
||||
{
|
||||
texture2d_ms<uint, access::read> texture;
|
||||
};
|
||||
|
||||
struct FragmentOut {
|
||||
uint stencil [[stencil]];
|
||||
};
|
||||
|
||||
fragment FragmentOut fragmentMain(CopyVertexOut in [[stage_in]],
|
||||
constant Textures &textures [[buffer(22)]],
|
||||
uint sample_id [[sample_id]]) {
|
||||
FragmentOut out;
|
||||
|
||||
uint2 tex_size = uint2(textures.texture.get_width(), textures.texture.get_height());
|
||||
uint2 tex_coord = uint2(in.uv * float2(tex_size));
|
||||
out.stencil = textures.texture.read(tex_coord, sample_id).r;
|
||||
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user