Kaynağa Gözat

More seperate image samplers

Panagiotis Christopoulos Charitos 6 yıl önce
ebeveyn
işleme
5383871959

+ 3 - 2
shaders/Blit.glslp

@@ -10,13 +10,14 @@
 #pragma anki start frag
 #include <shaders/Common.glsl>
 
-layout(set = 0, binding = 0) uniform sampler2D u_tex;
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform texture2D u_tex;
 
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out Vec3 out_col;
 
 void main()
 {
-	out_col = textureLod(u_tex, in_uv, 0.0).rgb;
+	out_col = textureLod(u_tex, u_linearAnyClampSampler, in_uv, 0.0).rgb;
 }
 #pragma anki end

+ 11 - 17
shaders/ExponentialShadowmappingResolve.glslp

@@ -10,23 +10,16 @@ const F32 OFFSET = 1.25;
 const Vec2 TEXEL_SIZE = 1.0 / Vec2(INPUT_TEXTURE_SIZE);
 const Vec2 HALF_TEXEL_SIZE = TEXEL_SIZE / 2.0;
 
-struct Uniforms
+layout(push_constant, std430) uniform pc_
 {
-	Vec2 m_uvScale;
-	Vec2 m_uvTranslation;
-	F32 m_near;
-	F32 m_far;
-	U32 m_renderingTechnique; // If value is 0: perspective+blur, 1: perspective, 2: ortho+blur, 3: ortho
-	U32 m_padding;
+	Vec2 u_uvScale;
+	Vec2 u_uvTranslation;
+	F32 u_near;
+	F32 u_far;
+	U32 u_renderingTechnique; // If value is 0: perspective+blur, 1: perspective, 2: ortho+blur, 3: ortho
+	U32 u_padding;
 };
 
-ANKI_PUSH_CONSTANTS(Uniforms, u_regs);
-#define u_uvScale u_regs.m_uvScale
-#define u_uvTranslation u_regs.m_uvTranslation
-#define u_near u_regs.m_near
-#define u_far u_regs.m_far
-#define u_renderingTechnique u_regs.m_renderingTechnique
-
 #pragma anki start vert
 #include <shaders/Common.glsl>
 
@@ -61,20 +54,21 @@ layout(location = 0) in Vec2 in_uv;
 layout(location = 1) flat in Vec2 in_maxUv;
 layout(location = 2) flat in Vec2 in_minUv;
 
-layout(set = 0, binding = 0) uniform sampler2D u_inputTex;
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform texture2D u_inputTex;
 
 layout(location = 0) out F32 out_color;
 
 F32 sampleLinearDepthPerspective(Vec2 uv)
 {
 	uv = clamp(uv, in_minUv, in_maxUv);
-	return linearizeDepth(textureLod(u_inputTex, uv, 0.0).r, u_near, u_far);
+	return linearizeDepth(textureLod(u_inputTex, u_linearAnyClampSampler, uv, 0.0).r, u_near, u_far);
 }
 
 F32 sampleLinearDepthOrhographic(Vec2 uv)
 {
 	uv = clamp(uv, in_minUv, in_maxUv);
-	return textureLod(u_inputTex, uv, 0.0).r;
+	return textureLod(u_inputTex, u_linearAnyClampSampler, uv, 0.0).r;
 }
 
 void main()

+ 15 - 14
shaders/GaussianBlur.glsl

@@ -39,11 +39,12 @@
 #	error See file
 #endif
 
-layout(set = 0, binding = 0) uniform sampler2D u_tex; ///< Input texture
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform texture2D u_tex; ///< Input texture
 
 #if USE_COMPUTE
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
-layout(set = 0, binding = 1) writeonly uniform image2D u_outImg;
+layout(set = 0, binding = 2) writeonly uniform image2D u_outImg;
 #else
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out COL_TYPE out_color;
@@ -75,15 +76,15 @@ void main()
 #		define X_OR_Y y
 #	endif
 
