From 93cf2b3ca8edeb1e8f1e00182f920b8d50664ed5 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Tue, 7 Feb 2023 21:33:57 -0500 Subject: texture_cache: OpenGL: Implement MSAA uploads and copies --- .../host_shaders/convert_non_msaa_to_msaa.comp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/video_core/host_shaders/convert_non_msaa_to_msaa.comp (limited to 'src/video_core/host_shaders/convert_non_msaa_to_msaa.comp') diff --git a/src/video_core/host_shaders/convert_non_msaa_to_msaa.comp b/src/video_core/host_shaders/convert_non_msaa_to_msaa.comp new file mode 100644 index 000000000..dedd962f1 --- /dev/null +++ b/src/video_core/host_shaders/convert_non_msaa_to_msaa.comp @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#version 450 core +layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout (binding = 0, rgba8) uniform readonly restrict image2DArray img_in; +layout (binding = 1, rgba8) uniform writeonly restrict image2DMSArray output_msaa; + +void main() { + const ivec3 coords = ivec3(gl_GlobalInvocationID); + if (any(greaterThanEqual(coords, imageSize(output_msaa)))) { + return; + } + + // TODO: Specialization constants for num_samples? + const int num_samples = imageSamples(output_msaa); + for (int curr_sample = 0; curr_sample < num_samples; ++curr_sample) { + const int single_sample_x = 2 * coords.x + (curr_sample & 1); + const int single_sample_y = 2 * coords.y + ((curr_sample / 2) & 1); + const ivec3 single_coords = ivec3(single_sample_x, single_sample_y, coords.z); + + if (any(greaterThanEqual(single_coords, imageSize(img_in)))) { + continue; + } + const vec4 pixel = imageLoad(img_in, single_coords); + imageStore(output_msaa, coords, curr_sample, pixel); + } +} -- cgit v1.2.3