set output shader uniforms

This commit is contained in:
Samuliak 2024-09-30 16:39:26 +02:00
parent 28e553eb1a
commit 07cb8b800a
3 changed files with 16 additions and 4 deletions

View File

@ -934,7 +934,7 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa
{
sint32 scaling_filter = downscaling ? GetConfig().downscale_filter : GetConfig().upscale_filter;
if (g_renderer->GetType() == RendererAPI::Vulkan || g_renderer->GetType() == RendererAPI::Metal)
if (g_renderer->GetType() == RendererAPI::Vulkan)
{
// force linear or nearest neighbor filter
if(scaling_filter != kLinearFilter && scaling_filter != kNearestNeighborFilter)
@ -978,8 +978,7 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa
filter = LatteTextureView::MagFilter::kNearestNeighbor;
}
}
// HACK: comment out the assert
//cemu_assert(shader);
cemu_assert(shader);
g_renderer->DrawBackbufferQuad(textureView, shader, filter==LatteTextureView::MagFilter::kLinear, imageX, imageY, imageWidth, imageHeight, isPadView, clearBackground);
g_renderer->HandleScreenshotRequest(textureView, isPadView);
if (!g_renderer->ImguiBegin(!isPadView))

View File

@ -310,6 +310,7 @@ void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutput
else if (shader == RendererOutputShader::s_copy_shader_ud) shaderIndex = 3;
else if (shader == RendererOutputShader::s_bicubic_shader_ud) shaderIndex = 4;
else if (shader == RendererOutputShader::s_hermit_shader_ud) shaderIndex = 5;
printf("Shader index: %u\n", shaderIndex);
uint8 shaderType = shaderIndex % 3;
@ -321,6 +322,17 @@ void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutput
renderCommandEncoder->setFragmentTexture(presentTexture, 0);
renderCommandEncoder->setFragmentSamplerState((useLinearTexFilter ? m_linearSampler : m_nearestSampler), 0);
// Set uniforms
float outputSize[2] = {(float)imageWidth, (float)imageHeight};
switch (shaderType)
{
case 2:
renderCommandEncoder->setFragmentBytes(outputSize, sizeof(outputSize), 0);
break;
default:
break;
}
renderCommandEncoder->setViewport(MTL::Viewport{(double)imageX, (double)imageY, (double)imageWidth, (double)imageHeight, 0.0, 1.0});
renderCommandEncoder->setScissorRect(MTL::ScissorRect{(uint32)imageX, (uint32)imageY, (uint32)imageWidth, (uint32)imageHeight});

View File

@ -138,7 +138,8 @@ struct VertexOut {
float2 uv;
};
fragment float4 main0(VertexOut in [[stage_in]], texture2d<float> textureSrc [[texture(0)]], sampler samplr [[sampler(0)]], constant float2& textureSrcResolution [[buffer(0)]]) {
fragment float4 main0(VertexOut in [[stage_in]], texture2d<float> textureSrc [[texture(0)]], sampler samplr [[sampler(0)]]) {
float2 textureSrcResolution = float2(textureSrc.get_width(), textureSrc.get_height());
return float4(bcFilter(textureSrc, samplr, in.uv * textureSrcResolution, float2(1.0, 1.0) / textureSrcResolution).rgb, 1.0);
}
)";