mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-13 07:29:07 +00:00
This runs dawn_end2end_tests both with/without use_tint_generator on Vulkan, OpenGL, and OpenGL ES backends. This is a temporary solution until we add an dawn_end2end_use_tint_generator_tests suite in the bot configuration after all backends can support use_tint_generator or have the appropriate test suppressions. Bug: dawn:571 Change-Id: I44ab0ba7261160e34dbad512d98602427dc7e966 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35044 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org>
76 lines
2.8 KiB
C++
76 lines
2.8 KiB
C++
// Copyright 2017 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "tests/DawnTest.h"
|
|
|
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
|
#include "utils/WGPUHelpers.h"
|
|
|
|
class ViewportOrientationTests : public DawnTest {};
|
|
|
|
// Test that the pixel in viewport coordinate (-1, -1) matches texel (0, 0)
|
|
TEST_P(ViewportOrientationTests, OriginAt0x0) {
|
|
// TODO(crbug.com/tint/398): GLSL builtins don't work with SPIR-V reader.
|
|
DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator"));
|
|
|
|
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
|
|
|
|
wgpu::ShaderModule vsModule =
|
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
|
#version 450
|
|
void main() {
|
|
gl_Position = vec4(-0.5f, 0.5f, 0.0f, 1.0f);
|
|
gl_PointSize = 1.0;
|
|
})");
|
|
|
|
wgpu::ShaderModule fsModule =
|
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
|
#version 450
|
|
layout(location = 0) out vec4 fragColor;
|
|
void main() {
|
|
fragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f);
|
|
})");
|
|
|
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
|
descriptor.vertexStage.module = vsModule;
|
|
descriptor.cFragmentStage.module = fsModule;
|
|
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
|
|
descriptor.cColorStates[0].format = renderPass.colorFormat;
|
|
|
|
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
|
|
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
|
pass.SetPipeline(pipeline);
|
|
pass.Draw(1);
|
|
pass.EndPass();
|
|
}
|
|
|
|
wgpu::CommandBuffer commands = encoder.Finish();
|
|
queue.Submit(1, &commands);
|
|
|
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 0, 0);
|
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kZero, renderPass.color, 0, 1);
|
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kZero, renderPass.color, 1, 0);
|
|
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kZero, renderPass.color, 1, 1);
|
|
}
|
|
|
|
DAWN_INSTANTIATE_TEST(ViewportOrientationTests,
|
|
D3D12Backend(),
|
|
MetalBackend(),
|
|
OpenGLBackend(),
|
|
OpenGLESBackend(),
|
|
VulkanBackend());
|