cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

Vulkan Tessellation: Incorrect result using DXC compiler for Domain shader.

Hi!

I'm trying to use Tessellation using HLSL with DXC compilation. AMD RX 650, Windows 10 X64 last Drivers Adrenalin-2020-21.11.2-Win10-Win11-64Bit-Nov11

 

Driver Date 10.11.2021

Driver Version 30.0.13033.5003

I see the result:

ScreenShot_incorrect.png

I think the problem in the Domain Shader, because if I replace DXC compilation to glslang compilation I see a corect result:

ScreenShot_correct.png

I attached full demo with source HLSL files and spir-v result: VulkanDemoTerrainTesselation

VulkanTest.exe - DXC compilation for all Shaders

VulkanTest_domain_glslang.exe - Domain shader that will create  dirrecly from file dMain_EShLangTessEvaluation.spv, this file is the result of glslang compilation.

Shader from VulkanDemoTerrainTesselation:

vs.vert - Vertex shader

 

 

 

#define location(x) [[vk::location(x)]]
struct Output {
	float4 pos : SV_POSITION;
	location(0) float2 texCoord : TEXCOORD0;
	location(1) float3 Normal : NORMAL;
};

struct Input {
	location(0) float4 pos: SV_POSITION;
	location(8) float2 uv	: TEXCOORD0;
	location(2) float3 Normal	: NORMAL;
};

Output vsMain(in Input input) {
	Output output;
	output.pos = float4(input.pos.xyz, 1.0f);
	output.Normal = input.Normal;	
	output.texCoord = input.uv;
	return output;
}

 

 

 

hs.tesc - Hull shader

 

 

 

#define location(x) [[vk::location(x)]]
#define binding(x) [[vk::binding(x)]]
#define MAX_TF 20.0f
struct ConstantsHSOutput {
		float Edges[4]	: SV_TessFactor;
		float Inside[2] : SV_InsideTessFactor;
	};
struct Input{
		float4 pos : SV_POSITION;
		location(0) float2 uv : TEXCOORD0;
		location(1) float3 Normal : NORMAL;
};
#define MAX_TF 20.0f
binding(0) cbuffer b0: register(b0) {
	row_major float4x4 view;
	row_major float4x4 proj;
	float4 cameraPosition;
	float LodDistance;
	float tessellationFactor;
	float tessellatedEdgeSize;
	float2 viewportDim;
	uint numLods;
};
float distSq(float3 p0, float3 p1) {
	float3 d = p0 - p1;
	return dot(d, d);
}
float screenSpaceTessFactor(float4 p0, float4 p1) {
	float4 midPoint = 0.5f * (p0 + p1);
	float radius = distance(p0, p1) * 0.5f;
	float4 v0 = mul(midPoint, view);	float4 clip0 = mul(float4(v0.x - radius, 
v0.yzw), proj);
	float4 clip1 = mul(float4(v0.x + radius, v0.yzw), proj);
	clip0 /= clip0.w;
	clip1 /= clip1.w;
	clip0.xy *= viewportDim;
	clip1.xy *= viewportDim;
#ifdef D3D12
	return max(distance(clip0, clip1) / tessellatedEdgeSize * tessellationFactor, 1.0f);
#else
	return clamp(distance(clip0, clip1) / tessellatedEdgeSize * tessellationFactor, 1.0f, MAX_TF);
#endif
}
float CalculateTessFactor(float4 p0, float4 p1) {
#ifdef USE_SS_TESS_FACTOR_CALC
	return screenSpaceTessFactor(p0, p1);
#else
	float3 center = (p0 + p1).xyz * 0.5f;
	float factor = LodDistance / distSq(center, cameraPosition);
	return clamp(factor, 1.0f, numLods);
#endif
}
ConstantsHSOutput ConstantsHS(InputPatch<Input, 4> ip, uint PatchID : SV_PrimitiveID) {
	ConstantsHSOutput hsOut;
	hsOut.Edges[0] = CalculateTessFactor(ip[0].pos, ip[3].pos);
	hsOut.Edges[1] = CalculateTessFactor(ip[1].pos, ip[0].pos);
	hsOut.Edges[2] = CalculateTessFactor(ip[2].pos, ip[1].pos);
	hsOut.Edges[3] = CalculateTessFactor(ip[3].pos, ip[2].pos);
	hsOut.Inside[0] = lerp(hsOut.Edges[0], hsOut.Edges[3], 0.5f);
	hsOut.Inside[1] = lerp(hsOut.Edges[1], hsOut.Edges[2], 0.5f);
	return hsOut;
}
[domain("quad")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(4)]
[patchconstantfunc("ConstantsHS")]
[maxtessfactor(MAX_TF)]
Input hMain(InputPatch<Input, 4> ip, uint i : SV_OutputControlPointID, uint PatchID : SV_PrimitiveID) {
	Input output;
	output.pos = float4(ip[i].pos.xyz, 1.0f);
	output.uv = ip[i].uv;
	output.Normal = ip[i].Normal;
	return output;
}

 

 

 

ds.tese - Domain shader

 

 

 

#define location(x) [[vk::location(x)]]
#define binding(x) [[vk::binding(x)]]
#define MULTIPLE_LIGHTS 1

struct ConstantsHSOutput {
		float Edges[4]	: SV_TessFactor;
		float Inside[2] : SV_InsideTessFactor;
	};
struct Output{
		location(0) float4 pos : POSITION;
		location(1) float2 texCoord : TEXCOORD0;
		location(2) float3 Normal : NORMAL;
		location(3) float3 lightDir : TEXCOORD1;
		location(4) float4 shadowCrd : TEXCOORD2;
		location(5) float4 lightProjSpaceLokup : TEXCOORD3;
		location(6) float3 vVec : TEXCOORD4;
		location(7) float3 viewDir : TEXCOORD5;
};

binding(1) cbuffer b0 : register(b0) {
	row_major float4x4 ModelViewProjection;
	row_major float4x4 proj;
	float4 cameraPosition;
	float4 LightDir;
	row_major float4x4 MatTexture;
	row_major float4x4 ViewMatrix;
	float scaleHeight;
	float2 uvScale;
};
binding(2) Texture2D HeightMap : register(t0);
binding(2) SamplerState Sampler : register(s0);
struct Input {
	location(0) float4 pos: SV_POSITION;
	location(8) float2 uv	: TEXCOORD0;
	location(2) float3 Normal	: NORMAL;
};
float4 CalcLightProjSpaceLookup(float4 projectSpace) {	projectSpace.xy = (projectSpace.xy + float2(projectSpace.w, projectSpace.w)) * 0.5;	return projectSpace;}

Output vsMain(in Input input) {
	Output output;
	float4 Pos = float4(input.pos.xyz, 1.0f); 
	output.pos = mul(Pos, ModelViewProjection);
#ifdef MULTIPLE_LIGHTS
	output.lightProjSpaceLokup = CalcLightProjSpaceLookup(output.pos);
#ifdef NO_LIGHT_VIEW_SPACE
	output.vVec = pos.xyz;
#else
	output.vVec = mul(Pos, ViewMatrix).xyz;
	output.viewDir = cameraPosition.xyz - Pos.xyz;
#endif
#endif
	output.shadowCrd = mul(Pos, MatTexture);
	output.texCoord = input.uv;
	output.Normal = mul(input.Normal, (float3x3)ViewMatrix);
	output.lightDir = -LightDir.xyz;
    return output;
}
[domain("quad")]
Output dMain(in ConstantsHSOutput input, float2 domain : SV_DomainLocation, const OutputPatch<Input, 4> patch) {
	Output dsOutput;
	Input vsIn;
	vsIn.pos = lerp(lerp(patch[0].pos, patch[1].pos, domain.x), lerp(patch[3].pos, patch[2].pos, domain.x), domain.y);
	float2 uv = vsIn.pos.xz * uvScale;
	vsIn.pos.y = HeightMap.SampleLevel(Sampler, uv, 0.0).r * scaleHeight;
	vsIn.uv = lerp(lerp(patch[0].uv, patch[1].uv, domain.x), lerp(patch[3].uv, patch[2].uv, domain.x), domain.y);
	vsIn.Normal = lerp(lerp(patch[0].Normal, patch[1].Normal, domain.x), lerp(patch[3].Normal, patch[2].Normal, domain.x), domain.y);
	dsOutput = vsMain(vsIn);
	return dsOutput;
}

 

 

 

ps.frag - Pixel shader

 

 

 

//
#define location(x) layout(location = x)
#define binding(x) [[vk::binding(x)]]
#define SIMPLE_POINT_LIGHT
#defne MULTIPLE_LIGHTS

//
struct PSOutput {
	location(0) float4 pos : SV_POSITION;
	location(1) float2 texCoord : TEXCOORD0;
	location(2) float3 Normal : NORMAL;
	location(3) float3 lightDir : TEXCOORD1;
	location(4) float4 shadowCrd: TEXCOORD2;
#ifdef MULTIPLE_LIGHTS
	location(5) float4 lightProjSpaceLokup : TEXCOORD3;
	location(6) float3 vVec : TEXCOORD4;
	location(7) float3 viewDir : TEXCOORD5;
#endif
};

binding(3) Texture2D tex1 : register(t0);
binding(3) SamplerState samLinear1 : register(s0);

binding(4) Texture2D tex2 : register(t1);
binding(4) SamplerState samLinear2 : register(s1);

binding(5) Texture2D ShadowMap : register(t2);
binding(5) SamplerState sShadowMap : register(s2);

#ifdef MULTIPLE_LIGHTS
binding(6) Texture2D BitPlane : register(t3);
binding(6) SamplerState sBitPlane : register(s3);
#endif

struct Light {
	float4 posRange;
	float4 colorLightType;
#ifndef SIMPLE_POINT_LIGHT
	float4 directionFalloff;
	float4 lighTypeAttenuation;
	float4 ThetaPhi;
#endif
};

#ifdef MULTIPLE_LIGHTS

binding(7) cbuffer b0: register(b0) {
	Light lights[NUM_LIGHTS];
};

#define NEW_MULTI_LIGHTING

#ifdef NEW_MULTI_LIGHTING

float4 CalculateLighting(float4 Color, float3 worldPos, float3 Normal, float3 viewDir, float4 lightIndex)
{
	float3 ambient_color = float3(0.0f, 0.0f, 0.0f);
    float3 color = float3(0.0f, 0.0f, 0.0f);
    
    float3 n = normalize(Normal);
    float3 v = normalize(viewDir);
#ifndef NO_LIGHT_BUFFER
    for (int i = 0; i < 4; ++i)
    {                   
		float lIndex = 256.0f * lightIndex[i];
		Light light = lights[int(lIndex)]; 
#else
    for (int i = 0; i < 255; ++i)
    {        		
		Light light = lights[i]; 
#endif
        float3 l = (light.posRange.xyz - worldPos) * light.posRange.w;
        float atten = saturate(1.0f - dot(l, l));
        l = normalize(l);
        float3 h = normalize(l + v);
        
        float nDotL = saturate(dot(n, l));
        float nDotH = saturate(dot(n, h));
        float power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, 16.0f);
        
        color += (light.colorLightType.xyz * nDotL * atten) + power * atten;
    }
	color += ambient_color;
	return float4(color.xyz, Color.a);
}

#else

float4 CalculateLighting(float4 color, float3 vVec, float3 Normal, float4 lightIndex)
{
	float3 ambient_color = float3(0.2f, 0.2f, 0.2f);
	float3 lighting = float3(0.0f, 0.0f, 0.0f);
	for (int i = 0; i < 4; ++i) {
		float lIndex = 255.0f * lightIndex[i];
		Light light = lights[int(lIndex)]; 
		if (!light.posRange.w) {
	    	//return float4(0.0f, 0.0f, 0.0f, 0.0f);
			//continue;
		}
	    // Get the vector from the light center to the surface
		float3 lightVec = light.posRange.xyz - vVec;
#if 1
#if 1
 		// Scale based on the light radius
		float3 lVec = lightVec * light.posRange.a;
		float atten = 1.0f - saturate(dot(lVec, lVec));
#else
		float d = length(lightVec) / light.posRange.a;
		float atten = 1.0f - saturate(d);
#endif
#else
		float d = length(lightVec) * light.posRange.a;
		const float3 ConstantAtten = float3(0.4f, 0.01f, 0.01f);
		float atten = 1.0f / (ConstantAtten.x + ConstantAtten.y * d + ConstantAtten.z * d * d);
#endif	
		lightVec = normalize(lightVec);
		float3 H = normalize(lightVec + vVec);
		float diffuse = saturate(dot(lightVec, Normal));
		float specular = pow(saturate(dot(lightVec, H)), 16.0);
		lighting += atten * (diffuse * light.colorLightType.xyz * color.xyz + color.xyz * ambient_color + light.colorLightType.xyz * specular);
	}
	//lighting = max(lighting, 0.0f);
	return float4(lighting.xyz, color.a);
	//return float4(color.xyz, color.a);
}
#endif // NEW_MULTI_LIGHTING 
#endif // MULTIPLE_LIGHTS

float4 psMain(in PSOutput In) : SV_Target {
	
	float4 color = tex1.Sample(samLinear1, In.texCoord);
	float4 color2 = tex2.Sample(samLinear2, In.texCoord);
	color *= color2;
	float4 shadowCrd = In.shadowCrd;
	float shadowColor = 0.5f;
#ifdef PCF
	float sh = PCFFilter(4.0, ShadowMap, shadowCrd, shadowColor);
#else
	shadowCrd.xyz /= shadowCrd.w;
	float shadow = ShadowMap.Sample(sShadowMap, shadowCrd.xy).r;
	float sh = shadow < shadowCrd.z - 0.001f ? shadowColor : 1.0f;
#endif
	float3 normal = normalize(In.Normal);
#ifdef MULTIPLE_LIGHTS
	float4 lightIndex = GetLightIndex(BitPlane, In.lightProjSpaceLokup);
#ifdef NEW_MULTI_LIGHTING
	float3 viewDir = normalize(In.viewDir);
	float4 Albedo = CalculateLighting(color, In.vVec, normal, viewDir, lightIndex);
#else
	float4 Albedo = CalculateLighting(color, In.vVec, normal, lightIndex);
#endif
#endif	
	float3 lightDir = normalize(In.lightDir);
	float I = saturate(dot(lightDir, normal));
	const float3 ambient = float3(0.2f, 0.2f, 0.2f);
#ifdef MULTIPLE_LIGHTS
	color.xyz += Albedo.zyz;
#endif
	color.xyz += ambient;
	color.xyz *= I;
	color.xyz *= sh;
	return color;
}

 

 

 

domainHLSL.spv - The spir-v compilation for Domaing shader using DXC, I used RGA to receive text result form binary spir-v:

 

 

 

