Przeglądaj źródła

Metal: Fixed pso collsion.

Branimir Karadžić 7 lat temu
rodzic
commit
ddb1ffae67
2 zmienionych plików z 22 dodań i 7 usunięć
  1. 6 5
      src/renderer_mtl.h
  2. 16 2
      src/renderer_mtl.mm

+ 6 - 5
src/renderer_mtl.h

@@ -54,11 +54,11 @@ namespace bgfx { namespace mtl
 
 #define MTL_MAX_FRAMES_IN_FLIGHT (3)
 
-#define MTL_CLASS(name) \
-	class name \
-	{ \
-	public: \
-		name(id <MTL##name> _obj = nil) : m_obj(_obj) {} \
+#define MTL_CLASS(name)                                   \
+	class name                                            \
+	{                                                     \
+	public:                                               \
+		name(id <MTL##name> _obj = nil) : m_obj(_obj) {}  \
 		operator id <MTL##name>() const { return m_obj; } \
 		id <MTL##name> m_obj;
 
@@ -775,6 +775,7 @@ namespace bgfx { namespace mtl
 		}
 
 		Function m_function;
+		uint32_t m_hash;
 	};
 
 	struct ProgramMtl

+ 16 - 2
src/renderer_mtl.mm

@@ -1780,7 +1780,8 @@ namespace bgfx { namespace mtl
 				| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
 				);
 
-			bool independentBlendEnable = !!(BGFX_STATE_BLEND_INDEPENDENT & _state);
+			const bool independentBlendEnable = !!(BGFX_STATE_BLEND_INDEPENDENT & _state);
+			ProgramMtl& program = m_program[_programIdx];
 
 			bx::HashMurmur2A murmur;
 			murmur.begin();
@@ -1798,6 +1799,12 @@ namespace bgfx { namespace mtl
 				murmur.add(frameBuffer.m_pixelFormatHash);
 			}
 
+			murmur.add(program.m_vsh->m_hash);
+			if (NULL != program.m_fsh)
+			{
+				murmur.add(program.m_fsh->m_hash);
+			}
+
 			for (uint8_t ii = 0; ii < _numStreams; ++ii)
 			{
 				murmur.add(_vertexDecls[ii]->m_hash);
@@ -1916,7 +1923,6 @@ namespace bgfx { namespace mtl
 					}
 				}
 
-				ProgramMtl& program = m_program[_programIdx];
 				pd.vertexFunction   = program.m_vsh->m_function;
 				pd.fragmentFunction = program.m_fsh != NULL ? program.m_fsh->m_function : NULL;
 
@@ -2374,6 +2380,14 @@ namespace bgfx { namespace mtl
 			, "Failed to create %s shader."
 			, BGFX_CHUNK_MAGIC_FSH == magic ? "Fragment" : BGFX_CHUNK_MAGIC_VSH == magic ? "Vertex" : "Compute"
 			);
+
+		bx::HashMurmur2A murmur;
+		murmur.begin();
+		murmur.add(iohash);
+		murmur.add(code, shaderSize);
+//		murmur.add(numAttrs);
+//		murmur.add(m_attrMask, numAttrs);
+		m_hash = murmur.end();
 	}
 
 	void ProgramMtl::create(const ShaderMtl* _vsh, const ShaderMtl* _fsh)