Kaynağa Gözat

shaderc: Fixed SPIR-V uniform array size reflection. Issue #2964.

Бранимир Караџић 3 yıl önce
ebeveyn
işleme
c4d4b90e32
2 değiştirilmiş dosya ile 6 ekleme ve 4 silme
  1. 4 2
      src/bgfx_p.h
  2. 2 2
      tools/shaderc/shaderc_spirv.cpp

+ 4 - 2
src/bgfx_p.h

@@ -4868,7 +4868,7 @@ namespace bgfx
 				}
 			}
 
-			_num  = bx::max<uint16_t>(1, _num);
+			_num = bx::max<uint16_t>(1, _num);
 
 			uint16_t idx = m_uniformHashMap.find(bx::hash<bx::HashMurmur2A>(_name) );
 			if (kInvalidHandle != idx)
@@ -4890,6 +4890,8 @@ namespace bgfx
 					uniform.m_type = oldsize < newsize ? _type : uniform.m_type;
 					uniform.m_num  = bx::max<uint16_t>(uniform.m_num, _num);
 
+					BX_TRACE("  Resize uniform (handle %3d) `%s`, num %d", handle.idx, _name, _num);
+
 					CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateUniform);
 					cmdbuf.write(handle);
 					cmdbuf.write(uniform.m_type);
@@ -4911,7 +4913,7 @@ namespace bgfx
 				return BGFX_INVALID_HANDLE;
 			}
 
-			BX_TRACE("Creating uniform (handle %3d) %s", handle.idx, _name);
+			BX_TRACE("Creating uniform (handle %3d) `%s`, num %d", handle.idx, _name, _num);
 
 			UniformRef& uniform = m_uniformRef[handle.idx];
 			uniform.m_name.set(_name);

+ 2 - 2
tools/shaderc/shaderc_spirv.cpp

@@ -652,10 +652,10 @@ namespace bgfx { namespace spirv
 							continue;
 						}
 
-						un.num = 0;
+						un.num = uint8_t(program->getUniformArraySize(ii) );
 						const uint32_t offset = program->getUniformBufferOffset(ii);
 						un.regIndex = uint16_t(offset);
-						un.regCount = uint16_t(program->getUniformArraySize(ii));
+						un.regCount = un.num;
 
 						switch (program->getUniformType(ii) )
 						{