; SPIR-V
; Version: 1.5
; Generator: Google spiregg; 0
; Bound: 150
; Schema: 0
               OpCapability Tessellation
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint TessellationEvaluation %dMain "dMain" %gl_Position_0 %gl_TessLevelOuter %out_var_NORMAL %out_var_TEXCOORD3 %out_var_TEXCOORD5 %gl_TessLevelInner %gl_TessCoord %out_var_TEXCOORD2 %gl_Position %out_var_TEXCOORD4 %in_var_NORMAL %out_var_TEXCOORD1 %Sampler %out_var_TEXCOORD0 %b0 %HeightMap %in_var_TEXCOORD0
               OpExecutionMode %dMain Quads
         %20 = OpString "hlsl.hlsl"
               OpSource HLSL 600 %20
               OpName %type_b0 "type.b0"
               OpMemberName %type_b0 0 "ModelViewProjection"
               OpMemberName %type_b0 1 "proj"
               OpMemberName %type_b0 2 "cameraPosition"
               OpMemberName %type_b0 3 "LightDir"
               OpMemberName %type_b0 4 "MatTexture"
               OpMemberName %type_b0 5 "ViewMatrix"
               OpMemberName %type_b0 6 "scaleHeight"
               OpMemberName %type_b0 7 "uvScale"
               OpName %b0 "b0"
               OpName %type_2d_image "type.2d.image"
               OpName %HeightMap "HeightMap"
               OpName %type_sampler "type.sampler"
               OpName %Sampler "Sampler"
               OpName %in_var_TEXCOORD0 "in.var.TEXCOORD0"
               OpName %in_var_NORMAL "in.var.NORMAL"
               OpName %out_var_TEXCOORD0 "out.var.TEXCOORD0"
               OpName %out_var_NORMAL "out.var.NORMAL"
               OpName %out_var_TEXCOORD1 "out.var.TEXCOORD1"
               OpName %out_var_TEXCOORD2 "out.var.TEXCOORD2"
               OpName %out_var_TEXCOORD3 "out.var.TEXCOORD3"
               OpName %out_var_TEXCOORD4 "out.var.TEXCOORD4"
               OpName %out_var_TEXCOORD5 "out.var.TEXCOORD5"
               OpName %dMain "dMain"
               OpName %type_sampled_image "type.sampled.image"
               OpModuleProcessed "dxc-commit-hash: 110a5be0"
               OpModuleProcessed "dxc-cl-option: -E dMain -T ds_6_0 -all_resources_bound -Zpr -Zi -fspv-extension=SPV_GOOGLE_hlsl_functionality1 -spirv -fvk-use-dx-layout -fspv-target-env=vulkan1.2 -D POSITION=SV_POSITION -D USE_SS_TESS_FACTOR_CALC=1"
               OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter
               OpDecorate %gl_TessLevelOuter Patch
               OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner
               OpDecorate %gl_TessLevelInner Patch
               OpDecorate %gl_TessCoord BuiltIn TessCoord
               OpDecorate %gl_TessCoord Patch
               OpDecorate %gl_Position BuiltIn Position
               OpDecorate %gl_Position_0 BuiltIn Position
               OpDecorate %in_var_TEXCOORD0 Location 8
               OpDecorate %in_var_NORMAL Location 2
               OpDecorate %out_var_TEXCOORD0 Location 0
               OpDecorate %out_var_NORMAL Location 1
               OpDecorate %out_var_TEXCOORD1 Location 2
               OpDecorate %out_var_TEXCOORD2 Location 3
               OpDecorate %out_var_TEXCOORD3 Location 4
               OpDecorate %out_var_TEXCOORD4 Location 5
               OpDecorate %out_var_TEXCOORD5 Location 6
               OpDecorate %b0 DescriptorSet 0
               OpDecorate %b0 Binding 1
               OpDecorate %HeightMap DescriptorSet 0
               OpDecorate %HeightMap Binding 2
               OpDecorate %Sampler DescriptorSet 0
               OpDecorate %Sampler Binding 2
               OpMemberDecorate %type_b0 0 Offset 0
               OpMemberDecorate %type_b0 0 MatrixStride 16
               OpMemberDecorate %type_b0 0 ColMajor
               OpMemberDecorate %type_b0 1 Offset 64
               OpMemberDecorate %type_b0 1 MatrixStride 16
               OpMemberDecorate %type_b0 1 ColMajor
               OpMemberDecorate %type_b0 2 Offset 128
               OpMemberDecorate %type_b0 3 Offset 144
               OpMemberDecorate %type_b0 4 Offset 160
               OpMemberDecorate %type_b0 4 MatrixStride 16
               OpMemberDecorate %type_b0 4 ColMajor
               OpMemberDecorate %type_b0 5 Offset 224
               OpMemberDecorate %type_b0 5 MatrixStride 16
               OpMemberDecorate %type_b0 5 ColMajor
               OpMemberDecorate %type_b0 6 Offset 288
               OpMemberDecorate %type_b0 7 Offset 292
               OpDecorate %type_b0 Block
       %uint = OpTypeInt 32 0
        %int = OpTypeInt 32 1
      %int_0 = OpConstant %int 0
     %uint_2 = OpConstant %uint 2
      %int_7 = OpConstant %int 7
      %float = OpTypeFloat 32
    %float_0 = OpConstant %float 0
      %int_6 = OpConstant %int 6
      %int_2 = OpConstant %int 2
    %float_1 = OpConstant %float 1
      %int_5 = OpConstant %int 5
      %int_4 = OpConstant %int 4
      %int_3 = OpConstant %int 3
  %float_0_5 = OpConstant %float 0.5
    %v4float = OpTypeVector %float 4