-	COL_TYPE color = textureLod(u_tex, uv, 0.0).TEX_FETCH * WEIGHTS[0u];
+	COL_TYPE color = textureLod(u_tex, u_linearAnyClampSampler, uv, 0.0).TEX_FETCH * WEIGHTS[0u];
 
 	Vec2 uvOffset = Vec2(0.0);
 	uvOffset.X_OR_Y = 1.5 * TEXEL_SIZE.X_OR_Y;
 
 	ANKI_UNROLL for(U32 i = 0u; i < STEP_COUNT; ++i)
 	{
-		const COL_TYPE col =
-			textureLod(u_tex, uv + uvOffset, 0.0).TEX_FETCH + textureLod(u_tex, uv - uvOffset, 0.0).TEX_FETCH;
+		COL_TYPE col = textureLod(u_tex, u_linearAnyClampSampler, uv + uvOffset, 0.0).TEX_FETCH;
+		col += textureLod(u_tex, u_linearAnyClampSampler, uv - uvOffset, 0.0).TEX_FETCH;
 		color += WEIGHTS[i + 1u] * col;
 
 		uvOffset.X_OR_Y += 2.0 * TEXEL_SIZE.X_OR_Y;
@@ -93,19 +94,19 @@ void main()
 
 	const Vec2 OFFSET = 1.5 * TEXEL_SIZE;
 
-	COL_TYPE color = textureLod(u_tex, uv, 0.0).TEX_FETCH * BOX_WEIGHTS[0u];
+	COL_TYPE color = textureLod(u_tex, u_linearAnyClampSampler, uv, 0.0).TEX_FETCH * BOX_WEIGHTS[0u];
 
 	COL_TYPE col;
-	col = textureLod(u_tex, uv + Vec2(OFFSET.x, 0.0), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, uv + Vec2(0.0, OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, uv + Vec2(-OFFSET.x, 0.0), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, uv + Vec2(0.0, -OFFSET.y), 0.0).TEX_FETCH;
+	col = textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(OFFSET.x, 0.0), 0.0).TEX_FETCH;
+	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(0.0, OFFSET.y), 0.0).TEX_FETCH;
+	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(-OFFSET.x, 0.0), 0.0).TEX_FETCH;
+	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(0.0, -OFFSET.y), 0.0).TEX_FETCH;
 	color += col * BOX_WEIGHTS[1u];
 
-	col = textureLod(u_tex, uv + Vec2(+OFFSET.x, +OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, uv + Vec2(+OFFSET.x, -OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, uv + Vec2(-OFFSET.x, +OFFSET.y), 0.0).TEX_FETCH;
-	col += textureLod(u_tex, uv + Vec2(-OFFSET.x, -OFFSET.y), 0.0).TEX_FETCH;
+	col = textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(+OFFSET.x, +OFFSET.y), 0.0).TEX_FETCH;
+	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(+OFFSET.x, -OFFSET.y), 0.0).TEX_FETCH;
+	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(-OFFSET.x, +OFFSET.y), 0.0).TEX_FETCH;
+	col += textureLod(u_tex, u_linearAnyClampSampler, uv + Vec2(-OFFSET.x, -OFFSET.y), 0.0).TEX_FETCH;
 	color += col * BOX_WEIGHTS[2u];
 #endif
 

+ 3 - 2
shaders/Irradiance.glslp

@@ -18,7 +18,8 @@
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out Vec3 out_color;
 
-layout(set = 0, binding = 0) uniform samplerCubeArray u_envTex;
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform textureCubeArray u_envTex;
 
 ANKI_PUSH_CONSTANTS(UVec4, u_faceIdxPad3);
 
@@ -48,7 +49,7 @@ void main()
 
 				if(lambert > 0.0)
 				{
-					const Vec3 col = textureLod(u_envTex, Vec4(r, texArrIdx), ENV_TEX_MIP).rgb;
+					const Vec3 col = textureLod(u_envTex, u_linearAnyClampSampler, Vec4(r, texArrIdx), ENV_TEX_MIP).rgb;
 					outCol += col * lambert * cubeCoordSolidAngle(ndc, F32(ENV_TEX_TILE_SIZE));
 				}
 			}

+ 3 - 2
shaders/LensFlareSprite.glslp

@@ -42,7 +42,8 @@ void main()
 #pragma anki start frag
 #include <shaders/Common.glsl>
 
-layout(set = 0, binding = 1) uniform sampler2DArray u_tex;
+layout(set = 0, binding = 1) uniform sampler u_trilinearRepeatSampler;
+layout(set = 0, binding = 2) uniform texture2DArray u_tex;
 
 layout(location = 0) in Vec3 in_uv;
 layout(location = 1) flat in Vec4 in_color;
@@ -51,7 +52,7 @@ layout(location = 0) out Vec4 out_color;
 
 void main()
 {
-	const Vec4 col = texture(u_tex, in_uv);
+	const Vec4 col = texture(u_tex, u_trilinearRepeatSampler, in_uv);
 	out_color = col * in_color;
 }
 #pragma anki end

+ 3 - 2
shaders/LensFlareUpdateIndirectInfo.glslp

@@ -30,7 +30,8 @@ layout(set = 0, binding = 1, std430) writeonly buffer ss1_
 	DrawArraysIndirectInfo u_indirectInfo[];
 };
 
-layout(set = 0, binding = 2) uniform sampler2D u_depthMap;
+layout(set = 0, binding = 2) uniform sampler u_nearestAnyClampSampler;
+layout(set = 0, binding = 3) uniform texture2D u_depthMap;
 
 shared U32 s_maxDepth;
 
