瀏覽代碼

Fix some GL errors and make valgrind happy again

Panagiotis Christopoulos Charitos 7 年之前
父節點
當前提交
a7458df61b

+ 1 - 1
programs/DeferredShading.ankiprog

@@ -38,7 +38,7 @@ void main()
 
 		<shader type="frag">
 			<inputs>
-				<input name="FB_SIZE" type="uvec2" const="1" />
+				<input name="FB_SIZE" type="uvec2" const="1"/>
 			</inputs>
 
 			<source><![CDATA[

+ 1 - 1
src/anki/collision/Aabb.h

@@ -30,7 +30,7 @@ public:
 		, m_min(min)
 		, m_max(max)
 	{
-		ANKI_ASSERT(min.x() == 0.0f && max.x() == 0.0f);
+		ANKI_ASSERT(min.w() == 0.0f && max.w() == 0.0f);
 		ANKI_ASSERT(m_min.xyz() < m_max.xyz());
 	}
 

+ 12 - 9
src/anki/gr/Common.h

@@ -108,15 +108,6 @@ extern Array<CString, U(GpuVendor::COUNT)> GPU_VENDOR_STR;
 class GpuDeviceCapabilities
 {
 public:
-	/// Max push constant size.
-	U32 m_pushConstantsSize = 128;
-
-	/// GPU vendor.
-	GpuVendor m_gpuVendor = GpuVendor::UNKNOWN;
-
-	/// Device supports subgroup operations.
-	Bool8 m_shaderSubgroups = false;
-
 	/// The alignment of offsets when bounding uniform buffers.
 	PtrSize m_uniformBufferBindOffsetAlignment = MAX_U32;
 
@@ -134,6 +125,18 @@ public:
 
 	/// The max visible range of texture buffers inside the shaders.
 	PtrSize m_textureBufferMaxRange = 0;
+
+	/// Max push constant size.
+	U32 m_pushConstantsSize = 128;
+
+	/// GPU vendor.
+	GpuVendor m_gpuVendor = GpuVendor::UNKNOWN;
+
+	/// Device supports subgroup operations.
+	Bool8 m_shaderSubgroups = false;
+
+	/// Pad it because valgrind complains.
+	U8 _m_padding[2] = {};
 };
 
 /// The type of the allocator for heap allocations

+ 1 - 1
src/anki/gr/ShaderCompiler.cpp

@@ -40,7 +40,7 @@ static const char* SHADER_HEADER = R"(#version 450 core
 #	define ANKI_TEX_BINDING(set_, binding_) binding = set_ * %u + binding_
 #	define ANKI_IMAGE_BINDING(set_, binding_) binding = set_ * %u + binding_
 #	define ANKI_SPEC_CONST(binding_, type_, name_) const type_ name_ = _anki_spec_const_ ## binding_
-#	define ANKI_PUSH_CONSTANTS(struct_, name_) layout(location = %u, row_major) uniform struct_ name_
+#	define ANKI_PUSH_CONSTANTS(struct_, name_) layout(location = %u) uniform struct_ name_
 #else
 #	define gl_VertexID gl_VertexIndex
 #	define gl_InstanceID gl_InstanceIndex

+ 11 - 2
src/anki/gr/ShaderCompiler.h

@@ -25,10 +25,19 @@ enum class ShaderLanguage : U8
 class ShaderCompilerOptions
 {
 public:
-	ShaderLanguage m_outLanguage = ShaderLanguage::COUNT;
-	ShaderType m_shaderType = ShaderType::COUNT;
+	ShaderLanguage m_outLanguage;
+	ShaderType m_shaderType;
 	GpuDeviceCapabilities m_gpuCapabilities;
 
+	ShaderCompilerOptions()
+	{
+		// Zero it because it will be hashed
+		zeroMemory(*this);
+		m_outLanguage = ShaderLanguage::COUNT;
+		m_shaderType = ShaderType::COUNT;
+		::new(&m_gpuCapabilities) GpuDeviceCapabilities();
+	}
+
 	void setFromGrManager(const GrManager& gr);
 };
 

+ 3 - 2
src/anki/gr/gl/CommandBuffer.cpp

@@ -1507,6 +1507,7 @@ void CommandBuffer::setPushConstants(const void* data, U32 dataSize)
 				static_cast<ShaderProgramImpl&>(*state.m_crntProg).getReflection();
 			ANKI_ASSERT(refl.m_uniformDataSize == m_data.getSizeInBytes());
 
+			const Bool transpose = true;
 			for(const ShaderProgramImplReflection::Uniform& uni : refl.m_uniforms)
 			{
 				const U8* data = reinterpret_cast<const U8*>(&m_data[0]) + uni.m_pushConstantOffset;
@@ -1525,7 +1526,7 @@ void CommandBuffer::setPushConstants(const void* data, U32 dataSize)
 					glUniform4uiv(loc, count, reinterpret_cast<const GLuint*>(data));
 					break;
 				case ShaderVariableDataType::MAT4:
-					glUniformMatrix4fv(loc, count, false, reinterpret_cast<const GLfloat*>(data));
+					glUniformMatrix4fv(loc, count, transpose, reinterpret_cast<const GLfloat*>(data));
 					break;
 				case ShaderVariableDataType::MAT3:
 				{
@@ -1533,7 +1534,7 @@ void CommandBuffer::setPushConstants(const void* data, U32 dataSize)
 					ANKI_ASSERT(count == 1 && "TODO");
 					const Mat3x4* m34 = reinterpret_cast<const Mat3x4*>(data);
 					Mat3 m3(m34->getRotationPart());
-					glUniformMatrix3fv(loc, count, false, reinterpret_cast<const GLfloat*>(&m3));
+					glUniformMatrix3fv(loc, count, transpose, reinterpret_cast<const GLfloat*>(&m3));
 					break;
 				}
 				default: