Panagiotis Christopoulos Charitos 3 年 前
コミット
1c84a6115e

+ 2 - 10
AnKi/Gr/Vulkan/CommandBufferImpl.cpp

@@ -778,6 +778,8 @@ void CommandBufferImpl::rebindDynamicState()
 	m_lastViewport = {};
 	m_scissorDirty = true;
 	m_lastScissor = {};
+	m_vrsRateDirty = true;
+	m_vrsRate = VrsRate::_1x1;
 
 	// Rebind the stencil compare mask
 	if(m_stencilCompareMasks[0] == m_stencilCompareMasks[1])
@@ -823,16 +825,6 @@ void CommandBufferImpl::rebindDynamicState()
 		ANKI_CMD(vkCmdSetStencilReference(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilReferenceMasks[1]),
 				 ANY_OTHER_COMMAND);
 	}
-
-	// Rebind VRS
-	if(m_vrsRate != VrsRate::COUNT)
-	{
-		const VkExtent2D extend = convertVrsShadingRate(m_vrsRate);
-		Array<VkFragmentShadingRateCombinerOpKHR, 2> combiner;
-		combiner[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; // Keep pipeline rating over primitive
-		combiner[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR; // Max of attachment and pipeline rates
-		vkCmdSetFragmentShadingRateKHR(m_handle, &extend, &combiner[0]);
-	}
 }
 
 void CommandBufferImpl::buildAccelerationStructureInternal(AccelerationStructurePtr& as)

+ 2 - 1
AnKi/Gr/Vulkan/CommandBufferImpl.h

@@ -433,7 +433,8 @@ private:
 #if ANKI_ENABLE_ASSERTIONS
 	Bool m_lineWidthSet = false;
 #endif
-	VrsRate m_vrsRate = VrsRate::COUNT;
+	Bool m_vrsRateDirty = true;
+	VrsRate m_vrsRate = VrsRate::_1x1;
 
 	/// Rebind the above dynamic state. Needed after pushing secondary command buffers (they dirty the state).
 	void rebindDynamicState();

+ 13 - 6
AnKi/Gr/Vulkan/CommandBufferImpl.inl.h

@@ -711,6 +711,18 @@ inline void CommandBufferImpl::drawcallCommon()
 		m_scissorDirty = false;
 	}
 
+	// VRS
+	if(getGrManagerImpl().getDeviceCapabilities().m_vrs && m_vrsRateDirty)
+	{
+		const VkExtent2D extend = convertVrsShadingRate(m_vrsRate);
+		Array<VkFragmentShadingRateCombinerOpKHR, 2> combiner;
+		combiner[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; // Keep pipeline rating over primitive
+		combiner[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR; // Max of attachment and pipeline rates
+		vkCmdSetFragmentShadingRateKHR(m_handle, &extend, &combiner[0]);
+
+		m_vrsRateDirty = false;
+	}
+
 	// Some checks
 #if ANKI_ENABLE_ASSERTIONS
 	if(m_state.getPrimitiveTopology() == PrimitiveTopology::LINES
@@ -959,13 +971,8 @@ inline void CommandBufferImpl::setVrsRateInternal(VrsRate rate)
 
 	if(m_vrsRate != rate)
 	{
-		const VkExtent2D extend = convertVrsShadingRate(rate);
-		Array<VkFragmentShadingRateCombinerOpKHR, 2> combiner;
-		combiner[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; // Keep pipeline rating over primitive
-		combiner[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR; // Max of attachment and pipeline rates
-		vkCmdSetFragmentShadingRateKHR(m_handle, &extend, &combiner[0]);
-
 		m_vrsRate = rate;
+		m_vrsRateDirty = true;
 	}
 }
 

+ 10 - 2
AnKi/Input/InputDummy.cpp

@@ -4,6 +4,7 @@
 // http://www.anki3d.org/LICENSE
 
 #include <AnKi/Input/Input.h>
+#include <AnKi/Core/NativeWindow.h>
 
 namespace anki {
 
@@ -15,6 +16,7 @@ Error Input::newInstance(AllocAlignedCallback allocCallback, void* allocCallback
 	HeapAllocator<U8> alloc(allocCallback, allocCallbackUserData, "Input");
 	Input* ainput = alloc.newInstance<Input>();
 
+	ainput->m_nativeWindow = nativeWindow;
 	ainput->m_alloc = alloc;
 
 	input = ainput;
@@ -32,13 +34,19 @@ void Input::deleteInstance(Input* input)
 
 Error Input::handleEvents()
 {
-	// Nothing
+	if(m_lockCurs)
+	{
+		moveCursor(Vec2(0.0f));
+	}
+
 	return Error::NONE;
 }
 
 void Input::moveCursor(const Vec2& posNdc)
 {
-	// Nothing
+	m_mousePosNdc = posNdc;
+	m_mousePosWin.x() = U32(F32(m_nativeWindow->getWidth()) * (posNdc.x() * 0.5f + 0.5f));
+	m_mousePosWin.y() = U32(F32(m_nativeWindow->getHeight()) * (-posNdc.y() * 0.5f + 0.5f));
 }
 
 void Input::hideCursor(Bool hide)

+ 1 - 1
AnKi/Renderer/MainRenderer.cpp

@@ -69,7 +69,7 @@ Error MainRenderer::init(const MainRendererInitInfo& inf)
 	m_rgraph = inf.m_gr->newRenderGraph();
 
 	ANKI_R_LOGI("Main renderer initialized. Swapchain resolution %ux%u", m_swapchainResolution.x(),
-				m_swapchainResolution.x());
+				m_swapchainResolution.y());
 
 	return Error::NONE;
 }