Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 22d7db6

Browse files
Brandon SchadeCommit Bot
authored andcommitted
Vulkan: Change sampleCoverage calculation
When emulating the sample coverage to a mask, truncate the value. Test: dEQP-GLES3.functional.multisample.fbo*sample_coverage* Bug: angleproject:4568 Change-Id: Ie0f9fee7dc7cf08e2289ff24f0fa69f9929c4ae3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433069 Commit-Queue: Brandon Schade <[email protected]> Commit-Queue: Mohan Maiya <[email protected]> Reviewed-by: Jamie Madill <[email protected]> Reviewed-by: Shahbaz Youssefi <[email protected]>
1 parent 6136cbc commit 22d7db6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/libANGLE/renderer/vulkan/ContextVk.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,18 @@ uint32_t GetCoverageSampleCount(const gl::State &glState, FramebufferVk *drawFra
165165
}
166166

167167
// Get a fraction of the samples based on the coverage parameters.
168-
return static_cast<uint32_t>(
169-
std::round(glState.getSampleCoverageValue() * drawFramebuffer->getSamples()));
168+
// There are multiple ways to obtain an integer value from a float -
169+
// truncation, ceil and round
170+
//
171+
// round() provides a more even distribution of values but doesn't seem to play well
172+
// with all vendors (AMD). A way to work around this is to increase the comparison threshold
173+
// of deqp tests. Though this takes care of deqp tests other apps would still have issues.
174+
//
175+
// Truncation provides an uneven distribution near the edges of the interval but seems to
176+
// play well with all vendors.
177+
//
178+
// We are going with truncation for expediency.
179+
return static_cast<uint32_t>(glState.getSampleCoverageValue() * drawFramebuffer->getSamples());
170180
}
171181

172182
void ApplySampleCoverage(const gl::State &glState,

0 commit comments

Comments
 (0)