diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-07-23 01:57:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-23 01:57:35 -0400 |
| commit | 89c4fdeeea69056a8f2441f6e0e0662ba1e6a7b8 (patch) | |
| tree | 3fa6ef316f6ec72fc0f8622d7ebda2d544382e00 /Source/Core/VideoCommon/FramebufferShaderGen.cpp | |
| parent | df399b0995febe451ecf231c9bfb68b73d51e3bb (diff) | |
| parent | 6559c6b8ee8d35694282f3dcfaf09f96f73874db (diff) | |
Merge pull request #10754 from tellowkrinkle/Metal
VideoBackends: Add Metal backend
Diffstat (limited to 'Source/Core/VideoCommon/FramebufferShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/FramebufferShaderGen.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/FramebufferShaderGen.cpp b/Source/Core/VideoCommon/FramebufferShaderGen.cpp index 345578d071..49684bb518 100644 --- a/Source/Core/VideoCommon/FramebufferShaderGen.cpp +++ b/Source/Core/VideoCommon/FramebufferShaderGen.cpp @@ -34,6 +34,7 @@ void EmitSamplerDeclarations(ShaderCode& code, u32 start = 0, u32 end = 1, switch (GetAPIType()) { case APIType::D3D: + case APIType::Metal: case APIType::OpenGL: case APIType::Vulkan: { @@ -55,6 +56,7 @@ void EmitSampleTexture(ShaderCode& code, u32 n, std::string_view coords) switch (GetAPIType()) { case APIType::D3D: + case APIType::Metal: case APIType::OpenGL: case APIType::Vulkan: code.Write("texture(samp{}, {})", n, coords); @@ -72,6 +74,7 @@ void EmitTextureLoad(ShaderCode& code, u32 n, std::string_view coords) switch (GetAPIType()) { case APIType::D3D: + case APIType::Metal: case APIType::OpenGL: case APIType::Vulkan: code.Write("texelFetch(samp{}, ({}).xyz, ({}).w)", n, coords, coords); @@ -89,6 +92,7 @@ void EmitVertexMainDeclaration(ShaderCode& code, u32 num_tex_inputs, u32 num_col switch (GetAPIType()) { case APIType::D3D: + case APIType::Metal: case APIType::OpenGL: case APIType::Vulkan: { @@ -138,6 +142,7 @@ void EmitPixelMainDeclaration(ShaderCode& code, u32 num_tex_inputs, u32 num_colo switch (GetAPIType()) { case APIType::D3D: + case APIType::Metal: case APIType::OpenGL: case APIType::Vulkan: { @@ -333,6 +338,22 @@ std::string GenerateColorPixelShader() return code.GetBuffer(); } +std::string GenerateResolveColorPixelShader(u32 samples) +{ + ShaderCode code; + EmitSamplerDeclarations(code, 0, 1, true); + EmitPixelMainDeclaration(code, 1, 0); + code.Write("{{\n" + " int layer = int(v_tex0.z);\n" + " int3 coords = int3(int2(gl_FragCoord.xy), layer);\n" + " ocol0 = float4(0.0f);\n"); + code.Write(" for (int i = 0; i < {}; i++)\n", samples); + code.Write(" ocol0 += texelFetch(samp0, coords, i);\n"); + code.Write(" ocol0 /= {}.0f;\n", samples); + code.Write("}}\n"); + return code.GetBuffer(); +} + std::string GenerateResolveDepthPixelShader(u32 samples) { ShaderCode code; |
