浏览代码

Optimizing renderer

Panagiotis Christopoulos Charitos 10 年之前
父节点
当前提交
f065b378d5

+ 2 - 1
include/anki/gr/Enums.h

@@ -156,7 +156,8 @@ enum class SamplingFilter: U8
 {
 	NEAREST,
 	LINEAR,
-	TRILINEAR
+	NEAREST_MIPMAP,
+	TRILINEAR,
 };
 
 enum class ShaderType: U8

+ 3 - 0
include/anki/gr/gl/TextureImpl.h

@@ -77,9 +77,12 @@ private:
 	U32 m_width = 0;
 	U32 m_height = 0;
 	U32 m_depth = 0;
+	U8 m_mipsCount = 0;
 	Bool8 m_compressed = false;
 
 	void destroy();
+
+	static U32 computeMaxMipmapCount(U32 w, U32 h);
 };
 
 /// Sampler container

+ 2 - 2
include/anki/renderer/Renderer.h

@@ -228,8 +228,8 @@ public:
 
 	/// Create a framebuffer attachment texture
 	ANKI_USE_RESULT Error createRenderTarget(U32 w, U32 h, 
-		const PixelFormat& format, U32 samples, Bool linear,
-		TextureHandle& rt);
+		const PixelFormat& format, U32 samples, SamplingFilter filter,
+		U mipsCount, TextureHandle& rt);
 
 	/// Create a pipeline object that has as a vertex shader the m_drawQuadVert
 	/// and the given fragment progam

+ 24 - 11
shaders/PpsHdr.frag.glsl

@@ -6,26 +6,39 @@
 #pragma anki type frag
 #pragma anki include "shaders/Common.glsl"
 
-layout(binding = 0) uniform lowp sampler2D tex; ///< Its the IS RT
+// Vars
+layout(binding = 0) uniform lowp sampler2D u_tex; ///< Its the IS RT
 
-layout(std140) uniform commonBlock
+layout(std140) uniform _blk
 {
-	vec4 inExposureComp;
+	vec4 u_exposureComp;
 };
-#define inExposure inExposureComp.x
 
-layout(location = 0) in vec2 inTexCoord;
-layout(location = 0) out vec3 outColor;
+layout(location = 0) in vec2 in_texCoord;
+layout(location = 0) out vec3 out_color;
 
-const float brightMax = 4.0;
+// Consts
+const uint MIPMAP = 4;
+const uint WIDTH = ANKI_RENDERER_WIDTH / (2 << (MIPMAP - 1));
+const uint HEIGHT = ANKI_RENDERER_HEIGHT / (2 << (MIPMAP - 1));
+
+const vec2 TEXTURE_SIZE = vec2(WIDTH, HEIGHT);
+const vec2 SCALE = (TEXTURE_SIZE - 1.0) / TEXTURE_SIZE;
+const vec2 OFFSET = 1.0 / (2.0 * TEXTURE_SIZE);
+
+const float BRIGHT_MAX = 5.0;
 
 void main()
 {
-	vec3 color = textureRt(tex, inTexCoord).rgb;
+	vec3 color = 
+		textureLod(u_tex, in_texCoord + OFFSET, float(MIPMAP)).rgb;
 
+#if 1
 	float luminance = dot(vec3(0.30, 0.59, 0.11), color);
-	float yd = inExposure * (inExposure / brightMax + 1.0) /
-		(inExposure + 1.0) * luminance;
+	float yd = u_exposureComp.x * (u_exposureComp.x / BRIGHT_MAX + 1.0) /
+		(u_exposureComp.x + 1.0) * luminance;
 	color *= yd;
-	outColor = color;
+#endif
+
+	out_color = color;
 }

+ 12 - 10
shaders/PpsSsao.frag.glsl

@@ -11,7 +11,13 @@
 
 const vec3 KERNEL[KERNEL_SIZE] = KERNEL_ARRAY; // This will be appended in C++
 
-layout(location = 0) in vec2 inTexCoords;
+const float RADIUS = 0.5;
+// Initial is 1.0 but the bigger it is the more darker the SSAO factor gets
+const float DARKNESS_MULTIPLIER = 2.5;
+
+
+
+layout(location = 0) in vec2 in_texCoords;
 
 layout(location = 0) out float outColor;
 
@@ -27,10 +33,6 @@ layout(binding = 0) uniform sampler2D uMsDepthRt;
 layout(binding = 1) uniform sampler2D uMsRt;
 layout(binding = 2) uniform sampler2D uNoiseMap;
 
-#define RADIUS 0.5
-#define DARKNESS_MULTIPLIER 1.5 // Initial is 1.0 but the bigger it is the more
-                                // darker the SSAO factor gets
-
 // Get normal
 vec3 readNormal(in vec2 uv)
 {
@@ -54,7 +56,7 @@ vec3 readRandom(in vec2 uv)
 // Returns the Z of the position in view space
 float readZ(in vec2 uv)
 {
-	float depth = textureRt(uMsDepthRt, uv).r;
+	float depth = textureLod(uMsDepthRt, uv, 1.0).r;
 	float z = uProjectionParams.z / (uProjectionParams.w + depth);
 	return z;
 }
@@ -62,7 +64,7 @@ float readZ(in vec2 uv)
 // Read position in view space
 vec3 readPosition(in vec2 uv)
 {
-	float depth = textureRt(uMsDepthRt, uv).r;
+	float depth = textureLod(uMsDepthRt, uv, 1.0).r;
 
 	vec3 fragPosVspace;
 	fragPosVspace.z = readZ(uv);
@@ -75,10 +77,10 @@ vec3 readPosition(in vec2 uv)
 
 void main(void)
 {
-	vec3 origin = readPosition(inTexCoords);
+	vec3 origin = readPosition(in_texCoords);
 
-	vec3 normal = readNormal(inTexCoords);
-	vec3 rvec = readRandom(inTexCoords);
+	vec3 normal = readNormal(in_texCoords);
+	vec3 rvec = readRandom(in_texCoords);
 	
 	vec3 tangent = normalize(rvec - normal * dot(rvec, normal));
 	vec3 bitangent = cross(normal, tangent);

+ 2 - 2
shaders/PpsSslr.frag.glsl

@@ -31,7 +31,7 @@ layout(binding = 2) uniform sampler2D uMsRt;
 // Returns the Z of the position in view space
 float readZ(in vec2 uv)
 {
-	float depth = textureRt(uMsDepthRt, uv).r;
+	float depth = textureLod(uMsDepthRt, uv, 1.0).r;
 	float z = uProjectionParams.z / (uProjectionParams.w + depth);
 	return z;
 }
@@ -39,7 +39,7 @@ float readZ(in vec2 uv)
 // Read position in view space
 vec3 readPosition(in vec2 uv)
 {
-	float depth = textureRt(uMsDepthRt, uv).r;
+	float depth = textureLod(uMsDepthRt, uv, 1.0).r;
 
 	vec3 fragPosVspace;
 	fragPosVspace.z = readZ(uv);

+ 9 - 7
shaders/VariableSamplingBlurGeneric.frag.glsl

@@ -38,7 +38,7 @@ layout(binding = 1)
 #endif
 	uniform mediump sampler2D uTex; 
 
-layout(location = 0) in vec2 inTexCoord;
+layout(location = 0) in vec2 in_texCoord;
 
 #if !defined(BLURRING_DIST)
 #	define BLURRING_DIST 0.0
@@ -62,8 +62,10 @@ layout(location = 0) in vec2 inTexCoord;
 #	define TEX_FETCH r
 #endif
 
+const float OFFSET = 1.0 / (2.0 * IMG_DIMENSION);
+
 // Calc the kernel. Use offsets of 3 to take advantage of bilinear filtering
-#define BLURRING(val, sign_) ((float(val) * (float(BLURRING_DIST) + 1.0) / float(IMG_DIMENSION)) * float(sign_))
+#define BLURRING(val, sign_) ((float(val) * (float(BLURRING_DIST) + 1.0) / float(IMG_DIMENSION)) * float(sign_) + OFFSET)
 
 #if defined(VPASS)
 #	define BLURRING_OFFSET_X(val, sign_) BLURRING(val, sign_)
@@ -75,7 +77,7 @@ layout(location = 0) in vec2 inTexCoord;
 
 #define BLURRING_OFFSET(v, s) vec2(BLURRING_OFFSET_X(v, s), BLURRING_OFFSET_Y(v, s))
 
-const vec2 kernel[SAMPLES - 1] = vec2[](
+const vec2 KERNEL[SAMPLES - 1] = vec2[](
 	BLURRING_OFFSET(1, -1),
 	BLURRING_OFFSET(1, 1)
 #if SAMPLES > 3
@@ -112,18 +114,18 @@ const vec2 kernel[SAMPLES - 1] = vec2[](
 #endif
 	);
 
-layout(location = 0) out COL_TYPE outFragColor;
+layout(location = 0) out COL_TYPE out_fragColor;
 
 void main()
 {
 	// Get the first
-	COL_TYPE col = textureRt(uTex, inTexCoord).TEX_FETCH;
+	COL_TYPE col = textureRt(uTex, in_texCoord).TEX_FETCH;
 
 	// Get the rest of the samples
 	for(uint i = 0; i < SAMPLES - 1; i++)
 	{
-		col += textureRt(uTex, inTexCoord + kernel[i]).TEX_FETCH;
+		col += textureRt(uTex, in_texCoord + KERNEL[i]).TEX_FETCH;
 	}
 
-	outFragColor = col / float(SAMPLES);
+	out_fragColor = col / float(SAMPLES);
 }

+ 26 - 5
src/gr/gl/TextureImpl.cpp

@@ -175,6 +175,9 @@ void TextureImpl::create(const Initializer& init)
 	convertTextureInformation(
 		init.m_format, m_compressed, m_format, m_internalFormat, m_type);
 
+	m_mipsCount = 
+		min<U>(init.m_mipmapsCount, computeMaxMipmapCount(m_width, m_height));
+
 	// Bind
 	bind(0);
 
@@ -184,7 +187,7 @@ void TextureImpl::create(const Initializer& init)
 	case GL_TEXTURE_2D:
 		glTexStorage2D(
 			m_target, 
-			init.m_mipmapsCount, 
+			m_mipsCount, 
 			m_internalFormat,
 			m_width,
 			m_height);
@@ -194,7 +197,7 @@ void TextureImpl::create(const Initializer& init)
 	case GL_TEXTURE_3D:
 		glTexStorage3D(
 			m_target,
-			init.m_mipmapsCount,
+			m_mipsCount,
 			m_internalFormat,
 			m_width,
 			m_height,
@@ -218,7 +221,7 @@ void TextureImpl::create(const Initializer& init)
 	{
 		U w = m_width;
 		U h = m_height;
-		for(U level = 0; level < init.m_mipmapsCount; level++)
+		for(U level = 0; level < m_mipsCount; level++)
 		{
 			ANKI_ASSERT(init.m_data[level][0].m_ptr != nullptr);
 
@@ -370,8 +373,7 @@ void TextureImpl::create(const Initializer& init)
 		}
 
 		// Make sure that the texture is complete
-		glTexParameteri(
-			m_target, GL_TEXTURE_MAX_LEVEL, init.m_mipmapsCount - 1);
+		glTexParameteri(m_target, GL_TEXTURE_MAX_LEVEL, m_mipsCount - 1);
 
 		// Set filtering type
 		switch(sinit.m_filterType)
@@ -384,6 +386,11 @@ void TextureImpl::create(const Initializer& init)
 			glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 			glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 			break;
+		case SamplingFilter::NEAREST_MIPMAP:
+			glTexParameteri(
+				m_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
+			glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+			break;
 		case SamplingFilter::TRILINEAR:
 			glTexParameteri(
 				m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
@@ -440,6 +447,20 @@ void TextureImpl::generateMipmaps()
 	glGenerateMipmap(m_target);
 }
 
+//==============================================================================
+U32 TextureImpl::computeMaxMipmapCount(U32 w, U32 h)
+{
+	U32 s = min(w, h);
+	U count = 0;
+	while(s)
+	{
+		s /= 2;
+		++count;
+	}
+
+	return count;
+}
+
 //==============================================================================
 // SamplerImpl                                                                 =
 //==============================================================================

+ 1 - 1
src/renderer/Dp.cpp

@@ -18,7 +18,7 @@ Error Dp::init(const ConfigSet& config)
 	ANKI_CHECK(m_r->createRenderTarget(
 		m_smallDepthSize.x(), m_smallDepthSize.y(),
 		PixelFormat(ComponentFormat::D24, TransformFormat::FLOAT),
-		1, true, m_smallDepthRt));
+		1, SamplingFilter::LINEAR, 1, m_smallDepthRt));
 
 	GrManager& gl = getGrManager();
 	CommandBufferHandle cmdb;

+ 1 - 1
src/renderer/Drawer.cpp

@@ -202,7 +202,7 @@ public:
 			{
 				auto unit = glvar.getTextureUnit();
 
-				m_drawer->m_r->getDp().getSmallDepthRt().bind(m_cmdBuff, unit);
+				m_drawer->m_r->getMs()._getDepthRt().bind(m_cmdBuff, unit);
 			}
 			break;
 		default:

+ 10 - 11
src/renderer/Hdr.cpp

@@ -18,7 +18,7 @@ Error Hdr::initFb(FramebufferHandle& fb, TextureHandle& rt)
 {
 	ANKI_CHECK(m_r->createRenderTarget(m_width, m_height, 
 		PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM), 
-		1, true, rt));
+		1, SamplingFilter::LINEAR, 1, rt));
 
 	// Set to bilinear because the blurring techniques take advantage of that
 	CommandBufferHandle cmdb;
@@ -74,8 +74,9 @@ Error Hdr::initInternal(const ConfigSet& initializer)
 
 	cmdb.flush();
 
-	ANKI_CHECK(
-		m_toneFrag.load("shaders/PpsHdr.frag.glsl", &getResourceManager()));
+	ANKI_CHECK(m_toneFrag.loadToCache(&getResourceManager(),
+		"shaders/PpsHdr.frag.glsl", 
+		m_r->_getShadersPrependedSource().toCString(), "r_"));
 
 	ANKI_CHECK(m_r->createDrawQuadPipeline(
 		m_toneFrag->getGrShader(), m_tonePpline));
@@ -87,11 +88,10 @@ Error Hdr::initInternal(const ConfigSet& initializer)
 	pps.sprintf(
 		"#define HPASS\n"
 		"#define COL_RGB\n"
-		"#define BLURRING_DIST float(%f)\n"
+		"#define BLURRING_DIST float(1.1)\n"
 		"#define IMG_DIMENSION %u\n"
-		"#define SAMPLES %u\n",
-		m_blurringDist, m_height, 
-		static_cast<U>(initializer.get("pps.hdr.samples")));
+		"#define SAMPLES 17\n",
+		m_height);
 
 	ANKI_CHECK(m_hblurFrag.loadToCache(&getResourceManager(),
 		SHADER_FILENAME, pps.toCString(), "r_"));
@@ -103,11 +103,10 @@ Error Hdr::initInternal(const ConfigSet& initializer)
 	pps.sprintf(
 		"#define VPASS\n"
 		"#define COL_RGB\n"
-		"#define BLURRING_DIST float(%f)\n"
+		"#define BLURRING_DIST float(1.0)\n"
 		"#define IMG_DIMENSION %u\n"
-		"#define SAMPLES %u\n",
-		m_blurringDist, m_width, 
-		static_cast<U>(initializer.get("pps.hdr.samples")));
+		"#define SAMPLES 15\n",
+		m_width);
 
 	ANKI_CHECK(m_vblurFrag.loadToCache(&getResourceManager(),
 		SHADER_FILENAME, pps.toCString(), "r_"));

+ 4 - 3
src/renderer/Is.cpp

@@ -164,7 +164,6 @@ Error Is::initInternal(const ConfigSet& config)
 	
 	m_maxLightIds *= m_r->getTilesCountXY();
 
-
 	//
 	// Init the passes
 	//
@@ -223,8 +222,8 @@ Error Is::initInternal(const ConfigSet& config)
 
 	ANKI_CHECK(m_r->createRenderTarget(
 		m_r->getWidth(), m_r->getHeight(), 
-		PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM), 
-		1, false, m_rt));
+		PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM), 
+		1, SamplingFilter::NEAREST_MIPMAP, 6, m_rt));
 
 	FramebufferHandle::Initializer fbInit;
 	fbInit.m_colorAttachmentsCount = 1;
@@ -471,6 +470,8 @@ Error Is::lightPass(CommandBufferHandle& cmdBuff)
 
 	cmdBuff.drawArrays(GL_TRIANGLE_STRIP, 4, m_r->getTilesCountXY());
 
+	m_rt.generateMipmaps(cmdBuff);
+
 	return err;
 }
 

+ 1 - 1
src/renderer/Lf.cpp

@@ -174,7 +174,7 @@ Error Lf::initInternal(const ConfigSet& config)
 	ANKI_CHECK(m_r->createRenderTarget(m_r->getPps().getHdr()._getWidth(), 
 		m_r->getPps().getHdr()._getHeight(), 
 		PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM), 
-		1, true, m_rt));
+		1, SamplingFilter::LINEAR, 1, m_rt));
 
 	FramebufferHandle::Initializer fbInit;
 	fbInit.m_colorAttachmentsCount = 1;

+ 4 - 6
src/renderer/MainRenderer.cpp

@@ -66,10 +66,9 @@ Error MainRenderer::render(SceneGraph& scene)
 
 	ANKI_CHECK(Renderer::render(scene, jobs));
 
-	/*Bool alreadyDrawnToDefault = 
+	Bool alreadyDrawnToDefault = 
 		!getDbg().getEnabled()
-		&& getRenderingQuality() == 1.0;*/
-	Bool alreadyDrawnToDefault = false;
+		&& getRenderingQuality() == 1.0;
 
 	if(!alreadyDrawnToDefault)
 	{
@@ -90,10 +89,9 @@ Error MainRenderer::render(SceneGraph& scene)
 			rt = &getIs()._getRt();
 		}
 
-		//rt = &getTiler().getRt();
-		//rt = &getMs()._getRt0();
+		//rt = &getIs()._getRt();
+		//rt = &getPps().getHdr()._getRt();
 
-		//rt->setFilter(lastJobs, TextureHandle::Filter::LINEAR);
 		rt->bind(lastJobs, 0);
 
 		drawQuad(lastJobs);

+ 12 - 11
src/renderer/Ms.cpp

@@ -25,15 +25,15 @@ Error Ms::createRt(U32 index, U32 samples)
 
 	ANKI_CHECK(m_r->createRenderTarget(m_r->getWidth(), m_r->getHeight(),
 		PixelFormat(ComponentFormat::D24, TransformFormat::FLOAT),
-		samples, false, plane.m_depthRt));
+		samples, SamplingFilter::NEAREST, 1, plane.m_depthRt));
 
 	ANKI_CHECK(m_r->createRenderTarget(m_r->getWidth(), m_r->getHeight(), 
-		PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM),
-		samples, false, plane.m_rt0));
+		PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM),
+		samples, SamplingFilter::NEAREST, 1, plane.m_rt0));
 
 	ANKI_CHECK(m_r->createRenderTarget(m_r->getWidth(), m_r->getHeight(), 
-		PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM), 
-		samples, false, plane.m_rt1));
+		PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM), 
+		samples, SamplingFilter::NEAREST, 2, plane.m_rt1));
 
 	GrManager& gl = getGrManager();
 	CommandBufferHandle cmdb;
@@ -88,15 +88,14 @@ Error Ms::initInternal(const ConfigSet& initializer)
 Error Ms::run(CommandBufferHandle& cmdb)
 {
 	// Chose the multisampled or the singlesampled framebuffer
-	if(m_r->getSamples() > 1)
-	{
-		m_planes[0].m_fb.bind(cmdb);
-	}
-	else
+	U planeId = 0;
+	if(m_r->getSamples() == 1)
 	{
-		m_planes[1].m_fb.bind(cmdb);
+		planeId = 1;
 	}
 
+	m_planes[planeId].m_fb.bind(cmdb);
+
 	cmdb.setViewport(0, 0, m_r->getWidth(), m_r->getHeight());
 
 	cmdb.enableDepthTest(true);
@@ -145,6 +144,8 @@ Error Ms::run(CommandBufferHandle& cmdb)
 		ANKI_ASSERT(0 && "TODO");
 	}
 
+	m_planes[planeId].m_depthRt.generateMipmaps(cmdb);
+
 	cmdb.enableDepthTest(false);
 
 	return ErrorCode::NONE;

+ 3 - 4
src/renderer/Pps.cpp

@@ -50,7 +50,7 @@ Error Pps::initInternal(const ConfigSet& config)
 		m_r->createRenderTarget(
 		m_r->getWidth(), m_r->getHeight(), 
 		PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM), 
-		1, true, m_rt));
+		1, SamplingFilter::LINEAR, 1, m_rt));
 
 	FramebufferHandle::Initializer fbInit;
 	fbInit.m_colorAttachmentsCount = 1;
@@ -125,11 +125,10 @@ Error Pps::run(CommandBufferHandle& cmdBuff)
 		ANKI_CHECK(m_lf.run(cmdBuff));
 	}
 
-	/*Bool drawToDefaultFbo = 
+	Bool drawToDefaultFbo = 
 		!m_r->getDbg().getEnabled() 
 		&& !m_r->getIsOffscreen()
-		&& m_r->getRenderingQuality() == 1.0;*/
-	Bool drawToDefaultFbo = false;
+		&& m_r->getRenderingQuality() == 1.0;
 
 	if(drawToDefaultFbo)
 	{

+ 10 - 11
src/renderer/Renderer.cpp

@@ -98,6 +98,13 @@ Error Renderer::initInternal(const ConfigSet& config)
 		return ErrorCode::USER_DATA;
 	}
 
+	// Set the default preprocessor string
+	m_shadersPrependedSource.sprintf(
+		m_alloc,
+		"#define ANKI_RENDERER_WIDTH %u\n"
+		"#define ANKI_RENDERER_HEIGHT %u\n",
+		m_width, m_height);
+
 	// Drawer
 	ANKI_CHECK(m_sceneDrawer.create(this));
 
@@ -131,13 +138,6 @@ Error Renderer::initInternal(const ConfigSet& config)
 
 	cmdBuff.finish();
 
-	// Set the default preprocessor string
-	m_shadersPrependedSource.sprintf(
-		m_alloc,
-		"#define ANKI_RENDERER_WIDTH %u\n"
-		"#define ANKI_RENDERER_HEIGHT %u\n",
-		m_width, m_height);
-
 	return ErrorCode::NONE;
 }
 
@@ -245,7 +245,7 @@ Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat,
 
 //==============================================================================
 Error Renderer::createRenderTarget(U32 w, U32 h, const PixelFormat& format, 
-	U32 samples, Bool linear, TextureHandle& rt)
+	U32 samples, SamplingFilter filter, U mipsCount, TextureHandle& rt)
 {
 	// Not very important but keep the resulution of render targets aligned to
 	// 16
@@ -262,10 +262,9 @@ Error Renderer::createRenderTarget(U32 w, U32 h, const PixelFormat& format,
 	init.m_depth = 0;
 	init.m_type = TextureType::_2D;
 	init.m_format = format;
-	init.m_mipmapsCount = 1;
+	init.m_mipmapsCount = mipsCount;
 	init.m_samples = samples;
-	init.m_sampling.m_filterType = 
-		(linear) ? SamplingFilter::LINEAR : SamplingFilter::NEAREST;
+	init.m_sampling.m_filterType = filter;
 	init.m_sampling.m_repeat = false;
 	init.m_sampling.m_anisotropyLevel = 0;
 

+ 1 - 1
src/renderer/RenderingPass.cpp

@@ -71,7 +71,7 @@ Error BlurringRenderingPass::initBlurring(
 
 		ANKI_CHECK(r.createRenderTarget(width, height, 
 			PixelFormat(ComponentFormat::R8G8B8, TransformFormat::UNORM),
-			1, true, dir.m_rt));
+			1, SamplingFilter::LINEAR, 1, dir.m_rt));
 
 		// Create FB
 		FramebufferHandle::Initializer fbInit;

+ 4 - 4
src/renderer/Ssao.cpp

@@ -71,7 +71,7 @@ Error Ssao::createFb(FramebufferHandle& fb, TextureHandle& rt)
 {
 	ANKI_CHECK(m_r->createRenderTarget(m_width, m_height, 
 		PixelFormat(ComponentFormat::R8, TransformFormat::UNORM), 
-		1, true, rt));
+		1, SamplingFilter::LINEAR, 1, rt));
 
 	// Set to bilinear because the blurring techniques take advantage of that
 	CommandBufferHandle cmdBuff;
