From ff57ccbcf1eadf84d4fbbdf7b2a70de4ff8ff549 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 13 Nov 2017 12:05:18 -0800 Subject: [PATCH] OpenGL: Fix rendered textures being flipped. This was because the clip space of OpenGL has an inverted Y compared to other APIs. This commit: - Updates SPIRV-Cross to the latest version - Uses the new vertex.flip_vert_y option in ShaderModuleGL - Enables tests that are now passing in GL. --- src/backend/d3d12/ShaderModuleD3D12.cpp | 12 +++++++----- src/backend/opengl/ShaderModuleGL.cpp | 1 + src/tests/end2end/InputStateTests.cpp | 2 +- src/tests/end2end/PrimitiveTopologyTests.cpp | 2 +- third_party/spirv-cross | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/backend/d3d12/ShaderModuleD3D12.cpp b/src/backend/d3d12/ShaderModuleD3D12.cpp index 1c3f522ef1..2e7c7c73ea 100644 --- a/src/backend/d3d12/ShaderModuleD3D12.cpp +++ b/src/backend/d3d12/ShaderModuleD3D12.cpp @@ -23,12 +23,14 @@ namespace d3d12 { : ShaderModuleBase(builder), device(device) { spirv_cross::CompilerHLSL compiler(builder->AcquireSpirv()); - spirv_cross::CompilerHLSL::Options options; - options.shader_model = 51; - options.flip_vert_y = false; - options.fixup_clipspace = true; + spirv_cross::CompilerGLSL::Options options_glsl; + options_glsl.vertex.flip_vert_y = false; + options_glsl.vertex.fixup_clipspace = true; + compiler.spirv_cross::CompilerGLSL::set_options(options_glsl); - compiler.set_options(options); + spirv_cross::CompilerHLSL::Options options_hlsl; + options_hlsl.shader_model = 51; + compiler.spirv_cross::CompilerHLSL::set_options(options_hlsl); ExtractSpirvInfo(compiler); diff --git a/src/backend/opengl/ShaderModuleGL.cpp b/src/backend/opengl/ShaderModuleGL.cpp index eb2ed2263c..e998ee582e 100644 --- a/src/backend/opengl/ShaderModuleGL.cpp +++ b/src/backend/opengl/ShaderModuleGL.cpp @@ -57,6 +57,7 @@ namespace opengl { #else options.version = 440; #endif + options.vertex.flip_vert_y = true; compiler.set_options(options); // Rename the push constant block to be prefixed with the shader stage type so that uniform names diff --git a/src/tests/end2end/InputStateTests.cpp b/src/tests/end2end/InputStateTests.cpp index 6cbda3f406..79a4895b14 100644 --- a/src/tests/end2end/InputStateTests.cpp +++ b/src/tests/end2end/InputStateTests.cpp @@ -439,7 +439,7 @@ TEST_P(InputStateTest, MixedEverything) { DoTestDraw(pipeline, 1, 1, {{0, &buffer0}, {1, &buffer1}}); } -NXT_INSTANTIATE_TEST(InputStateTest, D3D12Backend, MetalBackend) +NXT_INSTANTIATE_TEST(InputStateTest, D3D12Backend, MetalBackend, OpenGLBackend) // TODO for the input state: // - Add more vertex formats diff --git a/src/tests/end2end/PrimitiveTopologyTests.cpp b/src/tests/end2end/PrimitiveTopologyTests.cpp index ecef65a22f..659b192e77 100644 --- a/src/tests/end2end/PrimitiveTopologyTests.cpp +++ b/src/tests/end2end/PrimitiveTopologyTests.cpp @@ -308,4 +308,4 @@ TEST_P(PrimitiveTopologyTest, TriangleStrip) { }); } -NXT_INSTANTIATE_TEST(PrimitiveTopologyTest, D3D12Backend, MetalBackend) +NXT_INSTANTIATE_TEST(PrimitiveTopologyTest, D3D12Backend, MetalBackend, OpenGLBackend) diff --git a/third_party/spirv-cross b/third_party/spirv-cross index e8eae4d7dd..694cad5332 160000 --- a/third_party/spirv-cross +++ b/third_party/spirv-cross @@ -1 +1 @@ -Subproject commit e8eae4d7dde433b1a8dc7e9a977508f8cef9c984 +Subproject commit 694cad533296df02b4562f4a5a20cba1d1a9dbaf