Browse Source

Finalizing the Ms

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
ff2889723b

+ 2 - 2
CMakeLists.txt

@@ -129,8 +129,8 @@ LINK_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/extern/lib64")
 #
 # Defines & flags
 #
-ADD_DEFINITIONS(#-DANKI_MATH_INTEL_SIMD
-	-Dthread_local=__thread -pedantic-errors -pedantic -ansi -Wall -Winline 
+ADD_DEFINITIONS(-DANKI_MATH_INTEL_SIMD
+	-Dthread_local=__thread -pedantic-errors -pedantic -ansi -Wall 
 	-W -Wwrite-strings -Wno-unused -Wfatal-errors -Werror -Wno-long-long 
 	-msse4 -std=c++0x)
 

+ 2 - 0
include/anki/renderer/Is.h

@@ -23,6 +23,8 @@ class Is: private RenderingPass
 public:
 	Is(Renderer* r);
 
+	~Is();
+
 	void init(const RendererInitializer& initializer);
 	void run();
 

+ 3 - 0
include/anki/resource/ResourceManager.h

@@ -14,6 +14,9 @@ struct ResourceHook
 	int referenceCounter;
 	Type* resource;
 
+	~ResourceHook()
+	{}
+
 	bool operator==(const ResourceHook& b) const
 	{
 		return uuid == b.uuid 

+ 5 - 0
include/anki/resource/ShaderProgramResource.h

@@ -9,6 +9,11 @@ namespace anki {
 class ShaderProgramResource: public ShaderProgram
 {
 public:
+	ShaderProgramResource()
+	{}
+	~ShaderProgramResource()
+	{}
+
 	/// Resource load
 	void load(const char* filename);
 

+ 3 - 1
include/anki/scene/Movable.h

@@ -24,7 +24,7 @@ public:
 		MF_MOVED = 2 ///< Moved in the previous frame
 	};
 
-	/// @name Constructors
+	/// @name Constructors & destructor
 	/// @{
 
 	/// The one and only constructor
@@ -32,6 +32,8 @@ public:
 	/// @param parent The parent. It can be nullptr
 	/// @param pmap Property map to add a few variables
 	Movable(uint flags, Movable* parent, PropertyMap& pmap);
+
+	~Movable();
 	/// @}
 
 	/// @name Accessors

+ 2 - 0
include/anki/util/BinaryStream.h

@@ -26,6 +26,8 @@ public:
 		: std::iostream(sb), byteOrder(byteOrder_)
 	{}
 
+	~BinaryStream();
+
 	/// Read unsigned int (32bit)
 	/// @exception Exception
 	uint32_t readUint();

+ 12 - 8
shaders/Final.glsl

@@ -6,19 +6,23 @@
 
 #pragma anki start fragmentShader
 
+#if 1
+uniform usampler2D rasterImage;
+#else
 uniform sampler2D rasterImage;
+#endif
+
 in vec2 vTexCoords;
 layout(location = 0) out vec3 fFragColor;
 
-
 void main()
 {
-	/*if(vTexCoords.y > 0.5)
-	{
-		fFragColor = vec3(1.0, 0.0, 1.0);
-		return;
-	}*/
-
+#if 1
+	uvec2 a = texture2D(rasterImage, vTexCoords).rg;
+	vec4 diffAndSpec = unpackUnorm4x8(a.x);
+	fFragColor = diffAndSpec.rgb;
+#else
 	fFragColor = texture2D(rasterImage, vTexCoords).rgb;
-	//fFragColor = vec3(texture2D(rasterImage, vTexCoords).b);
+#endif
+	//fFragColor = texture2D(rasterImage, vTexCoords).rgb;
 }

+ 9 - 4
shaders/MaterialFragmentFunctions.glsl

@@ -120,11 +120,16 @@ vec3 readRgbFromTexture(in sampler2D tex, in vec2 texCoords)
 void writeFais(
 	in vec3 diffCol, // Normalized
 	in vec3 normal, 
-	in float specularComponent, // Normalized
+	in vec2 specular, // Streangth and shininess
 	in float blurring)
 {
-	uint diffAndSpec = packUnorm4x8(vec4(diffCol, specularComponent));
-	uint norm = packHalf2x16(packNormal(normal));
-	fMsFai0 = uvec3(diffAndSpec, norm, 0);
+#if 1
+	// Diffuse color and specular
+	fMsFai0[0] = packUnorm4x8(vec4(diffCol, packSpecular(specular)));
+	// Normal
+	fMsFai0[1] = packHalf2x16(packNormal(normal));
+#else
+	fMsFai0 = vec3(diffCol);
+#endif
 }
 #endif

+ 5 - 1
shaders/MaterialFragmentVariables.glsl

@@ -26,7 +26,11 @@ in vec3 vVertPosViewSpace;
 /// @name Fragment out
 /// @{
 #if defined(PASS_COLOR)
-layout(location = 0) out uvec3 fMsFai0;
+#if 1
+layout(location = 0) out uvec2 fMsFai0;
+#else
+layout(location = 0) out vec3 fMsFai0;
+#endif
 #	define fMsFai0_DEFINED
 #endif
 /// @}

+ 13 - 2
shaders/Pack.glsl

@@ -19,10 +19,21 @@ vec3 unpackNormal(in vec2 enc)
 	return normal;
 }
 
+#define MAX_SPECULARITY 128.0
+
 /// Pack specular stuff
-float packSpecular(int vec3 color, int float shininess)
+float packSpecular(in vec2 c)
 {
-	float s = shininess / 128.0;
+	return round(c[0] * 15.0) * 16.0 / 255.0 
+		+ round(c[1] / MAX_SPECULARITY * 15.0) / 255.0;
+}
 
+/// Unpack specular
+vec2 unpackSpecular(in float f)
+{
+	float r = floor(f * 255.0 / 16.0);
 
+	return vec2(
+		r / 15.0,
+		f * 255.0 * MAX_SPECULARITY / 15.0 - r * 16.0 * MAX_SPECULARITY / 15.0);
 }

+ 1 - 0
src/collision/CollisionAlgorithmsMatrix.cpp

@@ -60,6 +60,7 @@ bool CollisionAlgorithmsMatrix::collide(const CollisionShape& a,
 		out = tcollide<Frustum>(a, b);
 	default:
 		ANKI_ASSERT(0 && "Forgot something");
+		out = false;
 	}
 
 	return out;

+ 8 - 6
src/core/App.cpp

@@ -103,8 +103,8 @@ void App::initWindow()
 	}
 
 	// set GL attribs
-	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
-	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
+	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
+	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
 	// WARNING: Set this low only in deferred shading
 	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
 	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
@@ -214,19 +214,21 @@ void App::printAppInfo()
 //==============================================================================
 uint App::getDesktopWidth() const
 {
-	SDL_DisplayMode mode;
+	/*SDL_DisplayMode mode;
 	/// @todo re-enable it
 	//SDL_GetDesktopDisplayMode(&mode);
-	return mode.w;
+	return mode.w;*/
+	return 0;
 }
 
 //==============================================================================
 uint App::getDesktopHeight() const
 {
-	SDL_DisplayMode mode;
+	/*SDL_DisplayMode mode;
 	/// @todo re-enable it
 	//SDL_GetDesktopDisplayMode(&mode);
-	return mode.h;
+	return mode.h;*/
+	return 0;
 }
 
 } // end namespace