@@ -194,7 +194,7 @@ Error Ssao::initInternal(const ConfigSet& config)
 		"#define HPASS\n"
 		"#define COL_R\n"
 		"#define IMG_DIMENSION %u\n"
-		"#define SAMPLES 7\n", 
+		"#define SAMPLES 11\n", 
 		m_height);
 
 	ANKI_CHECK(m_hblurFrag.loadToCache(&getResourceManager(),
@@ -208,7 +208,7 @@ Error Ssao::initInternal(const ConfigSet& config)
 		"#define VPASS\n"
 		"#define COL_R\n"
 		"#define IMG_DIMENSION %u\n"
-		"#define SAMPLES 7\n", 
+		"#define SAMPLES 9\n", 
 		m_width);
 
 	ANKI_CHECK(m_vblurFrag.loadToCache(&getResourceManager(),
@@ -252,7 +252,7 @@ Error Ssao::run(CommandBufferHandle& cmdb)
 	m_uniformsBuff.bindShaderBuffer(cmdb, 0);
 
 	Array<TextureHandle, 3> tarr = {{
-		m_r->getDp().getSmallDepthRt(),
+		m_r->getMs()._getDepthRt(),
 		m_r->getMs()._getRt1(),
 		m_noiseTex}};
 	cmdb.bindTextures(0, tarr.begin(), tarr.getSize());

+ 3 - 3
src/renderer/Sslr.cpp

@@ -56,12 +56,12 @@ Error Sslr::init(const ConfigSet& config)
 	}
 	else
 	{
-		Direction& dir = m_dirs[(U)DirectionEnum::VERTICAL];
+		Direction& dir = m_dirs[U(DirectionEnum::VERTICAL)];
 
 		ANKI_CHECK(
 			m_r->createRenderTarget(m_width, m_height, 
 			PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM), 
-			1, true, dir.m_rt));
+			1, SamplingFilter::LINEAR, 1, dir.m_rt));
 
 		// Create FB
 		CommandBufferHandle cmdBuff;
@@ -94,7 +94,7 @@ Error Sslr::run(CommandBufferHandle& cmdBuff)
 
 	Array<TextureHandle, 3> tarr = {{
 		m_r->getIs()._getRt(),
-		m_r->getDp().getSmallDepthRt(),
+		m_r->getMs()._getDepthRt(),
 		m_r->getMs()._getRt1()}};
 	cmdBuff.bindTextures(0	, tarr.begin(), tarr.getSize()); 
 

+ 1 - 1
src/renderer/Tiler.cpp

@@ -105,7 +105,7 @@ Error Tiler::initInternal()
 		m_r->createRenderTarget(m_r->getTilesCount().x(), 
 		m_r->getTilesCount().y(), 
 		PixelFormat(ComponentFormat::R32G32, TransformFormat::UINT), 
-		1, false, m_rt));
+		1, SamplingFilter::NEAREST, 1, m_rt));
 
 	CommandBufferHandle cmdBuff;
 	ANKI_CHECK(cmdBuff.create(&getGrManager()));

+ 0 - 2
src/resource/Material.cpp

@@ -526,12 +526,10 @@ Error Material::parseMaterialTag(const XmlElement& materialEl,
 
 					StringAuto src(rinit.m_tempAlloc);
 					src.sprintf(
-						"%s\n"
 						"#define LOD %u\n"
 						"#define PASS %u\n"
 						"#define TESSELLATION %u\n"
 						"%s\n",
-						&rinit.m_resources._getShadersPrependedSource()[0],
 						level, pid, tess, &loader.getProgramSource(shader)[0]);
 
 					StringAuto filename(rinit.m_tempAlloc);

+ 4 - 1
src/resource/ShaderResource.cpp

@@ -31,9 +31,12 @@ Error ShaderResource::load(const CString& filename, const CString& extraSrc,
 	
 	// Allocate new source
 	StringAuto source(alloc);
+
+	source.append(manager._getShadersPrependedSource());
+
 	if(extraSrc.getLength() > 0)
 	{
-		source.create(extraSrc);
+		source.append(extraSrc);
 	}
 
 	source.append(pars.getShaderSource());