3
0
Fork 0
forked from suyu/suyu

host_shaders: More proper handling of x2 MSAA copies

This commit is contained in:
GPUCode 2023-09-23 11:25:24 +03:00 committed by Liam
parent 5e4938ab1a
commit b60013b277
2 changed files with 10 additions and 4 deletions

View file

@ -15,11 +15,14 @@ void main() {
// TODO: Specialization constants for num_samples? // TODO: Specialization constants for num_samples?
const int num_samples = imageSamples(msaa_in); const int num_samples = imageSamples(msaa_in);
const ivec3 msaa_size = imageSize(msaa_in);
const ivec3 out_size = imageSize(output_img);
const ivec3 scale = out_size / msaa_size;
for (int curr_sample = 0; curr_sample < num_samples; ++curr_sample) { for (int curr_sample = 0; curr_sample < num_samples; ++curr_sample) {
const vec4 pixel = imageLoad(msaa_in, coords, curr_sample); const vec4 pixel = imageLoad(msaa_in, coords, curr_sample);
const int single_sample_x = 2 * coords.x + (curr_sample & 1); const int single_sample_x = scale.x * coords.x + (curr_sample & 1);
const int single_sample_y = 2 * coords.y + ((curr_sample / 2) & 1); const int single_sample_y = scale.y * coords.y + ((curr_sample / 2) & 1);
const ivec3 dest_coords = ivec3(single_sample_x, single_sample_y, coords.z); const ivec3 dest_coords = ivec3(single_sample_x, single_sample_y, coords.z);
if (any(greaterThanEqual(dest_coords, imageSize(output_img)))) { if (any(greaterThanEqual(dest_coords, imageSize(output_img)))) {

View file

@ -15,9 +15,12 @@ void main() {
// TODO: Specialization constants for num_samples? // TODO: Specialization constants for num_samples?
const int num_samples = imageSamples(output_msaa); const int num_samples = imageSamples(output_msaa);
const ivec3 msaa_size = imageSize(output_msaa);
const ivec3 out_size = imageSize(img_in);
const ivec3 scale = out_size / msaa_size;
for (int curr_sample = 0; curr_sample < num_samples; ++curr_sample) { 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_x = scale.x * coords.x + (curr_sample & 1);
const int single_sample_y = 2 * coords.y + ((curr_sample / 2) & 1); const int single_sample_y = scale.y * coords.y + ((curr_sample / 2) & 1);
const ivec3 single_coords = ivec3(single_sample_x, single_sample_y, coords.z); const ivec3 single_coords = ivec3(single_sample_x, single_sample_y, coords.z);
if (any(greaterThanEqual(single_coords, imageSize(img_in)))) { if (any(greaterThanEqual(single_coords, imageSize(img_in)))) {