Skip to content
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

Implement the GetAttributeAtVertex HLSL Function #99201

Open
12 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 0 comments
Open
12 tasks
Tracked by #99235

Implement the GetAttributeAtVertex HLSL Function #99201

farzonl opened this issue Jul 16, 2024 · 0 comments
Labels
backend:DirectX backend:SPIR-V 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 GetAttributeAtVertex clang builtin,
  • Link GetAttributeAtVertex clang builtin with hlsl_intrinsics.h
  • Add sema checks for GetAttributeAtVertex to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for GetAttributeAtVertex to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/GetAttributeAtVertex.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/GetAttributeAtVertex-errors.hlsl
  • Create the int_dx_GetAttributeAtVertex intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_GetAttributeAtVertex to 137 in DXIL.td
  • Create the GetAttributeAtVertex.ll and GetAttributeAtVertex_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_GetAttributeAtVertex intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the GetAttributeAtVertex lowering and map it to int_spv_GetAttributeAtVertex in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/GetAttributeAtVertex.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
137 AttributeAtVertex 6.1 ('pixel',)

SPIR-V

OpAccessChain:

Description:

Create a pointer into a composite object.

Result Type must be an OpTypePointer. Its Type
operand must be the type reached by walking the Base’s type hierarchy
down to the last provided index in Indexes, and its Storage Class
operand must be the same as the Storage Class of Base.

Base must be a pointer, pointing to the base of a composite object.

Indexes walk the type hierarchy to the desired depth, potentially down
to scalar granularity. The first index in Indexes selects the
top-level member/element/component/element of the base composite. All
composite constituents use zero-based numbering, as described by their
OpType…​ instruction. The second index applies similarly to that
result, and so on. Once any non-composite type is reached, there must be
no remaining (unused) indexes.

Each index in Indexes

  • must have a scalar integer type
  • is treated as signed
  • if indexing into a structure, must be an OpConstant
    whose value is in bounds for selecting a member
  • if indexing into a vector, array, or matrix, with the result type
    being a logical pointer type, causes undefined
    behavior if not in bounds.
Word Count Opcode Results Operands

4 + variable

65

<id>
Result Type

Result <id>

<id>
Base

<id>, <id>, …​
Indexes

Test Case(s)

Example 1

//dxc GetAttributeAtVertex_test.hlsl -T lib_6_8 -enable-16bit-types -O0

[numthreads(1, 1, 1)]
[shader("pixel")]
float4 fn(nointerpolation float4 p1 : COLOR ) : SV_Target {
	uint p2 = 1;
	return GetAttributeAtVertex(p1, p2);
}

Example 2

//dxc GetAttributeAtVertex_1_test.hlsl -T lib_6_8 -enable-16bit-types -O0

[numthreads(1, 1, 1)]
[shader("pixel")]
uint4 fn(nointerpolation float4 p1 : COLOR ) : SV_Target {
	uint p2 = 1;
	return GetAttributeAtVertex(p1, p2);
}

Example 3

//dxc GetAttributeAtVertex_2_test.hlsl -T lib_6_8 -enable-16bit-types -O0

[numthreads(1, 1, 1)]
[shader("pixel")]
int4 fn(nointerpolation float4 p1 : COLOR ) : SV_Target {
	uint p2 = 1;
	return GetAttributeAtVertex(p1, p2);
}

HLSL:

Syntax

numeric<> GetAttributeAtVertex(numeric<> value, uint VertexID);

Type Description

Name Template Type Component Type Size
ret scalar, vector, or matrix float or int any
value scalar, vector, or matrix float or int any
VertexID scalar uint 1

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 6.1 and higher shader models yes

Shader Stages

See also

@farzonl farzonl added backend:DirectX backend:SPIR-V 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: Designing
Development

No branches or pull requests

1 participant