Set y-axis up in normalized coordinate system.
BUG=dawn:224 Change-Id: I6bb4946e87b593f1d62a13b3b8ab38f21d3e9ffb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10201 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
parent
a838c7d497
commit
394553b02e
|
@ -37,7 +37,6 @@ namespace dawn_native { namespace d3d12 {
|
|||
// If these options are changed, the values in DawnSPIRVCrossHLSLFastFuzzer.cpp need to be
|
||||
// updated.
|
||||
spirv_cross::CompilerGLSL::Options options_glsl;
|
||||
options_glsl.vertex.flip_vert_y = true;
|
||||
compiler.set_common_options(options_glsl);
|
||||
|
||||
spirv_cross::CompilerHLSL::Options options_hlsl;
|
||||
|
|
|
@ -54,10 +54,6 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
// If these options are changed, the values in DawnSPIRVCrossMSLFastFuzzer.cpp need to be
|
||||
// updated.
|
||||
spirv_cross::CompilerGLSL::Options options_glsl;
|
||||
options_glsl.vertex.flip_vert_y = true;
|
||||
compiler.spirv_cross::CompilerGLSL::set_common_options(options_glsl);
|
||||
|
||||
spirv_cross::CompilerMSL::Options options_msl;
|
||||
|
||||
// Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace dawn_native { namespace opengl {
|
|||
// in D3D12, Metal and Vulkan, so we should normalize it in shaders in all backends.
|
||||
// See the documentation of spirv_cross::CompilerGLSL::Options::vertex::fixup_clipspace for
|
||||
// more details.
|
||||
options.vertex.flip_vert_y = true;
|
||||
options.vertex.fixup_clipspace = true;
|
||||
|
||||
// TODO(cwallez@chromium.org): discover the backing context version and use that.
|
||||
|
|
|
@ -39,6 +39,12 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
MaybeError Adapter::Initialize() {
|
||||
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));
|
||||
if (!mDeviceInfo.maintenance1 &&
|
||||
mDeviceInfo.properties.apiVersion < VK_MAKE_VERSION(1, 1, 0)) {
|
||||
return DAWN_DEVICE_LOST_ERROR(
|
||||
"Dawn requires Vulkan 1.1 or Vulkan 1.0 with KHR_Maintenance1 in order to support "
|
||||
"viewport flipY");
|
||||
}
|
||||
|
||||
InitializeSupportedExtensions();
|
||||
|
||||
|
|
|
@ -659,9 +659,9 @@ namespace dawn_native { namespace vulkan {
|
|||
// The viewport and scissor default to cover all of the attachments
|
||||
VkViewport viewport;
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = 0.0f;
|
||||
viewport.y = static_cast<float>(renderPassCmd->height);
|
||||
viewport.width = static_cast<float>(renderPassCmd->width);
|
||||
viewport.height = static_cast<float>(renderPassCmd->height);
|
||||
viewport.height = -static_cast<float>(renderPassCmd->height);
|
||||
viewport.minDepth = 0.0f;
|
||||
viewport.maxDepth = 1.0f;
|
||||
device->fn.CmdSetViewport(commands, 0, 1, &viewport);
|
||||
|
@ -853,9 +853,9 @@ namespace dawn_native { namespace vulkan {
|
|||
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
|
||||
VkViewport viewport;
|
||||
viewport.x = cmd->x;
|
||||
viewport.y = cmd->y;
|
||||
viewport.y = cmd->y + cmd->height;
|
||||
viewport.width = cmd->width;
|
||||
viewport.height = cmd->height;
|
||||
viewport.height = -cmd->height;
|
||||
viewport.minDepth = cmd->minDepth;
|
||||
viewport.maxDepth = cmd->maxDepth;
|
||||
|
||||
|
|
|
@ -380,6 +380,10 @@ namespace dawn_native { namespace vulkan {
|
|||
extensionsToRequest.push_back(kExtensionNameKhrSwapchain);
|
||||
usedKnobs.swapchain = true;
|
||||
}
|
||||
if (mDeviceInfo.maintenance1) {
|
||||
extensionsToRequest.push_back(kExtensionNameKhrMaintenance1);
|
||||
usedKnobs.maintenance1 = true;
|
||||
}
|
||||
|
||||
// Always require independentBlend because it is a core Dawn feature
|
||||
usedKnobs.features.independentBlend = VK_TRUE;
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace dawn_native { namespace vulkan {
|
|||
const char kExtensionNameKhrXcbSurface[] = "VK_KHR_xcb_surface";
|
||||
const char kExtensionNameKhrXlibSurface[] = "VK_KHR_xlib_surface";
|
||||
const char kExtensionNameFuchsiaImagePipeSurface[] = "VK_FUCHSIA_imagepipe_surface";
|
||||
const char kExtensionNameKhrMaintenance1[] = "VK_KHR_maintenance1";
|
||||
|
||||
ResultOrError<VulkanGlobalInfo> GatherGlobalInfo(const Backend& backend) {
|
||||
VulkanGlobalInfo info = {};
|
||||
|
@ -301,6 +302,9 @@ namespace dawn_native { namespace vulkan {
|
|||
if (IsExtensionName(extension, kExtensionNameKhrSwapchain)) {
|
||||
info.swapchain = true;
|
||||
}
|
||||
if (IsExtensionName(extension, kExtensionNameKhrMaintenance1)) {
|
||||
info.maintenance1 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace dawn_native { namespace vulkan {
|
|||
extern const char kExtensionNameKhrXcbSurface[];
|
||||
extern const char kExtensionNameKhrXlibSurface[];
|
||||
extern const char kExtensionNameFuchsiaImagePipeSurface[];
|
||||
extern const char kExtensionNameKhrMaintenance1[];
|
||||
|
||||
// Global information - gathered before the instance is created
|
||||
struct VulkanGlobalKnobs {
|
||||
|
@ -92,6 +93,7 @@ namespace dawn_native { namespace vulkan {
|
|||
bool externalSemaphoreFD = false;
|
||||
bool externalSemaphoreZirconHandle = false;
|
||||
bool swapchain = false;
|
||||
bool maintenance1 = false;
|
||||
};
|
||||
|
||||
struct VulkanDeviceInfo : VulkanDeviceKnobs {
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace {
|
|||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp
|
||||
options.SetFlipVertY(true);
|
||||
options.SetHLSLShaderModel(51);
|
||||
// TODO (hao.x.li@intel.com): The HLSLPointCoordCompat and HLSLPointSizeCompat are
|
||||
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace {
|
|||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleMTL.mm
|
||||
options.SetFlipVertY(true);
|
||||
compiler.CompileSpvToMsl(input.data(), input.size(), options);
|
||||
});
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
return utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
|
||||
})");
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
|||
mat2 transform;
|
||||
};
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
|
||||
gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
|
||||
})");
|
||||
|
||||
|
@ -248,7 +248,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||
mat2 transform;
|
||||
};
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
|
||||
gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
|
||||
})");
|
||||
|
||||
|
@ -368,7 +368,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
|
|||
mat2 transform2;
|
||||
};
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
|
||||
gl_Position = vec4((transform1 + transform2) * pos[gl_VertexIndex], 0.f, 1.f);
|
||||
})");
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ class ClipSpaceTest : public DawnTest {
|
|||
// 2. The depth value of the bottom-right one is <= 0.5
|
||||
const char* vs =
|
||||
R"(#version 450
|
||||
const vec3 pos[6] = vec3[6](vec3(-1.0f, -1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, 0.5f),
|
||||
vec3( 1.0f, -1.0f, 0.5f),
|
||||
vec3( 1.0f, -1.0f, 0.5f),
|
||||
vec3(-1.0f, 1.0f, 0.5f),
|
||||
vec3( 1.0f, 1.0f, 0.0f));
|
||||
const vec3 pos[6] = vec3[6](vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, -1.0f, 0.5f),
|
||||
vec3( 1.0f, 1.0f, 0.5f),
|
||||
vec3( 1.0f, 1.0f, 0.5f),
|
||||
vec3(-1.0f, -1.0f, 0.5f),
|
||||
vec3( 1.0f, -1.0f, 0.0f));
|
||||
void main() {
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 1.0);
|
||||
})";
|
||||
|
|
|
@ -145,12 +145,12 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
|||
layout(location=0) out vec2 texCoord;
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](
|
||||
vec2(-3.0f, -1.0f),
|
||||
vec2( 3.0f, -1.0f),
|
||||
vec2( 0.0f, 2.0f)
|
||||
vec2(-3.0f, 1.0f),
|
||||
vec2( 3.0f, 1.0f),
|
||||
vec2( 0.0f, -2.0f)
|
||||
);
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.0f, 1.0f);
|
||||
texCoord = gl_Position.xy / 2.0f + vec2(0.5f);
|
||||
texCoord = vec2(gl_Position.x / 2.0f, -gl_Position.y / 2.0f) + vec2(0.5f);
|
||||
})");
|
||||
dawn::ShaderModule fsModule =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
||||
|
|
|
@ -27,12 +27,12 @@ class CullingTest : public DawnTest {
|
|||
// 2. The bottom-right one is clockwise (CW)
|
||||
const char* vs =
|
||||
R"(#version 450
|
||||
const vec2 pos[6] = vec2[6](vec2(-1.0f, -1.0f),
|
||||
vec2(-1.0f, 0.0f),
|
||||
vec2( 0.0f, -1.0f),
|
||||
vec2( 0.0f, 1.0f),
|
||||
vec2( 1.0f, 0.0f),
|
||||
vec2( 1.0f, 1.0f));
|
||||
const vec2 pos[6] = vec2[6](vec2(-1.0f, 1.0f),
|
||||
vec2(-1.0f, 0.0f),
|
||||
vec2( 0.0f, 1.0f),
|
||||
vec2( 0.0f, -1.0f),
|
||||
vec2( 1.0f, 0.0f),
|
||||
vec2( 1.0f, -1.0f));
|
||||
void main() {
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
|
||||
})";
|
||||
|
|
|
@ -57,7 +57,7 @@ class DestroyTest : public DawnTest {
|
|||
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{// The bottom left triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.BeginRenderPass(&renderPass.renderPassInfo).EndPass();
|
||||
|
|
|
@ -57,11 +57,11 @@ class DrawIndexedIndirectTest : public DawnTest {
|
|||
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{// First quad: the first 3 vertices represent the bottom left triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f,
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 1.0f,
|
||||
|
||||
// Second quad: the first 3 vertices represent the top right triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f,
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f,
|
||||
0.0f, 1.0f});
|
||||
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||
device, dawn::BufferUsage::Index,
|
||||
|
|
|
@ -57,12 +57,12 @@ class DrawIndexedTest : public DawnTest {
|
|||
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{// First quad: the first 3 vertices represent the bottom left triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
|
||||
-1.0f, 0.0f, 1.0f,
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f, 1.0f,
|
||||
|
||||
// Second quad: the first 3 vertices represent the top right triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f,
|
||||
1.0f, 0.0f, 1.0f});
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f,
|
||||
-1.0f, 0.0f, 1.0f});
|
||||
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||
device, dawn::BufferUsage::Index,
|
||||
{0, 1, 2, 0, 3, 1,
|
||||
|
|
|
@ -57,10 +57,10 @@ class DrawIndirectTest : public DawnTest {
|
|||
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{// The bottom left triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||
|
||||
// The top right triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f});
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f});
|
||||
}
|
||||
|
||||
utils::BasicRenderPass renderPass;
|
||||
|
|
|
@ -57,10 +57,10 @@ class DrawTest : public DawnTest {
|
|||
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{// The bottom left triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||
|
||||
// The top right triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f});
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f});
|
||||
}
|
||||
|
||||
utils::BasicRenderPass renderPass;
|
||||
|
|
|
@ -97,7 +97,7 @@ class DynamicBufferOffsetTests : public DawnTest {
|
|||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, -1.0f), vec2(0.0f, -1.0f));
|
||||
const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, 1.0f), vec2(0.0f, 1.0f));
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ TEST_P(IndexFormatTest, Uint32) {
|
|||
|
||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||
{-1.0f, -1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
||||
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
|
||||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
|
||||
|
@ -97,7 +97,7 @@ TEST_P(IndexFormatTest, Uint16) {
|
|||
|
||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||
{-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
||||
// If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing
|
||||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index, {1, 2, 0, 0, 0, 0});
|
||||
|
@ -138,8 +138,8 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
|||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{
|
||||
0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||
0.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||
});
|
||||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index,
|
||||
|
@ -179,8 +179,8 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
|
|||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{
|
||||
0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||
0.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||
});
|
||||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index,
|
||||
|
@ -226,8 +226,8 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
|
|||
|
||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||
{-1.0f, -1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
||||
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
|
||||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
|
||||
|
@ -260,7 +260,7 @@ TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
|
|||
|
||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||
{-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
||||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {0, 1, 2});
|
||||
|
||||
|
|
|
@ -134,12 +134,12 @@ constexpr static TestLocation kTriangleStripTestLocations[] = {
|
|||
|
||||
constexpr static float kRTSizef = static_cast<float>(kRTSize);
|
||||
constexpr static float kVertices[] = {
|
||||
2.f * (kPointTestLocations[0].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[0].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[1].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[1].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[2].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[2].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[3].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[3].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[4].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[4].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[5].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[5].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[0].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[0].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[1].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[1].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[2].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[2].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[3].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[3].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[4].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[4].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
|
||||
2.f * (kPointTestLocations[5].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[5].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -88,10 +88,10 @@ class RenderBundleTest : public DawnTest {
|
|||
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||
device, dawn::BufferUsage::Vertex,
|
||||
{// The bottom left triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||
|
||||
// The top right triangle
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f});
|
||||
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f});
|
||||
}
|
||||
|
||||
utils::BasicRenderPass renderPass;
|
||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
|||
#version 450
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](
|
||||
vec2(-1.f, -1.f), vec2(1.f, 1.f), vec2(-1.f, 1.f));
|
||||
vec2(-1.f, 1.f), vec2(1.f, -1.f), vec2(-1.f, -1.f));
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
|
||||
})");
|
||||
|
||||
|
|
|
@ -263,8 +263,8 @@ class VertexFormatTest : public DawnTest {
|
|||
vs << "void main() {\n";
|
||||
|
||||
// Hard code the triangle in the shader so that we don't have to add a vertex input for it.
|
||||
vs << " const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, -1.0f), vec2(0.0f, "
|
||||
"-1.0f));\n";
|
||||
vs << " const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, 1.0f), vec2(0.0f, "
|
||||
"1.0f));\n";
|
||||
vs << " gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n";
|
||||
|
||||
// Declare expected values.
|
||||
|
|
|
@ -87,7 +87,8 @@ class VertexInputTest : public DawnTest {
|
|||
"0.0f));\n";
|
||||
vs << " vec2 offset = vec2(float(gl_VertexIndex / 3), float(gl_InstanceIndex));\n";
|
||||
vs << " vec2 worldPos = pos[gl_VertexIndex % 3] + offset;\n";
|
||||
vs << " gl_Position = vec4(worldPos / 2 - vec2(1.0f), 0.0f, 1.0f);\n";
|
||||
vs << " vec4 position = vec4(worldPos / 2 - vec2(1.0f), 0.0f, 1.0f);\n";
|
||||
vs << " gl_Position = vec4(position.x, -position.y, position.z, position.w);\n";
|
||||
|
||||
// Perform the checks by successively ANDing a boolean
|
||||
vs << " bool success = true;\n";
|
||||
|
|
|
@ -27,7 +27,7 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
|
|||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
gl_Position = vec4(-0.5f, -0.5f, 0.0f, 1.0f);
|
||||
gl_Position = vec4(-0.5f, 0.5f, 0.0f, 1.0f);
|
||||
gl_PointSize = 1.0;
|
||||
})");
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ class ViewportTest : public DawnTest {
|
|||
const char* vs =
|
||||
R"(#version 450
|
||||
layout(location = 0) out vec4 color;
|
||||
const vec3 pos[6] = vec3[6](vec3(-1.0f, -1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, 0.5f),
|
||||
vec3( 1.0f, -1.0f, 0.5f),
|
||||
vec3( 1.0f, -1.0f, 0.5f),
|
||||
vec3(-1.0f, 1.0f, 0.5f),
|
||||
vec3( 1.0f, 1.0f, 0.0f));
|
||||
const vec3 pos[6] = vec3[6](vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, -1.0f, 0.5f),
|
||||
vec3( 1.0f, 1.0f, 0.5f),
|
||||
vec3( 1.0f, 1.0f, 0.5f),
|
||||
vec3(-1.0f, -1.0f, 0.5f),
|
||||
vec3( 1.0f, -1.0f, 0.0f));
|
||||
void main() {
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 1.0);
|
||||
if (gl_VertexIndex < 3) {
|
||||
|
|
Loading…
Reference in New Issue