mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-10 23:26:06 +00:00
Split ComparisonSampler tests with/without normalized depth textures
Depth textures outside the 0-1 range are clamped on OpenGL unless we reinterpret contents as R32 Bug: dawn:367 Change-Id: Ifb539689c55bb5a4a16427025c9f0d97c4156c6b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20823 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
991b947173
commit
531253357e
@ -13,11 +13,25 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr wgpu::CompareFunction kCompareFunctions[] = {
|
||||||
|
wgpu::CompareFunction::Never,
|
||||||
|
wgpu::CompareFunction::Less,
|
||||||
|
wgpu::CompareFunction::LessEqual,
|
||||||
|
wgpu::CompareFunction::Greater,
|
||||||
|
wgpu::CompareFunction::GreaterEqual,
|
||||||
|
wgpu::CompareFunction::Equal,
|
||||||
|
wgpu::CompareFunction::NotEqual,
|
||||||
|
wgpu::CompareFunction::Always,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
class ComparisonSamplerTest : public DawnTest {
|
class ComparisonSamplerTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
void TestSetUp() override {
|
void TestSetUp() override {
|
||||||
@ -135,33 +149,22 @@ class ComparisonSamplerTest : public DawnTest {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
|
||||||
|
|
||||||
// Set the input depth texture to the provided texture value
|
// Set the input depth texture to the provided texture value
|
||||||
if (textureValue >= 0.0 && textureValue <= 1.0) {
|
mTextureUploadBuffer.SetSubData(0, sizeof(float), &textureValue);
|
||||||
// For valid loadOp values, use a loadOp.
|
|
||||||
utils::ComboRenderPassDescriptor passDescriptor({}, mInputTexture.CreateView());
|
|
||||||
passDescriptor.cDepthStencilAttachmentInfo.clearDepth = textureValue;
|
|
||||||
|
|
||||||
wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&passDescriptor);
|
wgpu::BufferCopyView bufferCopyView = {};
|
||||||
pass.EndPass();
|
bufferCopyView.buffer = mTextureUploadBuffer;
|
||||||
} else {
|
bufferCopyView.offset = 0;
|
||||||
if (IsOpenGL()) {
|
bufferCopyView.bytesPerRow = kTextureBytesPerRowAlignment;
|
||||||
// TODO(enga): We don't support copying to depth textures yet on OpenGL.
|
|
||||||
return;
|
wgpu::TextureCopyView textureCopyView;
|
||||||
}
|
textureCopyView.texture = mInputTexture;
|
||||||
mTextureUploadBuffer.SetSubData(0, sizeof(float), &textureValue);
|
textureCopyView.origin = {0, 0, 0};
|
||||||
wgpu::BufferCopyView bufferCopyView;
|
|
||||||
bufferCopyView.buffer = mTextureUploadBuffer;
|
wgpu::Extent3D copySize = {1, 1, 1};
|
||||||
bufferCopyView.offset = 0;
|
|
||||||
bufferCopyView.rowPitch = kTextureBytesPerRowAlignment;
|
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||||
bufferCopyView.imageHeight = 1;
|
commandEncoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||||
wgpu::TextureCopyView textureCopyView;
|
|
||||||
textureCopyView.texture = mInputTexture;
|
|
||||||
textureCopyView.origin = {0, 0, 0};
|
|
||||||
wgpu::Extent3D copySize = {1, 1, 1};
|
|
||||||
commandEncoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render into the output texture
|
// Render into the output texture
|
||||||
{
|
{
|
||||||
@ -193,17 +196,26 @@ class ComparisonSamplerTest : public DawnTest {
|
|||||||
TEST_P(ComparisonSamplerTest, CompareFunctions) {
|
TEST_P(ComparisonSamplerTest, CompareFunctions) {
|
||||||
// Test a "normal" ref value between 0 and 1; as well as negative and > 1 refs.
|
// Test a "normal" ref value between 0 and 1; as well as negative and > 1 refs.
|
||||||
for (float compareRef : {-0.1, 0.4, 1.2}) {
|
for (float compareRef : {-0.1, 0.4, 1.2}) {
|
||||||
// Test negative, 0, below the ref, equal to, above the ref, 1, and above 1.
|
// Test 0, below the ref, equal to, above the ref, and 1.
|
||||||
std::vector<float> values = {-0.2, 0.0, 0.3, 0.4, 0.5, 1.0, 1.3};
|
for (wgpu::CompareFunction f : kCompareFunctions) {
|
||||||
|
DoCompareRefTest(compareRef, f, {0.0, 0.3, 0.4, 0.5, 1.0});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::Never, values);
|
// Test that sampling with all of the compare functions works, when the texture contents
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::Less, values);
|
// are outside the 0-1 range.
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::LessEqual, values);
|
TEST_P(ComparisonSamplerTest, CompareFunctionsUnnormalizedContents) {
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::Greater, values);
|
// TODO(enga): Copies to depth textures are clamped. Unless we reinterpret
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::GreaterEqual, values);
|
// contents as R32F.
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::Equal, values);
|
DAWN_SKIP_TEST_IF(IsOpenGL());
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::NotEqual, values);
|
|
||||||
DoCompareRefTest(compareRef, wgpu::CompareFunction::Always, values);
|
// Test a "normal" ref value between 0 and 1; as well as negative and > 1 refs.
|
||||||
|
for (float compareRef : {-0.1, 0.4, 1.2}) {
|
||||||
|
// Test negative, and above 1.
|
||||||
|
for (wgpu::CompareFunction f : kCompareFunctions) {
|
||||||
|
DoCompareRefTest(compareRef, f, {-0.2, 1.3});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user