Parcourir la source

Some RT optimizations

Panagiotis Christopoulos Charitos il y a 9 mois
Parent
commit
01428a625e

+ 13 - 13
AnKi/Shaders/ForwardShadingCommon.hlsl

@@ -19,15 +19,15 @@
 #if ANKI_PIXEL_SHADER
 struct PixelOut
 {
-	RVec4 m_color : SV_TARGET0;
+	Vec4 m_color : SV_TARGET0;
 };
 
 void packGBuffer(Vec4 color, out PixelOut output)
 {
-	output.m_color = RVec4(color.rgb, color.a);
+	output.m_color = Vec4(color.rgb, color.a);
 }
 
-RVec4 readAnimatedTextureRgba(Texture2DArray<Vec4> tex, SamplerState sampl, F32 period, Vec2 uv, F32 time)
+Vec4 readAnimatedTextureRgba(Texture2DArray<Vec4> tex, SamplerState sampl, F32 period, Vec2 uv, F32 time)
 {
 	Vec2 texSize;
 	F32 layerCount;
@@ -56,12 +56,12 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
 
 		const Vec3 frag2Light = light.m_position - worldPos;
-		const RF32 att = computeAttenuationFactor<RF32>(light.m_radius, frag2Light);
+		const F32 att = computeAttenuationFactor<F32>(light.m_radius, frag2Light);
 
-		RF32 shadow = 1.0;
+		F32 shadow = 1.0;
 		if(light.m_shadowAtlasTileScale >= 0.0)
 		{
-			shadow = computeShadowFactorPointLight<RF32>(light, frag2Light, g_shadowAtlasTex, g_shadowSampler);
+			shadow = computeShadowFactorPointLight<F32>(light, frag2Light, g_shadowAtlasTex, g_shadowSampler);
 		}
 
 		outColor += diffC * (att * shadow);
@@ -75,16 +75,16 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
 
 		const Vec3 frag2Light = light.m_position - worldPos;
-		const RF32 att = computeAttenuationFactor<RF32>(light.m_radius, frag2Light);
+		const F32 att = computeAttenuationFactor<F32>(light.m_radius, frag2Light);
 
 		const Vec3 l = normalize(frag2Light);
 
-		const F32 spot = computeSpotFactor<RF32>(l, light.m_outerCos, light.m_innerCos, light.m_direction);
+		const F32 spot = computeSpotFactor<F32>(l, light.m_outerCos, light.m_innerCos, light.m_direction);
 
 		F32 shadow = 1.0;
 		[branch] if(light.m_shadow != 0u)
 		{
-			shadow = computeShadowFactorSpotLight<RF32>(light, worldPos, g_shadowAtlasTex, g_shadowSampler);
+			shadow = computeShadowFactorSpotLight<F32>(light, worldPos, g_shadowAtlasTex, g_shadowSampler);
 		}
 
 		outColor += diffC * (att * spot * shadow);
@@ -94,7 +94,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 }
 
 // Just read the light color from the vol texture