@@ -57,7 +58,7 @@ void main()
 	const Vec2 uv = NDC_TO_UV(posNdc.xy) + displacement * TEXEL_SIZE;
 
 	// Sample and store depth
-	const F32 refDepth = textureLod(u_depthMap, uv, 0.0).r;
+	const F32 refDepth = textureLod(u_depthMap, u_nearestAnyClampSampler, uv, 0.0).r;
 	atomicMax(s_maxDepth, U32(refDepth * F32(MAX_U32)));
 
 	// Sync

+ 9 - 10
shaders/LightShadingApplyFog.glslp

@@ -17,21 +17,20 @@
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out Vec4 out_color;
 
-layout(set = 0, binding = 0) uniform sampler2D u_depthRt;
-layout(set = 0, binding = 1) uniform sampler3D u_fogVolume;
+layout(set = 0, binding = 0) uniform sampler u_nearestAnyClampSampler;
+layout(set = 0, binding = 1) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 2) uniform texture2D u_depthRt;
+layout(set = 0, binding = 3) uniform texture3D u_fogVolume;
 
-struct PushConsts
+layout(push_constant, std140, row_major) uniform pc_
 {
-	ClustererMagicValues m_clustererMagic;
-	Mat4 m_invViewProjMat;
+	ClustererMagicValues u_clustererMagic;
+	Mat4 u_invViewProjMat;
 };
-ANKI_PUSH_CONSTANTS(PushConsts, u_regs);
-#define u_clustererMagic u_regs.m_clustererMagic
-#define u_invViewProjMat u_regs.m_invViewProjMat
 
 void main()
 {
-	const F32 depth = textureLod(u_depthRt, in_uv, 0.0).r;
+	const F32 depth = textureLod(u_depthRt, u_nearestAnyClampSampler, in_uv, 0.0).r;
 
 	// Get world position
 	const Vec4 worldPos4 = u_invViewProjMat * Vec4(UV_TO_NDC(in_uv), depth, 1.0);
@@ -39,7 +38,7 @@ void main()
 
 	// Read the volume
 	const Vec3 uv3d = computeClustererVolumeTextureUvs(u_clustererMagic, in_uv, worldPos, FOG_LAST_CLASTER + 1u);
-	const Vec4 fogVals = textureLod(u_fogVolume, uv3d, 0.0);
+	const Vec4 fogVals = textureLod(u_fogVolume, u_linearAnyClampSampler, uv3d, 0.0);
 	const Vec3 inScattering = fogVals.rgb;
 	const F32 transmittance = fogVals.a;
 

+ 6 - 4
shaders/SceneDebug.glslp

@@ -42,7 +42,8 @@ void main()
 
 #if COLOR_TEXTURE == 1
 layout(location = 0) in Vec2 in_uv;
-layout(set = 1, binding = 1) uniform sampler2D u_tex;
+layout(set = 1, binding = 1) uniform sampler u_trilinearRepeatSampler;
+layout(set = 1, binding = 2) uniform texture2D u_tex;
 #endif
 
 layout(set = 1, binding = 0, row_major) uniform u0_
@@ -53,7 +54,8 @@ layout(set = 1, binding = 0, row_major) uniform u0_
 
 // NOTE: Don't eliminate the binding because it confuses the descriptor set creation
 #if DITHERED_DEPTH_TEST == 1
-layout(set = 0, binding = 0) uniform sampler2D u_depthRt;
+layout(set = 0, binding = 0) uniform sampler u_nearestAnyClampSampler;
+layout(set = 0, binding = 1) uniform texture2D u_depthRt;
 #endif
 
 layout(location = 0) out Vec4 out_color;
@@ -63,7 +65,7 @@ void main()
 	// Check if we should skip the frag
 #if DITHERED_DEPTH_TEST == 1
 	const Vec2 uv = gl_FragCoord.xy / Vec2(textureSize(u_depthRt, 0));
-	const F32 depthRef = textureLod(u_depthRt, uv, 0.0).r;
+	const F32 depthRef = textureLod(u_depthRt, u_nearestAnyClampSampler, uv, 0.0).r;
 	const Bool depthTestFailed = gl_FragCoord.z >= depthRef;
 	const IVec2 fragCoordi = IVec2(gl_FragCoord.xy);
 	if(depthTestFailed && ((fragCoordi.x + fragCoordi.y) % 8) != 0)
@@ -74,7 +76,7 @@ void main()
 
 	// Write the color
 #if COLOR_TEXTURE == 1
-	out_color = texture(u_tex, in_uv) * u_color;
+	out_color = texture(u_tex, u_trilinearRepeatSampler, in_uv) * u_color;
 #else
 	out_color = u_color;
 #endif

+ 17 - 13
shaders/Ssao.glsl

@@ -39,20 +39,23 @@ layout(location = 0) out F32 out_color;
 #else
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 
-layout(set = 0, binding = 4) writeonly uniform image2D out_img;
+layout(set = 0, binding = 5) writeonly uniform image2D out_img;
 #endif
 
-layout(set = 0, binding = 0, std140, row_major) uniform _blk
+layout(push_constant, std140, row_major) uniform _pc
 {
 	Vec4 u_unprojectionParams;
 	Vec4 u_projectionMat;
 	Mat3 u_viewRotMat;
 };
 
-layout(set = 0, binding = 1) uniform sampler2D u_depthRt;
-layout(set = 0, binding = 2) uniform sampler2DArray u_noiseMap;
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform sampler u_trilinearRepeatSampler;
+
+layout(set = 0, binding = 2) uniform texture2D u_depthRt;
+layout(set = 0, binding = 3) uniform texture2DArray u_noiseMap;
 #if USE_NORMAL
-layout(set = 0, binding = 3) uniform sampler2D u_msRt;
+layout(set = 0, binding = 4) uniform texture2D u_msRt;
 #endif
 
 // To compute the normals we need some extra work on compute
@@ -65,7 +68,7 @@ shared Vec3 s_scratch[WORKGROUP_SIZE.y][WORKGROUP_SIZE.x];
 // Get normal
 Vec3 readNormal(Vec2 uv)
 {
-	Vec3 normal = readNormalFromGBuffer(u_msRt, uv);
+	Vec3 normal = readNormalFromGBuffer(u_msRt, u_linearAnyClampSampler, uv);
 	normal = u_viewRotMat * normal;
 	return normal;
 }
@@ -75,7 +78,7 @@ Vec3 readNormal(Vec2 uv)
 Vec3 readRandom(Vec2 uv, F32 layer)
 {
 	const Vec2 tmp = Vec2(F32(FB_SIZE.x) / F32(NOISE_MAP_SIZE), F32(FB_SIZE.y) / F32(NOISE_MAP_SIZE));
-	const Vec3 r = texture(u_noiseMap, Vec3(tmp * uv, layer)).rgb;
+	const Vec3 r = textureLod(u_noiseMap, u_trilinearRepeatSampler, Vec3(tmp * uv, layer), 0.0).rgb;
 	return r;
 }
 
@@ -107,10 +110,10 @@ Vec3 computeNormal(Vec2 uv, Vec3 origin, F32 depth)
 #elif !COMPLEX_NORMALS
 	const Vec3 normal = normalize(cross(dFdx(origin), dFdy(origin)));
 #else
-	const F32 depthLeft = textureLodOffset(u_depthRt, uv, 0.0, ivec2(-2, 0)).r;
-	const F32 depthRight = textureLodOffset(u_depthRt, uv, 0.0, ivec2(2, 0)).r;
-	const F32 depthTop = textureLodOffset(u_depthRt, uv, 0.0, ivec2(0, 2)).r;
-	const F32 depthBottom = textureLodOffset(u_depthRt, uv, 0.0, ivec2(0, -2)).r;
+	const F32 depthLeft = textureLodOffset(sampler2D(u_depthRt, u_linearAnyClampSampler), uv, 0.0, ivec2(-2, 0)).r;
+	const F32 depthRight = textureLodOffset(sampler2D(u_depthRt, u_linearAnyClampSampler), uv, 0.0, ivec2(2, 0)).r;
+	const F32 depthTop = textureLodOffset(sampler2D(u_depthRt, u_linearAnyClampSampler), uv, 0.0, ivec2(0, 2)).r;
+	const F32 depthBottom = textureLodOffset(sampler2D(u_depthRt, u_linearAnyClampSampler), uv, 0.0, ivec2(0, -2)).r;
 
 	const F32 ddx = smallerDelta(depthLeft, depth, depthRight);
 	const F32 ddy = smallerDelta(depthBottom, depth, depthTop);
@@ -150,7 +153,7 @@ void main(void)
 	const Vec2 ndc = UV_TO_NDC(uv);
 
 	// Compute origin
-	const F32 depth = textureLod(u_depthRt, uv, 0.0).r;
+	const F32 depth = textureLod(u_depthRt, u_linearAnyClampSampler, uv, 0.0).r;
 	const Vec3 origin = unproject(ndc, depth);
 
 	// Get normal
@@ -184,7 +187,8 @@ void main(void)
 		const Vec2 finalDiskPoint = ndc + point * projRadius;
 
 		// Compute factor
-		const Vec3 s = unproject(finalDiskPoint, textureLod(u_depthRt, NDC_TO_UV(finalDiskPoint), 0.0).r);
+		const Vec3 s =
+			unproject(finalDiskPoint, textureLod(u_depthRt, u_linearAnyClampSampler, NDC_TO_UV(finalDiskPoint), 0.0).r);
 		const Vec3 u = s - origin;
 		ssao += max(dot(normal, u) + BIAS, EPSILON) / max(dot(u, u), EPSILON);
 	}

