Browse Source

Vulkan: revert the y flip

Panagiotis Christopoulos Charitos 8 years ago
parent
commit
f31476e66b

+ 2 - 1
shaders/Final.frag.glsl

@@ -16,9 +16,10 @@ layout(location = 0) out vec3 out_color;
 void main()
 {
 	vec2 uv = in_texCoord;
-#ifdef ANKI_VK
+#if ANKI_VK
 	uv.y = 1.0 - uv.y;
 #endif
+
 	vec3 col = textureLod(u_tex, uv, 0.0).rgb;
 	out_color = col;
 }

+ 3 - 0
shaders/Pps.frag.glsl

@@ -108,6 +108,9 @@ vec3 colorGrading(in vec3 color)
 void main()
 {
 	vec2 uv = in_uv.xy;
+#if DRAW_TO_DEFAULT && ANKI_VK
+	uv.y = 1.0 - uv.y;
+#endif
 
 #if SHARPEN_ENABLED
 	out_color = sharpen(u_isRt, uv);

+ 3 - 9
src/anki/gr/vulkan/CommandBufferImpl.inl.h

@@ -519,22 +519,16 @@ inline void CommandBufferImpl::drawcallCommon()
 	// Flush viewport
 	if(ANKI_UNLIKELY(m_viewportDirty))
 	{
-		// Do some hacks to flip the viewport
-		const Bool khrMaintenance1 = !!(getGrManagerImpl().getExtensions() & VulkanExtensions::KHR_MAINENANCE1);
-
 		const I minx = m_viewport[0];
 		const I miny = m_viewport[1];
 		const I maxx = m_viewport[2];
 		const I maxy = m_viewport[3];
 
-		U32 fbWidth, fbHeight;
-		m_activeFb->m_impl->getAttachmentsSize(fbWidth, fbHeight);
-
 		VkViewport s;
 		s.x = minx;
-		s.y = (khrMaintenance1) ? (fbHeight - miny) : (fbHeight - maxy); // Move to the bottom
+		s.y = miny;
 		s.width = maxx - minx;
-		s.height = -(maxy - miny); // Negate to flip
+		s.height = maxy - miny;
 		s.minDepth = 0.0;
 		s.maxDepth = 1.0;
 		ANKI_CMD(vkCmdSetViewport(m_handle, 0, 1, &s), ANY_OTHER_COMMAND);
@@ -543,7 +537,7 @@ inline void CommandBufferImpl::drawcallCommon()
 		scissor.extent.width = maxx - minx;
 		scissor.extent.height = maxy - miny;
 		scissor.offset.x = minx;
-		scissor.offset.y = fbHeight - maxy;
+		scissor.offset.y = miny;
 		ANKI_CMD(vkCmdSetScissor(m_handle, 0, 1, &scissor), ANY_OTHER_COMMAND);
 
 		m_viewportDirty = false;

+ 1 - 1
src/anki/gr/vulkan/Pipeline.cpp

@@ -246,7 +246,7 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 	rastCi.rasterizerDiscardEnable = false;
 	rastCi.polygonMode = convertFillMode(m_state.m_rasterizer.m_fillMode);
 	rastCi.cullMode = convertCullMode(m_state.m_rasterizer.m_cullMode);
-	rastCi.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
+	rastCi.frontFace = VK_FRONT_FACE_CLOCKWISE; // For viewport flip
 	rastCi.depthBiasEnable =
 		m_state.m_rasterizer.m_depthBiasConstantFactor != 0.0 && m_state.m_rasterizer.m_depthBiasSlopeFactor != 0.0;
 	rastCi.depthBiasConstantFactor = m_state.m_rasterizer.m_depthBiasConstantFactor;