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