Skip to content

Implement the Process2DQuadTessFactorsAvg HLSL Function #99141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
9 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 1 comment
Open
9 tasks
Tracked by #99235

Implement the Process2DQuadTessFactorsAvg HLSL Function #99141

farzonl opened this issue Jul 16, 2024 · 1 comment
Labels
backend:DirectX bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

  • Implement Process2DQuadTessFactorsAvg clang builtin,
  • Link Process2DQuadTessFactorsAvg clang builtin with hlsl_intrinsics.h
  • Add sema checks for Process2DQuadTessFactorsAvg to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for Process2DQuadTessFactorsAvg to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/Process2DQuadTessFactorsAvg.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/Process2DQuadTessFactorsAvg-errors.hlsl
  • Create the int_dx_Process2DQuadTessFactorsAvg intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_Process2DQuadTessFactorsAvg to 106 in DXIL.td
  • Create the Process2DQuadTessFactorsAvg.ll and Process2DQuadTessFactorsAvg_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 Process2DQuadTessFactorsAvg when targeting SPIR-V.

Test Case(s)

Example 1

//dxc Process2DQuadTessFactorsAvg_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;float4 p1;
float2 p2;
float4 p3;
float2 p4;
float2 p5;
Process2DQuadTessFactorsAvg(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 quad patch.

Syntax

void Process2DQuadTessFactorsAvg(
  in  float4 RawEdgeFactors,
  in  float2 InsideScale,
  out float4 RoundedEdgeTessFactors,
  out float2 RoundedInsideTessFactors,
  out float2 UnroundedInsideTessFactors
);

Parameters

RawEdgeFactors [in]

Type: float4

The edge tessellation factors, passed into the tessellator stage.

InsideScale [in]

Type: float2

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: float4

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

RoundedInsideTessFactors [out]

Type: float2

The rounded tessellation factors calculated by the tessellator stage for inside edges.

UnroundedInsideTessFactors [out]

Type: float2

The tessellation factors calculated by the tessellator stage for inside edges.

Return value

This function does not return a value.

Remarks

Generates the corrected tessellation factors for a quad patch, computing the inside tessellation factors as the average of the edge tessellation factors. The U and V inside tessellation factors are computed independently using the average of opposing sides of the domain, then are scaled by InsideScale. The result is then rounded based on the partitioning mode, but the unrounded results are available using the UnroundedInsideTessFactors 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

@farzonl farzonl added backend:DirectX bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
@damyanp damyanp moved this to Ready in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Ready to Planning in HLSL Support Oct 30, 2024
@pow2clk pow2clk moved this from Planning to Designing in HLSL Support Nov 19, 2024
@pow2clk
Copy link
Contributor

pow2clk commented Nov 19, 2024

Tessellation-specific helper functions. Implementable in the header.

@damyanp damyanp removed the status in HLSL Support Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: No status
Development

No branches or pull requests

2 participants