-RVec3 computeLightColorLow(RVec3 diffCol, RVec3 worldPos, Vec4 svPosition)
+Vec3 computeLightColorLow(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 {
 	ANKI_MAYBE_UNUSED(worldPos);
 
@@ -103,16 +103,16 @@ RVec3 computeLightColorLow(RVec3 diffCol, RVec3 worldPos, Vec4 svPosition)
 	const F32 w = linearDepth * (F32(g_globalRendererConstants.m_zSplitCount) / F32(g_globalRendererConstants.m_lightVolumeLastZSplit + 1u));
 	const Vec3 uvw = Vec3(uv, w);
 
-	const RVec3 light = g_lightVol.SampleLevel(g_linearAnyClampSampler, uvw, 0.0).rgb;
+	const Vec3 light = g_lightVol.SampleLevel(g_linearAnyClampSampler, uvw, 0.0).rgb;
 	return diffuseLobe(diffCol) * light;
 }
 
-void particleAlpha(RVec4 color, RVec4 scaleColor, RVec4 biasColor, out PixelOut output)
+void particleAlpha(Vec4 color, Vec4 scaleColor, Vec4 biasColor, out PixelOut output)
 {
 	packGBuffer(color * scaleColor + biasColor, output);
 }
 
-void fog(RVec3 color, RF32 fogAlphaScale, RF32 fogDistanceOfMaxThikness, F32 zVSpace, Vec2 svPosition, out PixelOut output)
+void fog(Vec3 color, F32 fogAlphaScale, F32 fogDistanceOfMaxThikness, F32 zVSpace, Vec2 svPosition, out PixelOut output)
 {
 	const Vec2 screenSize = 1.0 / g_globalRendererConstants.m_renderingSize;
 

+ 5 - 3
AnKi/Shaders/ForwardShadingFog.ankiprog

@@ -3,15 +3,17 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki technique ForwardLegacy vert pixel
 
 #include <AnKi/Shaders/ForwardShadingCommon.hlsl>
 #include <AnKi/Shaders/Functions.hlsl>
 
 #pragma anki struct AnKiLocalConstants
-#pragma anki member RVec3 m_fogColor
-#pragma anki member RF32 m_fogAlphaScale
-#pragma anki member RF32 m_fogDistanceOfMaxThikness
+#pragma anki member Vec3 m_fogColor
+#pragma anki member F32 m_fogAlphaScale
+#pragma anki member F32 m_fogDistanceOfMaxThikness
 #pragma anki struct_end
 
 struct VertIn

+ 5 - 3
AnKi/Shaders/ForwardShadingGenericTransparent.ankiprog

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki mutator TEXTURE 0 1
 #pragma anki mutator LIGHT 0 1
 
@@ -16,8 +18,8 @@
 
 #pragma anki struct AnKiLocalConstants
 #pragma anki member U32 m_texture
-#pragma anki member RVec4 m_colorScale
-#pragma anki member RVec4 m_colorBias
+#pragma anki member Vec4 m_colorScale
+#pragma anki member Vec4 m_colorBias
 #pragma anki struct_end
 
 struct VertIn
@@ -159,7 +161,7 @@ PixelOut main(VertOut input)
 
 	const AnKiLocalConstants localConstants = loadAnKiLocalConstants(g_gpuScene, WaveReadLaneFirst(input.m_constantsOffset));
 
-	output.m_color = RVec4(1.0, 1.0, 1.0, 1.0);
+	output.m_color = Vec4(1.0, 1.0, 1.0, 1.0);
 
 #	if TEXTURE == 1
 	output.m_color = getBindlessTexture2DVec4(localConstants.m_texture).Sample(g_globalSampler, input.m_uv);

+ 7 - 5
AnKi/Shaders/ForwardShadingParticles.ankiprog

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki mutator ANIMATED_TEXTURE 0 1
 #pragma anki mutator LIGHT 0 1
 
@@ -19,7 +21,7 @@ struct VertIn
 struct VertOut
 {
 	nointerpolation U32 m_constantsOffset : UNIS_OFFSET;
-	nointerpolation RF32 m_alpha : ALPHA;
+	nointerpolation F32 m_alpha : ALPHA;
 	Vec2 m_uv : TEXCOORD;
 	Vec3 m_worldPos : WORLD_POS;
 	Vec4 m_svPosition : SV_POSITION;
@@ -76,17 +78,17 @@ PixelOut main(VertOut input)
 	const AnKiLocalConstants localConstants = loadAnKiLocalConstants(g_gpuScene, WaveReadLaneFirst(input.m_constantsOffset));
 
 #	if ANIMATED_TEXTURE == 1
-	RVec4 texCol = readAnimatedTextureRgba(getBindlessTexture2DArrayVec4(localConstants.m_diffuseMap), g_globalSampler,
-										   localConstants.m_animationPeriod, input.m_uv, g_globalRendererConstants.m_time);
+	Vec4 texCol = readAnimatedTextureRgba(getBindlessTexture2DArrayVec4(localConstants.m_diffuseMap), g_globalSampler,
+										  localConstants.m_animationPeriod, input.m_uv, g_globalRendererConstants.m_time);
 #	else
-	RVec4 texCol = getBindlessTexture2DVec4(localConstants.m_diffuseMap).Sample(g_globalSampler, input.m_uv);
+	Vec4 texCol = getBindlessTexture2DVec4(localConstants.m_diffuseMap).Sample(g_globalSampler, input.m_uv);
 #	endif
 
 #	if LIGHT
 	texCol.rgb = computeLightColorLow(texCol.rgb, input.m_worldPos, input.m_svPosition);
 #	endif
 
-	RVec4 colScale = localConstants.m_colorScale;
+	Vec4 colScale = localConstants.m_colorScale;
 	colScale.a *= input.m_alpha;
 	particleAlpha(texCol, colScale, localConstants.m_colorBias, output);
 

+ 49 - 46
AnKi/Shaders/GBufferGeneric.ankiprog

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki mutator ANKI_VELOCITY 0 1
 #pragma anki mutator ANKI_BONES 0 1
 #pragma anki mutator DIFFUSE_TEX 0 1
@@ -103,13 +105,13 @@
 #pragma anki member U32 m_emissiveTex
 #pragma anki member U32 m_heightTex
 
-#pragma anki member RVec4 m_diffuseScale
-#pragma anki member RF32 m_roughnessScale
-#pragma anki member RF32 m_metalnessScale
-#pragma anki member RVec3 m_specularScale
-#pragma anki member RVec3 m_emissionScale
-#pragma anki member RF32 m_heightmapScale
-#pragma anki member RF32 m_subsurface
+#pragma anki member Vec4 m_diffuseScale
+#pragma anki member F32 m_roughnessScale
+#pragma anki member F32 m_metalnessScale
+#pragma anki member Vec3 m_specularScale
+#pragma anki member Vec3 m_emissionScale
+#pragma anki member F32 m_heightmapScale
+#pragma anki member F32 m_subsurface
 
 #pragma anki struct_end
 
@@ -137,7 +139,7 @@ struct VertOut
 #endif
 
 #if GBUFFER
-	RVec3 m_normal : NORMAL;
+	HVec3 m_normal : NORMAL;
 #endif
 
 #if VISUALIZE_MESHLETS
@@ -165,7 +167,7 @@ struct MeshPerVertOut
 #endif
 
 #if GBUFFER
-	RVec3 m_normal : NORMAL;
+	HVec3 m_normal : NORMAL;
 #endif
 };
 
@@ -195,7 +197,7 @@ Mat3x4_2 loadBoneTransforms(UnpackedMeshVertex vert, U32 boneTransformsOffset, U
 	return g_gpuScene.Load<Mat3x4_2>(byteOffset);
 }
 
-void skinning(UnpackedMeshVertex vert, U32 boneTransformsOffset, inout Vec3 pos, inout Vec3 prevPos, inout RVec3 normal)
+void skinning(UnpackedMeshVertex vert, U32 boneTransformsOffset, inout Vec3 pos, inout Vec3 prevPos, inout Vec3 normal)
 {
 	Mat3x4_2 mats = loadBoneTransforms(vert, boneTransformsOffset, 0);
 
@@ -486,8 +488,8 @@ void main(
 #		endif
 
 	const AnKiLocalConstants localConstants = loadAnKiLocalConstants(g_gpuScene, constantsOffset);
-	const RVec4 diffColorA = BINDLESS(localConstants.m_diffuseTex).Sample(g_globalSampler, vertInput.m_uv);
-	if(diffColorA.a * localConstants.m_diffuseScale.a < 0.5f)
+	const HVec4 diffColorA = BINDLESS(localConstants.m_diffuseTex).Sample(g_globalSampler, vertInput.m_uv);
+	if(diffColorA.a * F16(localConstants.m_diffuseScale.a) < 0.5f)
 	{
 		discard;
 	}
@@ -520,45 +522,45 @@ GBufferPixelOut main(
 	ANKI_MAYBE_UNUSED(uv);
 
 #		if DIFFUSE_TEX
-	const RVec4 diffColorA = BINDLESS(localConstants.m_diffuseTex).Sample(g_globalSampler, uv) * localConstants.m_diffuseScale;
-	const RVec3 diffColor = diffColorA.rgb;
+	const HVec4 diffColorA = BINDLESS(localConstants.m_diffuseTex).Sample(g_globalSampler, uv) * HVec4(localConstants.m_diffuseScale);
+	const HVec3 diffColor = diffColorA.rgb;
 #			if REALLY_ALPHA_TEST
-	if(diffColorA.a < 0.5f)
+	if(diffColorA.a < 0.5)
 	{
 		discard;
 	}
 #			endif
 #		else
-	const RVec3 diffColor = localConstants.m_diffuseScale;
+	const HVec3 diffColor = HVec4(localConstants.m_diffuseScale);
 #		endif
 
 #		if SPECULAR_TEX
-	const RVec3 specColor = BINDLESS(localConstants.m_specularTex).Sample(g_globalSampler, uv).rgb * localConstants.m_specularScale;
+	const HVec3 specColor = BINDLESS(localConstants.m_specularTex).Sample(g_globalSampler, uv).rgb * HVec3(localConstants.m_specularScale);
 #		else
-	const RVec3 specColor = localConstants.m_specularScale;
+	const HVec3 specColor = localConstants.m_specularScale;
 #		endif
 
 #		if ROUGHNESS_METALNESS_TEX
-	const RVec3 comp = BINDLESS(localConstants.m_roughnessMetalnessTex).Sample(g_globalSampler, uv).rgb;
-	const RF32 roughness = comp.g * localConstants.m_roughnessScale;
-	const RF32 metallic = comp.b * localConstants.m_metalnessScale;
+	const HVec3 comp = BINDLESS(localConstants.m_roughnessMetalnessTex).Sample(g_globalSampler, uv).rgb;
+	const F16 roughness = comp.g * F16(localConstants.m_roughnessScale);
+	const F16 metallic = comp.b * F16(localConstants.m_metalnessScale);
 #		else
-	const RF32 roughness = localConstants.m_roughnessScale;
-	const RF32 metallic = localConstants.m_metalnessScale;
+	const F16 roughness = localConstants.m_roughnessScale;
+	const F16 metallic = localConstants.m_metalnessScale;
 #		endif
 
 #		if NORMAL_TEX
-	const RVec3 nAtTangentspace = normalize((BINDLESS(localConstants.m_normalTex).Sample(g_globalSampler, uv).rgb - 0.5) * 2.0);
+	const HVec3 nAtTangentspace = normalize((BINDLESS(localConstants.m_normalTex).Sample(g_globalSampler, uv).rgb - 0.5) * 2.0);
 	const Vec3 viewDir = -normalize(g_globalConstants.m_cameraTransform.getTranslationPart() - vertInput.m_worldPos);
-	const RVec3 normal = perturbNormal(nAtTangentspace, viewDir, uv, normalize(vertInput.m_normal));
+	const HVec3 normal = perturbNormal(nAtTangentspace, viewDir, uv, normalize(vertInput.m_normal));
 #		else
-	const RVec3 normal = normalize(vertInput.m_normal);
+	const HVec3 normal = normalize(vertInput.m_normal);
 #		endif
 
 #		if EMISSIVE_TEX
-	const RVec3 emission = BINDLESS(localConstants.m_emissiveTex).Sample(g_globalSampler, uv).rgb * localConstants.m_emissionScale;
+	const HVec3 emission = BINDLESS(localConstants.m_emissiveTex).Sample(g_globalSampler, uv).rgb * HVec3(localConstants.m_emissionScale);
 #		else
-	const RVec3 emission = localConstants.m_emissionScale;
+	const HVec3 emission = localConstants.m_emissionScale;
 #		endif
 
 #		if ANKI_VELOCITY || ANKI_BONES
@@ -571,7 +573,7 @@ GBufferPixelOut main(
 	const Vec2 velocity = Vec2(1.0, 1.0);
 #		endif
 
-	GbufferInfo<RF32> g;
+	GbufferInfo<F16> g;
 	g.m_diffuse = diffColor;
 	g.m_normal = normal;
 	g.m_f0 = specColor;
@@ -590,22 +592,22 @@ GBufferPixelOut main(
 	switch(meshletIdx)
 	{
 	case 0:
-		g.m_diffuse = Vec3(1.0f, 0.0f, 0.0f);
+		g.m_diffuse = HVec3(1.0, 0.0, 0.0);
 		break;
 	case 1:
-		g.m_diffuse = Vec3(0.0f, 1.0f, 0.0f);
+		g.m_diffuse = HVec3(0.0, 1.0, 0.0);
 		break;
 	case 2:
-		g.m_diffuse = Vec3(0.0f, 0.0f, 1.0f);
+		g.m_diffuse = HVec3(0.0, 0.0, 1.0);
 		break;
 	case 3:
-		g.m_diffuse = Vec3(1.0f, 1.0f, 0.0f);
+		g.m_diffuse = HVec3(1.0, 1.0, 0.0);
 		break;
 	case 4:
-		g.m_diffuse = Vec3(1.0f, 0.0f, 1.0f);
+		g.m_diffuse = HVec3(1.0, 0.0, 1.0);
 		break;
 	case 5:
-		g.m_diffuse = Vec3(0.0f, 1.0f, 1.0f);
+		g.m_diffuse = HVec3(0.0, 1.0, 1.0);
 		break;
 	}
 #		endif
@@ -651,7 +653,7 @@ GBufferPixelOut main(
 	const Vec2 uv = vert0.m_uv * bary.x + vert1.m_uv * bary.y + vert2.m_uv * bary.z;
 
 	const AnKiLocalConstants localConstants = loadAnKiLocalConstants(g_gpuScene, g_gpuSceneRenderable.m_constantsOffset);
-	const RVec4 diffColorA =
+	const HVec4 diffColorA =
 		getBindlessTexture2DVec4(localConstants.m_diffuseTex).SampleLevel(g_globalSampler, uv, 0.0) * localConstants.m_diffuseScale;
 
 	if(diffColorA.a < 1.0)
@@ -709,28 +711,29 @@ GBufferPixelOut main(
 
 	// Metallness
 #		if ROUGHNESS_METALNESS_TEX
-	const RVec3 comp = getBindlessTexture2DVec4(localConstants.m_roughnessMetalnessTex).SampleLevel(g_globalSampler, uv, payload.m_textureLod).xyz;
-	const RF32 metallic = comp.b * localConstants.m_metalnessScale;
+	const HVec3 comp =
+		getBindlessTextureNonUniformIndex2DVec4(localConstants.m_roughnessMetalnessTex).SampleLevel(g_globalSampler, uv, payload.m_textureLod).xyz;
+	const F16 metallic = comp.b * F16(localConstants.m_metalnessScale);
 #		else
-	const RF32 metallic = localConstants.m_metalnessScale;
+	const F16 metallic = localConstants.m_metalnessScale;
 #		endif
 
 	// Diffuse
 #		if DIFFUSE_TEX
-	RVec3 diffColor = getBindlessTexture2DVec4(localConstants.m_diffuseTex).SampleLevel(g_globalSampler, uv, payload.m_textureLod).xyz;
+	HVec3 diffColor = getBindlessTextureNonUniformIndex2DVec4(localConstants.m_diffuseTex).SampleLevel(g_globalSampler, uv, payload.m_textureLod).xyz;
 #		else
-	RVec3 diffColor = 1.0;
+	HVec3 diffColor = 1.0;
 #		endif
-	diffColor *= localConstants.m_diffuseScale;
-	payload.m_diffuseColor = diffColor * (1.0 - metallic);
+	diffColor *= HVec4(localConstants.m_diffuseScale);
+	payload.m_diffuseColor = diffColor * (1.0h - metallic);
 
 	// Emissive
 #		if EMISSIVE_TEX
-	RVec3 emission = getBindlessTexture2DVec4(localConstants.m_emissiveTex).SampleLevel(g_globalSampler, uv, payload.m_textureLod).rgb;
+	HVec3 emission = getBindlessTextureNonUniformIndex2DVec4(localConstants.m_emissiveTex).SampleLevel(g_globalSampler, uv, payload.m_textureLod).rgb;
 #		else
-	RVec3 emission = 1.0;
+	HVec3 emission = 1.0;
 #		endif
-	emission *= localConstants.m_emissionScale;
+	emission *= HVec3(localConstants.m_emissionScale);
 	payload.m_emission = emission;
 
 	// Normal

+ 10 - 8
AnKi/Shaders/GBufferGpuParticles.ankiprog

@@ -3,17 +3,19 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki technique GBuffer vert pixel
 
 #include <AnKi/Shaders/MaterialShadersCommon.hlsl>
 
 #pragma anki struct AnKiLocalConstants
-#pragma anki member RVec3 m_diffColor
-#pragma anki member RF32 m_roughness
-#pragma anki member RVec3 m_specColor
-#pragma anki member RF32 m_metallic
-#pragma anki member RVec3 m_initialEmission
-#pragma anki member RVec3 m_finalEmission
+#pragma anki member Vec3 m_diffColor
+#pragma anki member F32 m_roughness
+#pragma anki member Vec3 m_specColor
+#pragma anki member F32 m_metallic
+#pragma anki member Vec3 m_initialEmission
+#pragma anki member Vec3 m_finalEmission
 #pragma anki struct_end
 
 struct VertIn
@@ -25,7 +27,7 @@ struct VertIn
 struct VertOut
 {
 	nointerpolation Vec2 m_velocity : VELOCITY;
-	nointerpolation RF32 m_lifeFactor : LIFE_FACTOR;
+	nointerpolation F32 m_lifeFactor : LIFE_FACTOR;
 	nointerpolation U32 m_constantsOffset : CONSTANTS_OFFSET;
 	Vec4 m_svPosition : SV_POSITION;
 };
@@ -79,7 +81,7 @@ GBufferPixelOut main(VertOut input)
 	GBufferPixelOut output;
 	const AnKiLocalConstants localConstants = loadAnKiLocalConstants(g_gpuScene, input.m_constantsOffset);
 
-	GbufferInfo<RF32> g;
+	GbufferInfo<F16> g;
 	g.m_diffuse = localConstants.m_diffColor;
 
 	const Mat3x4 camTrf = g_globalConstants.m_cameraTransform;

+ 4 - 4
AnKi/Shaders/MaterialShadersCommon.hlsl

@@ -49,7 +49,7 @@ ANKI_FAST_CONSTANTS(Consts, g_consts)
 
 SamplerState g_linearAnyClampSampler : register(ANKI_REG(s, ANKI_MATERIAL_REGISTER_LINEAR_CLAMP_SAMPLER));
 Texture2D g_gbufferDepthTex : register(ANKI_REG(t, ANKI_MATERIAL_REGISTER_SCENE_DEPTH));
-Texture3D<RVec4> g_lightVol : register(ANKI_REG(t, ANKI_MATERIAL_REGISTER_LIGHT_VOLUME));
+Texture3D<Vec4> g_lightVol : register(ANKI_REG(t, ANKI_MATERIAL_REGISTER_LIGHT_VOLUME));
 SamplerComparisonState g_shadowSampler : register(ANKI_REG(s, ANKI_MATERIAL_REGISTER_SHADOW_SAMPLER));
 
 ConstantBuffer<GlobalRendererConstants> g_globalRendererConstants : register(ANKI_REG(b, ANKI_MATERIAL_REGISTER_CLUSTER_SHADING_CONSTANTS));
@@ -63,9 +63,9 @@ Texture2D<Vec4> g_shadowAtlasTex : register(ANKI_REG(t, ANKI_MATERIAL_REGISTER_S
 
 struct GBufferPixelOut
 {
-	RVec4 m_color0 : SV_TARGET0;
-	RVec4 m_color1 : SV_TARGET1;
-	RVec4 m_color2 : SV_TARGET2;
+	HVec4 m_color0 : SV_TARGET0;
+	HVec4 m_color1 : SV_TARGET1;
+	HVec4 m_color2 : SV_TARGET2;
 	Vec2 m_color3 : SV_TARGET3;
 };
 

+ 4 - 4
AnKi/Shaders/RtMaterialFetch.hlsl

@@ -12,11 +12,11 @@
 
 struct [raypayload] RtMaterialFetchRayPayload // TODO make it FP16 when you change the GBufferGeneric.ankiprog
 {
-	Vec3 m_diffuseColor : write(closesthit, miss): read(caller);
-	Vec3 m_worldNormal : write(closesthit, miss): read(caller);
-	Vec3 m_emission : write(closesthit, miss): read(caller);
+	HVec3 m_diffuseColor : write(closesthit, miss): read(caller);
+	HVec3 m_worldNormal : write(closesthit, miss): read(caller);
+	HVec3 m_emission : write(closesthit, miss): read(caller);
+	F16 m_textureLod : write(caller): read(closesthit);
 	F32 m_rayT : write(closesthit, miss): read(caller);
-	F32 m_textureLod : write(caller): read(closesthit);
 };
 
 // Have a common resouce interface for all shaders. It should be compatible between all ray shaders in DX and VK

+ 2 - 0
AnKi/Shaders/RtMaterialFetchDbg.ankiprog

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki technique RtMaterialFetch rgen
 
 #include <AnKi/Shaders/RtMaterialFetch.hlsl>

+ 2 - 0
AnKi/Shaders/RtMaterialFetchMiss.ankiprog

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki technique RtMaterialFetch miss
 
 #include <AnKi/Shaders/RtMaterialFetch.hlsl>

+ 2 - 0
AnKi/Shaders/RtShadows.ankiprog

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma anki 16bit
+
 #pragma anki mutator RAYS_PER_PIXEL 1 2 4 8
 
 #pragma anki technique RtShadows rgen miss

+ 84 - 12
Tools/Shader/ShaderProgramBinaryDumpMain.cpp

@@ -17,11 +17,11 @@ using namespace anki;
 static const char* kUsage = R"(Dump the shader binary to stdout
 Usage: %s [options] input_shader_program_binary
 Options:
--stats     : Print performance statistics for all shaders. By default it doesn't
--no-binary : Don't print the binary
--no-glsl   : Don't print GLSL
--spirv     : Print SPIR-V
--v         : Verbose log
+-stats <0|1>  : Print performance statistics for all shaders. Default 0
+-binary <0|1> : Print the whole shader program binary. Default 1
+-glsl <0|1>   : Print GLSL. Default 1
+-spirv <0|1>  : Print SPIR-V. Default 0
+-v            : Verbose log
 )";
 
 static Error parseCommandLineArgs(WeakArray<char*> argv, Bool& dumpStats, Bool& dumpBinary, Bool& glsl, Bool& spirv, String& filename)
@@ -42,20 +42,87 @@ static Error parseCommandLineArgs(WeakArray<char*> argv, Bool& dumpStats, Bool&
 	{
 		if(CString(argv[i]) == "-stats")
 		{
-			dumpStats = true;
+			++i;
+			if(i >= argv.getSize())
+			{
+				return Error::kUserData;
+			}
+
+			if(CString(argv[i]) == "1")
+			{
+				dumpStats = true;
+			}
+			else if(CString(argv[i]) == "0")
+			{
+				dumpStats = false;
+			}
+			else
+			{
+				return Error::kUserData;
+			}
 		}
-		else if(CString(argv[i]) == "-no-binary")
+		else if(CString(argv[i]) == "-binary")
 		{
-			dumpBinary = false;
-			dumpStats = true;
+			++i;
+			if(i >= argv.getSize())
+			{
+				return Error::kUserData;
+			}
+
+			if(CString(argv[i]) == "1")
+			{
+				dumpBinary = true;
+			}
+			else if(CString(argv[i]) == "0")
+			{
+				dumpBinary = false;
+			}
+			else
+			{
+				return Error::kUserData;
+			}
 		}
-		else if(CString(argv[i]) == "-no-glsl")
+		else if(CString(argv[i]) == "-glsl")
 		{
-			glsl = false;
+			++i;
+			if(i >= argv.getSize())
+			{
+				return Error::kUserData;
+			}
+
+			if(CString(argv[i]) == "1")
+			{
+				glsl = true;
+			}
+			else if(CString(argv[i]) == "0")
+			{
+				glsl = false;
+			}
+			else
+			{
+				return Error::kUserData;
+			}
 		}
 		else if(CString(argv[i]) == "-spirv")
 		{
-			spirv = true;
+			++i;
+			if(i >= argv.getSize())
+			{
+				return Error::kUserData;
+			}
+
+			if(CString(argv[i]) == "1")
+			{
+				spirv = true;
+			}
+			else if(CString(argv[i]) == "0")
+			{
+				spirv = false;
+			}
+			else
+			{
+				return Error::kUserData;
+			}
 		}
 		else if(CString(argv[i]) == "-v")
 		{
@@ -63,6 +130,11 @@ static Error parseCommandLineArgs(WeakArray<char*> argv, Bool& dumpStats, Bool&
 		}
 	}
 
+	if(spirv || glsl)
+	{
+		dumpBinary = true;
+	}
+
 	return Error::kNone;
 }