+ 3 - 2
src/gl/ShaderProgram.cpp

@@ -137,7 +137,8 @@ void ShaderProgramUniformVariable::set(const Texture& tex) const
 {
 	doCommonSetCode();
 	ANKI_ASSERT(getGlDataType() == GL_SAMPLER_2D 
-		|| getGlDataType() == GL_SAMPLER_2D_SHADOW);
+		|| getGlDataType() == GL_SAMPLER_2D_SHADOW
+		|| getGlDataType() == GL_UNSIGNED_INT_SAMPLER_2D);
 	
 	glUniform1i(getLocation(), tex.bind());
 }
@@ -149,7 +150,7 @@ void ShaderProgramUniformVariable::set(const Texture& tex) const
 //==============================================================================
 
 const char* ShaderProgram::stdSourceCode =
-	"#version 330 core\n"
+	"#version 420 core\n"
 	//"precision lowp float;\n"
 #if defined(NDEBUG)
 	"#pragma optimize(on)\n"

+ 4 - 0
src/renderer/Is.cpp

@@ -10,6 +10,10 @@ Is::Is(Renderer* r_)
 	: RenderingPass(r_)
 {}
 
+//==============================================================================
+Is::~Is()
+{}
+
 //==============================================================================
 void Is::init(const RendererInitializer& /*initializer*/)
 {

+ 7 - 2
src/renderer/Ms.cpp

@@ -17,8 +17,13 @@ void Ms::init(const RendererInitializer& initializer)
 {
 	try
 	{
-		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGBA32UI,
-			GL_RGBA_INTEGER, GL_UNSIGNED_INT, fai0);
+#if 1
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RG32UI,
+			GL_RG_INTEGER, GL_UNSIGNED_INT, fai0);
+#else
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RG32F,
+			GL_RG, GL_UNSIGNED_INT, fai0);
+#endif
 		Renderer::createFai(r->getWidth(), r->getHeight(),
 			GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL,
 			GL_UNSIGNED_INT_24_8, depthFai);

+ 4 - 0
src/scene/Movable.cpp

@@ -19,6 +19,10 @@ Movable::Movable(uint flags_, Movable* parent, PropertyMap& pmap)
 	wTrf.setScale(0.0);
 }
 
+//==============================================================================
+Movable::~Movable()
+{}
+
 //==============================================================================
 void Movable::update()
 {

+ 4 - 0
src/util/BinaryStream.cpp

@@ -4,6 +4,10 @@
 
 namespace anki {
 
+//==============================================================================
+BinaryStream::~BinaryStream()
+{}
+
 //==============================================================================
 template<typename Type>
 Type BinaryStream::read32bitNumber()

+ 7 - 0
testapp/Main.cpp

@@ -232,12 +232,19 @@ void main()
 
 		// Sleep
 		//
+#if 0
 		timer.stop();
 		if(timer.getElapsedTime() < AppSingleton::get().getTimerTick())
 		{
 			SDL_Delay((AppSingleton::get().getTimerTick()
 				- timer.getElapsedTime()) * 1000.0);
 		}
+#else
+		if(MainRendererSingleton::get().getFramesCount() == 10000)
+		{
+			break;
+		}
+#endif
 
 	}