%mat4v4float = OpTypeMatrix %v4float 4
    %v2float = OpTypeVector %float 2
    %type_b0 = OpTypeStruct %mat4v4float %mat4v4float %v4float %v4float %mat4v4float %mat4v4float %float %v2float
%_ptr_Uniform_type_b0 = OpTypePointer Uniform %type_b0
%type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown
%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image
%type_sampler = OpTypeSampler
%_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler
     %uint_4 = OpConstant %uint 4
%_arr_float_uint_4 = OpTypeArray %float %uint_4
%_ptr_Input__arr_float_uint_4 = OpTypePointer Input %_arr_float_uint_4
%_arr_float_uint_2 = OpTypeArray %float %uint_2
%_ptr_Input__arr_float_uint_2 = OpTypePointer Input %_arr_float_uint_2
    %v3float = OpTypeVector %float 3
%_ptr_Input_v3float = OpTypePointer Input %v3float
%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
%_ptr_Input__arr_v4float_uint_4 = OpTypePointer Input %_arr_v4float_uint_4
%_arr_v2float_uint_4 = OpTypeArray %v2float %uint_4
%_ptr_Input__arr_v2float_uint_4 = OpTypePointer Input %_arr_v2float_uint_4
%_arr_v3float_uint_4 = OpTypeArray %v3float %uint_4
%_ptr_Input__arr_v3float_uint_4 = OpTypePointer Input %_arr_v3float_uint_4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_ptr_Output_v2float = OpTypePointer Output %v2float
%_ptr_Output_v3float = OpTypePointer Output %v3float
       %void = OpTypeVoid
         %62 = OpTypeFunction %void
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%type_sampled_image = OpTypeSampledImage %type_2d_image
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%mat3v3float = OpTypeMatrix %v3float 3
         %b0 = OpVariable %_ptr_Uniform_type_b0 Uniform
  %HeightMap = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant
    %Sampler = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant
%gl_TessLevelOuter = OpVariable %_ptr_Input__arr_float_uint_4 Input
%gl_TessLevelInner = OpVariable %_ptr_Input__arr_float_uint_2 Input
%gl_TessCoord = OpVariable %_ptr_Input_v3float Input
%gl_Position = OpVariable %_ptr_Input__arr_v4float_uint_4 Input
%in_var_TEXCOORD0 = OpVariable %_ptr_Input__arr_v2float_uint_4 Input
%in_var_NORMAL = OpVariable %_ptr_Input__arr_v3float_uint_4 Input
%gl_Position_0 = OpVariable %_ptr_Output_v4float Output
%out_var_TEXCOORD0 = OpVariable %_ptr_Output_v2float Output
%out_var_NORMAL = OpVariable %_ptr_Output_v3float Output
%out_var_TEXCOORD1 = OpVariable %_ptr_Output_v3float Output
%out_var_TEXCOORD2 = OpVariable %_ptr_Output_v4float Output
%out_var_TEXCOORD3 = OpVariable %_ptr_Output_v4float Output
%out_var_TEXCOORD4 = OpVariable %_ptr_Output_v3float Output
%out_var_TEXCOORD5 = OpVariable %_ptr_Output_v3float Output
      %dMain = OpFunction %void None %62
         %68 = OpLabel
         %69 = OpLoad %v3float %gl_TessCoord
         %70 = OpLoad %_arr_v4float_uint_4 %gl_Position
         %71 = OpLoad %_arr_v2float_uint_4 %in_var_TEXCOORD0
         %72 = OpLoad %_arr_v3float_uint_4 %in_var_NORMAL
         %73 = OpCompositeExtract %v4float %70 0
         %74 = OpCompositeExtract %v2float %71 0
         %75 = OpCompositeExtract %v3float %72 0
         %76 = OpCompositeExtract %v4float %70 1
         %77 = OpCompositeExtract %v2float %71 1
         %78 = OpCompositeExtract %v3float %72 1
         %79 = OpCompositeExtract %v4float %70 2
         %80 = OpCompositeExtract %v2float %71 2
         %81 = OpCompositeExtract %v3float %72 2
         %82 = OpCompositeExtract %v4float %70 3
         %83 = OpCompositeExtract %v2float %71 3
         %84 = OpCompositeExtract %v3float %72 3
               OpLine %20 63 51
         %85 = OpCompositeExtract %float %69 0
         %86 = OpCompositeConstruct %v4float %85 %85 %85 %85
               OpLine %20 63 18
         %87 = OpExtInst %v4float %1 FMix %73 %76 %86
               OpLine %20 63 62
         %88 = OpExtInst %v4float %1 FMix %82 %79 %86
               OpLine %20 63 106
         %89 = OpCompositeExtract %float %69 1
         %90 = OpCompositeConstruct %v4float %89 %89 %89 %89
               OpLine %20 63 13
         %91 = OpExtInst %v4float %1 FMix %87 %88 %90
               OpLine %20 64 14
         %92 = OpVectorShuffle %v2float %91 %91 0 2
               OpLine %20 64 28
         %93 = OpAccessChain %_ptr_Uniform_v2float %b0 %int_7
         %94 = OpLoad %v2float %93
               OpLine %20 64 26
         %95 = OpFMul %v2float %92 %94
               OpLine %20 65 15
         %96 = OpLoad %type_2d_image %HeightMap
               OpLine %20 65 37
         %97 = OpLoad %type_sampler %Sampler
               OpLine %20 65 15
         %98 = OpSampledImage %type_sampled_image %96 %97
         %99 = OpImageSampleExplicitLod %v4float %98 %95 Lod %float_0
        %100 = OpCompositeExtract %float %99 0
               OpLine %20 65 59
        %101 = OpAccessChain %_ptr_Uniform_float %b0 %int_6
        %102 = OpLoad %float %101
               OpLine %20 65 57
        %103 = OpFMul %float %100 %102
               OpLine %20 66 48
        %104 = OpCompositeConstruct %v2float %85 %85
               OpLine %20 66 17
        %105 = OpExtInst %v2float %1 FMix %74 %77 %104
               OpLine %20 66 59
        %106 = OpExtInst %v2float %1 FMix %83 %80 %104
               OpLine %20 66 101
        %107 = OpCompositeConstruct %v2float %89 %89
               OpLine %20 66 12
        %108 = OpExtInst %v2float %1 FMix %105 %106 %107
               OpLine %20 67 60
        %109 = OpCompositeConstruct %v3float %85 %85 %85
               OpLine %20 67 21
        %110 = OpExtInst %v3float %1 FMix %75 %78 %109
               OpLine %20 67 71
        %111 = OpExtInst %v3float %1 FMix %84 %81 %109
               OpLine %20 67 121
        %112 = OpCompositeConstruct %v3float %89 %89 %89
               OpLine %20 67 16
        %113 = OpExtInst %v3float %1 FMix %110 %111 %112
               OpLine %20 42 22
        %114 = OpCompositeExtract %float %91 0
        %115 = OpCompositeExtract %float %91 2
        %116 = OpCompositeConstruct %v4float %114 %103 %115 %float_1
               OpLine %20 43 24
        %117 = OpAccessChain %_ptr_Uniform_mat4v4float %b0 %int_0
        %118 = OpLoad %mat4v4float %117
               OpLine %20 43 15
        %119 = OpMatrixTimesVector %v4float %118 %116
               OpLine %20 38 75
        %120 = OpVectorShuffle %v2float %119 %119 0 1
               OpLine %20 38 100
        %121 = OpCompositeExtract %float %119 3
        %122 = OpCompositeConstruct %v2float %121 %121
               OpLine %20 38 91
        %123 = OpFAdd %v2float %120 %122
               OpLine %20 38 133
        %124 = OpVectorTimesScalar %v2float %123 %float_0_5
               OpLine %20 38 56
        %125 = OpVectorShuffle %v4float %119 %124 4 5 2 3
               OpLine %20 49 25
        %126 = OpAccessChain %_ptr_Uniform_mat4v4float %b0 %int_5
        %127 = OpLoad %mat4v4float %126
               OpLine %20 49 16
        %128 = OpMatrixTimesVector %v4float %127 %116
        %129 = OpVectorShuffle %v3float %128 %128 0 1 2
               OpLine %20 50 19
        %130 = OpAccessChain %_ptr_Uniform_v4float %b0 %int_2
        %131 = OpLoad %v4float %130
        %132 = OpVectorShuffle %v3float %131 %131 0 1 2
               OpLine %20 50 40
        %133 = OpVectorShuffle %v3float %116 %116 0 1 2
               OpLine %20 50 38
        %134 = OpFSub %v3float %132 %133
               OpLine %20 53 30
        %135 = OpAccessChain %_ptr_Uniform_mat4v4float %b0 %int_4
        %136 = OpLoad %mat4v4float %135
               OpLine %20 53 21
        %137 = OpMatrixTimesVector %v4float %136 %116
               OpLine %20 55 46
        %138 = OpCompositeExtract %v4float %127 0
        %139 = OpVectorShuffle %v3float %138 %138 0 1 2
        %140 = OpCompositeExtract %v4float %127 1
        %141 = OpVectorShuffle %v3float %140 %140 0 1 2
        %142 = OpCompositeExtract %v4float %127 2
        %143 = OpVectorShuffle %v3float %142 %142 0 1 2
        %144 = OpCompositeConstruct %mat3v3float %139 %141 %143
               OpLine %20 55 18
        %145 = OpMatrixTimesVector %v3float %144 %113
               OpLine %20 56 21
        %146 = OpAccessChain %_ptr_Uniform_v4float %b0 %int_3
        %147 = OpLoad %v4float %146
        %148 = OpVectorShuffle %v3float %147 %147 0 1 2
               OpLine %20 56 20
        %149 = OpFNegate %v3float %148
               OpNoLine
               OpStore %gl_Position_0 %119
               OpStore %out_var_TEXCOORD0 %108
               OpStore %out_var_NORMAL %145
               OpStore %out_var_TEXCOORD1 %149
               OpStore %out_var_TEXCOORD2 %137
               OpStore %out_var_TEXCOORD3 %125
               OpStore %out_var_TEXCOORD4 %129
               OpStore %out_var_TEXCOORD5 %134
               OpLine %20 70 1
               OpReturn
               OpFunctionEnd

 

 

 

 

domainGLSL.spv - The spir-v compilation for Domaing shader using glslang, I used RGA to receive text result form binary spir-v

hs_6_0_hMain.spv - DXC compilation for Hull shader

ds_6_0_dMain.spv - DXC compilation for Domain shader

hMain_EShLangTessControl.spv - glslang compilation for Hull shader

dMain_EShLangTessEvaluation.spv - glslang compilation for Domain shader

RGA Project for Vulkan Tessellation 

The same demo can show correct result od Direct3D12.

Do we have driver bug of DXC compilation problem?

0 Likes
1 Solution

Problem has been fixed using a new DXC compiler.

View solution in original post

0 Likes
2 Replies

Bug can be reproduced on Adrenalin-2020-21.11.3 and Redeon (TM) Graphics (Vega 6 inside AMD Ryzen 3 PRO 4350G)

0 Likes

Problem has been fixed using a new DXC compiler.

0 Likes