+ 17 - 16
shaders/TemporalAAResolve.glslp

@@ -20,16 +20,11 @@
 
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 
-layout(set = 0, binding = 0) uniform sampler2D u_depthRt;
-layout(set = 0, binding = 1) uniform sampler2D u_inputRt;
-layout(set = 0, binding = 2) uniform sampler2D u_historyRt;
-layout(set = 0, binding = 3) uniform sampler2D u_velocityRt;
-
-layout(set = 0, binding = 4, std140, row_major) uniform u0_
-{
-	Mat4 u_prevViewProjMatMulInvViewProjMat;
-};
-
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform texture2D u_depthRt;
+layout(set = 0, binding = 2) uniform texture2D u_inputRt;
+layout(set = 0, binding = 3) uniform texture2D u_historyRt;
+layout(set = 0, binding = 4) uniform texture2D u_velocityRt;
 layout(set = 0, binding = 5) writeonly uniform image2D out_img;
 
 #if TONEMAP_FIX
@@ -38,12 +33,18 @@ layout(set = 0, binding = 5) writeonly uniform image2D out_img;
 #	include <shaders/TonemappingResources.glsl>
 #endif
 
+layout(push_constant, std140, row_major) uniform pc_
+{
+	Mat4 u_prevViewProjMatMulInvViewProjMat;
+};
+
 #if YCBCR
-#	define sample(s, uv) rgbToYCbCr(textureLod(s, uv, 0.0).rgb)
-#	define sampleOffset(s, uv, x, y) rgbToYCbCr(textureLodOffset(s, uv, 0.0, IVec2(x, y)).rgb)
+#	define sample(s, uv) rgbToYCbCr(textureLod(s, u_linearAnyClampSampler, uv, 0.0).rgb)
+#	define sampleOffset(s, uv, x, y) \
+		rgbToYCbCr(textureLodOffset(sampler2D(s, u_linearAnyClampSampler), uv, 0.0, IVec2(x, y)).rgb)
 #else
-#	define sample(s, uv) textureLod(s, uv, 0.0).rgb
-#	define sampleOffset(s, uv, x, y) textureLodOffset(s, uv, 0.0, IVec2(x, y)).rgb
+#	define sample(s, uv) textureLod(s, u_linearAnyClampSampler, uv, 0.0).rgb
+#	define sampleOffset(s, uv, x, y) textureLodOffset(sampler2D(s, u_linearAnyClampSampler), uv, 0.0, IVec2(x, y)).rgb
 #endif
 
 #define VELOCITY 0
@@ -72,12 +73,12 @@ void main()
 	}
 
 	const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) + 0.5) / Vec2(FB_SIZE);
-	const F32 depth = textureLod(u_depthRt, uv, 0.0).r;
+	const F32 depth = textureLod(u_depthRt, u_linearAnyClampSampler, uv, 0.0).r;
 
 	// Get prev uv coords
 	Vec2 oldUv;
 #if VELOCITY
-	const Vec2 velocity = textureLod(u_velocityRt, uv, 0.0).rg;
+	const Vec2 velocity = textureLod(u_velocityRt, u_linearAnyClampSampler, uv, 0.0).rg;
 	if(velocity.x != -1.0)
 	{
 		oldUv = uv + velocity;

+ 1 - 1
shaders/TonemappingAverageLuminance.glslp

@@ -21,7 +21,7 @@ const UVec2 TRIMMED_INPUT_TEX_SIZE = (INPUT_TEX_SIZE / WORKGROUP_SIZE) * WORKGRO
 
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 
-layout(set = 0, binding = 0) uniform sampler2D u_tex;
+layout(set = 0, binding = 0) uniform texture2D u_tex;
 
 #define TONEMAPPING_RESOURCE_AS_BUFFER 1
 #define TONEMAPPING_SET 0

+ 5 - 3
shaders/VolumetricFogAccumulation.glslp

@@ -16,8 +16,9 @@
 
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 
-layout(set = 0, binding = 0) uniform sampler3D u_lightVolume;
-layout(set = 0, binding = 1) writeonly uniform image3D u_fogVolume;
+layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
+layout(set = 0, binding = 1) uniform texture3D u_lightVolume;
+layout(set = 0, binding = 2) writeonly uniform image3D u_fogVolume;
 
 struct PushConsts
 {
@@ -56,7 +57,8 @@ void main()
 		const F32 layerThinkness = abs(zVSpaceNear - zVSpaceFar);
 
 		// Read the light value and the fog density from the fog volumes
-		Vec4 lightAndFogDensity = textureLod(u_lightVolume, Vec3(uv, clusterKFar / F32(FINAL_CLUSTER_Z + 1u)), 0.0);
+		Vec4 lightAndFogDensity =
+			textureLod(u_lightVolume, u_linearAnyClampSampler, Vec3(uv, clusterKFar / F32(FINAL_CLUSTER_Z + 1u)), 0.0);
 		lightAndFogDensity.xyz *= u_fogDiffuse / PI;
 		lightAndFogDensity.w += u_density; // Apply the default density
 

+ 3 - 5
src/anki/renderer/Dbg.cpp

@@ -62,11 +62,9 @@ void Dbg::run(RenderPassWorkContext& rgraphCtx, const RenderingContext& ctx)
 	cmdb->setViewport(0, 0, m_r->getWidth(), m_r->getHeight());
 	cmdb->setDepthWrite(false);
 
-	rgraphCtx.bindTextureAndSampler(0,
-		0,
-		m_r->getGBuffer().getDepthRt(),
-		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
-		m_r->getNearestSampler());
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_nearestNearestClamp);
+
+	rgraphCtx.bindTexture(0, 1, m_r->getGBuffer().getDepthRt(), TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
 
 	// Set the context
 	RenderQueueDrawContext dctx;

+ 3 - 1
src/anki/renderer/Indirect.cpp

@@ -469,10 +469,12 @@ void Indirect::runIrradiance(U32 faceIdx, RenderPassWorkContext& rgraphCtx)
 	cmdb->setViewport(0, 0, m_irradiance.m_tileSize, m_irradiance.m_tileSize);
 	cmdb->bindShaderProgram(m_irradiance.m_grProg);
 
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+
 	TextureSubresourceInfo subresource;
 	subresource.m_faceCount = 6;
 	subresource.m_firstLayer = cacheEntryIdx;
-	rgraphCtx.bindTextureAndSampler(0, 0, m_ctx.m_lightShadingRt, subresource, m_r->getLinearSampler());
+	rgraphCtx.bindTexture(0, 1, m_ctx.m_lightShadingRt, subresource);
 
 	// Set uniforms
 	UVec4 pushConsts(faceIdx);

+ 5 - 7
src/anki/renderer/LensFlare.cpp

@@ -107,8 +107,8 @@ void LensFlare::updateIndirectInfo(const RenderingContext& ctx, RenderPassWorkCo
 
 	rgraphCtx.bindStorageBuffer(0, 1, m_runCtx.m_indirectBuffHandle);
 	// Bind neareset because you don't need high quality
-	rgraphCtx.bindTextureAndSampler(
-		0, 2, m_r->getDepthDownscale().getHiZRt(), HIZ_QUARTER_DEPTH, m_r->getNearestSampler());
+	cmdb->bindSampler(0, 2, m_r->getSamplers().m_nearestNearestClamp);
+	rgraphCtx.bindTexture(0, 3, m_r->getDepthDownscale().getHiZRt(), HIZ_QUARTER_DEPTH);
 	cmdb->dispatchCompute(count, 1, 1);
 }
 
@@ -191,11 +191,9 @@ void LensFlare::runDrawFlares(const RenderingContext& ctx, CommandBufferPtr& cmd
 
 		// Render
 		ANKI_ASSERT(flareEl.m_textureView);
-		cmdb->bindTextureAndSampler(0,
-			1,
-			TextureViewPtr(const_cast<TextureView*>(flareEl.m_textureView)),
-			m_r->getTrilinearRepeatSampler(),
-			TextureUsageBit::SAMPLED_FRAGMENT);
+		cmdb->bindSampler(0, 1, m_r->getSamplers().m_trilinearRepeat);
+		cmdb->bindTexture(
+			0, 2, TextureViewPtr(const_cast<TextureView*>(flareEl.m_textureView)), TextureUsageBit::SAMPLED_FRAGMENT);
 
 		cmdb->drawArraysIndirect(
 			PrimitiveTopology::TRIANGLE_STRIP, 1, i * sizeof(DrawArraysIndirectInfo), m_indirectBuff);

+ 8 - 9
src/anki/renderer/LightShading.cpp

@@ -141,15 +141,14 @@ void LightShading::run(RenderPassWorkContext& rgraphCtx)
 	{
 		cmdb->bindShaderProgram(m_applyFog.m_grProg);
 
-		// Bind textures
-		rgraphCtx.bindTextureAndSampler(0,
-			0,
-			m_r->getGBuffer().getDepthRt(),
-			TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
-			m_r->getNearestSampler());
-		rgraphCtx.bindColorTextureAndSampler(0, 1, m_r->getVolumetricFog().getRt(), m_r->getLinearSampler());
-
-		// Uniforms
+		// Bind all
+		cmdb->bindSampler(0, 0, m_r->getSamplers().m_nearestNearestClamp);
+		cmdb->bindSampler(0, 1, m_r->getSamplers().m_trilinearClamp);
+
+		rgraphCtx.bindTexture(
+			0, 2, m_r->getGBuffer().getDepthRt(), TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
+		rgraphCtx.bindColorTexture(0, 3, m_r->getVolumetricFog().getRt());
+
 		struct PushConsts
 		{
 			ClustererMagicValues m_clustererMagic;

+ 2 - 1
src/anki/renderer/MainRenderer.cpp

@@ -200,7 +200,8 @@ void MainRenderer::runBlit(RenderPassWorkContext& rgraphCtx)
 	cmdb->setViewport(0, 0, m_width, m_height);
 
 	cmdb->bindShaderProgram(m_blitGrProg);
-	rgraphCtx.bindColorTextureAndSampler(0, 0, m_runCtx.m_ctx->m_outRenderTarget, m_r->getLinearSampler());
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+	rgraphCtx.bindColorTexture(0, 1, m_runCtx.m_ctx->m_outRenderTarget);
 
 	cmdb->drawArrays(PrimitiveTopology::TRIANGLES, 3, 1);
 }

+ 3 - 2
src/anki/renderer/ShadowMapping.cpp

@@ -157,8 +157,9 @@ void ShadowMapping::runEsm(RenderPassWorkContext& rgraphCtx)
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 
 	cmdb->bindShaderProgram(m_esmResolveGrProg);
-	rgraphCtx.bindTextureAndSampler(
-		0, 0, m_scratchRt, TextureSubresourceInfo(DepthStencilAspectBit::DEPTH), m_r->getLinearSampler());
+
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+	rgraphCtx.bindTexture(0, 1, m_scratchRt, TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
 
 	for(const EsmResolveWorkItem& workItem : m_esmResolveWorkItems)
 	{

+ 17 - 15
src/anki/renderer/Ssao.cpp

@@ -127,16 +127,16 @@ void Ssao::runMain(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx
 
 	cmdb->bindShaderProgram(m_main.m_grProg);
 
-	rgraphCtx.bindTextureAndSampler(0, 1, m_r->getDepthDownscale().getHiZRt(), HIZ_HALF_DEPTH, m_r->getLinearSampler());
-	cmdb->bindTextureAndSampler(0,
-		2,
-		m_main.m_noiseTex->getGrTextureView(),
-		m_r->getTrilinearRepeatSampler(),
-		TextureUsageBit::SAMPLED_FRAGMENT);
+	// Bind resources
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+	cmdb->bindSampler(0, 1, m_r->getSamplers().m_trilinearRepeat);
+
+	rgraphCtx.bindTexture(0, 2, m_r->getDepthDownscale().getHiZRt(), HIZ_HALF_DEPTH);
+	cmdb->bindTexture(0, 3, m_main.m_noiseTex->getGrTextureView(), TextureUsageBit::SAMPLED_FRAGMENT);
 
 	if(m_useNormal)
 	{
-		rgraphCtx.bindColorTextureAndSampler(0, 3, m_r->getGBuffer().getColorRt(2), m_r->getLinearSampler());
+		rgraphCtx.bindColorTexture(0, 4, m_r->getGBuffer().getColorRt(2));
 	}
 
 	struct Unis
@@ -144,17 +144,17 @@ void Ssao::runMain(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx
 		Vec4 m_unprojectionParams;
 		Vec4 m_projectionMat;
 		Mat3x4 m_viewRotMat;
-	};
+	} unis;
 
-	Unis* unis = allocateAndBindUniforms<Unis*>(sizeof(Unis), cmdb, 0, 0);
 	const Mat4& pmat = ctx.m_renderQueue->m_projectionMatrix;
-	unis->m_unprojectionParams = ctx.m_unprojParams;
-	unis->m_projectionMat = Vec4(pmat(0, 0), pmat(1, 1), pmat(2, 2), pmat(2, 3));
-	unis->m_viewRotMat = Mat3x4(ctx.m_renderQueue->m_viewMatrix.getRotationPart());
+	unis.m_unprojectionParams = ctx.m_unprojParams;
+	unis.m_projectionMat = Vec4(pmat(0, 0), pmat(1, 1), pmat(2, 2), pmat(2, 3));
+	unis.m_viewRotMat = Mat3x4(ctx.m_renderQueue->m_viewMatrix.getRotationPart());
+	cmdb->setPushConstants(&unis, sizeof(unis));
 
 	if(m_useCompute)
 	{
-		rgraphCtx.bindImage(0, 4, m_runCtx.m_rts[0], TextureSubresourceInfo());
+		rgraphCtx.bindImage(0, 5, m_runCtx.m_rts[0], TextureSubresourceInfo());
 
 		const U sizeX = (m_width + m_workgroupSize[0] - 1) / m_workgroupSize[0];
 		const U sizeY = (m_height + m_workgroupSize[1] - 1) / m_workgroupSize[1];
@@ -172,11 +172,13 @@ void Ssao::runBlur(RenderPassWorkContext& rgraphCtx)
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 
 	cmdb->bindShaderProgram(m_blur.m_grProg);
-	rgraphCtx.bindColorTextureAndSampler(0, 0, m_runCtx.m_rts[0], m_r->getLinearSampler());
+
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+	rgraphCtx.bindColorTexture(0, 1, m_runCtx.m_rts[0]);
 
 	if(m_blurUseCompute)
 	{
-		rgraphCtx.bindImage(0, 1, m_runCtx.m_rts[1], TextureSubresourceInfo());
+		rgraphCtx.bindImage(0, 2, m_runCtx.m_rts[1], TextureSubresourceInfo());
 		dispatchPPCompute(cmdb, m_workgroupSize[0], m_workgroupSize[1], m_width, m_height);
 	}
 	else

+ 9 - 14
src/anki/renderer/TemporalAA.cpp

@@ -76,23 +76,18 @@ void TemporalAA::run(const RenderingContext& ctx, RenderPassWorkContext& rgraphC
 
 	cmdb->bindShaderProgram(m_grProgs[m_r->getFrameCount() & 1]);
 
-	rgraphCtx.bindTextureAndSampler(0,
-		0,
-		m_r->getGBuffer().getDepthRt(),
-		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH),
-		m_r->getLinearSampler());
-	rgraphCtx.bindColorTextureAndSampler(0, 1, m_r->getLightShading().getRt(), m_r->getLinearSampler());
-	rgraphCtx.bindColorTextureAndSampler(0, 2, m_runCtx.m_historyRt, m_r->getLinearSampler());
-	rgraphCtx.bindColorTextureAndSampler(0, 3, m_r->getGBuffer().getColorRt(3), m_r->getLinearSampler());
-
-	Mat4* unis = allocateAndBindUniforms<Mat4*>(sizeof(Mat4), cmdb, 0, 4);
-	*unis = ctx.m_matrices.m_jitter * ctx.m_prevMatrices.m_viewProjection
-			* ctx.m_matrices.m_viewProjectionJitter.getInverse();
-
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+	rgraphCtx.bindTexture(0, 1, m_r->getGBuffer().getDepthRt(), TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
+	rgraphCtx.bindColorTexture(0, 2, m_r->getLightShading().getRt());
+	rgraphCtx.bindColorTexture(0, 3, m_runCtx.m_historyRt);
+	rgraphCtx.bindColorTexture(0, 4, m_r->getGBuffer().getColorRt(3));
 	rgraphCtx.bindImage(0, 5, m_runCtx.m_renderRt, TextureSubresourceInfo());
-
 	rgraphCtx.bindUniformBuffer(0, 6, m_r->getTonemapping().getAverageLuminanceBuffer());
 
+	const Mat4 mat = ctx.m_matrices.m_jitter * ctx.m_prevMatrices.m_viewProjection
+					 * ctx.m_matrices.m_viewProjectionJitter.getInverse();
+	cmdb->setPushConstants(&mat, sizeof(mat));
+
 	dispatchPPCompute(cmdb, m_workgroupSize[0], m_workgroupSize[1], m_r->getWidth(), m_r->getHeight());
 }
 

+ 1 - 2
src/anki/renderer/Tonemapping.cpp

@@ -102,8 +102,7 @@ void Tonemapping::run(RenderPassWorkContext& rgraphCtx)
 
 	TextureSubresourceInfo inputTexSubresource;
 	inputTexSubresource.m_firstMipmap = m_inputTexMip;
-	rgraphCtx.bindTextureAndSampler(
-		0, 0, m_r->getDownscaleBlur().getRt(), inputTexSubresource, m_r->getLinearSampler());
+	rgraphCtx.bindTexture(0, 0, m_r->getDownscaleBlur().getRt(), inputTexSubresource);
 
 	cmdb->dispatchCompute(1, 1, 1);
 }

+ 3 - 3
src/anki/renderer/VolumetricFog.cpp

@@ -61,10 +61,10 @@ void VolumetricFog::run(RenderPassWorkContext& rgraphCtx)
 
 	cmdb->bindShaderProgram(m_grProg);
 
-	rgraphCtx.bindColorTextureAndSampler(
-		0, 0, m_r->getVolumetricLightingAccumulation().getRt(), m_r->getLinearSampler());
+	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
+	rgraphCtx.bindColorTexture(0, 1, m_r->getVolumetricLightingAccumulation().getRt());
 
-	rgraphCtx.bindImage(0, 1, m_runCtx.m_rt, TextureSubresourceInfo());
+	rgraphCtx.bindImage(0, 2, m_runCtx.m_rt, TextureSubresourceInfo());
 
 	struct PushConsts
 	{