Skip to content

Implement the ProcessTriTessFactorsAvg HLSL Function #99148

Open
@farzonl

Description

@farzonl
  • Implement ProcessTriTessFactorsAvg clang builtin,
  • Link ProcessTriTessFactorsAvg clang builtin with hlsl_intrinsics.h
  • Add sema checks for ProcessTriTessFactorsAvg to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for ProcessTriTessFactorsAvg to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/ProcessTriTessFactorsAvg.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/ProcessTriTessFactorsAvg-errors.hlsl
  • Create the int_dx_ProcessTriTessFactorsAvg intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_ProcessTriTessFactorsAvg to 106 in DXIL.td
  • Create the ProcessTriTessFactorsAvg.ll and ProcessTriTessFactorsAvg_errors.ll tests in llvm/test/CodeGen/DirectX/

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
106 StorePatchConstant 6.0 ('hull',)

SPIR-V

There is no support for ProcessTriTessFactorsAvg when targeting SPIR-V.

Test Case(s)

Example 1

//dxc ProcessTriTessFactorsAvg_test.hlsl -T hs_6_8 -enable-16bit-types -O0

struct HSPerPatchData
{
	float edges[ 3 ] : SV_TessFactor;
	float inside : SV_InsideTessFactor;
};
struct PSSceneIn {
	float4 pos : SV_Position;
	float2 tex : TEXCOORD0;
	float3 norm : NORMAL;
};
struct HSPerVertexData {
	PSSceneIn v;
};

export HSPerPatchData fn( const InputPatch< PSSceneIn, 3 > points ) {
	HSPerPatchData d;
	float4 edgeFactor;
	float2 insideFactor;float3 p1;
float p2;
float3 p3;
float p4;
float p5;
ProcessTriTessFactorsAvg(p1, p2, p3, p4, p5);

	d.edges[0]=edgeFactor.x;
	d.edges[1]=edgeFactor.y;
	d.edges[2]=edgeFactor.z + edgeFactor.w;
	d.inside = insideFactor.x + insideFactor.y;
	return d;
}

[domain("tri")]
[outputtopology("triangle_cw")]
[patchconstantfunc("fn")]
[outputcontrolpoints(3)]
[partitioning("pow2")]
HSPerVertexData main( const uint id : SV_OutputControlPointID,const InputPatch< PSSceneIn, 3 > points ) {

	HSPerVertexData v;
	v.v = points[ id ];
	return v;
}

HLSL:

Generates the corrected tessellation factors for a tri patch.

Syntax

void ProcessTriTessFactorsAvg(
  in  float3 RawEdgeFactors,
  in  float InsideScale,
  out float3 RoundedEdgeTessFactors,
  out float RoundedInsideTessFactor,
  out float UnroundedInsideTessFactor
);

Parameters

RawEdgeFactors [in]

Type: float3

The edge tessellation factors, passed into the tessellator stage.

InsideScale [in]

Type: float

The scale factor applied to the UV tessellation factors computed by the tessellation stage. The allowable range for InsideScale is 0.0 to 1.0.

RoundedEdgeTessFactors [out]

Type: float3

The rounded edge-tessellation factors calculated by the tessellator stage.

RoundedInsideTessFactor [out]

Type: float

The tessellation factors calculated by the tessellator stage, and rounded.

UnroundedInsideTessFactor [out]

Type: float

The original, unrounded, UV tessellation factors computed by the tessellation stage.

Return value

This function does not return a value.

Remarks

Generates the corrected tessellation factors for a tri patch, computing the inside tessellation factor as the average of the edge tessellation factors, which is then scaled by InsideScale. The result is then rounded based on the partitioning mode, but the unrounded results are available using the UnroundedInsideTessFactor parameter.

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 5 and higher shader models yes

 

This function is supported in the following types of shaders:

Vertex Hull Domain Geometry Pixel Compute
x

 

See also

Intrinsic Functions

Shader Model 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    HLSLHLSL Language Supportbackend:DirectXbot:HLSLmetaissueIssue to collect references to a group of similar or related issues.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions