Jelajahi Sumber

Add depth to RenderKey

Daniele Bartolini 11 tahun lalu
induk
melakukan
b0c92479a3

+ 7 - 2
engine/renderers/backend/RenderContext.h

@@ -226,17 +226,21 @@ struct RenderKey
 
 
 	uint64_t encode()
 	uint64_t encode()
 	{
 	{
-		return uint64_t(m_layer) << RENDER_LAYER_SHIFT;
+		const uint64_t a = uint64_t(m_layer) << RENDER_LAYER_SHIFT;
+		const uint64_t b = m_depth;
+		return a | b;
 	}
 	}
 
 
 	void decode(uint64_t key)
 	void decode(uint64_t key)
 	{
 	{
 		m_layer = (key & RENDER_LAYER_MASK) >> RENDER_LAYER_SHIFT;
 		m_layer = (key & RENDER_LAYER_MASK) >> RENDER_LAYER_SHIFT;
+		m_depth = (key & 0xFFFFFFFF);
 	}
 	}
 
 
 public:
 public:
 
 
 	uint8_t m_layer;
 	uint8_t m_layer;
+	int32_t m_depth;
 };
 };
 
 
 struct SortKey
 struct SortKey
@@ -417,10 +421,11 @@ struct RenderContext
 		m_scissors[layer].m_height = height;
 		m_scissors[layer].m_height = height;
 	}
 	}
 
 
-	void commit(uint8_t layer)
+	void commit(uint8_t layer, int32_t depth)
 	{
 	{
 		CE_ASSERT(layer < MAX_RENDER_LAYERS, "Layer out of bounds");
 		CE_ASSERT(layer < MAX_RENDER_LAYERS, "Layer out of bounds");
 		m_render_key.m_layer = layer;
 		m_render_key.m_layer = layer;
+		m_render_key.m_depth = depth;
 
 
 		m_state.begin_uniform = m_last_uniform_offset;
 		m_state.begin_uniform = m_last_uniform_offset;
 		m_state.end_uniform = m_constants.position();
 		m_state.end_uniform = m_constants.position();

+ 2 - 2
engine/renderers/backend/Renderer.h

@@ -845,9 +845,9 @@ public:
 		m_submit->set_layer_scissor(layer, x, y, width, height);
 		m_submit->set_layer_scissor(layer, x, y, width, height);
 	}
 	}
 
 
-	void commit(uint8_t layer)
+	void commit(uint8_t layer, int32_t depth = 0)
 	{
 	{
-		m_submit->commit(layer);
+		m_submit->commit(layer, depth);
 	}
 	}
 
 
 	static int32_t render_thread(void* thiz)
 	static int32_t render_thread(void* thiz)